mirror of https://github.com/M66B/FairEmail.git
Added edit account color to folder list menu
This commit is contained in:
parent
6c967f7e57
commit
dd8bd36712
|
@ -216,6 +216,9 @@ public interface DaoAccount {
|
|||
@Query("UPDATE account SET name = :name WHERE id = :id AND NOT (name IS :name)")
|
||||
int setAccountName(long id, String name);
|
||||
|
||||
@Query("UPDATE account SET color = :color WHERE id = :id AND NOT (color IS :color)")
|
||||
int setAccountColor(long id, Integer color);
|
||||
|
||||
@Query("UPDATE account" +
|
||||
" SET password = :password, auth_type = :auth_type" +
|
||||
" WHERE id = :id" +
|
||||
|
|
|
@ -134,6 +134,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
static final int REQUEST_EXECUTE_RULES = 4;
|
||||
static final int REQUEST_EXPORT_MESSAGES = 5;
|
||||
static final int REQUEST_EDIT_ACCOUNT_NAME = 6;
|
||||
static final int REQUEST_EDIT_ACCOUNT_COLOR = 7;
|
||||
|
||||
private static final long EXPORT_PROGRESS_INTERVAL = 5000L; // milliseconds
|
||||
|
||||
|
@ -690,6 +691,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
menu.findItem(R.id.menu_sort_unread_atop).setChecked(sort_unread_atop);
|
||||
menu.findItem(R.id.menu_apply_all).setVisible(account >= 0 && imap);
|
||||
menu.findItem(R.id.menu_edit_account_name).setVisible(account >= 0);
|
||||
menu.findItem(R.id.menu_edit_account_color).setVisible(account >= 0);
|
||||
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
@ -730,6 +732,9 @@ public class FragmentFolders extends FragmentBase {
|
|||
} else if (itemId == R.id.menu_edit_account_name) {
|
||||
onMenuEditAccount();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_edit_account_color) {
|
||||
onMenuEditColor();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_force_sync) {
|
||||
onMenuForceSync();
|
||||
return true;
|
||||
|
@ -877,6 +882,41 @@ public class FragmentFolders extends FragmentBase {
|
|||
}.execute(this, args, "account:name");
|
||||
}
|
||||
|
||||
private void onMenuEditColor() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", account);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
protected EntityAccount onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
return db.account().getAccount(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityAccount account) {
|
||||
if (account == null)
|
||||
return;
|
||||
|
||||
args.putInt("color", account.color == null ? Color.TRANSPARENT : account.color);
|
||||
args.putString("title", getString(R.string.title_color));
|
||||
args.putBoolean("reset", true);
|
||||
|
||||
FragmentDialogColor fragment = new FragmentDialogColor();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentFolders.this, REQUEST_EDIT_ACCOUNT_COLOR);
|
||||
fragment.show(getParentFragmentManager(), "edit:color");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(this, args, "edit:color");
|
||||
}
|
||||
|
||||
private void onMenuForceSync() {
|
||||
refresh(true);
|
||||
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
|
||||
|
@ -912,6 +952,10 @@ public class FragmentFolders extends FragmentBase {
|
|||
if (resultCode == RESULT_OK && data != null)
|
||||
onEditAccountName(data.getBundleExtra("args"));
|
||||
break;
|
||||
case REQUEST_EDIT_ACCOUNT_COLOR:
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
onEditAccountColor(data.getBundleExtra("args"));
|
||||
break;
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
@ -1387,6 +1431,33 @@ public class FragmentFolders extends FragmentBase {
|
|||
}.execute(this, args, "edit:name");
|
||||
}
|
||||
|
||||
private void onEditAccountColor(Bundle args) {
|
||||
if (!ActivityBilling.isPro(getContext())) {
|
||||
startActivity(new Intent(getContext(), ActivityBilling.class));
|
||||
return;
|
||||
}
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
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, "edit:color");
|
||||
}
|
||||
|
||||
public static class FragmentDialogApply extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
|
@ -75,6 +75,12 @@
|
|||
<menu />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_edit_account_color"
|
||||
android:title="@string/title_edit_account_color">
|
||||
<menu />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_force_sync"
|
||||
android:title="@string/title_force_sync"
|
||||
|
|
|
@ -1104,6 +1104,7 @@
|
|||
<string name="title_search_folder">Search for folder</string>
|
||||
<string name="title_apply_to_all">Apply to all</string>
|
||||
<string name="title_edit_account_name">Edit account name</string>
|
||||
<string name="title_edit_account_color">Edit account color</string>
|
||||
<string name="title_hide_folder">Hide folder</string>
|
||||
<string name="title_hide_seen_folder">Hide folder if all messages are read</string>
|
||||
<string name="title_hide_seen_folder_hint">Only in the folder list shown on the start screen</string>
|
||||
|
|
Loading…
Reference in New Issue