Skip to content

Commit

Permalink
优化获取SIM信息(兼容高版本Android) & 自动填写设备备注 & 自动填充卡槽信息到SIM1备注/SIM2备注 & 支持卡槽匹配规…
Browse files Browse the repository at this point in the history
…则 & 支持正则匹配规则
  • Loading branch information
pppscn committed Mar 12, 2021
1 parent 23c51a5 commit 560cfae
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 82 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "转发短信模板增加卡槽标识") | |

--------

Expand All @@ -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
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
80 changes: 70 additions & 10 deletions app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -144,7 +145,15 @@ private void setRule(final RuleModel ruleModel) {
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());
Expand Down Expand Up @@ -174,7 +183,7 @@ public void onClick(View view) {
//当更新选择的字段的时候,更新之下各个选项的状态
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);
Expand All @@ -189,10 +198,12 @@ public void onClick(View view) {
@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) {
Expand All @@ -203,7 +214,7 @@ public void onClick(View view) {
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) {
Expand Down Expand Up @@ -237,18 +248,19 @@ public void onClick(View view) {
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()));

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()));
Expand All @@ -264,18 +276,57 @@ public void onClick(View view) {
//当更新选择的字段的时候,更新之下各个选项的状态
// 如果设置了转发全部,禁用选择模式和匹配值输入
// 如果设置了多重规则,选择模式置为是
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);
Expand All @@ -285,6 +336,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
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);
Expand All @@ -293,6 +347,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
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);
Expand All @@ -301,6 +358,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class RuleModel {
CHECK_MAP.put("startwith", "开头是");
CHECK_MAP.put("endwith", "结尾是");
CHECK_MAP.put("notis", "不是");
CHECK_MAP.put("regex", "正则匹配");
}

static {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="开源地址" />
android:text="更新日志" />

<TextView
android:id="@+id/linkweb"
Expand All @@ -120,7 +120,7 @@
android:layout_weight="3"
android:autoLink="web"
android:gravity="right"
android:text="https://github.com/pppscn/SmsForwarder"
android:text="https://github.com/pppscn/SmsForwarder/releases"
android:textSize="14sp" />
</LinearLayout>

Expand Down
Loading

0 comments on commit 560cfae

Please sign in to comment.