支持多重匹配规则

This commit is contained in:
pppscn 2021-03-04 14:08:40 +08:00
parent a27fb0d5da
commit b3ec467284
7 changed files with 48 additions and 32 deletions

View File

@ -46,6 +46,7 @@ Android手机监听短信并根据指定规则转发到其他手机、钉钉机
- [x] 清理缓存 - [x] 清理缓存
- [x] 兼容6.xx、7.xx、8.xx、9.xx、10.xx - [x] 兼容6.xx、7.xx、8.xx、9.xx、10.xx
- [x] 支持双卡手机,增加卡槽标识/运营商/手机号(如果能获取的话) - [x] 支持双卡手机,增加卡槽标识/运营商/手机号(如果能获取的话)
- [x] 支持多重匹配规则
### 使用流程: ### 使用流程:
1. 在Android手机上安装SmsForwarder 本APP后点击应用图标打开 1. 在Android手机上安装SmsForwarder 本APP后点击应用图标打开
@ -74,11 +75,14 @@ Android手机监听短信并根据指定规则转发到其他手机、钉钉机
| ![添加编辑发送方网页通知](pic/sendersetwebnotify.png "添加编辑发送方网页通知") | ![添加编辑发送方企业微信群机器人](pic/sendersetqywechat.png "添加编辑发送方企业微信群机器人") | | ![添加编辑发送方网页通知](pic/sendersetwebnotify.png "添加编辑发送方网页通知") | ![添加编辑发送方企业微信群机器人](pic/sendersetqywechat.png "添加编辑发送方企业微信群机器人") |
| ![状态栏运行状态](pic/taskbar.png "状态栏运行状态") | ![应用设置](pic/setting.png "应用设置") | | ![状态栏运行状态](pic/taskbar.png "状态栏运行状态") | ![应用设置](pic/setting.png "应用设置") |
| ![在线升级](pic/update.png "在线升级") | ![增加卡槽标识](pic/siminfo.png "增加卡槽标识") | | ![在线升级](pic/update.png "在线升级") | ![增加卡槽标识](pic/siminfo.png "增加卡槽标识") |
| ![多重匹配规则](pic/multimatch.png "多重匹配规则") | |
-------- --------
## 更新记录: ## 更新记录:
> [v1.4.0](app/release/SmsForwarder_release_20210304_1.4.0.apk) 支持多重匹配规则
> [v1.3.0](app/release/SmsForwarder_release_20210303_1.3.0.apk) 支持双卡手机,增加卡槽标识/运营商/手机号(如果能获取的话) > [v1.3.0](app/release/SmsForwarder_release_20210303_1.3.0.apk) 支持双卡手机,增加卡槽标识/运营商/手机号(如果能获取的话)
> [v1.2.3](app/release/SmsForwarder_release_20210302_1.2.3.apk) 【预发布】转发日志列表/详情增加卡槽标识SIM1 或 SIM2 > [v1.2.3](app/release/SmsForwarder_release_20210302_1.2.3.apk) 【预发布】转发日志列表/详情增加卡槽标识SIM1 或 SIM2

View File

@ -14,8 +14,8 @@ android {
applicationId "com.idormy.sms.forwarder" applicationId "com.idormy.sms.forwarder"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 10 versionCode 11
versionName "1.3.0" versionName "1.4.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
signingConfigs { signingConfigs {

Binary file not shown.

View File

@ -10,9 +10,9 @@
{ {
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"versionCode": 10, "versionCode": 11,
"versionName": "1.3.0", "versionName": "1.4.0",
"outputFile": "SmsForwarder_release_20210303_1.3.0.apk" "outputFile": "SmsForwarder_release_20210304_1.4.0.apk"
} }
] ]
} }

View File

