Revert "Added account color to long press menu"

This reverts commit 5be1b53250.
This commit is contained in:
M66B 2021-06-20 14:39:20 +02:00
parent 5be1b53250
commit 2e76898655
3 changed files with 3 additions and 66 deletions

View File

@ -324,7 +324,6 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
.setCheckable(true).setChecked(account.synchronize);
popupMenu.getMenu().add(Menu.NONE, R.string.title_primary, 2, R.string.title_primary)
.setCheckable(true).setChecked(account.primary);
popupMenu.getMenu().add(Menu.NONE, R.string.title_color, 3, R.string.title_color);
if (account.notify &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@ -332,14 +331,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = nm.getNotificationChannel(channelId);
if (channel != null)
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, 4, 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)
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 5, R.string.title_copy);
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 4, R.string.title_copy);
if (debug)
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 6, R.string.title_reset);
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 5, R.string.title_reset);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@ -351,8 +350,6 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
} else if (itemId == R.string.title_primary) {
onActionPrimary(!item.isChecked());
return true;
} else if (itemId == R.string.title_color) {
onActionColor();
} else if (itemId == R.string.title_edit_channel) {
onActionEditChannel();
return true;
@ -440,19 +437,6 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
}.execute(context, owner, args, "account:primary");
}
private void onActionColor() {
Bundle args = new Bundle();
args.putLong("id", account.id);
args.putInt("color", account.color == null ? Color.TRANSPARENT : account.color);
args.putString("title", context.getString(R.string.title_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args);
fragment.setTargetFragment(parentFragment, FragmentAccounts.REQUEST_ACCOUNT_COLOR);
fragment.show(parentFragment.getParentFragmentManager(), "account:color");
}
@TargetApi(Build.VERSION_CODES.O)
private void onActionEditChannel() {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)

View File

@ -136,9 +136,6 @@ public interface DaoAccount {
@Query("UPDATE account SET `primary` = :primary WHERE id = :id AND NOT (`primary` IS :primary)")
int setAccountPrimary(long id, boolean primary);
@Query("UPDATE account SET color = :color WHERE id = :id AND NOT (color IS :color)")
int setAccountColor(long id, Integer color);
@Query("UPDATE account SET thread = :thread WHERE id = :id AND NOT (thread IS :thread)")
int setAccountThread(long id, Long thread);

View File

@ -55,7 +55,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static android.app.Activity.RESULT_OK;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
public class FragmentAccounts extends FragmentBase {
@ -77,7 +76,6 @@ public class FragmentAccounts extends FragmentBase {
private AdapterAccount adapter;
private static final int REQUEST_IMPORT_OAUTH = 1;
static final int REQUEST_ACCOUNT_COLOR = 2;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -338,25 +336,6 @@ public class FragmentAccounts extends FragmentBase {
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
}
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
switch (requestCode) {
case REQUEST_ACCOUNT_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext()))
onAccountColor(data.getBundleExtra("args"));
else
startActivity(new Intent(getContext(), ActivityBilling.class));
}
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
@ -366,29 +345,6 @@ public class FragmentAccounts extends FragmentBase {
ServiceSynchronize.reload(getContext(), null, false, "Permissions regranted");
}
private void onAccountColor(Bundle args) {
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
Integer color = args.getInt("color");
if (color == Color.TRANSPARENT)
color = null;
DB db = DB.getInstance(context);
db.account().setAccountColor(id, color);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "account:color");
}
private void onSwipeRefresh() {
Bundle args = new Bundle();