mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 20:34:49 +01:00
Added account/identity copy
This commit is contained in:
@@ -214,6 +214,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, 2, R.string.title_edit_channel);
|
||||
}
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 3, R.string.title_copy);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
@@ -226,6 +228,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
onActionEditChannel();
|
||||
return true;
|
||||
|
||||
case R.string.title_copy:
|
||||
onActionCopy();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -271,6 +277,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
.putExtra(Settings.EXTRA_CHANNEL_ID, EntityAccount.getNotificationChannelId(account.id));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private void onActionCopy() {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
|
||||
.putExtra("id", account.id)
|
||||
.putExtra("copy", true));
|
||||
}
|
||||
});
|
||||
|
||||
popupMenu.show();
|
||||
|
||||
@@ -167,6 +167,8 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_enabled, 1, R.string.title_synchronize_enabled)
|
||||
.setCheckable(true).setChecked(identity.synchronize);
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 2, R.string.title_copy);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
@@ -174,6 +176,11 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
||||
case R.string.title_synchronize_enabled:
|
||||
onActionSync(!item.isChecked());
|
||||
return true;
|
||||
|
||||
case R.string.title_copy:
|
||||
onActionCopy();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -204,6 +211,14 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
||||
}
|
||||
}.execute(context, owner, args, "identitty:enable");
|
||||
}
|
||||
|
||||
private void onActionCopy() {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivitySetup.ACTION_EDIT_IDENTITY)
|
||||
.putExtra("id", identity.id)
|
||||
.putExtra("copy", true));
|
||||
}
|
||||
});
|
||||
|
||||
popupMenu.show();
|
||||
|
||||
@@ -135,6 +135,7 @@ public class FragmentAccount extends FragmentBase {
|
||||
private Group grpFolders;
|
||||
|
||||
private long id = -1;
|
||||
private long copy = -1;
|
||||
private boolean saving = false;
|
||||
private int color = Color.TRANSPARENT;
|
||||
|
||||
@@ -151,7 +152,10 @@ public class FragmentAccount extends FragmentBase {
|
||||
|
||||
// Get arguments
|
||||
Bundle args = getArguments();
|
||||
id = args.getLong("id", -1);
|
||||
if (args.getBoolean("copy"))
|
||||
copy = args.getLong("id", -1);
|
||||
else
|
||||
id = args.getLong("id", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1114,7 +1118,7 @@ public class FragmentAccount extends FragmentBase {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putLong("id", copy < 0 ? id : copy);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
@@ -1213,34 +1217,36 @@ public class FragmentAccount extends FragmentBase {
|
||||
// Consider previous check/save/delete as cancelled
|
||||
pbWait.setVisibility(View.GONE);
|
||||
|
||||
args.putLong("account", account == null ? -1 : account.id);
|
||||
if (copy < 0) {
|
||||
args.putLong("account", account == null ? -1 : account.id);
|
||||
|
||||
new SimpleTask<List<EntityFolder>>() {
|
||||
@Override
|
||||
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
||||
long account = args.getLong("account");
|
||||
new SimpleTask<List<EntityFolder>>() {
|
||||
@Override
|
||||
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
||||
long account = args.getLong("account");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
List<EntityFolder> folders = db.folder().getFolders(account, false, true);
|
||||
DB db = DB.getInstance(context);
|
||||
List<EntityFolder> folders = db.folder().getFolders(account, false, true);
|
||||
|
||||
if (folders != null && folders.size() > 0)
|
||||
Collections.sort(folders, folders.get(0).getComparator(null));
|
||||
if (folders != null && folders.size() > 0)
|
||||
Collections.sort(folders, folders.get(0).getComparator(null));
|
||||
|
||||
return folders;
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
setFolders(folders, account);
|
||||
}
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
setFolders(folders, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentAccount.this, args, "account:folders");
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentAccount.this, args, "account:folders");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,6 +124,7 @@ public class FragmentIdentity extends FragmentBase {
|
||||
private Group grpAdvanced;
|
||||
|
||||
private long id = -1;
|
||||
private long copy = -1;
|
||||
private boolean saving = false;
|
||||
private int color = Color.TRANSPARENT;
|
||||
|
||||
@@ -138,7 +139,10 @@ public class FragmentIdentity extends FragmentBase {
|
||||
|
||||
// Get arguments
|
||||
Bundle args = getArguments();
|
||||
id = args.getLong("id", -1);
|
||||
if (args.getBoolean("copy"))
|
||||
copy = args.getLong("id", -1);
|
||||
else
|
||||
id = args.getLong("id", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -826,7 +830,7 @@ public class FragmentIdentity extends FragmentBase {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putLong("id", copy < 0 ? id : copy);
|
||||
|
||||
new SimpleTask<EntityIdentity>() {
|
||||
@Override
|
||||
@@ -867,7 +871,7 @@ public class FragmentIdentity extends FragmentBase {
|
||||
|
||||
color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color);
|
||||
|
||||
if (identity == null)
|
||||
if (identity == null || copy > 0)
|
||||
new SimpleTask<Integer>() {
|
||||
@Override
|
||||
protected Integer onExecute(Context context, Bundle args) {
|
||||
|
||||
Reference in New Issue
Block a user