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通知转发规则 - 规则删除确认 + 规则操作确认 确定删除该条规则? 该条规则已经删除! 请选择发送通道(若无,请先添加)