/* * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.huawei.push.android; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; import com.huawei.push.message.Notification; import com.huawei.push.model.Importance; import com.huawei.push.model.Visibility; import com.huawei.push.util.CollectionUtils; import com.huawei.push.util.ValidatorUtils; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; public class AndroidNotification { private static final String COLOR_PATTERN = "^#[0-9a-fA-F]{6}$"; private static final String URL_PATTERN = "^https.*"; private static final String VIBRATE_PATTERN = "[0-9]+|[0-9]+[sS]|[0-9]+[.][0-9]{1,9}|[0-9]+[.][0-9]{1,9}[sS]"; @JSONField(name = "title") private String title; @JSONField(name = "body") private String body; @JSONField(name = "icon") private String icon; @JSONField(name = "color") private String color; @JSONField(name = "sound") private String sound; @JSONField(name = "default_sound") private boolean defaultSound; @JSONField(name = "tag") private String tag; @JSONField(name = "click_action") private ClickAction clickAction; @JSONField(name = "body_loc_key") private String bodyLocKey; @JSONField(name = "body_loc_args") private List bodyLocArgs = new ArrayList<>(); @JSONField(name = "title_loc_key") private String titleLocKey; @JSONField(name = "title_loc_args") private List titleLocArgs = new ArrayList<>(); @JSONField(name = "multi_lang_key") private JSONObject multiLangKey; @JSONField(name = "channel_id") private String channelId; @JSONField(name = "notify_summary") private String notifySummary; @JSONField(name = "image") private String image; @JSONField(name = "style") private Integer style; @JSONField(name = "big_title") private String bigTitle; @JSONField(name = "big_body") private String bigBody; @JSONField(name = "auto_clear") private Integer autoClear; @JSONField(name = "notify_id") private Integer notifyId; @JSONField(name = "group") private String group; @JSONField(name = "badge") private BadgeNotification badge; @JSONField(name = "ticker") private String ticker; @JSONField(name = "auto_cancel") private boolean autoCancel; @JSONField(name = "when") private String when; @JSONField(name = "local_only") private Boolean localOnly; @JSONField(name = "importance") private String importance; @JSONField(name = "use_default_vibrate") private boolean useDefaultVibrate; @JSONField(name = "use_default_light") private boolean useDefaultLight; @JSONField(name = "vibrate_config") private List vibrateConfig = new ArrayList<>(); @JSONField(name = "visibility") private String visibility; @JSONField(name = "light_settings") private LightSettings lightSettings; @JSONField(name = "foreground_show") private boolean foregroundShow; @JSONField(name = "inbox_content") private List inboxContent; @JSONField(name = "buttons") private List