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.ListView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -165,6 +166,14 @@ public class RuleActivity extends AppCompatActivity {
|
||||
final LinearLayout matchValueLayout = view1.findViewById(R.id.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 buttonRuleDel = view1.findViewById(R.id.buttonRuleDel);
|
||||
Button buttonRuleTest = view1.findViewById(R.id.buttonRuleTest);
|
||||
@ -184,6 +193,8 @@ public class RuleActivity extends AppCompatActivity {
|
||||
newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
||||
newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
||||
newRuleModel.setValue(editTextRuleValue.getText().toString());
|
||||
newRuleModel.setSwitchSmsTemplate(switchSmsTemplate.isChecked());
|
||||
newRuleModel.setSmsTemplate(textSmsTemplate.getText().toString());
|
||||
if (senderId != null) {
|
||||
newRuleModel.setSenderId(Long.valueOf(senderId.toString()));
|
||||
}
|
||||
@ -195,6 +206,8 @@ public class RuleActivity extends AppCompatActivity {
|
||||
ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
||||
ruleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
||||
ruleModel.setValue(editTextRuleValue.getText().toString());
|
||||
ruleModel.setSwitchSmsTemplate(switchSmsTemplate.isChecked());
|
||||
ruleModel.setSmsTemplate(textSmsTemplate.getText().toString());
|
||||
if (senderId != null) {
|
||||
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 time;
|
||||
private String simSlot;
|
||||
private boolean switchSmsTemplate;
|
||||
private String smsTemplate;
|
||||
|
||||
public static String getRuleMatch(String filed, String check, String value, String simSlot) {
|
||||
String SimStr = SIM_SLOT_MAP.get(simSlot) + "卡 ";
|
||||
@ -271,6 +273,10 @@ public class RuleModel {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSwitchSmsTemplate() {
|
||||
return switchSmsTemplate;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
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_TIME = "time";
|
||||
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")
|
||||
public String getSmsVoForSend() {
|
||||
boolean switchAddExtra = SettingUtil.getSwitchAddExtra();
|
||||
boolean switchAddDeviceName = SettingUtil.getSwitchAddDeviceName();
|
||||
public String getSmsVoForSend(String ruleSmsTemplate) {
|
||||
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
|
||||
String customSmsTemplate = "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}";
|
||||
|
||||
//优先取转发规则的自定义模板,留空则取全局设置
|
||||
if (!ruleSmsTemplate.isEmpty()) {
|
||||
customSmsTemplate = ruleSmsTemplate;
|
||||
} else {
|
||||
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
|
||||
String smsTemplate = SettingUtil.getSmsTemplate().trim();
|
||||
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
|
||||
if (!switchSmsTemplate) {
|
||||
smsTemplate = "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}";
|
||||
if (switchSmsTemplate && !smsTemplate.isEmpty()) {
|
||||
customSmsTemplate = smsTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
return smsTemplate.replace("{{来源号码}}", mobile)
|
||||
return customSmsTemplate.replace("{{来源号码}}", mobile)
|
||||
.replace("{{短信内容}}", content)
|
||||
.replace("{{卡槽信息}}", simInfo)
|
||||
.replace("{{接收时间}}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date))
|
||||
|
@ -63,7 +63,8 @@ public class SendUtil {
|
||||
for (SenderModel senderModel : senderModels
|
||||
) {
|
||||
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) {
|
||||
@ -96,15 +97,15 @@ public class SendUtil {
|
||||
|
||||
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()) {
|
||||
@ -114,7 +115,7 @@ public class SendUtil {
|
||||
DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class);
|
||||
if (dingDingSettingVo != null) {
|
||||
try {
|
||||
SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend());
|
||||
SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
|
||||
@ -130,7 +131,7 @@ public class SendUtil {
|
||||
if (emailSettingVo != null) {
|
||||
try {
|
||||
SenderMailMsg.sendEmail(logId, handError, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(), emailSettingVo.getNickname(),
|
||||
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
|
||||
@ -145,7 +146,7 @@ public class SendUtil {
|
||||
BarkSettingVo barkSettingVo = JSON.parseObject(senderModel.getJsonSetting(), BarkSettingVo.class);
|
||||
if (barkSettingVo != null) {
|
||||
try {
|
||||
SenderBarkMsg.sendMsg(logId, handError, barkSettingVo.getServer(), barkSettingVo.getIcon(), smsVo.getMobile(), smsVo.getSmsVoForSend(), senderModel.getName());
|
||||
SenderBarkMsg.sendMsg(logId, handError, barkSettingVo.getServer(), barkSettingVo.getIcon(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate), senderModel.getName());
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
|
||||
@ -160,7 +161,7 @@ public class SendUtil {
|
||||
WebNotifySettingVo webNotifySettingVo = JSON.parseObject(senderModel.getJsonSetting(), WebNotifySettingVo.class);
|
||||
if (webNotifySettingVo != null) {
|
||||
try {
|
||||
SenderWebNotifyMsg.sendMsg(logId, handError, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
SenderWebNotifyMsg.sendMsg(logId, handError, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
|
||||
@ -175,7 +176,7 @@ public class SendUtil {
|
||||
QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXGroupRobotSettingVo.class);
|
||||
if (qywxGroupRobotSettingVo != null) {
|
||||
try {
|
||||
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
|
||||
@ -190,7 +191,7 @@ public class SendUtil {
|
||||
QYWXAppSettingVo qYWXAppSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXAppSettingVo.class);
|
||||
if (qYWXAppSettingVo != null) {
|
||||
try {
|
||||
SenderQyWxAppMsg.sendMsg(logId, handError, qYWXAppSettingVo.getCorpID(), qYWXAppSettingVo.getAgentID(), qYWXAppSettingVo.getSecret(), qYWXAppSettingVo.getToUser(), smsVo.getSmsVoForSend(), false);
|
||||
SenderQyWxAppMsg.sendMsg(logId, handError, qYWXAppSettingVo.getCorpID(), qYWXAppSettingVo.getAgentID(), qYWXAppSettingVo.getSecret(), qYWXAppSettingVo.getToUser(), smsVo.getSmsVoForSend(smsTemplate), false);
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
|
||||
@ -205,7 +206,7 @@ public class SendUtil {
|
||||
ServerChanSettingVo serverChanSettingVo = JSON.parseObject(senderModel.getJsonSetting(), ServerChanSettingVo.class);
|
||||
if (serverChanSettingVo != null) {
|
||||
try {
|
||||
SenderServerChanMsg.sendMsg(logId, handError, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
SenderServerChanMsg.sendMsg(logId, handError, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage());
|
||||
@ -220,7 +221,7 @@ public class SendUtil {
|
||||
TelegramSettingVo telegramSettingVo = JSON.parseObject(senderModel.getJsonSetting(), TelegramSettingVo.class);
|
||||
if (telegramSettingVo != null) {
|
||||
try {
|
||||
SenderTelegramMsg.sendMsg(logId, handError, telegramSettingVo.getApiToken(), telegramSettingVo.getChatId(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
SenderTelegramMsg.sendMsg(logId, handError, telegramSettingVo.getApiToken(), telegramSettingVo.getChatId(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderTelegramMsg error " + e.getMessage());
|
||||
@ -247,7 +248,7 @@ public class SendUtil {
|
||||
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());
|
||||
SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage());
|
||||
@ -262,7 +263,7 @@ public class SendUtil {
|
||||
FeiShuSettingVo feiShuSettingVo = JSON.parseObject(senderModel.getJsonSetting(), FeiShuSettingVo.class);
|
||||
if (feiShuSettingVo != null) {
|
||||
try {
|
||||
SenderFeishuMsg.sendMsg(logId, handError, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), smsVo.getSmsVoForSend());
|
||||
SenderFeishuMsg.sendMsg(logId, handError, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), smsVo.getSmsVoForSend(smsTemplate));
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
|
||||
|
@ -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 = 4;
|
||||
public static final int DATABASE_VERSION = 5;
|
||||
public static final String DATABASE_NAME = "sms_forwarder.db";
|
||||
|
||||
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_SENDER_ID + " INTEGER," +
|
||||
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')"
|
||||
, "CREATE TABLE " + SenderTable.SenderEntry.TABLE_NAME + " (" +
|
||||
SenderTable.SenderEntry._ID + " INTEGER PRIMARY KEY," +
|
||||
@ -77,20 +78,24 @@ public class DbHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
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 ";
|
||||
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' ";
|
||||
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 ";
|
||||
db.execSQL(sql);
|
||||
sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + LogTable.LogEntry.COLUMN_NAME_FORWARD_RESPONSE + " TEXT NOT NULL DEFAULT 'ok' ";
|
||||
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) {
|
||||
|
@ -43,6 +43,7 @@ public class RuleUtil {
|
||||
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_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
|
||||
|
||||
@ -59,6 +60,7 @@ public class RuleUtil {
|
||||
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_SIM_SLOT, ruleModel.getSimSlot());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE, ruleModel.getSmsTemplate());
|
||||
|
||||
String selection = RuleTable.RuleEntry._ID + " = ? ";
|
||||
String[] whereArgs = {String.valueOf(ruleModel.getId())};
|
||||
@ -95,6 +97,7 @@ public class RuleUtil {
|
||||
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_TIME,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT,
|
||||
RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE,
|
||||
};
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 = 1 ";
|
||||
@ -149,6 +152,8 @@ public class RuleUtil {
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TIME));
|
||||
String itemSimSlot = cursor.getString(
|
||||
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);
|
||||
RuleModel ruleModel = new RuleModel();
|
||||
@ -159,6 +164,8 @@ public class RuleUtil {
|
||||
ruleModel.setSenderId(itemSenderId);
|
||||
ruleModel.setTime(itemTime);
|
||||
ruleModel.setSimSlot(itemSimSlot);
|
||||
ruleModel.setSwitchSmsTemplate(!smsTemplate.trim().isEmpty());
|
||||
ruleModel.setSmsTemplate(smsTemplate);
|
||||
|
||||
tRules.add(ruleModel);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@
|
||||
android:autofillHints=""
|
||||
android:ems="14"
|
||||
android:inputType="textMultiLine"
|
||||
android:gravity="left|top"
|
||||
android:gravity="start|top"
|
||||
android:minLines="1"
|
||||
android:text=""
|
||||
tools:ignore="LabelFor" />
|
||||
@ -192,7 +192,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -224,6 +223,144 @@
|
||||
|
||||
</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
|
||||
android:layout_width="match_parent"
|
||||
|
@ -149,7 +149,7 @@
|
||||
<string name="add_extra">转发时附加卡槽信息</string>
|
||||
<string name="add_device_name">转发时附加设备名称</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_tips">Tip:按需插入内容标签;留空使用默认模版</string>
|
||||
<string name="insert_sender">来源号码</string>
|
||||
|
Loading…
Reference in New Issue
Block a user