mirror of https://github.com/M66B/FairEmail.git
Added swipe down to close conversation
This commit is contained in:
parent
504cbe102c
commit
cf7163b814
|
@ -75,6 +75,7 @@ import android.view.MenuItem;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
@ -503,6 +504,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
rvMessage.setHasFixedSize(false);
|
||||
//rvMessage.setItemViewCacheSize(10);
|
||||
//rvMessage.getRecycledViewPool().setMaxRecycledViews(0, 10);
|
||||
|
||||
final int minOverscroll = Helper.dp2pixels(getContext(),
|
||||
ViewConfiguration.get(getContext()).getScaledPagingTouchSlop());
|
||||
|
||||
final LinearLayoutManager llm = new LinearLayoutManager(getContext()) {
|
||||
private Rect parentRect = new Rect();
|
||||
private Rect childRect = new Rect();
|
||||
|
@ -578,6 +583,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scrollVerticallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
int scrollRange = super.scrollVerticallyBy(dx, recycler, state);
|
||||
boolean swipe_close = prefs.getBoolean("swipe_close", false);
|
||||
if (swipe_close && viewType == AdapterMessage.ViewType.THREAD) {
|
||||
int overscroll = dx - scrollRange;
|
||||
Log.i("Overscroll=" + overscroll + "/" + minOverscroll);
|
||||
if (overscroll < -minOverscroll)
|
||||
handleAutoClose();
|
||||
}
|
||||
return scrollRange;
|
||||
}
|
||||
};
|
||||
rvMessage.setLayoutManager(llm);
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
private SwitchCompat swSwipeNav;
|
||||
private SwitchCompat swVolumeNav;
|
||||
private SwitchCompat swReversed;
|
||||
private SwitchCompat swSwipeClose;
|
||||
private SwitchCompat swAutoExpand;
|
||||
private SwitchCompat swExpandAll;
|
||||
private SwitchCompat swExpandOne;
|
||||
|
@ -86,7 +87,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
"double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||
"default_snooze",
|
||||
"pull", "autoscroll", "quick_filter", "quick_scroll",
|
||||
"doubletap", "swipenav", "volumenav", "reversed",
|
||||
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close",
|
||||
"autoexpand", "expand_all", "expand_one", "collapse_multiple",
|
||||
"autoclose", "onclose", "undo_timeout",
|
||||
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance"
|
||||
|
@ -116,6 +117,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
swSwipeNav = view.findViewById(R.id.swSwipeNav);
|
||||
swVolumeNav = view.findViewById(R.id.swVolumeNav);
|
||||
swReversed = view.findViewById(R.id.swReversed);
|
||||
swSwipeClose = view.findViewById(R.id.swSwipeClose);
|
||||
swAutoExpand = view.findViewById(R.id.swAutoExpand);
|
||||
swExpandAll = view.findViewById(R.id.swExpandAll);
|
||||
swExpandOne = view.findViewById(R.id.swExpandOne);
|
||||
|
@ -253,6 +255,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
}
|
||||
});
|
||||
|
||||
swSwipeClose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("swipe_close", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAutoExpand.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -426,6 +435,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
|
||||
swVolumeNav.setChecked(prefs.getBoolean("volumenav", false));
|
||||
swReversed.setChecked(prefs.getBoolean("reversed", false));
|
||||
swSwipeClose.setChecked(prefs.getBoolean("swipe_close", false));
|
||||
|
||||
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
|
||||
swExpandAll.setChecked(prefs.getBoolean("expand_all", false));
|
||||
|
|
|
@ -251,6 +251,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swVolumeNav"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSwipeClose"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_swipe_close"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swReversed"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoExpand"
|
||||
android:layout_width="0dp"
|
||||
|
@ -260,7 +271,7 @@
|
|||
android:text="@string/title_advanced_autoexpand"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swReversed"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSwipeClose"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -385,6 +385,7 @@
|
|||
<string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string>
|
||||
<string name="title_advanced_volumenav">Volume up/down to go to next/previous conversation</string>
|
||||
<string name="title_advanced_reversed">Reverse navigation direction</string>
|
||||
<string name="title_advanced_swipe_close">Swipe down to close conversation</string>
|
||||
<string name="title_advanced_autoexpand">Automatically expand messages</string>
|
||||
<string name="title_advanced_expand_all">Automatically expand all read messages</string>
|
||||
<string name="title_advanced_expand_one">Expand only one message at a time</string>
|
||||
|
|
Loading…
Reference in New Issue