新增:支持一键克隆单条转发规则(长按弹出对话框)

This commit is contained in:
pppscn 2021-12-21 17:56:54 +08:00
parent 282a5b7b43
commit 412ad3dc3e
3 changed files with 20 additions and 8 deletions

View File

@ -87,8 +87,9 @@ public class RuleActivity extends AppCompatActivity {
listView.setOnItemClickListener((parent, view, position, id) -> { listView.setOnItemClickListener((parent, view, position, id) -> {
RuleModel ruleModel = ruleModels.get(position); RuleModel ruleModel = ruleModels.get(position);
Log.d(TAG, "onItemClick: " + ruleModel); Log.d(TAG, "onItemClick: " + ruleModel);
setRule(ruleModel); setRule(ruleModel, false);
}); });
listView.setOnItemLongClickListener((parent, view, position, id) -> { listView.setOnItemLongClickListener((parent, view, position, id) -> {
//定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框 //定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框
AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this); 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(); 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()方法 //添加AlertDialog.Builder对象的setNegativeButton()方法
builder.setNegativeButton(R.string.cancel, (dialog, which) -> { builder.setNegativeButton(R.string.cancel, (dialog, which) -> {
@ -169,10 +181,10 @@ public class RuleActivity extends AppCompatActivity {
final RadioGroup radioGroupTypeCheck = findViewById(R.id.radioGroupTypeCheck); final RadioGroup radioGroupTypeCheck = findViewById(R.id.radioGroupTypeCheck);
radioGroupTypeCheck.check(typeCheckId); 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 AlertDialog.Builder alertDialog71 = new AlertDialog.Builder(RuleActivity.this);
final View view1 = View.inflate(RuleActivity.this, getDialogView(currentType), null); 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()); int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId());
Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId); Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId);
if (ruleModel == null) { if (isClone || ruleModel == null) {
RuleModel newRuleModel = new RuleModel(); RuleModel newRuleModel = new RuleModel();
newRuleModel.setType(currentType); newRuleModel.setType(currentType);
newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId()));

View File

@ -17,7 +17,7 @@
<string name="sender_setting">Sender Setting</string> <string name="sender_setting">Sender Setting</string>
<string name="app_list">App List</string> <string name="app_list">App List</string>
<string name="log_tips">Tips: Pull to refresh; Long press to delete one log entry.</string> <string name="log_tips">Tips: Pull to refresh; Long press to delete one log entry.</string>
<string name="rule_tips">Tips: Tap "NEW FORWARDING RULE" to add a new rule; Long press a rule to delete; Tap an existing rule to edit.</string> <string name="rule_tips">Tips: Tap "NEW FORWARDING RULE" to add a new rule; Long press a rule to delete or clone; Tap an existing rule to edit.</string>
<string name="sender_tips">Tips: Tap "NEW SENDER" to add a new sender; Long press a sender to delete; Tap an existing sender to edit.</string> <string name="sender_tips">Tips: Tap "NEW SENDER" to add a new sender; Long press a sender to delete; Tap an existing sender to edit.</string>
<string name="app_tips">Tips: Tap to copy the package name of an App; Long press an App to start and jump to it.</string> <string name="app_tips">Tips: Tap to copy the package name of an App; Long press an App to start and jump to it.</string>
<!--AboutActivity--> <!--AboutActivity-->
@ -52,7 +52,7 @@
<string name="setrule">Fwd Rule Settings</string> <string name="setrule">Fwd Rule Settings</string>
<string name="setrule_call">Fwd Rule Settings of call</string> <string name="setrule_call">Fwd Rule Settings of call</string>
<string name="setrule_app">Fwd Rule Settings of app</string> <string name="setrule_app">Fwd Rule Settings of app</string>
<string name="delete_rule_title">Delete confirmation</string> <string name="delete_rule_title">Confirmation</string>
<string name="delete_rule_tips">Are you sure to delete this rule entry?</string> <string name="delete_rule_tips">Are you sure to delete this rule entry?</string>
<string name="delete_rule_toast">The rule entry has deleted.</string> <string name="delete_rule_toast">The rule entry has deleted.</string>
<string name="new_sender_first">Please add a new sender and then choose it.</string> <string name="new_sender_first">Please add a new sender and then choose it.</string>

View File

@ -17,7 +17,7 @@
<string name="sender_setting">发送通道</string> <string name="sender_setting">发送通道</string>
<string name="app_list">应用列表</string> <string name="app_list">应用列表</string>
<string name="log_tips">提示:置顶下拉刷新,长按删除单条,选项卡切换日志类型</string> <string name="log_tips">提示:置顶下拉刷新,长按删除单条,选项卡切换日志类型</string>
<string name="rule_tips">提示:新建规则点击“添加”,长按删除/点击编辑已有</string> <string name="rule_tips">提示:新建规则点击“添加”,长按删除/克隆,点击编辑已有</string>
<string name="sender_tips">提示:新建发送通道点击“添加”,长按删除/点击编辑已有</string> <string name="sender_tips">提示:新建发送通道点击“添加”,长按删除/点击编辑已有</string>
<string name="app_tips">提示点击复制APP的包名长按则启动并跳转该APP</string> <string name="app_tips">提示点击复制APP的包名长按则启动并跳转该APP</string>
<!--AboutActivity--> <!--AboutActivity-->
@ -52,7 +52,7 @@
<string name="setrule">设置短信转发规则</string> <string name="setrule">设置短信转发规则</string>
<string name="setrule_call">设置来电转发规则</string> <string name="setrule_call">设置来电转发规则</string>
<string name="setrule_app">设置APP通知转发规则</string> <string name="setrule_app">设置APP通知转发规则</string>
<string name="delete_rule_title">规则删除确认</string> <string name="delete_rule_title">规则操作确认</string>
<string name="delete_rule_tips">确定删除该条规则?</string> <string name="delete_rule_tips">确定删除该条规则?</string>
<string name="delete_rule_toast">该条规则已经删除!</string> <string name="delete_rule_toast">该条规则已经删除!</string>
<string name="new_sender_first">请选择发送通道(若无,请先添加)</string> <string name="new_sender_first">请选择发送通道(若无,请先添加)</string>