Added copy rule

pull/161/head
M66B 5 years ago
parent 348fd3806d
commit 4f68d86316

@ -185,6 +185,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
.setCheckable(true).setChecked(rule.enabled); .setCheckable(true).setChecked(rule.enabled);
popupMenu.getMenu().add(Menu.NONE, R.string.title_rule_execute, 2, R.string.title_rule_execute) popupMenu.getMenu().add(Menu.NONE, R.string.title_rule_execute, 2, R.string.title_rule_execute)
.setEnabled(ActivityBilling.isPro(context)); .setEnabled(ActivityBilling.isPro(context));
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 3, R.string.title_copy);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
@ -193,9 +194,15 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
case R.string.title_rule_enabled: case R.string.title_rule_enabled:
onActionEnabled(!item.isChecked()); onActionEnabled(!item.isChecked());
return true; return true;
case R.string.title_rule_execute: case R.string.title_rule_execute:
onActionExecute(); onActionExecute();
return true; return true;
case R.string.title_copy:
onActionCopy();
return true;
default: default:
return false; return false;
} }
@ -278,6 +285,16 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
} }
}.execute(context, owner, args, "rule:execute"); }.execute(context, owner, args, "rule:execute");
} }
private void onActionCopy() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULE)
.putExtra("id", rule.id)
.putExtra("account", rule.account)
.putExtra("folder", rule.folder)
.putExtra("copy", true));
}
}); });
popupMenu.show(); popupMenu.show();

@ -40,7 +40,6 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
@ -143,6 +142,7 @@ public class FragmentRule extends FragmentBase {
private ArrayAdapter<EntityAnswer> adapterAnswer; private ArrayAdapter<EntityAnswer> adapterAnswer;
private long id = -1; private long id = -1;
private long copy = -1;
private long account = -1; private long account = -1;
private long folder = -1; private long folder = -1;
private int color = Color.TRANSPARENT; private int color = Color.TRANSPARENT;
@ -162,7 +162,10 @@ public class FragmentRule extends FragmentBase {
// Get arguments // Get arguments
Bundle args = getArguments(); Bundle args = getArguments();
id = args.getLong("id", -1); if (args.getBoolean("copy"))
copy = args.getLong("id", -1);
else
id = args.getLong("id", -1);
account = args.getLong("account", -1); account = args.getLong("account", -1);
folder = args.getLong("folder", -1); folder = args.getLong("folder", -1);
} }
@ -591,7 +594,7 @@ public class FragmentRule extends FragmentBase {
private void loadRule() { private void loadRule() {
Bundle rargs = new Bundle(); Bundle rargs = new Bundle();
rargs.putLong("id", id); rargs.putLong("id", copy < 0 ? id : copy);
rargs.putString("sender", getArguments().getString("sender")); rargs.putString("sender", getArguments().getString("sender"));
rargs.putString("recipient", getArguments().getString("recipient")); rargs.putString("recipient", getArguments().getString("recipient"));
rargs.putString("subject", getArguments().getString("subject")); rargs.putString("subject", getArguments().getString("subject"));

Loading…
Cancel
Save