mirror of https://github.com/M66B/FairEmail.git
Added remove button
This commit is contained in:
parent
f45145d225
commit
5b9a2446b5
|
@ -379,10 +379,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private ImageButton ibFull;
|
||||
private ImageButton ibImages;
|
||||
private ImageButton ibUnsubscribe;
|
||||
private ImageButton ibJunk;
|
||||
private ImageButton ibDecrypt;
|
||||
private ImageButton ibVerify;
|
||||
private ImageButton ibUndo;
|
||||
private ImageButton ibRemove;
|
||||
private ImageButton ibMore;
|
||||
private TextView tvSignedData;
|
||||
private ImageButton ibActionBarHint;
|
||||
|
@ -422,9 +422,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private TwoStateOwner cowner = new TwoStateOwner(owner, "MessageAttachments");
|
||||
private TwoStateOwner powner = new TwoStateOwner(owner, "MessagePopup");
|
||||
|
||||
private boolean hasJunk;
|
||||
private boolean delete;
|
||||
|
||||
private ScaleGestureDetector gestureDetector;
|
||||
|
||||
private SimpleTask taskContactInfo;
|
||||
|
@ -567,10 +564,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibFull = vsBody.findViewById(R.id.ibFull);
|
||||
ibImages = vsBody.findViewById(R.id.ibImages);
|
||||
ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe);
|
||||
ibJunk = vsBody.findViewById(R.id.ibJunk);
|
||||
ibDecrypt = vsBody.findViewById(R.id.ibDecrypt);
|
||||
ibVerify = vsBody.findViewById(R.id.ibVerify);
|
||||
ibUndo = vsBody.findViewById(R.id.ibUndo);
|
||||
ibRemove = vsBody.findViewById(R.id.ibRemove);
|
||||
ibMore = vsBody.findViewById(R.id.ibMore);
|
||||
tvSignedData = vsBody.findViewById(R.id.tvSignedData);
|
||||
ibActionBarHint = vsBody.findViewById(R.id.ibActionBarHint);
|
||||
|
@ -647,10 +644,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibFull.setOnClickListener(this);
|
||||
ibImages.setOnClickListener(this);
|
||||
ibUnsubscribe.setOnClickListener(this);
|
||||
ibJunk.setOnClickListener(this);
|
||||
ibDecrypt.setOnClickListener(this);
|
||||
ibVerify.setOnClickListener(this);
|
||||
ibUndo.setOnClickListener(this);
|
||||
ibRemove.setOnClickListener(this);
|
||||
ibMore.setOnClickListener(this);
|
||||
ibActionBarHint.setOnClickListener(this);
|
||||
|
||||
|
@ -716,10 +713,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibFull.setOnClickListener(null);
|
||||
ibImages.setOnClickListener(null);
|
||||
ibUnsubscribe.setOnClickListener(null);
|
||||
ibJunk.setOnClickListener(null);
|
||||
ibDecrypt.setOnClickListener(null);
|
||||
ibVerify.setOnClickListener(null);
|
||||
ibUndo.setOnClickListener(null);
|
||||
ibRemove.setOnClickListener(null);
|
||||
ibMore.setOnClickListener(null);
|
||||
ibActionBarHint.setOnClickListener(null);
|
||||
|
||||
|
@ -1144,10 +1141,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibFull.setVisibility(View.GONE);
|
||||
ibImages.setVisibility(View.GONE);
|
||||
ibUnsubscribe.setVisibility(View.GONE);
|
||||
ibJunk.setVisibility(View.GONE);
|
||||
ibDecrypt.setVisibility(View.GONE);
|
||||
ibVerify.setVisibility(View.GONE);
|
||||
ibUndo.setVisibility(View.GONE);
|
||||
ibRemove.setVisibility(View.GONE);
|
||||
ibMore.setVisibility(View.GONE);
|
||||
tvSignedData.setVisibility(View.GONE);
|
||||
grpActionBarHint.setVisibility(View.GONE);
|
||||
|
@ -1298,11 +1295,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibFull.setVisibility(View.VISIBLE);
|
||||
ibImages.setVisibility(View.GONE);
|
||||
ibUnsubscribe.setVisibility(View.GONE);
|
||||
ibJunk.setEnabled(false);
|
||||
ibJunk.setVisibility(View.GONE);
|
||||
ibDecrypt.setVisibility(View.GONE);
|
||||
ibVerify.setVisibility(View.GONE);
|
||||
ibUndo.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) ? View.VISIBLE : View.GONE);
|
||||
ibRemove.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) || message.folderReadOnly ? View.GONE : View.VISIBLE);
|
||||
ibMore.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) ? View.GONE : View.VISIBLE);
|
||||
tvSignedData.setVisibility(View.GONE);
|
||||
grpActionBarHint.setVisibility(View.GONE);
|
||||
|
@ -1406,52 +1402,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
// Attachments
|
||||
bindAttachments(message, properties.getAttachments(message.id));
|
||||
|
||||
// Setup actions
|
||||
Bundle sargs = new Bundle();
|
||||
sargs.putLong("id", message.id);
|
||||
sargs.putLong("account", message.account);
|
||||
|
||||
new SimpleTask<List<EntityFolder>>() {
|
||||
@Override
|
||||
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
||||
long account = args.getLong("account");
|
||||
return DB.getInstance(context).folder().getSystemFolders(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
||||
long id = args.getLong("id");
|
||||
TupleMessageEx amessage = getMessage();
|
||||
if (amessage == null || !amessage.id.equals(id))
|
||||
return;
|
||||
|
||||
boolean hasArchive = false;
|
||||
boolean hasTrash = false;
|
||||
hasJunk = false;
|
||||
if (folders != null)
|
||||
for (EntityFolder folder : folders) {
|
||||
if (EntityFolder.ARCHIVE.equals(folder.type))
|
||||
hasArchive = true;
|
||||
else if (EntityFolder.TRASH.equals(folder.type))
|
||||
hasTrash = true;
|
||||
else if (EntityFolder.JUNK.equals(folder.type))
|
||||
hasJunk = true;
|
||||
}
|
||||
|
||||
boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType);
|
||||
boolean inTrash = EntityFolder.TRASH.equals(message.folderType);
|
||||
|
||||
delete = (inTrash || !hasTrash || inOutbox);
|
||||
|
||||
ibJunk.setEnabled(hasJunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.setLog(false).execute(context, owner, sargs, "message:actions");
|
||||
|
||||
// Message text
|
||||
tvNoInternetBody.setVisibility(suitable || message.content ? View.GONE : View.VISIBLE);
|
||||
|
||||
|
@ -1856,10 +1806,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibImages.setVisibility(has_images && !(show_full && always_images) ? View.VISIBLE : View.GONE);
|
||||
|
||||
ibUnsubscribe.setVisibility(message.unsubscribe == null ? View.GONE : View.VISIBLE);
|
||||
ibJunk.setVisibility(
|
||||
message.uid == null || message.folderReadOnly ||
|
||||
EntityFolder.JUNK.equals(message.folderType)
|
||||
? View.GONE : View.VISIBLE);
|
||||
|
||||
// Show encrypt actions
|
||||
ibVerify.setVisibility(false ||
|
||||
|
@ -2326,9 +2272,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
case R.id.ibUnsubscribe:
|
||||
onActionUnsubscribe(message);
|
||||
break;
|
||||
case R.id.ibJunk:
|
||||
onActionJunk(message);
|
||||
break;
|
||||
case R.id.ibDecrypt:
|
||||
boolean lock =
|
||||
(EntityMessage.PGP_SIGNENCRYPT.equals(message.ui_encrypt) &&
|
||||
|
@ -2346,6 +2289,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
case R.id.ibUndo:
|
||||
onActionUndo(message);
|
||||
break;
|
||||
case R.id.ibRemove:
|
||||
onActionRemove(message);
|
||||
break;
|
||||
case R.id.ibMore:
|
||||
onActionMore(message);
|
||||
break;
|
||||
|
@ -2977,17 +2923,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
onOpenLink(uri, context.getString(R.string.title_legend_show_unsubscribe));
|
||||
}
|
||||
|
||||
private void onActionJunk(TupleMessageEx message) {
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putString("from", MessageHelper.formatAddresses(message.from));
|
||||
|
||||
FragmentDialogJunk ask = new FragmentDialogJunk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_JUNK);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "message:junk");
|
||||
}
|
||||
|
||||
private void onActionDecrypt(TupleMessageEx message, boolean auto) {
|
||||
int encrypt = (message.encrypt == null ? EntityMessage.PGP_SIGNENCRYPT /* Inline */ : message.encrypt);
|
||||
|
||||
|
@ -3085,6 +3020,102 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
properties.move(message.id, EntityFolder.INBOX);
|
||||
}
|
||||
|
||||
private void onActionRemove(TupleMessageEx message) {
|
||||
// Setup actions
|
||||
Bundle sargs = new Bundle();
|
||||
sargs.putLong("id", message.id);
|
||||
sargs.putLong("account", message.account);
|
||||
|
||||
new SimpleTask<List<EntityFolder>>() {
|
||||
@Override
|
||||
protected List<EntityFolder> onExecute(Context context, Bundle args) {
|
||||
long account = args.getLong("account");
|
||||
return DB.getInstance(context).folder().getSystemFolders(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
|
||||
long id = args.getLong("id");
|
||||
TupleMessageEx amessage = getMessage();
|
||||
if (amessage == null || !amessage.id.equals(id))
|
||||
return;
|
||||
|
||||
boolean hasArchive = false;
|
||||
boolean hasTrash = false;
|
||||
boolean hasJunk = false;
|
||||
if (folders != null)
|
||||
for (EntityFolder folder : folders)
|
||||
if (EntityFolder.ARCHIVE.equals(folder.type))
|
||||
hasArchive = true;
|
||||
else if (EntityFolder.TRASH.equals(folder.type))
|
||||
hasTrash = true;
|
||||
else if (EntityFolder.JUNK.equals(folder.type))
|
||||
hasJunk = true;
|
||||
|
||||
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
|
||||
boolean inTrash = EntityFolder.TRASH.equals(message.folderType);
|
||||
boolean inJunk = EntityFolder.JUNK.equals(message.folderType);
|
||||
final boolean delete = (inTrash || !hasTrash);
|
||||
|
||||
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, ibMore);
|
||||
popupMenu.inflate(R.menu.popup_message_move);
|
||||
popupMenu.getMenu().findItem(R.id.menu_archive).setEnabled(message.uid != null && (hasArchive && !inArchive));
|
||||
popupMenu.getMenu().findItem(R.id.menu_trash).setEnabled(message.uid != null);
|
||||
popupMenu.getMenu().findItem(R.id.menu_junk).setEnabled(message.uid != null && (hasJunk && !inJunk));
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem target) {
|
||||
switch (target.getItemId()) {
|
||||
case R.id.menu_archive:
|
||||
properties.move(message.id, EntityFolder.ARCHIVE);
|
||||
return true;
|
||||
case R.id.menu_trash:
|
||||
if (delete)
|
||||
onActionDelete(message);
|
||||
else
|
||||
properties.move(message.id, EntityFolder.TRASH);
|
||||
return true;
|
||||
case R.id.menu_junk:
|
||||
onActionJunk(message);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
popupMenu.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.setLog(false).execute(context, owner, sargs, "message:actions");
|
||||
}
|
||||
|
||||
private void onActionDelete(TupleMessageEx message) {
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question", context.getString(R.string.title_ask_delete));
|
||||
aargs.putLong("id", message.id);
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_DELETE);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "message:delete");
|
||||
}
|
||||
|
||||
private void onActionJunk(TupleMessageEx message) {
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putString("from", MessageHelper.formatAddresses(message.from));
|
||||
|
||||
FragmentDialogJunk ask = new FragmentDialogJunk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_JUNK);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "message:junk");
|
||||
}
|
||||
|
||||
private void onActionMore(TupleMessageEx message) {
|
||||
boolean show_headers = properties.getValue("headers", message.id);
|
||||
boolean full = properties.getValue("full", message.id);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"/>
|
||||
</vector>
|
|
@ -17,7 +17,6 @@
|
|||
android:id="@+id/ibMore"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/title_more"
|
||||
android:foregroundTint="?android:attr/textColorSecondary"
|
||||
|
@ -28,6 +27,21 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/vSeparator"
|
||||
app:srcCompat="@drawable/baseline_more_vert_24" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibRemove"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/title_delete"
|
||||
android:foregroundTint="?android:attr/textColorSecondary"
|
||||
android:padding="3dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_delete"
|
||||
app:layout_constraintStart_toEndOf="@id/ibMore"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparator"
|
||||
app:srcCompat="@drawable/baseline_remove_circle_24" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbBody"
|
||||
style="@style/Base.Widget.AppCompat.ProgressBar"
|
||||
|
@ -36,7 +50,7 @@
|
|||
android:layout_marginStart="6dp"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ibFull"
|
||||
app:layout_constraintStart_toEndOf="@id/ibMore"
|
||||
app:layout_constraintStart_toEndOf="@id/ibRemove"
|
||||
app:layout_constraintTop_toTopOf="@+id/ibFull" />
|
||||
|
||||
<ImageButton
|
||||
|
@ -80,24 +94,9 @@
|
|||
android:padding="3dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_decrypt"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibJunk"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparator"
|
||||
app:srcCompat="@drawable/baseline_lock_open_24" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibJunk"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/title_legend_show_junk"
|
||||
android:foregroundTint="?android:attr/textColorSecondary"
|
||||
android:padding="3dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_legend_show_junk"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibUnsubscribe"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparator"
|
||||
app:srcCompat="@drawable/baseline_flag_24" />
|
||||
app:srcCompat="@drawable/baseline_lock_open_24" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibUnsubscribe"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_archive"
|
||||
android:title="@string/title_archive" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_trash"
|
||||
android:title="@string/title_trash" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_junk"
|
||||
android:title="@string/title_spam" />
|
||||
</menu>
|
Loading…
Reference in New Issue