From 412ad3dc3ea08dd1c1d2705abf1167d90a887024 Mon Sep 17 00:00:00 2001 From: pppscn <35696959@qq.com> Date: Tue, 21 Dec 2021 17:56:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E9=94=AE=E5=85=8B=E9=9A=86=E5=8D=95=E6=9D=A1=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E8=A7=84=E5=88=99=EF=BC=88=E9=95=BF=E6=8C=89=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E5=AF=B9=E8=AF=9D=E6=A1=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idormy/sms/forwarder/RuleActivity.java | 20 +++++++++++++++---- app/src/main/res/values-en/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) 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 55e37667..fe550a69 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java +++ b/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java @@ -87,8 +87,9 @@ public class RuleActivity extends AppCompatActivity { listView.setOnItemClickListener((parent, view, position, id) -> { RuleModel ruleModel = ruleModels.get(position); Log.d(TAG, "onItemClick: " + ruleModel); - setRule(ruleModel); + setRule(ruleModel, false); }); + listView.setOnItemLongClickListener((parent, view, position, id) -> { //定义AlertDialog.Builder对象,当长按列表项的时候弹出确认删除对话框 AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this); @@ -103,6 +104,17 @@ public class RuleActivity extends AppCompatActivity { Toast.makeText(getBaseContext(), R.string.delete_rule_toast, Toast.LENGTH_SHORT).show(); }); + //添加AlertDialog.Builder对象的setNegativeButton()方法 + builder.setNeutralButton(R.string.clone, (dialog, which) -> { + RuleModel ruleModel = ruleModels.get(position); + //TODO:直接复制 + //RuleUtil.addRule(ruleModel); + //initRules(); + //adapter.add(ruleModels); + //TODO:只复制到编辑对话框 + setRule(ruleModel, true); + }); + //添加AlertDialog.Builder对象的setNegativeButton()方法 builder.setNegativeButton(R.string.cancel, (dialog, which) -> { @@ -169,10 +181,10 @@ public class RuleActivity extends AppCompatActivity { final RadioGroup radioGroupTypeCheck = findViewById(R.id.radioGroupTypeCheck); radioGroupTypeCheck.check(typeCheckId); - setRule(null); + setRule(null, false); } - private void setRule(final RuleModel ruleModel) { + private void setRule(final RuleModel ruleModel, final boolean isClone) { final AlertDialog.Builder alertDialog71 = new AlertDialog.Builder(RuleActivity.this); final View view1 = View.inflate(RuleActivity.this, getDialogView(currentType), null); @@ -260,7 +272,7 @@ public class RuleActivity extends AppCompatActivity { int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId()); Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId); - if (ruleModel == null) { + if (isClone || ruleModel == null) { RuleModel newRuleModel = new RuleModel(); newRuleModel.setType(currentType); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 0615a37a..7852191b 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -17,7 +17,7 @@ Sender Setting App List Tips: Pull to refresh; Long press to delete one log entry. - Tips: Tap "NEW FORWARDING RULE" to add a new rule; Long press a rule to delete; Tap an existing rule to edit. + Tips: Tap "NEW FORWARDING RULE" to add a new rule; Long press a rule to delete or clone; Tap an existing rule to edit. Tips: Tap "NEW SENDER" to add a new sender; Long press a sender to delete; Tap an existing sender to edit. Tips: Tap to copy the package name of an App; Long press an App to start and jump to it. @@ -52,7 +52,7 @@ Fwd Rule Settings Fwd Rule Settings of call Fwd Rule Settings of app - Delete confirmation + Confirmation Are you sure to delete this rule entry? The rule entry has deleted. Please add a new sender and then choose it. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d1acc975..f1e45d92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,7 +17,7 @@ 发送通道 应用列表 提示:置顶下拉刷新,长按删除单条,选项卡切换日志类型 - 提示:新建规则点击“添加”,长按删除/点击编辑已有 + 提示:新建规则点击“添加”,长按删除/克隆,点击编辑已有 提示:新建发送通道点击“添加”,长按删除/点击编辑已有 提示:点击复制APP的包名,长按则启动并跳转该APP @@ -52,7 +52,7 @@ 设置短信转发规则 设置来电转发规则 设置APP通知转发规则 - 规则删除确认 + 规则操作确认 确定删除该条规则? 该条规则已经删除! 请选择发送通道(若无,请先添加)