|
|
|
@ -20,6 +20,7 @@ package eu.faircode.email;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.res.ColorStateList;
|
|
|
|
@ -78,7 +79,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|
|
|
|
|
|
|
|
|
private final static int action_synchronize_now = 1;
|
|
|
|
|
private final static int action_delete_local = 2;
|
|
|
|
|
private final static int action_edit_properties = 3;
|
|
|
|
|
private final static int action_empty_trash = 3;
|
|
|
|
|
private final static int action_edit_properties = 4;
|
|
|
|
|
|
|
|
|
|
ViewHolder(View itemView) {
|
|
|
|
|
super(itemView);
|
|
|
|
@ -222,9 +224,11 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|
|
|
|
|
|
|
|
|
if (!EntityFolder.DRAFTS.equals(folder.type))
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, action_delete_local, 2, R.string.title_delete_local);
|
|
|
|
|
if (EntityFolder.TRASH.equals(folder.type))
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, action_empty_trash, 3, R.string.title_empty_trash);
|
|
|
|
|
|
|
|
|
|
if (folder.account != null)
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, action_edit_properties, 3, R.string.title_edit_properties);
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, action_edit_properties, 4, R.string.title_edit_properties);
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
@Override
|
|
|
|
@ -238,6 +242,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|
|
|
|
OnActionDeleteLocal();
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case action_empty_trash:
|
|
|
|
|
onActionEmptyTrash();
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case action_edit_properties:
|
|
|
|
|
onActionEditProperties();
|
|
|
|
|
return true;
|
|
|
|
@ -305,6 +313,49 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|
|
|
|
}.load(context, owner, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onActionEmptyTrash() {
|
|
|
|
|
new DialogBuilderLifecycle(context, owner)
|
|
|
|
|
.setMessage(R.string.title_empty_trash_ask)
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", folder.id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onLoad(Context context, Bundle args) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
for (Long mid : db.message().getMessageByFolder(id)) {
|
|
|
|
|
EntityMessage message = db.message().getMessage(mid);
|
|
|
|
|
EntityOperation.queue(db, message, EntityOperation.DELETE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
}
|
|
|
|
|
}.load(context, owner, args);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onActionEditProperties() {
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
lbm.sendBroadcast(
|
|
|
|
|