Added copy rule to account/folder

pull/212/head
M66B 2 years ago
parent f2212e0e26
commit 61ad1cc974

@ -475,14 +475,14 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
} }
private void onActionCopy() { private void onActionCopy() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); Bundle args = new Bundle();
lbm.sendBroadcast( args.putLong("rule", rule.id);
new Intent(ActivityView.ACTION_EDIT_RULE) args.putInt("type", protocol); // account selector
.putExtra("id", rule.id)
.putExtra("account", rule.account) FragmentDialogSelectAccount fragment = new FragmentDialogSelectAccount();
.putExtra("folder", rule.folder) fragment.setArguments(args);
.putExtra("protocol", protocol) fragment.setTargetFragment(parentFragment, FragmentRules.REQUEST_RULE_COPY_ACCOUNT);
.putExtra("copy", true)); fragment.show(parentFragment.getParentFragmentManager(), "rule:copy:account");
} }
}); });

@ -46,6 +46,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.OnLifecycleEvent; import androidx.lifecycle.OnLifecycleEvent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -87,7 +88,9 @@ public class FragmentRules extends FragmentBase {
private static final int REQUEST_EXPORT = 1; private static final int REQUEST_EXPORT = 1;
private static final int REQUEST_IMPORT = 2; private static final int REQUEST_IMPORT = 2;
static final int REQUEST_MOVE = 3; static final int REQUEST_MOVE = 3;
private static final int REQUEST_CLEAR = 4; static final int REQUEST_RULE_COPY_ACCOUNT = 4;
static final int REQUEST_RULE_COPY_FOLDER = 5;
private static final int REQUEST_CLEAR = 6;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -210,6 +213,14 @@ public class FragmentRules extends FragmentBase {
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onMove(data.getBundleExtra("args")); onMove(data.getBundleExtra("args"));
break; break;
case REQUEST_RULE_COPY_ACCOUNT:
if (resultCode == RESULT_OK && data != null)
onRuleCopyAccount(data.getBundleExtra("args"));
break;
case REQUEST_RULE_COPY_FOLDER:
if (resultCode == RESULT_OK && data != null)
onRuleCopyFolder(data.getBundleExtra("args"));
break;
case REQUEST_CLEAR: case REQUEST_CLEAR:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onClear(data.getBundleExtra("args")); onClear(data.getBundleExtra("args"));
@ -605,6 +616,28 @@ public class FragmentRules extends FragmentBase {
}.execute(this, args, "rule:move"); }.execute(this, args, "rule:move");
} }
private void onRuleCopyAccount(Bundle args) {
args.putString("title", getString(R.string.title_copy_to));
args.putLongArray("disabled", new long[0]);
args.putBoolean("cancopy", false);
FragmentDialogSelectFolder fragment = new FragmentDialogSelectFolder();
fragment.setArguments(args);
fragment.setTargetFragment(this, REQUEST_RULE_COPY_FOLDER);
fragment.show(getParentFragmentManager(), "rule:copy:folder");
}
private void onRuleCopyFolder(Bundle args) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULE)
.putExtra("id", args.getLong("rule"))
.putExtra("account", args.getLong("account"))
.putExtra("folder", args.getLong("folder"))
.putExtra("protocol", args.getInt("protocol"))
.putExtra("copy", true));
}
private void onClear(Bundle args) { private void onClear(Bundle args) {
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override

Loading…
Cancel
Save