mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-02 03:40:26 +00:00
新增:添加转发规则时允许自定义模板(留空则取全局设置)
This commit is contained in:
parent
fb437fb329
commit
90b495a2de
@ -13,6 +13,7 @@ import android.widget.EditText;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -165,6 +166,14 @@ public class RuleActivity extends AppCompatActivity {
|
|||||||
final LinearLayout matchValueLayout = view1.findViewById(R.id.matchValueLayout);
|
final LinearLayout matchValueLayout = view1.findViewById(R.id.matchValueLayout);
|
||||||
refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
|
refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
|
||||||
|
|
||||||
|
//自定义模板
|
||||||
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switchSmsTemplate = view1.findViewById(R.id.switch_sms_template);
|
||||||
|
EditText textSmsTemplate = view1.findViewById(R.id.text_sms_template);
|
||||||
|
if (ruleModel != null) {
|
||||||
|
switchSmsTemplate.setChecked(ruleModel.getSwitchSmsTemplate());
|
||||||
|
textSmsTemplate.setText(ruleModel.getSmsTemplate());
|
||||||
|
}
|
||||||
|
|
||||||
Button buttonRuleOk = view1.findViewById(R.id.buttonRuleOk);
|
Button buttonRuleOk = view1.findViewById(R.id.buttonRuleOk);
|
||||||
Button buttonRuleDel = view1.findViewById(R.id.buttonRuleDel);
|
Button buttonRuleDel = view1.findViewById(R.id.buttonRuleDel);
|
||||||
Button buttonRuleTest = view1.findViewById(R.id.buttonRuleTest);
|
Button buttonRuleTest = view1.findViewById(R.id.buttonRuleTest);
|
||||||
@ -184,6 +193,8 @@ public class RuleActivity extends AppCompatActivity {
|
|||||||
newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
||||||
newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
||||||
newRuleModel.setValue(editTextRuleValue.getText().toString());
|
newRuleModel.setValue(editTextRuleValue.getText().toString());
|
||||||
|
newRuleModel.setSwitchSmsTemplate(switchSmsTemplate.isChecked());
|
||||||
|
newRuleModel.setSmsTemplate(textSmsTemplate.getText().toString());
|
||||||
if (senderId != null) {
|
if (senderId != null) {
|
||||||
newRuleModel.setSenderId(Long.valueOf(senderId.toString()));
|
newRuleModel.setSenderId(Long.valueOf(senderId.toString()));
|
||||||
}
|
}
|
||||||
@ -195,6 +206,8 @@ public class RuleActivity extends AppCompatActivity {
|
|||||||
ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
||||||
ruleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
ruleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
||||||
ruleModel.setValue(editTextRuleValue.getText().toString());
|
ruleModel.setValue(editTextRuleValue.getText().toString());
|
||||||
|
ruleModel.setSwitchSmsTemplate(switchSmsTemplate.isChecked());
|
||||||
|
ruleModel.setSmsTemplate(textSmsTemplate.getText().toString());
|
||||||
if (senderId != null) {
|
if (senderId != null) {
|
||||||
ruleModel.setSenderId(Long.valueOf(senderId.toString()));
|
ruleModel.setSenderId(Long.valueOf(senderId.toString()));
|
||||||
}
|
}
|
||||||
@ -242,6 +255,53 @@ public class RuleActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//自定义模板
|
||||||
|
final LinearLayout layout_sms_template = view1.findViewById(R.id.layout_sms_template);
|
||||||
|
if (ruleModel != null) {
|
||||||
|
layout_sms_template.setVisibility(ruleModel.getSwitchSmsTemplate() ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
switchSmsTemplate.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||||
|
if (!isChecked) {
|
||||||
|
textSmsTemplate.setText("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button buttonInsertSender = view1.findViewById(R.id.bt_insert_sender);
|
||||||
|
buttonInsertSender.setOnClickListener(view -> {
|
||||||
|
textSmsTemplate.setFocusable(true);
|
||||||
|
textSmsTemplate.requestFocus();
|
||||||
|
textSmsTemplate.append("{{来源号码}}");
|
||||||
|
});
|
||||||
|
|
||||||
|
Button buttonInsertContent = view1.findViewById(R.id.bt_insert_content);
|
||||||
|
buttonInsertContent.setOnClickListener(view -> {
|
||||||
|
textSmsTemplate.setFocusable(true);
|
||||||
|
textSmsTemplate.requestFocus();
|
||||||
|
textSmsTemplate.append("{{短信内容}}");
|
||||||
|
});
|
||||||
|
|
||||||
|
Button buttonInsertExtra = view1.findViewById(R.id.bt_insert_extra);
|
||||||
|
buttonInsertExtra.setOnClickListener(view -> {
|
||||||
|
textSmsTemplate.setFocusable(true);
|
||||||
|
textSmsTemplate.requestFocus();
|
||||||
|
textSmsTemplate.append("{{卡槽信息}}");
|
||||||
|
});
|
||||||
|
|
||||||
|
Button buttonInsertTime = view1.findViewById(R.id.bt_insert_time);
|
||||||
|
buttonInsertTime.setOnClickListener(view -> {
|
||||||
|
textSmsTemplate.setFocusable(true);
|
||||||
|
textSmsTemplate.requestFocus();
|
||||||
|
textSmsTemplate.append("{{接收时间}}");
|
||||||
|
});
|
||||||
|
|
||||||
|
Button buttonInsertDeviceName = view1.findViewById(R.id.bt_insert_device_name);
|
||||||
|
buttonInsertDeviceName.setOnClickListener(view -> {
|
||||||
|
textSmsTemplate.setFocusable(true);
|
||||||
|
textSmsTemplate.requestFocus();
|
||||||
|
textSmsTemplate.append("{{设备名称}}");
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//当更新选择的字段的时候,更新之下各个选项的状态
|
//当更新选择的字段的时候,更新之下各个选项的状态
|
||||||
|
@ -69,6 +69,8 @@ public class RuleModel {
|
|||||||
private Long senderId;
|
private Long senderId;
|
||||||
private Long time;
|
private Long time;
|
||||||
private String simSlot;
|
private String simSlot;
|
||||||
|
private boolean switchSmsTemplate;
|
||||||
|
private String smsTemplate;
|
||||||
|
|
||||||
public static String getRuleMatch(String filed, String check, String value, String simSlot) {
|
public static String getRuleMatch(String filed, String check, String value, String simSlot) {
|
||||||
String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";
|
String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";
|
||||||
@ -271,6 +273,10 @@ public class RuleModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSwitchSmsTemplate() {
|
||||||
|
return switchSmsTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -17,5 +17,6 @@ public final class RuleTable {
|
|||||||
public static final String COLUMN_NAME_SENDER_ID = "sender_id";
|
public static final String COLUMN_NAME_SENDER_ID = "sender_id";
|
||||||
public static final String COLUMN_NAME_TIME = "time";
|
public static final String COLUMN_NAME_TIME = "time";
|
||||||
public static final String COLUMN_NAME_SIM_SLOT = "sim_slot";
|
public static final String COLUMN_NAME_SIM_SLOT = "sim_slot";
|
||||||
|
public static final String COLUMN_SMS_TEMPLATE = "sms_template";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,17 +30,22 @@ public class SmsVo implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
public String getSmsVoForSend() {
|
public String getSmsVoForSend(String ruleSmsTemplate) {
|
||||||
boolean switchAddExtra = SettingUtil.getSwitchAddExtra();
|
|
||||||
boolean switchAddDeviceName = SettingUtil.getSwitchAddDeviceName();
|
|
||||||
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
|
|
||||||
String smsTemplate = SettingUtil.getSmsTemplate().trim();
|
|
||||||
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
|
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
|
||||||
if (!switchSmsTemplate) {
|
String customSmsTemplate = "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}";
|
||||||
smsTemplate = "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}";
|
|
||||||
|
//优先取转发规则的自定义模板,留空则取全局设置
|
||||||
|
if (!ruleSmsTemplate.isEmpty()) {
|
||||||
|
customSmsTemplate = ruleSmsTemplate;
|
||||||
|
} else {
|
||||||
|
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
|
||||||
|
String smsTemplate = SettingUtil.getSmsTemplate().trim();
|
||||||
|
if (switchSmsTemplate && !smsTemplate.isEmpty()) {
|
||||||
|
customSmsTemplate = smsTemplate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return smsTemplate.replace("{{来源号码}}", mobile)
|
return customSmsTemplate.replace("{{来源号码}}", mobile)
|
||||||
.replace("{{短信内容}}", content)
|
.replace("{{短信内容}}", content)
|
||||||
.replace("{{卡槽信息}}", simInfo)
|
.replace("{{卡槽信息}}", simInfo)
|
||||||
.replace("{{接收时间}}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date))
|
.replace("{{接收时间}}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date))
|
||||||
|
@ -1,279 +1,280 @@
|
|||||||
package com.idormy.sms.forwarder.sender;
|
package com.idormy.sms.forwarder.sender;
|
||||||
|
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_BARK;
|
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_DINGDING;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_EMAIL;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_EMAIL;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_FEISHU;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_FEISHU;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_QYWX_APP;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_QYWX_APP;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_QYWX_GROUP_ROBOT;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_QYWX_GROUP_ROBOT;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_SERVER_CHAN;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_SERVER_CHAN;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_SMS;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_SMS;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_TELEGRAM;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_TELEGRAM;
|
||||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY;
|
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.idormy.sms.forwarder.model.LogModel;
|
import com.idormy.sms.forwarder.model.LogModel;
|
||||||
import com.idormy.sms.forwarder.model.RuleModel;
|
import com.idormy.sms.forwarder.model.RuleModel;
|
||||||
import com.idormy.sms.forwarder.model.SenderModel;
|
import com.idormy.sms.forwarder.model.SenderModel;
|
||||||
import com.idormy.sms.forwarder.model.vo.BarkSettingVo;
|
import com.idormy.sms.forwarder.model.vo.BarkSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.DingDingSettingVo;
|
import com.idormy.sms.forwarder.model.vo.DingDingSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.EmailSettingVo;
|
import com.idormy.sms.forwarder.model.vo.EmailSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.FeiShuSettingVo;
|
import com.idormy.sms.forwarder.model.vo.FeiShuSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.QYWXAppSettingVo;
|
import com.idormy.sms.forwarder.model.vo.QYWXAppSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.QYWXGroupRobotSettingVo;
|
import com.idormy.sms.forwarder.model.vo.QYWXGroupRobotSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.ServerChanSettingVo;
|
import com.idormy.sms.forwarder.model.vo.ServerChanSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.SmsSettingVo;
|
import com.idormy.sms.forwarder.model.vo.SmsSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
|
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
|
||||||
import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo;
|
import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo;
|
||||||
import com.idormy.sms.forwarder.utils.LogUtil;
|
import com.idormy.sms.forwarder.utils.LogUtil;
|
||||||
import com.idormy.sms.forwarder.utils.NetUtil;
|
import com.idormy.sms.forwarder.utils.NetUtil;
|
||||||
import com.idormy.sms.forwarder.utils.RuleUtil;
|
import com.idormy.sms.forwarder.utils.RuleUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SendUtil {
|
public class SendUtil {
|
||||||
private static final String TAG = "SendUtil";
|
private static final String TAG = "SendUtil";
|
||||||
|
|
||||||
public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId) {
|
public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId) {
|
||||||
Log.i(TAG, "send_msg_list size: " + smsVoList.size());
|
Log.i(TAG, "send_msg_list size: " + smsVoList.size());
|
||||||
for (SmsVo smsVo : smsVoList) {
|
for (SmsVo smsVo : smsVoList) {
|
||||||
SendUtil.send_msg(context, smsVo, simId);
|
SendUtil.send_msg(context, smsVo, simId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send_msg(Context context, SmsVo smsVo, int simId) {
|
public static void send_msg(Context context, SmsVo smsVo, int simId) {
|
||||||
Log.i(TAG, "send_msg smsVo:" + smsVo);
|
Log.i(TAG, "send_msg smsVo:" + smsVo);
|
||||||
RuleUtil.init(context);
|
RuleUtil.init(context);
|
||||||
LogUtil.init(context);
|
LogUtil.init(context);
|
||||||
|
|
||||||
String key = "SIM" + simId;
|
String key = "SIM" + simId;
|
||||||
List<RuleModel> ruleList = RuleUtil.getRule(null, key);
|
List<RuleModel> ruleList = RuleUtil.getRule(null, key);
|
||||||
if (!ruleList.isEmpty()) {
|
if (!ruleList.isEmpty()) {
|
||||||
SenderUtil.init(context);
|
SenderUtil.init(context);
|
||||||
for (RuleModel ruleModel : ruleList) {
|
for (RuleModel ruleModel : ruleList) {
|
||||||
//规则匹配发现需要发送
|
//规则匹配发现需要发送
|
||||||
try {
|
try {
|
||||||
if (ruleModel.checkMsg(smsVo)) {
|
if (ruleModel.checkMsg(smsVo)) {
|
||||||
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
|
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
|
||||||
for (SenderModel senderModel : senderModels
|
for (SenderModel senderModel : senderModels
|
||||||
) {
|
) {
|
||||||
long logId = LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId()));
|
long logId = LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId()));
|
||||||
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId);
|
String smsTemplate = ruleModel.getSwitchSmsTemplate() ? ruleModel.getSmsTemplate() : "";
|
||||||
}
|
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
Log.e(TAG, "send_msg: fail checkMsg:", e);
|
} catch (Exception e) {
|
||||||
}
|
Log.e(TAG, "send_msg: fail checkMsg:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static void sendMsgByRuleModelSenderId(final Handler handError, RuleModel ruleModel, SmsVo smsVo, Long senderId) throws Exception {
|
|
||||||
if (senderId == null) {
|
public static void sendMsgByRuleModelSenderId(final Handler handError, RuleModel ruleModel, SmsVo smsVo, Long senderId) throws Exception {
|
||||||
throw new Exception("先新建并选择发送方");
|
if (senderId == null) {
|
||||||
}
|
throw new Exception("先新建并选择发送方");
|
||||||
|
}
|
||||||
String testSim = smsVo.getSimInfo().substring(0, 4);
|
|
||||||
String ruleSim = ruleModel.getSimSlot();
|
String testSim = smsVo.getSimInfo().substring(0, 4);
|
||||||
|
String ruleSim = ruleModel.getSimSlot();
|
||||||
if (!ruleSim.equals("ALL") && !ruleSim.equals(testSim)) {
|
|
||||||
throw new Exception("接收卡槽未匹配中规则");
|
if (!ruleSim.equals("ALL") && !ruleSim.equals(testSim)) {
|
||||||
}
|
throw new Exception("接收卡槽未匹配中规则");
|
||||||
|
}
|
||||||
if (!ruleModel.checkMsg(smsVo)) {
|
|
||||||
throw new Exception("短信未匹配中规则");
|
if (!ruleModel.checkMsg(smsVo)) {
|
||||||
}
|
throw new Exception("短信未匹配中规则");
|
||||||
|
}
|
||||||
List<SenderModel> senderModels = SenderUtil.getSender(senderId, null);
|
|
||||||
if (senderModels.isEmpty()) {
|
List<SenderModel> senderModels = SenderUtil.getSender(senderId, null);
|
||||||
throw new Exception("未找到发送方");
|
if (senderModels.isEmpty()) {
|
||||||
}
|
throw new Exception("未找到发送方");
|
||||||
|
}
|
||||||
for (SenderModel senderModel : senderModels
|
|
||||||
) {
|
for (SenderModel senderModel : senderModels
|
||||||
SendUtil.senderSendMsg(handError, smsVo, senderModel, 0);
|
) {
|
||||||
}
|
SendUtil.senderSendMsg(handError, smsVo, senderModel, 0, "");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static void senderSendMsgNoHandError(SmsVo smsVo, SenderModel senderModel, long logId) {
|
|
||||||
SendUtil.senderSendMsg(null, smsVo, senderModel, logId);
|
public static void senderSendMsgNoHandError(SmsVo smsVo, SenderModel senderModel, long logId, String smsTemplate) {
|
||||||
}
|
SendUtil.senderSendMsg(null, smsVo, senderModel, logId, smsTemplate);
|
||||||
|
}
|
||||||
public static void senderSendMsg(Handler handError, SmsVo smsVo, SenderModel senderModel, long logId) {
|
|
||||||
|
public static void senderSendMsg(Handler handError, SmsVo smsVo, SenderModel senderModel, long logId, String smsTemplate) {
|
||||||
Log.i(TAG, "senderSendMsg smsVo:" + smsVo + "senderModel:" + senderModel);
|
|
||||||
switch (senderModel.getType()) {
|
Log.i(TAG, "senderSendMsg smsVo:" + smsVo + "senderModel:" + senderModel);
|
||||||
case TYPE_DINGDING:
|
switch (senderModel.getType()) {
|
||||||
//try phrase json setting
|
case TYPE_DINGDING:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (dingDingSettingVo != null) {
|
DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class);
|
||||||
try {
|
if (dingDingSettingVo != null) {
|
||||||
SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_EMAIL:
|
|
||||||
//try phrase json setting
|
case TYPE_EMAIL:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
EmailSettingVo emailSettingVo = JSON.parseObject(senderModel.getJsonSetting(), EmailSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (emailSettingVo != null) {
|
EmailSettingVo emailSettingVo = JSON.parseObject(senderModel.getJsonSetting(), EmailSettingVo.class);
|
||||||
try {
|
if (emailSettingVo != null) {
|
||||||
SenderMailMsg.sendEmail(logId, handError, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(), emailSettingVo.getNickname(),
|
try {
|
||||||
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
SenderMailMsg.sendEmail(logId, handError, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(), emailSettingVo.getNickname(),
|
||||||
} catch (Exception e) {
|
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_BARK:
|
|
||||||
//try phrase json setting
|
case TYPE_BARK:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
BarkSettingVo barkSettingVo = JSON.parseObject(senderModel.getJsonSetting(), BarkSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (barkSettingVo != null) {
|
BarkSettingVo barkSettingVo = JSON.parseObject(senderModel.getJsonSetting(), BarkSettingVo.class);
|
||||||
try {
|
if (barkSettingVo != null) {
|
||||||
SenderBarkMsg.sendMsg(logId, handError, barkSettingVo.getServer(), barkSettingVo.getIcon(), smsVo.getMobile(), smsVo.getSmsVoForSend(), senderModel.getName());
|
try {
|
||||||
} catch (Exception e) {
|
SenderBarkMsg.sendMsg(logId, handError, barkSettingVo.getServer(), barkSettingVo.getIcon(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate), senderModel.getName());
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_WEB_NOTIFY:
|
|
||||||
//try phrase json setting
|
case TYPE_WEB_NOTIFY:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
WebNotifySettingVo webNotifySettingVo = JSON.parseObject(senderModel.getJsonSetting(), WebNotifySettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (webNotifySettingVo != null) {
|
WebNotifySettingVo webNotifySettingVo = JSON.parseObject(senderModel.getJsonSetting(), WebNotifySettingVo.class);
|
||||||
try {
|
if (webNotifySettingVo != null) {
|
||||||
SenderWebNotifyMsg.sendMsg(logId, handError, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderWebNotifyMsg.sendMsg(logId, handError, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_QYWX_GROUP_ROBOT:
|
|
||||||
//try phrase json setting
|
case TYPE_QYWX_GROUP_ROBOT:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXGroupRobotSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (qywxGroupRobotSettingVo != null) {
|
QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXGroupRobotSettingVo.class);
|
||||||
try {
|
if (qywxGroupRobotSettingVo != null) {
|
||||||
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_QYWX_APP:
|
|
||||||
//try phrase json setting
|
case TYPE_QYWX_APP:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
QYWXAppSettingVo qYWXAppSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXAppSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (qYWXAppSettingVo != null) {
|
QYWXAppSettingVo qYWXAppSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXAppSettingVo.class);
|
||||||
try {
|
if (qYWXAppSettingVo != null) {
|
||||||
SenderQyWxAppMsg.sendMsg(logId, handError, qYWXAppSettingVo.getCorpID(), qYWXAppSettingVo.getAgentID(), qYWXAppSettingVo.getSecret(), qYWXAppSettingVo.getToUser(), smsVo.getSmsVoForSend(), false);
|
try {
|
||||||
} catch (Exception e) {
|
SenderQyWxAppMsg.sendMsg(logId, handError, qYWXAppSettingVo.getCorpID(), qYWXAppSettingVo.getAgentID(), qYWXAppSettingVo.getSecret(), qYWXAppSettingVo.getToUser(), smsVo.getSmsVoForSend(smsTemplate), false);
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_SERVER_CHAN:
|
|
||||||
//try phrase json setting
|
case TYPE_SERVER_CHAN:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
ServerChanSettingVo serverChanSettingVo = JSON.parseObject(senderModel.getJsonSetting(), ServerChanSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (serverChanSettingVo != null) {
|
ServerChanSettingVo serverChanSettingVo = JSON.parseObject(senderModel.getJsonSetting(), ServerChanSettingVo.class);
|
||||||
try {
|
if (serverChanSettingVo != null) {
|
||||||
SenderServerChanMsg.sendMsg(logId, handError, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderServerChanMsg.sendMsg(logId, handError, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_TELEGRAM:
|
|
||||||
//try phrase json setting
|
case TYPE_TELEGRAM:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
TelegramSettingVo telegramSettingVo = JSON.parseObject(senderModel.getJsonSetting(), TelegramSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (telegramSettingVo != null) {
|
TelegramSettingVo telegramSettingVo = JSON.parseObject(senderModel.getJsonSetting(), TelegramSettingVo.class);
|
||||||
try {
|
if (telegramSettingVo != null) {
|
||||||
SenderTelegramMsg.sendMsg(logId, handError, telegramSettingVo.getApiToken(), telegramSettingVo.getChatId(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderTelegramMsg.sendMsg(logId, handError, telegramSettingVo.getApiToken(), telegramSettingVo.getChatId(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderTelegramMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderTelegramMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_SMS:
|
|
||||||
//try phrase json setting
|
case TYPE_SMS:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (smsSettingVo != null) {
|
SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class);
|
||||||
//仅当无网络时启用
|
if (smsSettingVo != null) {
|
||||||
if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) {
|
//仅当无网络时启用
|
||||||
String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus();
|
if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) {
|
||||||
LogUtil.updateLog(logId, 0, msg);
|
String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus();
|
||||||
Log.d(TAG, msg);
|
LogUtil.updateLog(logId, 0, msg);
|
||||||
return;
|
Log.d(TAG, msg);
|
||||||
}
|
return;
|
||||||
try {
|
}
|
||||||
int simSlot = smsSettingVo.getSimSlot() - 1;
|
try {
|
||||||
if (simSlot < 0) { //原进原出
|
int simSlot = smsSettingVo.getSimSlot() - 1;
|
||||||
simSlot = Integer.parseInt(smsVo.getSimInfo().substring(3, 4)) - 1;
|
if (simSlot < 0) { //原进原出
|
||||||
Log.d(TAG, "simSlot = " + simSlot);
|
simSlot = Integer.parseInt(smsVo.getSimInfo().substring(3, 4)) - 1;
|
||||||
}
|
Log.d(TAG, "simSlot = " + simSlot);
|
||||||
SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
}
|
||||||
} catch (Exception e) {
|
SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case TYPE_FEISHU:
|
|
||||||
//try phrase json setting
|
case TYPE_FEISHU:
|
||||||
if (senderModel.getJsonSetting() != null) {
|
//try phrase json setting
|
||||||
FeiShuSettingVo feiShuSettingVo = JSON.parseObject(senderModel.getJsonSetting(), FeiShuSettingVo.class);
|
if (senderModel.getJsonSetting() != null) {
|
||||||
if (feiShuSettingVo != null) {
|
FeiShuSettingVo feiShuSettingVo = JSON.parseObject(senderModel.getJsonSetting(), FeiShuSettingVo.class);
|
||||||
try {
|
if (feiShuSettingVo != null) {
|
||||||
SenderFeishuMsg.sendMsg(logId, handError, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), smsVo.getSmsVoForSend());
|
try {
|
||||||
} catch (Exception e) {
|
SenderFeishuMsg.sendMsg(logId, handError, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), smsVo.getSmsVoForSend(smsTemplate));
|
||||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
|
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||||
}
|
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
default:
|
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||||||
public class DbHelper extends SQLiteOpenHelper {
|
public class DbHelper extends SQLiteOpenHelper {
|
||||||
// If you change the database schema, you must increment the database version.
|
// If you change the database schema, you must increment the database version.
|
||||||
public static final String TAG = "DbHelper";
|
public static final String TAG = "DbHelper";
|
||||||
public static final int DATABASE_VERSION = 4;
|
public static final int DATABASE_VERSION = 5;
|
||||||
public static final String DATABASE_NAME = "sms_forwarder.db";
|
public static final String DATABASE_NAME = "sms_forwarder.db";
|
||||||
|
|
||||||
private static final List<String> SQL_CREATE_ENTRIES =
|
private static final List<String> SQL_CREATE_ENTRIES =
|
||||||
@ -37,6 +37,7 @@ public class DbHelper extends SQLiteOpenHelper {
|
|||||||
RuleTable.RuleEntry.COLUMN_NAME_VALUE + " TEXT," +
|
RuleTable.RuleEntry.COLUMN_NAME_VALUE + " TEXT," +
|
||||||
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID + " INTEGER," +
|
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID + " INTEGER," +
|
||||||
RuleTable.RuleEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
RuleTable.RuleEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
|
RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE + " TEXT NOT NULL DEFAULT ''," +
|
||||||
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT + " TEXT NOT NULL DEFAULT 'ALL')"
|
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT + " TEXT NOT NULL DEFAULT 'ALL')"
|
||||||
, "CREATE TABLE " + SenderTable.SenderEntry.TABLE_NAME + " (" +
|
, "CREATE TABLE " + SenderTable.SenderEntry.TABLE_NAME + " (" +
|
||||||
SenderTable.SenderEntry._ID + " INTEGER PRIMARY KEY," +
|
SenderTable.SenderEntry._ID + " INTEGER PRIMARY KEY," +
|
||||||
@ -77,20 +78,24 @@ public class DbHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
if (oldVersion < 2) { //当数据库版本小于版本2时
|
if (oldVersion < 2) { //转发日志添加SIM卡槽信息
|
||||||
String sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_SIM_INFO + " TEXT ";
|
String sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_SIM_INFO + " TEXT ";
|
||||||
db.execSQL(sql);
|
db.execSQL(sql);
|
||||||
}
|
}
|
||||||
if (oldVersion < 3) { //当数据库版本小于版本3时
|
if (oldVersion < 3) { //转发规则添加SIM卡槽信息
|
||||||
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT + " TEXT NOT NULL DEFAULT 'ALL' ";
|
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT + " TEXT NOT NULL DEFAULT 'ALL' ";
|
||||||
db.execSQL(sql);
|
db.execSQL(sql);
|
||||||
}
|
}
|
||||||
if (oldVersion < 4) { //添加转发状态与返回信息
|
if (oldVersion < 4) { //转发日志添加转发状态与返回信息
|
||||||
String sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS + " INTEGER NOT NULL DEFAULT 1 ";
|
String sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS + " INTEGER NOT NULL DEFAULT 1 ";
|
||||||
db.execSQL(sql);
|
db.execSQL(sql);
|
||||||
sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_FORWARD_RESPONSE + " TEXT NOT NULL DEFAULT 'ok' ";
|
sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_FORWARD_RESPONSE + " TEXT NOT NULL DEFAULT 'ok' ";
|
||||||
db.execSQL(sql);
|
db.execSQL(sql);
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 5) { //转发规则添加规则自定义信息模板
|
||||||
|
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE + " TEXT NOT NULL DEFAULT '' ";
|
||||||
|
db.execSQL(sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
@ -43,6 +43,7 @@ public class RuleUtil {
|
|||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT, ruleModel.getSimSlot());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT, ruleModel.getSimSlot());
|
||||||
|
values.put(RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE, ruleModel.getSmsTemplate());
|
||||||
|
|
||||||
// Insert the new row, returning the primary key value of the new row
|
// Insert the new row, returning the primary key value of the new row
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ public class RuleUtil {
|
|||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
||||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT, ruleModel.getSimSlot());
|
values.put(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT, ruleModel.getSimSlot());
|
||||||
|
values.put(RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE, ruleModel.getSmsTemplate());
|
||||||
|
|
||||||
String selection = RuleTable.RuleEntry._ID + " = ? ";
|
String selection = RuleTable.RuleEntry._ID + " = ? ";
|
||||||
String[] whereArgs = {String.valueOf(ruleModel.getId())};
|
String[] whereArgs = {String.valueOf(ruleModel.getId())};
|
||||||
@ -95,6 +97,7 @@ public class RuleUtil {
|
|||||||
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID,
|
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID,
|
||||||
RuleTable.RuleEntry.COLUMN_NAME_TIME,
|
RuleTable.RuleEntry.COLUMN_NAME_TIME,
|
||||||
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT,
|
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT,
|
||||||
|
RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE,
|
||||||
};
|
};
|
||||||
// Define 'where' part of query.
|
// Define 'where' part of query.
|
||||||
String selection = " 1 = 1 ";
|
String selection = " 1 = 1 ";
|
||||||
@ -149,6 +152,8 @@ public class RuleUtil {
|
|||||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TIME));
|
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TIME));
|
||||||
String itemSimSlot = cursor.getString(
|
String itemSimSlot = cursor.getString(
|
||||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT));
|
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT));
|
||||||
|
String smsTemplate = cursor.getString(
|
||||||
|
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE));
|
||||||
|
|
||||||
Log.d(TAG, "getRule: itemId" + itemId);
|
Log.d(TAG, "getRule: itemId" + itemId);
|
||||||
RuleModel ruleModel = new RuleModel();
|
RuleModel ruleModel = new RuleModel();
|
||||||
@ -159,6 +164,8 @@ public class RuleUtil {
|
|||||||
ruleModel.setSenderId(itemSenderId);
|
ruleModel.setSenderId(itemSenderId);
|
||||||
ruleModel.setTime(itemTime);
|
ruleModel.setTime(itemTime);
|
||||||
ruleModel.setSimSlot(itemSimSlot);
|
ruleModel.setSimSlot(itemSimSlot);
|
||||||
|
ruleModel.setSwitchSmsTemplate(!smsTemplate.trim().isEmpty());
|
||||||
|
ruleModel.setSmsTemplate(smsTemplate);
|
||||||
|
|
||||||
tRules.add(ruleModel);
|
tRules.add(ruleModel);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@
|
|||||||
android:autofillHints=""
|
android:autofillHints=""
|
||||||
android:ems="14"
|
android:ems="14"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:gravity="left|top"
|
android:gravity="start|top"
|
||||||
android:minLines="1"
|
android:minLines="1"
|
||||||
android:text=""
|
android:text=""
|
||||||
tools:ignore="LabelFor" />
|
tools:ignore="LabelFor" />
|
||||||
@ -192,7 +192,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -224,6 +223,144 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="3"
|
||||||
|
android:text="@string/enable_custom_templates"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switch_sms_template"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="3"
|
||||||
|
android:gravity="end"
|
||||||
|
android:textSize="18sp"
|
||||||
|
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_sms_template"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/custom_templates"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:text="@string/custom_templates_tips"
|
||||||
|
android:textSize="11sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/text_sms_template"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:gravity="start|top"
|
||||||
|
android:minLines="1"
|
||||||
|
android:text=""
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_insert_sender"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:text="@string/insert_sender"
|
||||||
|
tools:ignore="ButtonStyle,NestedWeights" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_insert_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:text="@string/insert_content"
|
||||||
|
tools:ignore="ButtonStyle,NestedWeights" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_insert_extra"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:text="@string/insert_extra"
|
||||||
|
tools:ignore="ButtonStyle,NestedWeights" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_insert_time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:text="@string/insert_time"
|
||||||
|
tools:ignore="ButtonStyle,NestedWeights" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_insert_device_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:text="@string/insert_device_name"
|
||||||
|
tools:ignore="ButtonStyle,NestedWeights" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -149,7 +149,7 @@
|
|||||||
<string name="add_extra">转发时附加卡槽信息</string>
|
<string name="add_extra">转发时附加卡槽信息</string>
|
||||||
<string name="add_device_name">转发时附加设备名称</string>
|
<string name="add_device_name">转发时附加设备名称</string>
|
||||||
<string name="forward_missed_calls">转发未接来电</string>
|
<string name="forward_missed_calls">转发未接来电</string>
|
||||||
<string name="enable_custom_templates">转发时启用自定义模版</string>
|
<string name="enable_custom_templates">启用自定义模版</string>
|
||||||
<string name="custom_templates">转发信息模版</string>
|
<string name="custom_templates">转发信息模版</string>
|
||||||
<string name="custom_templates_tips">Tip:按需插入内容标签;留空使用默认模版</string>
|
<string name="custom_templates_tips">Tip:按需插入内容标签;留空使用默认模版</string>
|
||||||
<string name="insert_sender">来源号码</string>
|
<string name="insert_sender">来源号码</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user