mirror of https://github.com/M66B/FairEmail.git
Added long press folder to edit folder color
This commit is contained in:
parent
a95b5cc886
commit
7e74869f8f
|
@ -658,6 +658,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
if (parentFragment instanceof FragmentFolders)
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_color, order++, R.string.title_color);
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_properties, order++, R.string.title_edit_properties);
|
||||
|
||||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) {
|
||||
|
@ -810,6 +813,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
} else if (itemId == R.string.title_import_messages) {
|
||||
onActionImportMessages();
|
||||
return true;
|
||||
} else if (itemId == R.string.title_color) {
|
||||
onActionEditColor();
|
||||
return true;
|
||||
} else if (itemId == R.string.title_edit_properties) {
|
||||
onActionEditProperties();
|
||||
return true;
|
||||
|
@ -1319,6 +1325,19 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
FragmentFolders.REQUEST_IMPORT_MESSAGES);
|
||||
}
|
||||
|
||||
private void onActionEditColor() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", folder.id);
|
||||
args.putInt("color", folder.color == null ? Color.TRANSPARENT : folder.color);
|
||||
args.putString("title", context.getString(R.string.title_color));
|
||||
args.putBoolean("reset", true);
|
||||
|
||||
FragmentDialogColor fragment = new FragmentDialogColor();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(parentFragment, FragmentFolders.REQUEST_EDIT_FOLDER_COLOR);
|
||||
fragment.show(parentFragment.getParentFragmentManager(), "edit:color");
|
||||
}
|
||||
|
||||
private void onActionEditProperties() {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
|
|
|
@ -319,6 +319,9 @@ public interface DaoFolder {
|
|||
@Query("UPDATE folder SET type = :type WHERE id = :id AND NOT (type IS :type)")
|
||||
int setFolderType(long id, String type);
|
||||
|
||||
@Query("UPDATE folder SET color = :color WHERE id = :id AND NOT (color IS :color)")
|
||||
int setFolderColor(long id, Integer color);
|
||||
|
||||
@Query("UPDATE folder SET inherited_type = :type WHERE id = :id AND NOT (inherited_type IS :type)")
|
||||
int setFolderInheritedType(long id, String type);
|
||||
|
||||
|
|
|
@ -133,8 +133,9 @@ public class FragmentFolders extends FragmentBase {
|
|||
static final int REQUEST_EXECUTE_RULES = 4;
|
||||
static final int REQUEST_EXPORT_MESSAGES = 5;
|
||||
static final int REQUEST_IMPORT_MESSAGES = 6;
|
||||
static final int REQUEST_EDIT_ACCOUNT_NAME = 7;
|
||||
static final int REQUEST_EDIT_ACCOUNT_COLOR = 8;
|
||||
static final int REQUEST_EDIT_FOLDER_COLOR = 7;
|
||||
static final int REQUEST_EDIT_ACCOUNT_NAME = 8;
|
||||
static final int REQUEST_EDIT_ACCOUNT_COLOR = 9;
|
||||
|
||||
private static final long EXPORT_PROGRESS_INTERVAL = 5000L; // milliseconds
|
||||
|
||||
|
@ -972,6 +973,10 @@ public class FragmentFolders extends FragmentBase {
|
|||
if (resultCode == RESULT_OK && data != null)
|
||||
onImportMessages(data.getData());
|
||||
break;
|
||||
case REQUEST_EDIT_FOLDER_COLOR:
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
onEditFolderColor(data.getBundleExtra("args"));
|
||||
break;
|
||||
case REQUEST_EDIT_ACCOUNT_NAME:
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
onEditAccountName(data.getBundleExtra("args"));
|
||||
|
@ -1691,6 +1696,33 @@ public class FragmentFolders extends FragmentBase {
|
|||
}.setKeepAwake(true).execute(this, args, "folder:export");
|
||||
}
|
||||
|
||||
private void onEditFolderColor(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.folder().setFolderColor(id, color);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(this, args, "edit:color");
|
||||
}
|
||||
|
||||
private void onEditAccountName(Bundle args) {
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue