整理:code review

This commit is contained in:
pppscn 2023-02-01 10:51:17 +08:00
parent 992fc2eb8c
commit e1660fe9bb
16 changed files with 713 additions and 714 deletions

View File

@ -162,7 +162,7 @@ class ForegroundService : Service() {
// if (DeviceUtils.getDeviceBrand().contains("Xiaomi")) {
builder.setContentTitle(getString(R.string.app_name))
//}
builder.setContentText(SettingUtils.notifyContent.toString())
builder.setContentText(SettingUtils.notifyContent)
builder.setWhen(System.currentTimeMillis())
val activityIntent = Intent(this, MainActivity::class.java)
val flags = if (Build.VERSION.SDK_INT >= 30) PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_UPDATE_CURRENT

View File

@ -35,7 +35,7 @@ class BarkUtils {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl: String = setting.server //推送地址

View File

@ -35,7 +35,7 @@ class DingtalkGroupRobotUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
var requestUrl = if (setting.token.startsWith("http")) setting.token else "https://oapi.dingtalk.com/robot/send?access_token=" + setting.token

View File

@ -126,7 +126,7 @@ class DingtalkInnerRobotUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val msgParam: MutableMap<String, Any> = mutableMapOf()

View File

@ -31,7 +31,7 @@ class EmailUtils {
val message: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
//常用邮箱类型的转换

View File

@ -84,7 +84,7 @@ class FeishuAppUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val msgContent = if ("interactive" == setting.msgType) {

View File

@ -94,7 +94,7 @@ class FeishuUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl = setting.webhook

View File

@ -33,7 +33,7 @@ class GotifyUtils {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl: String = setting.webServer //推送地址

View File

@ -37,7 +37,7 @@ class PushplusUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl = "https://" + setting.website + "/send"
@ -63,7 +63,6 @@ class PushplusUtils private constructor() {
}
}
val requestMsg: String = Gson().toJson(msgMap)
Log.i(TAG, "requestMsg:$requestMsg")

View File

@ -34,7 +34,7 @@ class ServerchanUtils {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl: String = String.format("https://sctapi.ftqq.com/%s.send", setting.sendKey) //推送地址

View File

@ -40,7 +40,7 @@ class TelegramUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
var requestUrl = if (setting.apiToken.startsWith("http")) {

View File

@ -38,7 +38,7 @@ class WebhookUtils {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
var requestUrl: String = setting.webServer //推送地址
@ -46,7 +46,7 @@ class WebhookUtils {
val timestamp = System.currentTimeMillis()
val orgContent: String = msgInfo.content
val deviceMark: String = SettingUtils.extraDeviceMark ?: ""
val deviceMark: String = SettingUtils.extraDeviceMark
val appVersion: String = AppUtils.getAppVersionName()
val simInfo: String = msgInfo.simInfo
@SuppressLint("SimpleDateFormat") val receiveTime =

View File

@ -120,7 +120,7 @@ class WeworkAgentUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val textMsgMap: MutableMap<String, Any> = mutableMapOf()
@ -132,7 +132,7 @@ class WeworkAgentUtils private constructor() {
val textText: MutableMap<String, Any> = mutableMapOf()
textText["content"] = content
textMsgMap["text"] = textText
var accessToken: String by SharedPreference("access_token_" + setting.agentID, "")
val accessToken: String by SharedPreference("access_token_" + setting.agentID, "")
val requestUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$accessToken"
Log.i(TAG, "requestUrl:$requestUrl")
val requestMsg: String = Gson().toJson(textMsgMap)

View File

@ -28,7 +28,7 @@ class WeworkRobotUtils private constructor() {
val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
msgInfo.getContentForSend(SettingUtils.smsTemplate.toString())
msgInfo.getContentForSend(SettingUtils.smsTemplate)
}
val requestUrl = setting.webHook

View File

@ -340,7 +340,7 @@
<string name="sim2_remark" tools:ignore="Typos">SIM2 SubId/Label</string>
<string name="carrier_mobile" tools:ignore="Typos">Label of SIM,\neg. AT&amp;T_88888888</string>
<string name="tip_number_only_error_message">Number must be greater than 0!</string>
<string name="regexp_number_only" tools:ignore="Typos">^[1-9]?\\d+$</string>
<string name="regexp_number_only" tools:ignore="TypographyDashes,Typos">^[1-9]?\\d+$</string>
<string name="low_power_alarm_threshold">Low Power Alarm</string>
<string name="low_power_alarm_threshold_tips">Value range: 099.\nLeft blank or 0 is disabled</string>
<string name="retry_interval">Retry Interval</string>

View File

@ -341,7 +341,7 @@
<string name="sim2_remark" tools:ignore="Typos">SIM2主键/备注</string>
<string name="carrier_mobile">序号/运营商_手机号</string>
<string name="tip_number_only_error_message">数字必须大于0!</string>
<string name="regexp_number_only" tools:ignore="Typos">^[1-9]?\\d+$</string>
<string name="regexp_number_only" tools:ignore="TypographyDashes,Typos">^[1-9]?\\d+$</string>
<string name="low_power_alarm_threshold">安全电量范围(%)</string>
<string name="low_power_alarm_threshold_tips">超出安全范围将发出预警</string>
<string name="retry_interval">请求重试机制</string>