mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-29 04:06:42 +02:00
Experiment: swipe right to reply
This commit is contained in:
@@ -1990,6 +1990,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
boolean button_headers = prefs.getBoolean("button_headers", false);
|
||||
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
|
||||
boolean button_rule = prefs.getBoolean("button_rule", false);
|
||||
boolean experiments = prefs.getBoolean("experiments", false);
|
||||
|
||||
ibHide.setImageResource(message.ui_snoozed == null ? R.drawable.twotone_visibility_off_24 : R.drawable.twotone_visibility_24);
|
||||
ibSeen.setImageResource(message.ui_seen ? R.drawable.twotone_mail_24 : R.drawable.twotone_drafts_24);
|
||||
@@ -2013,7 +2014,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
ibForceLight.setImageLevel(force_light ? 1 : 0);
|
||||
ibHide.setVisibility(tools && button_hide && !outbox ? View.VISIBLE : View.GONE);
|
||||
ibSeen.setVisibility(tools && button_seen && !outbox && seen ? View.VISIBLE : View.GONE);
|
||||
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) || !threading ? View.GONE : View.VISIBLE);
|
||||
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) || !threading || experiments ? View.GONE : View.VISIBLE);
|
||||
ibNotes.setVisibility(tools && button_notes && !outbox ? View.VISIBLE : View.GONE);
|
||||
ibLabels.setVisibility(tools && labels_header && labels ? View.VISIBLE : View.GONE);
|
||||
ibKeywords.setVisibility(tools && button_keywords && keywords ? View.VISIBLE : View.GONE);
|
||||
|
||||
@@ -113,6 +113,7 @@ public class EntityMessage implements Serializable {
|
||||
static final Long SWIPE_ACTION_FLAG = -6L;
|
||||
static final Long SWIPE_ACTION_DELETE = -7L;
|
||||
static final Long SWIPE_ACTION_JUNK = -8L;
|
||||
static final Long SWIPE_ACTION_REPLY = -9L;
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
public Long id;
|
||||
|
||||
@@ -317,6 +317,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
private String onclose;
|
||||
private boolean quick_scroll;
|
||||
private boolean addresses;
|
||||
private boolean experiments;
|
||||
|
||||
private int colorPrimary;
|
||||
private int colorAccent;
|
||||
@@ -444,6 +445,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
onclose = (autoclose ? null : prefs.getString("onclose", null));
|
||||
quick_scroll = prefs.getBoolean("quick_scroll", true);
|
||||
addresses = prefs.getBoolean("addresses", false);
|
||||
experiments = prefs.getBoolean("experiments", false);
|
||||
|
||||
colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
|
||||
colorAccent = Helper.resolveColor(getContext(), R.attr.colorAccent);
|
||||
@@ -2112,6 +2114,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
if (message == null)
|
||||
return 0;
|
||||
|
||||
boolean expanded = iProperties.getValue("expanded", message.id);
|
||||
|
||||
if (expanded && experiments)
|
||||
return makeMovementFlags(0, ItemTouchHelper.RIGHT);
|
||||
|
||||
if (EntityFolder.OUTBOX.equals(message.folderType))
|
||||
return makeMovementFlags(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
|
||||
|
||||
@@ -2184,8 +2191,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
if (message == null)
|
||||
return;
|
||||
|
||||
boolean expanded = iProperties.getValue("expanded", message.id);
|
||||
|
||||
TupleAccountSwipes swipes;
|
||||
if (EntityFolder.OUTBOX.equals(message.folderType)) {
|
||||
if (expanded && experiments) {
|
||||
swipes = new TupleAccountSwipes();
|
||||
swipes.swipe_right = EntityMessage.SWIPE_ACTION_REPLY;
|
||||
swipes.right_type = null;
|
||||
swipes.swipe_left = null;
|
||||
swipes.left_type = null;
|
||||
} else if (EntityFolder.OUTBOX.equals(message.folderType)) {
|
||||
swipes = new TupleAccountSwipes();
|
||||
swipes.swipe_right = 0L;
|
||||
swipes.right_type = EntityFolder.DRAFTS;
|
||||
@@ -2226,6 +2241,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
int margin = Helper.dp2pixels(context, 12);
|
||||
int size = Helper.dp2pixels(context, 24);
|
||||
|
||||
if (expanded && experiments) {
|
||||
Rect r1 = new Rect();
|
||||
holder.itemView.getGlobalVisibleRect(r1);
|
||||
Rect r2 = new Rect();
|
||||
recyclerView.getGlobalVisibleRect(r2);
|
||||
rect.top = Math.max(rect.top, r1.top - r2.top);
|
||||
rect.bottom = Math.min(rect.bottom, r1.bottom - r2.top);
|
||||
}
|
||||
|
||||
int icon;
|
||||
if (EntityMessage.SWIPE_ACTION_ASK.equals(action))
|
||||
icon = R.drawable.twotone_help_24;
|
||||
@@ -2247,6 +2271,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
(action.equals(message.folder) && EntityFolder.TRASH.equals(message.folderType)) ||
|
||||
(EntityFolder.TRASH.equals(actionType) && EntityFolder.JUNK.equals(message.folderType)))
|
||||
icon = R.drawable.twotone_delete_forever_24;
|
||||
else if (EntityMessage.SWIPE_ACTION_REPLY.equals(action))
|
||||
icon = R.drawable.twotone_reply_24;
|
||||
else
|
||||
icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type);
|
||||
|
||||
@@ -2315,6 +2341,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
return;
|
||||
}
|
||||
|
||||
boolean expanded = iProperties.getValue("expanded", message.id);
|
||||
|
||||
if (expanded && experiments) {
|
||||
adapter.notifyItemChanged(pos);
|
||||
onMenuReply(message, "reply", null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityFolder.OUTBOX.equals(message.folderType)) {
|
||||
ActivityCompose.undoSend(message.id, getContext(), getViewLifecycleOwner(), getParentFragmentManager());
|
||||
return;
|
||||
@@ -2396,7 +2430,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
if (message == null)
|
||||
return null;
|
||||
|
||||
if (iProperties.getValue("expanded", message.id))
|
||||
boolean expanded = iProperties.getValue("expanded", message.id);
|
||||
|
||||
if (expanded && !experiments)
|
||||
return null;
|
||||
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user