Pull to close down with effect

pull/184/head
M66B 4 years ago
parent e5c3d54401
commit eb3420aacc

@ -26,3 +26,4 @@ FairEmail uses:
* [File Icon Images](https://github.com/dmhendricks/file-icon-vectors). A collection of file type/extension SVG icons, available free for use in your applications. [MIT License](https://github.com/dmhendricks/file-icon-vectors/blob/master/LICENSE).
* [GPX file type icon](https://www.flaticon.com/free-icon/gpx-file-format-variant_29258) made by [Freepik](https://www.flaticon.com/authors/freepik) from [Flaticon](https://www.flaticon.com).
* [Disconnect's tracker protection lists](https://github.com/disconnectme/disconnect-tracking-protection). Copyright 2010-2020 Disconnect, Inc. [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license](https://github.com/disconnectme/disconnect-tracking-protection/blob/master/LICENSE).
* [Over-Scroll Support For Android's RecyclerView, ListView, GridView, ScrollView ...](https://github.com/EverythingMe/overscroll-decor). Copyright (c) 2015, DoAT Media Ltd. [BSD-2-Clause License](https://github.com/EverythingMe/overscroll-decor/blob/master/LICENSE)

@ -244,6 +244,7 @@ dependencies {
def markwon_version = "4.4.0"
def bouncycastle_version = "1.66"
def colorpicker_version = "0.0.15"
def overscroll_version = "1.1.0"
def appauth_version = "0.7.1"
def jcharset_version = "2.1"
@ -383,6 +384,10 @@ dependencies {
// // https://github.com/QuadFlask/colorpicker
implementation "com.github.QuadFlask:colorpicker:$colorpicker_version"
// https://github.com/EverythingMe/overscroll-decor
// https://mvnrepository.com/artifact/me.everything/overscroll-decor-android?repo=jcenter
implementation "me.everything:overscroll-decor-android:$overscroll_version"
// https://www.bouncycastle.org/latest_releases.html
// https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on
implementation "org.bouncycastle:bcpkix-jdk15to18:$bouncycastle_version"

@ -26,3 +26,4 @@ FairEmail uses:
* [File Icon Images](https://github.com/dmhendricks/file-icon-vectors). A collection of file type/extension SVG icons, available free for use in your applications. [MIT License](https://github.com/dmhendricks/file-icon-vectors/blob/master/LICENSE).
* [GPX file type icon](https://www.flaticon.com/free-icon/gpx-file-format-variant_29258) made by [Freepik](https://www.flaticon.com/authors/freepik) from [Flaticon](https://www.flaticon.com).
* [Disconnect's tracker protection lists](https://github.com/disconnectme/disconnect-tracking-protection). Copyright 2010-2020 Disconnect, Inc. [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license](https://github.com/disconnectme/disconnect-tracking-protection/blob/master/LICENSE).
* [Over-Scroll Support For Android's RecyclerView, ListView, GridView, ScrollView ...](https://github.com/EverythingMe/overscroll-decor). Copyright (c) 2015, DoAT Media Ltd. [BSD-2-Clause License](https://github.com/EverythingMe/overscroll-decor/blob/master/LICENSE)

@ -75,7 +75,6 @@ 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;
@ -206,6 +205,11 @@ import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import me.everything.android.ui.overscroll.IOverScrollDecor;
import me.everything.android.ui.overscroll.IOverScrollUpdateListener;
import me.everything.android.ui.overscroll.VerticalOverScrollBounceEffectDecorator;
import me.everything.android.ui.overscroll.adapters.RecyclerViewOverScrollDecorAdapter;
import static android.app.Activity.RESULT_OK;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
@ -214,6 +218,9 @@ import static android.text.format.DateUtils.FORMAT_SHOW_WEEKDAY;
import static android.view.KeyEvent.ACTION_DOWN;
import static android.view.KeyEvent.ACTION_UP;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_DECELERATE_FACTOR;
import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_TOUCH_DRAG_MOVE_RATIO_BCK;
import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD;
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_KEY_MISSING;
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_NO_SIGNATURE;
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED;
@ -505,9 +512,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
//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();
@ -583,19 +587,6 @@ 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);
@ -1315,6 +1306,30 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
});
boolean swipe_close = prefs.getBoolean("swipe_close", false);
if (swipe_close && viewType == AdapterMessage.ViewType.THREAD) {
IOverScrollDecor decor = new VerticalOverScrollBounceEffectDecorator(
new RecyclerViewOverScrollDecorAdapter(rvMessage, touchHelper) {
@Override
public boolean isInAbsoluteEnd() {
return false;
}
},
DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD,
DEFAULT_TOUCH_DRAG_MOVE_RATIO_BCK,
DEFAULT_DECELERATE_FACTOR
);
decor.setOverScrollUpdateListener(new IOverScrollUpdateListener() {
@Override
public void onOverScrollUpdate(IOverScrollDecor decor, int state, float offset) {
float height = decor.getView().getHeight() / DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD;
if (height != 0 && offset > height / 3)
handleAutoClose();
}
});
}
final String pkg = Helper.getOpenKeychainPackage(getContext());
Log.i("PGP binding to " + pkg);
pgpService = new OpenPgpServiceConnection(getContext(), pkg);

@ -87,7 +87,7 @@ public class FragmentOptions extends FragmentBase {
"message_zoom", "addresses", "attachments_alt", "thumbnails",
"contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
"autoscroll", "swipenav", "swipe_close", "autoexpand", "autoclose", "onclose",
"language_detection",
"quick_filter", "quick_scroll",
"experiments", "debug",

Loading…
Cancel
Save