@ -9,6 +9,7 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
@ -157,13 +158,16 @@ public class RuleActivity extends AppCompatActivity {
editTextRuleValue.setText(ruleModel.getValue()); editTextRuleValue.setText(ruleModel.getValue());
//当更新选择的字段的时候更新之下各个选项的状态 //当更新选择的字段的时候更新之下各个选项的状态
refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips); 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);
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);
alertDialog71 alertDialog71
.setTitle(R.string.setrule) .setTitle(R.string.setrule)
//.setIcon(R.drawable.ic_sms_forwarder)
.setView(view1) .setView(view1)
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
@ -236,7 +240,6 @@ public class RuleActivity extends AppCompatActivity {
} }
} }
} }
@ -247,19 +250,21 @@ public class RuleActivity extends AppCompatActivity {
//当更新选择的字段的时候更新之下各个选项的状态 //当更新选择的字段的时候更新之下各个选项的状态
// 如果设置了转发全部禁用选择模式和匹配值输入 // 如果设置了转发全部禁用选择模式和匹配值输入
// 如果设置了多重规则选择模式置为是 // 如果设置了多重规则选择模式置为是
private void refreshSelectRadioGroupRuleFiled(RadioGroup radioGroupRuleFiled, final RadioGroup radioGroupRuleCheck, final EditText editTextRuleValue, final TextView tv_mu_rule_tips) { 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); refreshSelectRadioGroupRuleFiledAction(radioGroupRuleFiled.getCheckedRadioButtonId(), radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
radioGroupRuleFiled.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { radioGroupRuleFiled.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips); refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
} }
}); });
} }
private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final EditText editTextRuleValue, final TextView tv_mu_rule_tips) { private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) {
tv_mu_rule_tips.setVisibility(View.GONE); tv_mu_rule_tips.setVisibility(View.GONE);
matchTypeLayout.setVisibility(View.VISIBLE);
matchValueLayout.setVisibility(View.VISIBLE);
switch (checkedRuleFiledId) { switch (checkedRuleFiledId) {
case R.id.btnTranspondAll: case R.id.btnTranspondAll:
@ -267,12 +272,15 @@ public class RuleActivity extends AppCompatActivity {
((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); ((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false);
} }
editTextRuleValue.setEnabled(false); editTextRuleValue.setEnabled(false);
matchTypeLayout.setVisibility(View.GONE);
matchValueLayout.setVisibility(View.GONE);
break; break;
case R.id.btnMultiMatch: case R.id.btnMultiMatch:
for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); ((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false);
} }
editTextRuleValue.setEnabled(true); editTextRuleValue.setEnabled(true);
matchTypeLayout.setVisibility(View.GONE);
tv_mu_rule_tips.setVisibility(View.VISIBLE); tv_mu_rule_tips.setVisibility(View.VISIBLE);
break; break;
default: default:

View File

@ -18,7 +18,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="设置匹配的字段" /> android:text="设置匹配的字段"
android:textStyle="bold" />
<RadioGroup <RadioGroup
android:id="@+id/radioGroupRuleFiled" android:id="@+id/radioGroupRuleFiled"
@ -43,7 +44,7 @@
android:id="@+id/btnContent" android:id="@+id/btnContent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="内容" /> android:text="短信内容" />
<RadioButton <RadioButton
android:id="@+id/btnMultiMatch" android:id="@+id/btnMultiMatch"
@ -52,21 +53,6 @@
android:text="多重匹配" /> android:text="多重匹配" />
</RadioGroup> </RadioGroup>
<TextView
android:id="@+id/tv_mu_rule_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="
多重匹配规则如下:\n
\n
并且 是 手机号 相等 10086\n
或者 是 手机号 相等 10011\n
并且 是 短信内容 包含 欠费\n
\n
已上规则表示:收到短信,并且手机号是10086 或者 手机号是10010 并且短信内容包含欠费 时转发短信\n
注意每行开始的空格代表层级,太过复杂的多重规则可能导致内存占用很大
" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -80,7 +66,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="设置匹配的模式" /> android:text="设置匹配的模式"
android:textStyle="bold" />
<RadioGroup <RadioGroup
android:id="@+id/radioGroupRuleCheck" android:id="@+id/radioGroupRuleCheck"
@ -133,7 +120,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="设置匹配的值" /> android:text="设置匹配的值"
android:textStyle="bold" />
<EditText <EditText
android:id="@+id/editTextRuleValue" android:id="@+id/editTextRuleValue"
@ -142,6 +130,22 @@
android:ems="14" android:ems="14"
android:inputType="" android:inputType=""
android:text="" /> android:text="" />
<TextView
android:id="@+id/tv_mu_rule_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="
多重匹配规则示例:\n
\n
并且 是 手机号 相等 10086\n
或者 是 手机号 相等 10011\n
并且 是 短信内容 包含 欠费\n
\n
以上规则表示收到短信并且手机号是10086 或者 手机号是10010并且 短信内容 包含 欠费 时转发短信\n
注意:每行开始的空格代表层级,太过复杂的多重规则可能导致内存占用很大!
" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -154,8 +158,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp" android:text="设置发送方"
android:text="设置发送方" /> android:textStyle="bold" />
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"

BIN
pic/multimatch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB