新增:发送通道新增是否启用状态

pull/115/head
pppscn 3 years ago
parent cc8037db2e
commit 336df5008d

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder;
import static com.idormy.sms.forwarder.model.SenderModel.STATUS_OFF;
import static com.idormy.sms.forwarder.model.SenderModel.STATUS_ON;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_BARK;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_DINGDING;
@ -309,8 +310,11 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_dingding, null);
final EditText editTextDingdingName = view1.findViewById(R.id.editTextDingdingName);
if (senderModel != null)
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchDingdingEnable = view1.findViewById(R.id.switchDingdingEnable);
if (senderModel != null) {
editTextDingdingName.setText(senderModel.getName());
switchDingdingEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextDingdingToken = view1.findViewById(R.id.editTextDingdingToken);
if (dingDingSettingVo != null)
editTextDingdingToken.setText(dingDingSettingVo.getToken());
@ -339,7 +343,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextDingdingName.getText().toString().trim());
newSenderModel.setType(TYPE_DINGDING);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchDingdingEnable.isChecked() ? STATUS_ON : STATUS_OFF);
DingDingSettingVo dingDingSettingVoNew = new DingDingSettingVo(
editTextDingdingToken.getText().toString().trim(),
editTextDingdingSecret.getText().toString().trim(),
@ -352,7 +356,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextDingdingName.getText().toString().trim());
senderModel.setType(TYPE_DINGDING);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchDingdingEnable.isChecked() ? STATUS_ON : STATUS_OFF);
DingDingSettingVo dingDingSettingVoNew = new DingDingSettingVo(
editTextDingdingToken.getText().toString().trim(),
editTextDingdingSecret.getText().toString().trim(),
@ -411,7 +415,11 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_email, null);
final EditText editTextEmailName = view1.findViewById(R.id.editTextEmailName);
if (senderModel != null) editTextEmailName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchEmailEnable = view1.findViewById(R.id.switchEmailEnable);
if (senderModel != null) {
editTextEmailName.setText(senderModel.getName());
switchEmailEnable.setChecked(senderModel.getStatusChecked());
}
final EditText editTextEmailHost = view1.findViewById(R.id.editTextEmailHost);
final EditText editTextEmailPort = view1.findViewById(R.id.editTextEmailPort);
@ -469,7 +477,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextEmailName.getText().toString().trim());
newSenderModel.setType(TYPE_EMAIL);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchEmailEnable.isChecked() ? STATUS_ON : STATUS_OFF);
newSenderModel.setJsonSetting(JSON.toJSONString(emailSettingVoNew));
SenderUtil.addSender(newSenderModel);
initSenders();
@ -477,7 +485,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextEmailName.getText().toString().trim());
senderModel.setType(TYPE_EMAIL);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchEmailEnable.isChecked() ? STATUS_ON : STATUS_OFF);
senderModel.setJsonSetting(JSON.toJSONString(emailSettingVoNew));
SenderUtil.updateSender(senderModel);
initSenders();
@ -567,7 +575,12 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_bark, null);
final EditText editTextBarkName = view1.findViewById(R.id.editTextBarkName);
if (senderModel != null) editTextBarkName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchBarkEnable = view1.findViewById(R.id.switchBarkEnable);
if (senderModel != null) {
editTextBarkName.setText(senderModel.getName());
switchBarkEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextBarkServer = view1.findViewById(R.id.editTextBarkServer);
if (barkSettingVo != null) editTextBarkServer.setText(barkSettingVo.getServer());
final EditText editTextBarkIcon = view1.findViewById(R.id.editTextBarkIcon);
@ -589,7 +602,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextBarkName.getText().toString().trim());
newSenderModel.setType(TYPE_BARK);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchBarkEnable.isChecked() ? STATUS_ON : STATUS_OFF);
BarkSettingVo barkSettingVoNew = new BarkSettingVo(
editTextBarkServer.getText().toString().trim(),
editTextBarkIcon.getText().toString().trim()
@ -601,7 +614,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextBarkName.getText().toString().trim());
senderModel.setType(TYPE_BARK);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchBarkEnable.isChecked() ? STATUS_ON : STATUS_OFF);
BarkSettingVo barkSettingVoNew = new BarkSettingVo(
editTextBarkServer.getText().toString().trim(),
editTextBarkIcon.getText().toString().trim()
@ -654,7 +667,12 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_serverchan, null);
final EditText editTextServerChanName = view1.findViewById(R.id.editTextServerChanName);
if (senderModel != null) editTextServerChanName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchServerChanEnable = view1.findViewById(R.id.switchServerChanEnable);
if (senderModel != null) {
editTextServerChanName.setText(senderModel.getName());
switchServerChanEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextServerChanSendKey = view1.findViewById(R.id.editTextServerChanSendKey);
if (serverchanSettingVo != null)
editTextServerChanSendKey.setText(serverchanSettingVo.getSendKey());
@ -675,7 +693,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextServerChanName.getText().toString().trim());
newSenderModel.setType(TYPE_SERVER_CHAN);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchServerChanEnable.isChecked() ? STATUS_ON : STATUS_OFF);
ServerChanSettingVo serverChanSettingVoNew = new ServerChanSettingVo(
editTextServerChanSendKey.getText().toString().trim()
);
@ -686,7 +704,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextServerChanName.getText().toString().trim());
senderModel.setType(TYPE_SERVER_CHAN);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchServerChanEnable.isChecked() ? STATUS_ON : STATUS_OFF);
ServerChanSettingVo serverChanSettingVoNew = new ServerChanSettingVo(
editTextServerChanSendKey.getText().toString().trim()
);
@ -738,15 +756,22 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_webnotify, null);
final EditText editTextWebNotifyName = view1.findViewById(R.id.editTextWebNotifyName);
if (senderModel != null) editTextWebNotifyName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchWebNotifyEnable = view1.findViewById(R.id.switchWebNotifyEnable);
if (senderModel != null) {
editTextWebNotifyName.setText(senderModel.getName());
switchWebNotifyEnable.setChecked(senderModel.getStatusChecked());
}
final EditText editTextWebNotifyWebServer = view1.findViewById(R.id.editTextWebNotifyWebServer);
if (webNotifySettingVo != null) editTextWebNotifyWebServer.setText(webNotifySettingVo.getWebServer());
final EditText editTextWebNotifyWebParams = view1.findViewById(R.id.editTextWebNotifyWebParams);
if (webNotifySettingVo != null) editTextWebNotifyWebParams.setText(webNotifySettingVo.getWebParams());
final ClearEditText editTextWebNotifySecret = view1.findViewById(R.id.editTextWebNotifySecret);
if (webNotifySettingVo != null) editTextWebNotifySecret.setText(webNotifySettingVo.getSecret());
final RadioGroup radioGroupWebNotifyMethod = view1.findViewById(R.id.radioGroupWebNotifyMethod);
if (webNotifySettingVo != null) radioGroupWebNotifyMethod.check(webNotifySettingVo.getWebNotifyMethodCheckId());
if (webNotifySettingVo != null) {
editTextWebNotifyWebServer.setText(webNotifySettingVo.getWebServer());
editTextWebNotifyWebParams.setText(webNotifySettingVo.getWebParams());
editTextWebNotifySecret.setText(webNotifySettingVo.getSecret());
radioGroupWebNotifyMethod.check(webNotifySettingVo.getWebNotifyMethodCheckId());
}
Button buttonWebNotifyOk = view1.findViewById(R.id.buttonWebNotifyOk);
Button buttonWebNotifyDel = view1.findViewById(R.id.buttonWebNotifyDel);
@ -769,13 +794,13 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextWebNotifyName.getText().toString().trim());
newSenderModel.setType(TYPE_WEB_NOTIFY);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchWebNotifyEnable.isChecked() ? STATUS_ON : STATUS_OFF);
newSenderModel.setJsonSetting(JSON.toJSONString(webNotifySettingVoNew));
SenderUtil.addSender(newSenderModel);
} else {
senderModel.setName(editTextWebNotifyName.getText().toString().trim());
senderModel.setType(TYPE_WEB_NOTIFY);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchWebNotifyEnable.isChecked() ? STATUS_ON : STATUS_OFF);
senderModel.setJsonSetting(JSON.toJSONString(webNotifySettingVoNew));
SenderUtil.updateSender(senderModel);
}
@ -825,10 +850,16 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_qywxgrouprobot, null);
final EditText editTextQYWXGroupRobotName = view1.findViewById(R.id.editTextQYWXGroupRobotName);
if (senderModel != null) editTextQYWXGroupRobotName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchQYWXGroupRobotEnable = view1.findViewById(R.id.switchQYWXGroupRobotEnable);
if (senderModel != null) {
editTextQYWXGroupRobotName.setText(senderModel.getName());
switchQYWXGroupRobotEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextQYWXGroupRobotWebHook = view1.findViewById(R.id.editTextQYWXGroupRobotWebHook);
if (qywxGroupRobotSettingVo != null)
if (qywxGroupRobotSettingVo != null) {
editTextQYWXGroupRobotWebHook.setText(qywxGroupRobotSettingVo.getWebHook());
}
Button buttonQyWxGroupRobotOk = view1.findViewById(R.id.buttonQyWxGroupRobotOk);
Button buttonQyWxGroupRobotDel = view1.findViewById(R.id.buttonQyWxGroupRobotDel);
@ -846,7 +877,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextQYWXGroupRobotName.getText().toString().trim());
newSenderModel.setType(TYPE_QYWX_GROUP_ROBOT);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchQYWXGroupRobotEnable.isChecked() ? STATUS_ON : STATUS_OFF);
QYWXGroupRobotSettingVo qywxGroupRobotSettingVoNew = new QYWXGroupRobotSettingVo(
editTextQYWXGroupRobotWebHook.getText().toString().trim()
);
@ -857,7 +888,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextQYWXGroupRobotName.getText().toString().trim());
senderModel.setType(TYPE_QYWX_GROUP_ROBOT);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchQYWXGroupRobotEnable.isChecked() ? STATUS_ON : STATUS_OFF);
QYWXGroupRobotSettingVo qywxGroupRobotSettingVoNew = new QYWXGroupRobotSettingVo(
editTextQYWXGroupRobotWebHook.getText().toString().trim()
);
@ -908,8 +939,12 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_qywxapp, null);
final EditText editTextQYWXAppName = view1.findViewById(R.id.editTextQYWXAppName);
if (senderModel != null)
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchQYWXAppEnable = view1.findViewById(R.id.switchQYWXAppEnable);
if (senderModel != null) {
editTextQYWXAppName.setText(senderModel.getName());
switchQYWXAppEnable.setChecked(senderModel.getStatusChecked());
}
final EditText editTextQYWXAppCorpID = view1.findViewById(R.id.editTextQYWXAppCorpID);
final EditText editTextQYWXAppAgentID = view1.findViewById(R.id.editTextQYWXAppAgentID);
final ClearEditText editTextQYWXAppSecret = view1.findViewById(R.id.editTextQYWXAppSecret);
@ -957,7 +992,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextQYWXAppName.getText().toString().trim());
newSenderModel.setType(TYPE_QYWX_APP);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchQYWXAppEnable.isChecked() ? STATUS_ON : STATUS_OFF);
QYWXAppSettingVo QYWXAppSettingVoNew = new QYWXAppSettingVo(
editTextQYWXAppCorpID.getText().toString().trim(),
editTextQYWXAppAgentID.getText().toString().trim(),
@ -971,7 +1006,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextQYWXAppName.getText().toString().trim());
senderModel.setType(TYPE_QYWX_APP);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchQYWXAppEnable.isChecked() ? STATUS_ON : STATUS_OFF);
QYWXAppSettingVo QYWXAppSettingVoNew = new QYWXAppSettingVo(
editTextQYWXAppCorpID.getText().toString().trim(),
editTextQYWXAppAgentID.getText().toString().trim(),
@ -1031,7 +1066,11 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_telegram, null);
final EditText editTextTelegramName = view1.findViewById(R.id.editTextTelegramName);
if (senderModel != null) editTextTelegramName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchTelegramEnable = view1.findViewById(R.id.switchTelegramEnable);
if (senderModel != null) {
editTextTelegramName.setText(senderModel.getName());
switchTelegramEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextTelegramApiToken = view1.findViewById(R.id.editTextTelegramApiToken);
final EditText editTextTelegramChatId = view1.findViewById(R.id.editTextTelegramChatId);
@ -1108,7 +1147,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextTelegramName.getText().toString().trim());
newSenderModel.setType(TYPE_TELEGRAM);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchTelegramEnable.isChecked() ? STATUS_ON : STATUS_OFF);
TelegramSettingVo telegramSettingVoNew = new TelegramSettingVo(
editTextTelegramApiToken.getText().toString().trim(),
editTextTelegramChatId.getText().toString().trim(),
@ -1128,7 +1167,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextTelegramName.getText().toString().trim());
senderModel.setType(TYPE_TELEGRAM);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchTelegramEnable.isChecked() ? STATUS_ON : STATUS_OFF);
TelegramSettingVo telegramSettingVoNew = new TelegramSettingVo(
editTextTelegramApiToken.getText().toString().trim(),
editTextTelegramChatId.getText().toString().trim(),
@ -1200,13 +1239,20 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_sms, null);
final EditText editTextSmsName = view1.findViewById(R.id.editTextSmsName);
if (senderModel != null) editTextSmsName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchSmsEnable = view1.findViewById(R.id.switchSmsEnable);
if (senderModel != null) {
editTextSmsName.setText(senderModel.getName());
switchSmsEnable.setChecked(senderModel.getStatusChecked());
}
final RadioGroup radioGroupSmsSimSlot = view1.findViewById(R.id.radioGroupSmsSimSlot);
if (smsSettingVo != null) radioGroupSmsSimSlot.check(smsSettingVo.getSmsSimSlotCheckId());
final EditText editTextSmsMobiles = view1.findViewById(R.id.editTextSmsMobiles);
if (smsSettingVo != null) editTextSmsMobiles.setText(smsSettingVo.getMobiles());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchSmsOnlyNoNetwork = view1.findViewById(R.id.switchSmsOnlyNoNetwork);
if (smsSettingVo != null) switchSmsOnlyNoNetwork.setChecked(smsSettingVo.getOnlyNoNetwork());
if (smsSettingVo != null) {
radioGroupSmsSimSlot.check(smsSettingVo.getSmsSimSlotCheckId());
editTextSmsMobiles.setText(smsSettingVo.getMobiles());
switchSmsOnlyNoNetwork.setChecked(smsSettingVo.getOnlyNoNetwork());
}
Button buttonSmsOk = view1.findViewById(R.id.buttonSmsOk);
Button buttonSmsDel = view1.findViewById(R.id.buttonSmsDel);
@ -1224,7 +1270,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextSmsName.getText().toString().trim());
newSenderModel.setType(TYPE_SMS);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchSmsEnable.isChecked() ? STATUS_ON : STATUS_OFF);
SmsSettingVo smsSettingVoNew = new SmsSettingVo(
newSenderModel.getSmsSimSlotId(radioGroupSmsSimSlot.getCheckedRadioButtonId()),
editTextSmsMobiles.getText().toString().trim(),
@ -1237,7 +1283,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextSmsName.getText().toString().trim());
senderModel.setType(TYPE_SMS);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchSmsEnable.isChecked() ? STATUS_ON : STATUS_OFF);
SmsSettingVo smsSettingVoNew = new SmsSettingVo(
senderModel.getSmsSimSlotId(radioGroupSmsSimSlot.getCheckedRadioButtonId()),
editTextSmsMobiles.getText().toString().trim(),
@ -1295,14 +1341,18 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_feishu, null);
final EditText editTextFeishuName = view1.findViewById(R.id.editTextFeishuName);
if (senderModel != null)
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchFeishuEnable = view1.findViewById(R.id.switchFeishuEnable);
if (senderModel != null) {
editTextFeishuName.setText(senderModel.getName());
switchFeishuEnable.setChecked(senderModel.getStatusChecked());
}
final EditText editTextFeishuWebhook = view1.findViewById(R.id.editTextFeishuWebhook);
if (feiShuSettingVo != null)
editTextFeishuWebhook.setText(feiShuSettingVo.getWebhook());
final ClearEditText editTextFeishuSecret = view1.findViewById(R.id.editTextFeishuSecret);
if (feiShuSettingVo != null)
if (feiShuSettingVo != null) {
editTextFeishuWebhook.setText(feiShuSettingVo.getWebhook());
editTextFeishuSecret.setText(feiShuSettingVo.getSecret());
}
Button buttonFeishuOk = view1.findViewById(R.id.buttonFeishuOk);
Button buttonFeishuDel = view1.findViewById(R.id.buttonFeishuDel);
@ -1319,7 +1369,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextFeishuName.getText().toString().trim());
newSenderModel.setType(TYPE_FEISHU);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchFeishuEnable.isChecked() ? STATUS_ON : STATUS_OFF);
FeiShuSettingVo feiShuSettingVoNew = new FeiShuSettingVo(
editTextFeishuWebhook.getText().toString().trim(),
editTextFeishuSecret.getText().toString().trim());
@ -1330,7 +1380,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextFeishuName.getText().toString().trim());
senderModel.setType(TYPE_FEISHU);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchFeishuEnable.isChecked() ? STATUS_ON : STATUS_OFF);
FeiShuSettingVo feiShuSettingVoNew = new FeiShuSettingVo(
editTextFeishuWebhook.getText().toString().trim(),
editTextFeishuSecret.getText().toString().trim());
@ -1382,6 +1432,12 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_pushplus, null);
final EditText editTextPushPlusName = view1.findViewById(R.id.editTextPushPlusName);
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchPushPlusEnable = view1.findViewById(R.id.switchPushPlusEnable);
if (senderModel != null) {
editTextPushPlusName.setText(senderModel.getName());
switchPushPlusEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextPushPlusToken = view1.findViewById(R.id.editTextPushPlusToken);
final EditText editTextPushPlusTopic = view1.findViewById(R.id.editTextPushPlusTopic);
final EditText editTextPushPlusTemplate = view1.findViewById(R.id.editTextPushPlusTemplate);
@ -1391,7 +1447,6 @@ public class SenderActivity extends AppCompatActivity {
final EditText editTextPushPlusValidTime = view1.findViewById(R.id.editTextPushPlusValidTime);
if (pushPlusSettingVo != null) {
editTextPushPlusName.setText(senderModel.getName());
editTextPushPlusToken.setText(pushPlusSettingVo.getToken());
editTextPushPlusTopic.setText(pushPlusSettingVo.getTopic());
editTextPushPlusTemplate.setText(pushPlusSettingVo.getTemplate());
@ -1416,7 +1471,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextPushPlusName.getText().toString().trim());
newSenderModel.setType(TYPE_PUSHPLUS);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchPushPlusEnable.isChecked() ? STATUS_ON : STATUS_OFF);
PushPlusSettingVo pushPlusSettingVoNew = new PushPlusSettingVo(
editTextPushPlusToken.getText().toString().trim(),
editTextPushPlusTopic.getText().toString().trim(),
@ -1433,7 +1488,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextPushPlusName.getText().toString());
senderModel.setType(TYPE_PUSHPLUS);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchPushPlusEnable.isChecked() ? STATUS_ON : STATUS_OFF);
PushPlusSettingVo pushPlusSettingVoNew = new PushPlusSettingVo(
editTextPushPlusToken.getText().toString().trim(),
editTextPushPlusTopic.getText().toString().trim(),
@ -1501,7 +1556,11 @@ public class SenderActivity extends AppCompatActivity {
View view1 = View.inflate(SenderActivity.this, R.layout.alert_dialog_setview_gotify, null);
final EditText editTextGotifyName = view1.findViewById(R.id.editTextGotifyName);
if (senderModel != null) editTextGotifyName.setText(senderModel.getName());
@SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchGotifyEnable = view1.findViewById(R.id.switchGotifyEnable);
if (senderModel != null) {
editTextGotifyName.setText(senderModel.getName());
switchGotifyEnable.setChecked(senderModel.getStatusChecked());
}
final ClearEditText editTextGotifyWebServer = view1.findViewById(R.id.editTextGotifyWebServer);
final EditText editTextGotifyTitle = view1.findViewById(R.id.editTextGotifyTitle);
@ -1540,7 +1599,7 @@ public class SenderActivity extends AppCompatActivity {
SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextGotifyName.getText().toString().trim());
newSenderModel.setType(TYPE_GOTIFY);
newSenderModel.setStatus(STATUS_ON);
newSenderModel.setStatus(switchGotifyEnable.isChecked() ? STATUS_ON : STATUS_OFF);
newSenderModel.setJsonSetting(JSON.toJSONString(gotifySettingVoNew));
SenderUtil.addSender(newSenderModel);
initSenders();
@ -1548,7 +1607,7 @@ public class SenderActivity extends AppCompatActivity {
} else {
senderModel.setName(editTextGotifyName.getText().toString().trim());
senderModel.setType(TYPE_GOTIFY);
senderModel.setStatus(STATUS_ON);
senderModel.setStatus(switchGotifyEnable.isChecked() ? STATUS_ON : STATUS_OFF);
senderModel.setJsonSetting(JSON.toJSONString(gotifySettingVoNew));
SenderUtil.updateSender(senderModel);
initSenders();

@ -60,6 +60,7 @@ public class SenderAdapter extends ArrayAdapter<SenderModel> {
// 避免每次调用getView()时都要重新获取控件实例
viewHolder = new ViewHolder();
viewHolder.senderImage = view.findViewById(R.id.sender_image);
viewHolder.senderStatus = view.findViewById(R.id.sender_status);
viewHolder.senderName = view.findViewById(R.id.sender_name);
// 将ViewHolder存储在View中即将控件的实例存储在其中
@ -72,6 +73,7 @@ public class SenderAdapter extends ArrayAdapter<SenderModel> {
// 获取控件实例并调用set...方法使其显示出来
if (senderModel != null) {
viewHolder.senderImage.setImageResource(senderModel.getImageId());
viewHolder.senderStatus.setImageResource(senderModel.getStatusImageId());
viewHolder.senderName.setText(senderModel.getName());
}
@ -123,6 +125,7 @@ public class SenderAdapter extends ArrayAdapter<SenderModel> {
// 定义一个内部类,用于对控件的实例进行缓存
static class ViewHolder {
ImageView senderImage;
ImageView senderStatus;
TextView senderName;
}

@ -85,6 +85,7 @@ public class RuleModel {
private String smsTemplate;
private boolean switchRegexReplace;
private String regexReplace;
private int status;
public static String getRuleMatch(String filed, String check, String value, String simSlot) {
String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";

@ -20,5 +20,6 @@ public final class RuleTable {
public static final String COLUMN_NAME_SIM_SLOT = "sim_slot";
public static final String COLUMN_SMS_TEMPLATE = "sms_template";
public static final String COLUMN_REGEX_REPLACE = "regex_replace";
public static final String COLUMN_NAME_STATUS = "status";
}
}

@ -97,7 +97,6 @@ public class SenderModel {
case (TYPE_SMS):
default:
return R.mipmap.sms;
}
}
@ -111,6 +110,20 @@ public class SenderModel {
}
}
public int getStatusImageId() {
switch (status) {
case (STATUS_OFF):
return R.drawable.ic_round_pause;
case (STATUS_ON):
default:
return R.drawable.ic_round_play;
}
}
public boolean getStatusChecked() {
return !(status == STATUS_OFF);
}
@NonNull
@Override
public String toString() {

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.sender;
import static com.idormy.sms.forwarder.model.SenderModel.STATUS_OFF;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_BARK;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_DINGDING;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_EMAIL;
@ -166,7 +167,14 @@ public class SendUtil {
public static void senderSendMsg(Handler handError, SmsVo smsVo, SenderModel senderModel, long logId, String smsTemplate, String regexReplace) {
Log.i(TAG, "senderSendMsg smsVo:" + smsVo + "senderModel:" + senderModel);
Log.i(TAG, "senderSendMsg smsVo:" + smsVo.toString() + "senderModel:" + senderModel.toString());
if (senderModel.getStatus() == STATUS_OFF) {
LogUtil.updateLog(logId, 0, "发送通道已被禁用!");
Log.i(TAG, "发送通道已被禁用!");
return;
}
switch (senderModel.getType()) {
case TYPE_DINGDING:
//try phrase json setting

@ -16,7 +16,7 @@ import java.util.List;
public class DbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version.
public static final String TAG = "DbHelper";
public static final int DATABASE_VERSION = 8;
public static final int DATABASE_VERSION = 9;
public static final String DATABASE_NAME = "sms_forwarder.db";
private static final List<String> SQL_CREATE_ENTRIES =
@ -41,12 +41,13 @@ public class DbHelper extends SQLiteOpenHelper {
RuleTable.RuleEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE + " TEXT NOT NULL DEFAULT ''," +
RuleTable.RuleEntry.COLUMN_REGEX_REPLACE + " TEXT NOT NULL DEFAULT ''," +
RuleTable.RuleEntry.COLUMN_NAME_STATUS + " INTEGER NOT NULL DEFAULT 1," +
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT + " TEXT NOT NULL DEFAULT 'ALL')"
, "CREATE TABLE " + SenderTable.SenderEntry.TABLE_NAME + " (" +
SenderTable.SenderEntry._ID + " INTEGER PRIMARY KEY," +
SenderTable.SenderEntry.COLUMN_NAME_NAME + " TEXT," +
SenderTable.SenderEntry.COLUMN_NAME_STATUS + " INTEGER," +
SenderTable.SenderEntry.COLUMN_NAME_TYPE + " INTEGER," +
SenderTable.SenderEntry.COLUMN_NAME_STATUS + " INTEGER NOT NULL DEFAULT 1," +
SenderTable.SenderEntry.COLUMN_NAME_TYPE + " INTEGER NOT NULL DEFAULT 1," +
SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING + " TEXT," +
SenderTable.SenderEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"
);
@ -113,6 +114,12 @@ public class DbHelper extends SQLiteOpenHelper {
String sql = "update " + LogTable.LogEntry.TABLE_NAME + " set " + LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS + " = 2 where " + LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS + " = 1 ";
db.execSQL(sql);
}
if (oldVersion < 9) { //规则/通道状态0=禁用1=启用
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_NAME_STATUS + " INTEGER NOT NULL DEFAULT 1 ";
db.execSQL(sql);
sql = "update " + SenderTable.SenderEntry.TABLE_NAME + " set " + SenderTable.SenderEntry.COLUMN_NAME_STATUS + " = 1 ";
db.execSQL(sql);
}
}
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#666666"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,16L9,16L9,8h2v8zM15,16h-2L13,8h2v8z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#1C8DD4"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,16.5v-9l6,4.5 -6,4.5z"/>
</vector>

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="9"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchBarkEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchDingdingEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout
@ -39,6 +49,7 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
@ -73,6 +84,7 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
@ -106,6 +118,7 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
@ -138,8 +151,10 @@
<Switch
android:id="@+id/switchDingdingAtAll"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />

@ -28,11 +28,21 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:maxLines="1"
android:text=""
tools:ignore="LabelFor,TextFields" />
<Switch
android:id="@+id/switchEmailEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<TextView

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchFeishuEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,11 +28,21 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:maxLines="1"
android:text=""
tools:ignore="LabelFor,TextFields" />
<Switch
android:id="@+id/switchGotifyEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="14"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor,TextFields" />
<Switch
android:id="@+id/switchPushPlusEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -26,13 +26,24 @@
<EditText
android:id="@+id/editTextQYWXAppName"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:ems="9"
android:autofillHints=""
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchQYWXAppEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchQYWXGroupRobotEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchServerChanEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -27,10 +27,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="14"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchSmsEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -33,6 +33,16 @@
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchTelegramEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -28,10 +28,20 @@
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:autofillHints=""
android:ems="11"
android:ems="10"
android:inputType="text"
android:text=""
tools:ignore="LabelFor" />
<Switch
android:id="@+id/switchWebNotifyEnable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:checked="false"
android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<LinearLayout

@ -3,14 +3,32 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UseCompoundDrawables">
tools:ignore="UseCompoundDrawables"
android:background="@android:color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="@+id/sender_image"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="5dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_marginStart="5dp"
android:orientation="vertical">
<ImageView
android:id="@+id/sender_image"
android:layout_width="32dp"
android:layout_height="32dp"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/sender_status"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginStart="18dp"
android:layout_marginTop="-14dp"
tools:ignore="ContentDescription" />
</LinearLayout>
<TextView
android:id="@+id/sender_name"
@ -18,4 +36,5 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp" />
</LinearLayout>

@ -117,10 +117,10 @@
<string name="invalid_at_mobiles">The specified member cannot be blank or select @all</string> <!-- “指定成员 不能为空 或者 选择@all” 这句话是什么意思?“指定成员既不能为‘空’也不能为‘选择@all”吗还是“指定成员不能为空或者可以@all”呢 -->
<string name="invalid_phone_num">Phone number cannot be blank</string>
<string name="new_sender">New Sender</string>
<string name="set_bark_name">Bark Group Name</string>
<string name="set_bark_name">Bark Group Name/Status</string>
<string name="set_bark_server">Bark-Server, e.g. https://bark.bms.ink/XXXXXXXX/</string>
<string name="set_bark_icon">Bark-Icon (optional), e.g. http://day.app/assets/images/avatar.jpg</string>
<string name="set_name">Name</string>
<string name="set_name">Name/Staus</string>
<string name="dingding_token">Token e.g. the XXXXXX part of https://oapi.dingtalk.com/robot/send?access_token=XXXXXX</string>
<string name="dingding_secret">Secret (optional)</string>
<string name="dingding_at">At Mobiles e.g. 18888888888,19999999999</string>
@ -279,4 +279,5 @@
<string name="priority">Priority1 9</string>
<string name="_5">5</string>
<string name="enter_webserver_tips">Please enter the WebServer</string>
<string name="is_enable">Is Enable</string>
</resources>

@ -117,10 +117,10 @@
<string name="invalid_at_mobiles">指定成员 不能为空 或者 选择@all</string>
<string name="invalid_phone_num">接收手机号不能为空</string>
<string name="new_sender">添加发送通道</string>
<string name="set_bark_name">设置分组名称</string>
<string name="set_bark_name">分组名称/状态</string>
<string name="set_bark_server">设置Bark-Server地址示例https://bark.bms.ink/XXXXXXXX/</string>
<string name="set_bark_icon">设置推送消息图标(可选)示例http://day.app/assets/images/avatar.jpg</string>
<string name="set_name">设置名称</string>
<string name="set_name">名称/状态</string>
<string name="dingding_token">设置Token 例如 https://oapi.dingtalk.com/robot/send?access_token=XXXXXX 中的 XXXXXX</string>
<string name="dingding_secret">加签 Secret (没有可不填)</string>
<string name="dingding_at">转发时@某人 填写某人的手机号,多个用逗号分开 例如18888888888,19999999999</string>
@ -278,4 +278,5 @@
<string name="priority">优先级1 - 9</string>
<string name="_5">5</string>
<string name="enter_webserver_tips">请输入WebServer</string>
<string name="is_enable">是否启用</string>
</resources>

Loading…
Cancel
Save