mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Add parameter to MyGestureDetector to enable gestures for a specific detector, even if system-wide gestures are disabled.
This commit is contained in:
parent
edd78ea10c
commit
30151f1a70
@ -128,6 +128,25 @@ public class K9Activity extends Activity {
|
||||
}
|
||||
|
||||
class MyGestureDetector extends SimpleOnGestureListener {
|
||||
private boolean gesturesEnabled = false;
|
||||
|
||||
/**
|
||||
* Creates a new {@link android.view.GestureDetector.OnGestureListener}. Enabled/disabled based upon
|
||||
* {@link com.fsck.k9.K9#gesturesEnabled()}}.
|
||||
*/
|
||||
public MyGestureDetector() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link android.view.GestureDetector.OnGestureListener}.
|
||||
* @param gesturesEnabled Setting to <code>true</code> will enable gesture detection,
|
||||
* regardless of the system-wide gesture setting.
|
||||
*/
|
||||
public MyGestureDetector(final boolean gesturesEnabled) {
|
||||
super();
|
||||
this.gesturesEnabled = gesturesEnabled;
|
||||
}
|
||||
|
||||
private static final float SWIPE_MIN_DISTANCE_DIP = 130.0f;
|
||||
private static final float SWIPE_MAX_OFF_PATH_DIP = 250f;
|
||||
@ -151,7 +170,8 @@ public class K9Activity extends Activity {
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
if (K9.gesturesEnabled()) {
|
||||
// Do fling-detection if gestures are force-enabled or we have system-wide gestures enabled.
|
||||
if (gesturesEnabled || K9.gesturesEnabled()) {
|
||||
// Convert the dips to pixels
|
||||
final float mGestureScale = getResources().getDisplayMetrics().density;
|
||||
int min_distance = (int)(SWIPE_MIN_DISTANCE_DIP * mGestureScale + 0.5f);
|
||||
|
@ -818,7 +818,7 @@ public class MessageList
|
||||
mBatchDoneButton.setOnClickListener(this);
|
||||
|
||||
// Gesture detection
|
||||
gestureDetector = new GestureDetector(new MyGestureDetector());
|
||||
gestureDetector = new GestureDetector(new MyGestureDetector(true));
|
||||
gestureListener = new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user