|
|
@ -241,6 +241,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled)
|
|
|
|
.setCheckable(true).setChecked(account.synchronize);
|
|
|
|
.setCheckable(true).setChecked(account.synchronize);
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_primary, 2, R.string.title_primary)
|
|
|
|
|
|
|
|
.setCheckable(true).setChecked(account.primary);
|
|
|
|
|
|
|
|
|
|
|
|
if (account.notify &&
|
|
|
|
if (account.notify &&
|
|
|
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
@ -248,11 +250,11 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
|
|
|
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
|
|
|
if (channel != null)
|
|
|
|
if (channel != null)
|
|
|
|
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, 3, R.string.title_edit_channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (account.protocol == EntityAccount.TYPE_IMAP && settings)
|
|
|
|
if (account.protocol == EntityAccount.TYPE_IMAP && settings)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 3, R.string.title_copy);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 4, R.string.title_copy);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -262,6 +264,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
onActionSync(!item.isChecked());
|
|
|
|
onActionSync(!item.isChecked());
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case R.string.title_primary:
|
|
|
|
|
|
|
|
onActionPrimary(!item.isChecked());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
case R.string.title_edit_channel:
|
|
|
|
case R.string.title_edit_channel:
|
|
|
|
onActionEditChannel();
|
|
|
|
onActionEditChannel();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -308,6 +314,40 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
}.execute(context, owner, args, "account:enable");
|
|
|
|
}.execute(context, owner, args, "account:enable");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionPrimary(boolean primary) {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", account.id);
|
|
|
|
|
|
|
|
args.putBoolean("primary", primary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
boolean primary = args.getBoolean("primary");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (primary)
|
|
|
|
|
|
|
|
db.account().resetPrimary();
|
|
|
|
|
|
|
|
db.account().setAccountPrimary(id, primary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, args, "account:primary");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
private void onActionEditChannel() {
|
|
|
|
private void onActionEditChannel() {
|
|
|
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
|
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
|
|