mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-02 03:40:26 +00:00
commit
a2999a2ade
@ -374,49 +374,49 @@ public class RuleActivity extends AppCompatActivity {
|
||||
buttonInsertSender.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{来源号码}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{来源号码}}");
|
||||
});
|
||||
|
||||
Button buttonInsertContent = view1.findViewById(R.id.bt_insert_content);
|
||||
buttonInsertContent.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{短信内容}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{短信内容}}");
|
||||
});
|
||||
|
||||
Button buttonInsertSenderApp = view1.findViewById(R.id.bt_insert_sender_app);
|
||||
buttonInsertSenderApp.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{APP包名}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{APP包名}}");
|
||||
});
|
||||
|
||||
Button buttonInsertContentApp = view1.findViewById(R.id.bt_insert_content_app);
|
||||
buttonInsertContentApp.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{通知内容}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{通知内容}}");
|
||||
});
|
||||
|
||||
Button buttonInsertExtra = view1.findViewById(R.id.bt_insert_extra);
|
||||
buttonInsertExtra.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{卡槽信息}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{卡槽信息}}");
|
||||
});
|
||||
|
||||
Button buttonInsertTime = view1.findViewById(R.id.bt_insert_time);
|
||||
buttonInsertTime.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{接收时间}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{接收时间}}");
|
||||
});
|
||||
|
||||
Button buttonInsertDeviceName = view1.findViewById(R.id.bt_insert_device_name);
|
||||
buttonInsertDeviceName.setOnClickListener(view -> {
|
||||
textSmsTemplate.setFocusable(true);
|
||||
textSmsTemplate.requestFocus();
|
||||
textSmsTemplate.append("{{设备名称}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{设备名称}}");
|
||||
});
|
||||
|
||||
//正则替换
|
||||
@ -433,6 +433,12 @@ public class RuleActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
private void insertOrReplaceText2Cursor(EditText editText, String str) {
|
||||
int start = Math.max(editText.getSelectionStart(), 0);
|
||||
int end = Math.max(editText.getSelectionEnd(), 0);
|
||||
editText.getText().replace(Math.min(start, end), Math.max(start, end), str, 0, str.length());
|
||||
}
|
||||
|
||||
//当更新选择的字段的时候,更新之下各个选项的状态
|
||||
// 如果设置了转发全部,禁用选择模式和匹配值输入
|
||||
// 如果设置了多重规则,选择模式置为是
|
||||
|
@ -356,24 +356,30 @@ public class SettingActivity extends AppCompatActivity {
|
||||
textSmsTemplate.requestFocus();
|
||||
switch (v.getId()) {
|
||||
case R.id.bt_insert_sender:
|
||||
textSmsTemplate.append("{{来源号码}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{来源号码}}");
|
||||
return;
|
||||
case R.id.bt_insert_content:
|
||||
textSmsTemplate.append("{{短信内容}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{短信内容}}");
|
||||
return;
|
||||
case R.id.bt_insert_extra:
|
||||
textSmsTemplate.append("{{卡槽信息}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{卡槽信息}}");
|
||||
return;
|
||||
case R.id.bt_insert_time:
|
||||
textSmsTemplate.append("{{接收时间}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{接收时间}}");
|
||||
return;
|
||||
case R.id.bt_insert_device_name:
|
||||
textSmsTemplate.append("{{设备名称}}");
|
||||
insertOrReplaceText2Cursor(textSmsTemplate, "{{设备名称}}");
|
||||
return;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private void insertOrReplaceText2Cursor(EditText editText, String str) {
|
||||
int start = Math.max(editText.getSelectionStart(), 0);
|
||||
int end = Math.max(editText.getSelectionEnd(), 0);
|
||||
editText.getText().replace(Math.min(start, end), Math.max(start, end), str, 0, str.length());
|
||||
}
|
||||
|
||||
//恢复初始化配置
|
||||
public void initSetting(View view) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user