Skip to content

Commit

Permalink
新增测试通知标题和修复英文正则表达式 (#208)
Browse files Browse the repository at this point in the history
* 新增:测试通知转发规则时可以指定通知标题

* 修复:英文版多重匹配的正则错误
  • Loading branch information
genment authored Aug 18, 2022
1 parent bffebeb commit 84d321d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,16 @@ class RulesEditFragment : BaseFragment<FragmentRulesEditBinding?>(), View.OnClic
val rgSimSlot = dialogTest.findViewById<RadioGroup>(R.id.rg_sim_slot)
val tvFrom = dialogTest.findViewById<TextView>(R.id.tv_from)
val etFrom = dialogTest.findViewById<EditText>(R.id.et_from)
val tvTitle = dialogTest.findViewById<TextView>(R.id.tv_title)
val etTitle = dialogTest.findViewById<EditText>(R.id.et_title)
val tvContent = dialogTest.findViewById<TextView>(R.id.tv_content)
val etContent = dialogTest.findViewById<EditText>(R.id.et_content)

if ("app" == ruleType) {
tvSimSlot.visibility = View.GONE
rgSimSlot.visibility = View.GONE
tvTitle.visibility = View.VISIBLE
etTitle.visibility = View.VISIBLE
tvFrom.setText(R.string.test_package_name)
tvContent.setText(R.string.test_inform_content)
} else if ("call" == ruleType) {
Expand All @@ -592,7 +596,7 @@ class RulesEditFragment : BaseFragment<FragmentRulesEditBinding?>(), View.OnClic
.positiveText(R.string.action_test)
.onPositive { _: MaterialDialog?, _: DialogAction? ->
try {
val simSlot = when (rgSimSlot.checkedRadioButtonId) {
val simSlot = when (if (ruleType == "app") -1 else rgSimSlot.checkedRadioButtonId) {
R.id.rb_sim_slot_1 -> 0
R.id.rb_sim_slot_2 -> 1
else -> -1
Expand All @@ -608,7 +612,7 @@ class RulesEditFragment : BaseFragment<FragmentRulesEditBinding?>(), View.OnClic
val simInfo = when (simSlot) {
0 -> "SIM1_" + SettingUtils.extraSim1
1 -> "SIM2_" + SettingUtils.extraSim2
else -> ""
else -> etTitle.text.toString()
}

val msgInfo = MsgInfo(ruleType, etFrom.text.toString(), etContent.text.toString(), Date(), simInfo, simSlot)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/dialog_rule_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
android:inputType="textMultiLine"
app:met_clearButton="true" />

<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test_inform_title"
android:visibility="gone" />

<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
android:id="@+id/et_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:visibility="gone"
app:met_clearButton="true" />

<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
<string name="test_phone_number">Test Phone Number</string>
<string name="test_msg_content">Test Msg Content</string>
<string name="test_package_name">Test PackageName</string>
<string name="test_inform_title">Test Notify Title</string>
<string name="test_inform_content">Test Notify Content</string>
<string name="match_sim_slot">SIM Slot</string>
<string name="match_field">Field</string>
Expand Down Expand Up @@ -708,7 +709,7 @@
<string name="choose_sender">Drop-down selection, keyword fuzzy match</string>
<string name="choose_app">Installed apps</string>
<string name="choose_app_hint">Drop-down selection to get package name, keyword fuzzy matching APP name</string>
<string name="regex_multi_match" tools:ignore="TypographyDashes">^\\s*(AND|OR)\\s(IS|NOTIS)\\s(PHONE_NUM|PACKAGE_NAME|MSG_CONTENT|INFORM_CONTENT|INFORM_TITLE|CARD_SLOT)\\\\s(EQUALS|CONTAIN|NOTCONTAIN|STARTWITH|ENDWITH|REGEX)\\s(.*)$</string>
<string name="regex_multi_match" tools:ignore="TypographyDashes">^\\s*(AND|OR)\\s(IS|NOTIS)\\s(PHONE_NUM|PACKAGE_NAME|MSG_CONTENT|INFORM_CONTENT|INFORM_TITLE|CARD_SLOT)\\s(EQUALS|CONTAIN|NOTCONTAIN|STARTWITH|ENDWITH|REGEX)\\s(.*)$</string>
<string name="privacy_content_1">Welcome to</string>
<string name="privacy_content_2">We understand the importance of personal information to you and thank you for your trust in us.\n</string>
<string name="privacy_content_3">In order to better protect your rights and comply with relevant regulatory requirements, we will pass "</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<string name="test_phone_number">测试模拟的来源号码</string>
<string name="test_msg_content">测试模拟的短信内容</string>
<string name="test_package_name">测试模拟的APP包名</string>
<string name="test_inform_title">测试模拟的通知标题</string>
<string name="test_inform_content">测试模拟的通知内容</string>
<string name="match_sim_slot">匹配卡槽</string>
<string name="match_field">匹配字段</string>
Expand Down

0 comments on commit 84d321d

Please sign in to comment.