mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-04 03:43:55 +01:00
Added account/identity copy
This commit is contained in:
2
FAQ.md
2
FAQ.md
@@ -49,7 +49,7 @@ For authorizing:
|
|||||||
* ~~[Autocrypt Setup Message](https://autocrypt.org/autocrypt-spec-1.0.0.pdf) (section 4.4)~~ (IMO it is not a good idea to let an email client handle sensitive encryption keys for an exceptional use case while OpenKeychain can export keys too)
|
* ~~[Autocrypt Setup Message](https://autocrypt.org/autocrypt-spec-1.0.0.pdf) (section 4.4)~~ (IMO it is not a good idea to let an email client handle sensitive encryption keys for an exceptional use case while OpenKeychain can export keys too)
|
||||||
* ~~Generic unified folders~~
|
* ~~Generic unified folders~~
|
||||||
* ~~New message notification schedules per account~~ (implemented by added a time condition to rules, so messages can be snoozed in selected periods)
|
* ~~New message notification schedules per account~~ (implemented by added a time condition to rules, so messages can be snoozed in selected periods)
|
||||||
* Copy accounts and identities
|
* ~~Copy accounts and identities~~
|
||||||
|
|
||||||
Anything on this list is in random order and *might* be added in the near future.
|
Anything on this list is in random order and *might* be added in the near future.
|
||||||
|
|
||||||
|
|||||||
@@ -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_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() {
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
@@ -226,6 +228,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||||||
onActionEditChannel();
|
onActionEditChannel();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case R.string.title_copy:
|
||||||
|
onActionCopy();
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -271,6 +277,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||||||
.putExtra(Settings.EXTRA_CHANNEL_ID, EntityAccount.getNotificationChannelId(account.id));
|
.putExtra(Settings.EXTRA_CHANNEL_ID, EntityAccount.getNotificationChannelId(account.id));
|
||||||
context.startActivity(intent);
|
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();
|
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)
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_enabled, 1, R.string.title_synchronize_enabled)
|
||||||
.setCheckable(true).setChecked(identity.synchronize);
|
.setCheckable(true).setChecked(identity.synchronize);
|
||||||
|
|
||||||
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 2, R.string.title_copy);
|
||||||
|
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
@@ -174,6 +176,11 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||||||
case R.string.title_synchronize_enabled:
|
case R.string.title_synchronize_enabled:
|
||||||
onActionSync(!item.isChecked());
|
onActionSync(!item.isChecked());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case R.string.title_copy:
|
||||||
|
onActionCopy();
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -204,6 +211,14 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||||||
}
|
}
|
||||||
}.execute(context, owner, args, "identitty:enable");
|
}.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();
|
popupMenu.show();
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ public class FragmentAccount extends FragmentBase {
|
|||||||
private Group grpFolders;
|
private Group grpFolders;
|
||||||
|
|
||||||
private long id = -1;
|
private long id = -1;
|
||||||
|
private long copy = -1;
|
||||||
private boolean saving = false;
|
private boolean saving = false;
|
||||||
private int color = Color.TRANSPARENT;
|
private int color = Color.TRANSPARENT;
|
||||||
|
|
||||||
@@ -151,7 +152,10 @@ public class FragmentAccount 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1114,7 +1118,7 @@ public class FragmentAccount extends FragmentBase {
|
|||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("id", id);
|
args.putLong("id", copy < 0 ? id : copy);
|
||||||
|
|
||||||
new SimpleTask<EntityAccount>() {
|
new SimpleTask<EntityAccount>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1213,34 +1217,36 @@ public class FragmentAccount extends FragmentBase {
|
|||||||
// Consider previous check/save/delete as cancelled
|
// Consider previous check/save/delete as cancelled
|
||||||
pbWait.setVisibility(View.GONE);
|
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>>() {
|
new SimpleTask<List<EntityFolder>>() {
|
||||||
@Override
|
@Override
|
||||||
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
||||||
long account = args.getLong("account");
|
long account = args.getLong("account");
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
List<EntityFolder> folders = db.folder().getFolders(account, false, true);
|
List<EntityFolder> folders = db.folder().getFolders(account, false, true);
|
||||||
|
|
||||||
if (folders != null && folders.size() > 0)
|
if (folders != null && folders.size() > 0)
|
||||||
Collections.sort(folders, folders.get(0).getComparator(null));
|
Collections.sort(folders, folders.get(0).getComparator(null));
|
||||||
|
|
||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
||||||
if (folders == null)
|
if (folders == null)
|
||||||
folders = new ArrayList<>();
|
folders = new ArrayList<>();
|
||||||
setFolders(folders, account);
|
setFolders(folders, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
Helper.unexpectedError(getFragmentManager(), ex);
|
Helper.unexpectedError(getFragmentManager(), ex);
|
||||||
}
|
}
|
||||||
}.execute(FragmentAccount.this, args, "account:folders");
|
}.execute(FragmentAccount.this, args, "account:folders");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||||||
private Group grpAdvanced;
|
private Group grpAdvanced;
|
||||||
|
|
||||||
private long id = -1;
|
private long id = -1;
|
||||||
|
private long copy = -1;
|
||||||
private boolean saving = false;
|
private boolean saving = false;
|
||||||
private int color = Color.TRANSPARENT;
|
private int color = Color.TRANSPARENT;
|
||||||
|
|
||||||
@@ -138,7 +139,10 @@ public class FragmentIdentity 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -826,7 +830,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("id", id);
|
args.putLong("id", copy < 0 ? id : copy);
|
||||||
|
|
||||||
new SimpleTask<EntityIdentity>() {
|
new SimpleTask<EntityIdentity>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -867,7 +871,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||||||
|
|
||||||
color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color);
|
color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color);
|
||||||
|
|
||||||
if (identity == null)
|
if (identity == null || copy > 0)
|
||||||
new SimpleTask<Integer>() {
|
new SimpleTask<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
protected Integer onExecute(Context context, Bundle args) {
|
protected Integer onExecute(Context context, Bundle args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user