aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle1
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java51
-rw-r--r--src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java57
3 files changed, 45 insertions, 64 deletions
diff --git a/build.gradle b/build.gradle
index 7408f6cee..cfb3a4029 100644
--- a/build.gradle
+++ b/build.gradle
@@ -69,6 +69,7 @@ dependencies {
implementation 'pub.devrel:easypermissions:1.1.3'
implementation 'com.wefika:flowlayout:0.4.1'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.3'
+ implementation 'in.championswimmer:SimpleFingerGestures_Android_Library:1.2'
implementation 'rocks.xmpp:xmpp-addr:0.8.0-SNAPSHOT'
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 1d0a0fce3..1a4095b0e 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -110,6 +110,7 @@ import de.pixart.messenger.utils.StylingHelper;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xmpp.XmppConnection;
import de.pixart.messenger.xmpp.chatstate.ChatState;
+import in.championswimmer.sfg.lib.SimpleFingerGestures;
import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.ui.XmppActivity.EXTRA_ACCOUNT;
@@ -155,6 +156,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private Toast messageLoaderToast;
private ConversationsActivity activity;
private boolean reInitRequiredOnStart = true;
+
+ private SimpleFingerGestures gesturesDetector = new SimpleFingerGestures();
+
protected OnClickListener clickToVerify = new OnClickListener() {
@Override
public void onClick(View v) {
@@ -2110,13 +2114,46 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
// todo add swipe listener --> causes strange scrolling in chats
- /*this.binding.messagesView.setOnTouchListener(new OnSwipeTouchListener(getContext()) {
- @Override
- public void onSwipeRight() {
- Log.d(Config.LOGTAG, "Swipe right detected");
- activity.onBackPressed();
- }
- });*/
+ //this.binding.messagesView.setOnTouchListener(new OnSwipeTouchListener(getContext()) {
+ gesturesDetector.setOnFingerGestureListener(new SimpleFingerGestures.OnFingerGestureListener() {
+ @Override
+ public boolean onSwipeUp(int fingers, long gestureDuration, double gestureDistance) {
+ return false;
+ }
+
+ @Override
+ public boolean onSwipeDown(int fingers, long gestureDuration, double gestureDistance) {
+ return false;
+ }
+
+ @Override
+ public boolean onSwipeLeft(int fingers, long gestureDuration, double gestureDistance) {
+ return false;
+ }
+
+ @Override
+ public boolean onSwipeRight(int fingers, long gestureDuration, double gestureDistance) {
+ activity.onBackPressed();
+ return false;
+ }
+
+ @Override
+ public boolean onPinch(int fingers, long gestureDuration, double gestureDistance) {
+ return false;
+ }
+
+ @Override
+ public boolean onUnpinch(int fingers, long gestureDuration, double gestureDistance) {
+ return false;
+ }
+
+ @Override
+ public boolean onDoubleTap(int fingers) {
+ return false;
+ }
+ });
+ this.binding.messagesView.setOnTouchListener(gesturesDetector);
+
activity.onConversationRead(this.conversation);
//TODO if we only do this when this fragment is running on main it won't *bing* in tablet layout which might be unnecessary since we can *see* it
activity.xmppConnectionService.getNotificationService().setOpenConversation(this.conversation);
diff --git a/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java b/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java
deleted file mode 100644
index 716127c8c..000000000
--- a/src/main/java/de/pixart/messenger/ui/interfaces/OnSwipeTouchListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package de.pixart.messenger.ui.interfaces;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View;
-
-import de.pixart.messenger.Config;
-
-public class OnSwipeTouchListener implements View.OnTouchListener {
-
- private final GestureDetector gestureDetector;
-
- public OnSwipeTouchListener(Context context) {
- gestureDetector = new GestureDetector(context, new GestureListener());
- }
-
- public void onSwipeLeft() {
- }
-
- public void onSwipeRight() {
- }
-
- public boolean onTouch(View v, MotionEvent event) {
- return gestureDetector.onTouchEvent(event);
- }
-
- private final class GestureListener extends GestureDetector.SimpleOnGestureListener {
-
- private static final int SWIPE_DISTANCE_THRESHOLD = 120;
- private static final int SWIPE_VELOCITY_THRESHOLD = 200;
-
- @Override
- public boolean onDown(MotionEvent e) {
- return true;
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if (e1 == null || e2 == null) {
- Log.d(Config.LOGTAG, "Error MotionEvent");
- return false;
- }
- float distanceX = e2.getX() - e1.getX();
- float distanceY = e2.getY() - e1.getY();
- if (Math.abs(distanceX) > Math.abs(distanceY) && Math.abs(distanceX) > SWIPE_DISTANCE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
- if (distanceX > 0)
- onSwipeRight();
- else
- onSwipeLeft();
- return true;
- }
- return false;
- }
- }
-} \ No newline at end of file