diff --git a/README.md b/README.md index ac5cc7fe..4f01c311 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,10 @@ Android手机监听短信并根据指定规则转发到其他手机:钉钉机 | ![添加/编辑发送方网页通知](pic/sendersetwebnotify.jpg "添加/编辑发送方网页通知") | ![添加/编辑发送方企业微信群机器人](pic/sendersetqywechat.jpg "添加/编辑发送方企业微信群机器人") | | 添加/编辑发送方企业微信应用 | 应用设置 | | ![添加/编辑发送方企业微信应用](pic/sendersetqywxapp.jpg "添加/编辑发送方企业微信应用") | ![应用设置](pic/setting.jpg "应用设置") | -| 关于/在线升级 | 转发短信模板增加卡槽标识 | -| ![在线升级](pic/update.jpg "在线升级") | ![转发短信模板增加卡槽标识](pic/siminfo.jpg "转发短信模板增加卡槽标识") | - +| 关于/在线升级 | 支持正则匹配规则 & 支持卡槽匹配规则 | +| ![在线升级](pic/update.jpg "在线升级") | ![支持正则匹配规则 & 支持卡槽匹配规则](pic/regex.jpg "支持正则匹配规则 & 支持卡槽匹配规则") | +| 转发短信模板增加卡槽标识 | | +| ![转发短信模板增加卡槽标识](pic/siminfo.jpg "转发短信模板增加卡槽标识") | | -------- @@ -114,15 +115,19 @@ Android手机监听短信并根据指定规则转发到其他手机:钉钉机 + [v1.5.0](app/release/SmsForwarder_release_20210305_1.5.0.apk) 新增转发到企业微信应用消息 + [v1.5.1](app/release/SmsForwarder_release_20210310_1.5.1.apk) 解决Android 9.xx、10.xx收不到广播问题 + [v1.5.2](app/release/SmsForwarder_release_20210311_1.5.2.apk) 支持标注卡槽号码(优先使用)、设备信息;自定义转发信息模版 ++ [v1.6.0](app/release/SmsForwarder_release_20210312_1.6.0.apk) 优化获取SIM信息(兼容高版本Android) & 自动填写设备备注 & 自动填充卡槽信息到SIM1备注/SIM2备注 & 支持卡槽匹配规则 & 支持正则匹配规则 -------- ## 反馈与建议: ++ 提交issues 或 pr ++ 加入交流群 + | | | | ---- | ---- | -| QQ交流群:562854376 | 提交issues 或 pr | -| ![QQ交流群:562854376](pic/qqgroup.jpg "QQ交流群:562854376") | ![QQ交流群:562854376](pic/about.jpg "QQ交流群:562854376") | +| QQ交流群:562854376 | 微信交流群 | +| ![QQ交流群:562854376](pic/qqgroup.jpg "QQ交流群:562854376") | ![微信交流群](pic/wechat.jpg "微信交流群") | ## LICENSE diff --git a/app/release/SmsForwarder_release_20210312_1.6.0.apk b/app/release/SmsForwarder_release_20210312_1.6.0.apk new file mode 100644 index 00000000..763302a1 Binary files /dev/null and b/app/release/SmsForwarder_release_20210312_1.6.0.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 2271234c..591213aa 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -10,9 +10,9 @@ { "type": "SINGLE", "filters": [], - "versionCode": 15, - "versionName": "1.5.2", - "outputFile": "SmsForwarder_release_20210311_1.5.2.apk" + "versionCode": 16, + "versionName": "1.6.0", + "outputFile": "SmsForwarder_release_20210312_1.6.0.apk" } ] } \ No newline at end of file diff --git a/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java b/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java index 2ab362c9..e0b33f76 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java +++ b/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java @@ -1,5 +1,6 @@ package com.idormy.sms.forwarder; +import android.annotation.SuppressLint; import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; @@ -144,7 +145,15 @@ public class RuleActivity extends AppCompatActivity { if (ruleModel != null) radioGroupRuleFiled.check(ruleModel.getRuleFiledCheckId()); final RadioGroup radioGroupRuleCheck = (RadioGroup) view1.findViewById(R.id.radioGroupRuleCheck); - if (ruleModel != null) radioGroupRuleCheck.check(ruleModel.getRuleCheckCheckId()); + final RadioGroup radioGroupRuleCheck2 = (RadioGroup) view1.findViewById(R.id.radioGroupRuleCheck2); + if (ruleModel != null) { + int ruleCheckCheckId = ruleModel.getRuleCheckCheckId(); + if (ruleCheckCheckId == R.id.btnIs || ruleCheckCheckId == R.id.btnNotIs || ruleCheckCheckId == R.id.btnContain) { + radioGroupRuleCheck.check(ruleCheckCheckId); + } else { + radioGroupRuleCheck2.check(ruleCheckCheckId); + } + } final RadioGroup radioGroupSimSlot = (RadioGroup) view1.findViewById(R.id.radioGroupSimSlot); if (ruleModel != null) radioGroupSimSlot.check(ruleModel.getRuleSimSlotCheckId()); @@ -174,7 +183,7 @@ public class RuleActivity extends AppCompatActivity { //当更新选择的字段的时候,更新之下各个选项的状态 final LinearLayout matchTypeLayout = (LinearLayout) view1.findViewById(R.id.matchTypeLayout); final LinearLayout matchValueLayout = (LinearLayout) view1.findViewById(R.id.matchValueLayout); - refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); + refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); Button buttonruleok = view1.findViewById(R.id.buttonruleok); Button buttonruledel = view1.findViewById(R.id.buttonruledel); @@ -189,10 +198,12 @@ public class RuleActivity extends AppCompatActivity { @Override public void onClick(View view) { Object senderId = ruleSenderTv.getTag(); + int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId()); + Log.d(TAG, "XXXX " + radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId); if (ruleModel == null) { RuleModel newRuleModel = new RuleModel(); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); - newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheck.getCheckedRadioButtonId())); + newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId)); newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId())); newRuleModel.setValue(editTextRuleValue.getText().toString()); if (senderId != null) { @@ -203,7 +214,7 @@ public class RuleActivity extends AppCompatActivity { adapter.add(ruleModels); } else { ruleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); - ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheck.getCheckedRadioButtonId())); + ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId)); ruleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId())); ruleModel.setValue(editTextRuleValue.getText().toString()); if (senderId != null) { @@ -237,10 +248,11 @@ public class RuleActivity extends AppCompatActivity { if (senderId == null) { Toast.makeText(RuleActivity.this, "请先创建选择发送方", Toast.LENGTH_LONG).show(); } else { + int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId()); if (ruleModel == null) { RuleModel newRuleModel = new RuleModel(); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); - newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheck.getCheckedRadioButtonId())); + newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId)); newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId())); newRuleModel.setValue(editTextRuleValue.getText().toString()); newRuleModel.setSenderId(Long.valueOf(senderId.toString())); @@ -248,7 +260,7 @@ public class RuleActivity extends AppCompatActivity { testRule(newRuleModel, Long.valueOf(senderId.toString())); } else { ruleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); - ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheck.getCheckedRadioButtonId())); + ruleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId)); ruleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId())); ruleModel.setValue(editTextRuleValue.getText().toString()); ruleModel.setSenderId(Long.valueOf(senderId.toString())); @@ -264,18 +276,57 @@ public class RuleActivity extends AppCompatActivity { //当更新选择的字段的时候,更新之下各个选项的状态 // 如果设置了转发全部,禁用选择模式和匹配值输入 // 如果设置了多重规则,选择模式置为是 - private void refreshSelectRadioGroupRuleFiled(RadioGroup radioGroupRuleFiled, final RadioGroup radioGroupRuleCheck, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { - refreshSelectRadioGroupRuleFiledAction(radioGroupRuleFiled.getCheckedRadioButtonId(), radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); + private void refreshSelectRadioGroupRuleFiled(RadioGroup radioGroupRuleFiled, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { + refreshSelectRadioGroupRuleFiledAction(radioGroupRuleFiled.getCheckedRadioButtonId(), radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); + radioGroupRuleCheck.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @SuppressLint("ResourceType") + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + Log.d(TAG, String.valueOf(group)); + Log.d(TAG, String.valueOf(checkedId)); + if (group != null && checkedId > 0) { + if (group == radioGroupRuleCheck) { + radioGroupRuleCheck2.clearCheck(); + } else if (group == radioGroupRuleCheck2) { + radioGroupRuleCheck.clearCheck(); + } + group.check(checkedId); + } + } + }); + radioGroupRuleCheck2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @SuppressLint("ResourceType") + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + Log.d(TAG, String.valueOf(group)); + Log.d(TAG, String.valueOf(checkedId)); + if (group != null && checkedId > 0) { + if (group == radioGroupRuleCheck) { + radioGroupRuleCheck2.clearCheck(); + } else if (group == radioGroupRuleCheck2) { + radioGroupRuleCheck.clearCheck(); + } + group.check(checkedId); + } + } + }); radioGroupRuleFiled.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { - refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); + Log.d(TAG, String.valueOf(group)); + Log.d(TAG, String.valueOf(checkedId)); + if (group == radioGroupRuleCheck) { + radioGroupRuleCheck2.clearCheck(); + } else if (group == radioGroupRuleCheck2) { + radioGroupRuleCheck.clearCheck(); + } + refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); } }); } - private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { + private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { tv_mu_rule_tips.setVisibility(View.GONE); matchTypeLayout.setVisibility(View.VISIBLE); matchValueLayout.setVisibility(View.VISIBLE); @@ -285,6 +336,9 @@ public class RuleActivity extends AppCompatActivity { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { ((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); } + for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { + ((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(false); + } editTextRuleValue.setEnabled(false); matchTypeLayout.setVisibility(View.GONE); matchValueLayout.setVisibility(View.GONE); @@ -293,6 +347,9 @@ public class RuleActivity extends AppCompatActivity { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { ((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); } + for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { + ((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(false); + } editTextRuleValue.setEnabled(true); matchTypeLayout.setVisibility(View.GONE); tv_mu_rule_tips.setVisibility(MyApplication.showHelpTip ? View.VISIBLE : View.GONE); @@ -301,6 +358,9 @@ public class RuleActivity extends AppCompatActivity { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { ((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(true); } + for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { + ((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(true); + } editTextRuleValue.setEnabled(true); break; } diff --git a/app/src/main/java/com/idormy/sms/forwarder/model/RuleModel.java b/app/src/main/java/com/idormy/sms/forwarder/model/RuleModel.java index e2e6de83..a0076784 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/model/RuleModel.java +++ b/app/src/main/java/com/idormy/sms/forwarder/model/RuleModel.java @@ -42,6 +42,7 @@ public class RuleModel { CHECK_MAP.put("startwith", "开头是"); CHECK_MAP.put("endwith", "结尾是"); CHECK_MAP.put("notis", "不是"); + CHECK_MAP.put("regex", "正则匹配"); } static { diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 186fa2c2..7697de08 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -111,7 +111,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:text="开源地址" /> + android:text="更新日志" /> diff --git a/app/src/main/res/layout/alert_dialog_setview_rule.xml b/app/src/main/res/layout/alert_dialog_setview_rule.xml index b1dde0f2..0122ae90 100644 --- a/app/src/main/res/layout/alert_dialog_setview_rule.xml +++ b/app/src/main/res/layout/alert_dialog_setview_rule.xml @@ -24,32 +24,24 @@ + android:text="全部" /> + style="@style/rg_rb_style" + android:text="SIM1" /> + style="@style/rg_rb_style" + android:text="SIM2" /> @@ -70,38 +62,29 @@ + android:text="全部" /> + style="@style/rg_rb_style" + android:text="手机号" /> + style="@style/rg_rb_style" + android:text="内容" /> + style="@style/rg_rb_style" + android:text="多重匹配" /> @@ -123,53 +106,45 @@ + android:text="是   " /> + style="@style/rg_rb_style" + android:text="不是  " /> + style="@style/rg_rb_style" + android:text="包含  " /> + + + + style="@style/rg_rb_style" + android:text="开头  " /> + style="@style/rg_rb_style" + android:text="结尾  " /> + style="@style/rg_rb_style" + android:text="正则匹配" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 5885930d..99c83901 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,4 +8,15 @@ @color/colorAccent + + + + diff --git a/app/version.gradle b/app/version.gradle index b805ec71..39063da7 100644 --- a/app/version.gradle +++ b/app/version.gradle @@ -1,4 +1,4 @@ ext { - appVersionCode = 15 - appVersionName = "1.5.2" + appVersionCode = 16 + appVersionName = "1.6.0" } \ No newline at end of file diff --git a/pic/regex.jpg b/pic/regex.jpg new file mode 100644 index 00000000..6cb49e8b Binary files /dev/null and b/pic/regex.jpg differ diff --git a/pic/setting.jpg b/pic/setting.jpg index c4572982..608e35f0 100644 Binary files a/pic/setting.jpg and b/pic/setting.jpg differ diff --git a/pic/wechat.jpg b/pic/wechat.jpg new file mode 100644 index 00000000..655725cd Binary files /dev/null and b/pic/wechat.jpg differ