From c69d66e6a4c46535eb106177507434a679ae9355 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 10 Jun 2021 11:37:24 +1000 Subject: [PATCH] Fix scrolling --- .../conversation/v2/ConversationRecyclerView.kt | 16 ++++++++++------ .../v2/messages/VisibleMessageView.kt | 2 +- app/src/main/res/layout/view_visible_message.xml | 2 +- app/src/main/res/values-notnight-v21/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt index 05db29ee95..9a1d2bd721 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2 import android.content.Context import android.util.AttributeSet +import android.util.Log import android.view.MotionEvent import android.view.VelocityTracker import androidx.recyclerview.widget.RecyclerView @@ -20,26 +21,29 @@ class ConversationRecyclerView : RecyclerView { } override fun onInterceptTouchEvent(e: MotionEvent): Boolean { - return false - /* + Log.d("Test", "here") val velocityTracker = velocityTracker ?: return super.onInterceptTouchEvent(e) velocityTracker.computeCurrentVelocity(1000) // Specifying 1000 gives pixels per second val vx = velocityTracker.xVelocity val vy = velocityTracker.yVelocity + Log.d("Test", "vx: $vx, vy: $vy") // Only allow swipes to the left; allowing swipes to the right interferes with some back gestures if (vx > 0) { return super.onInterceptTouchEvent(e) } // Return false if abs(v.x) > abs(v.y) so that only swipes that are more horizontal than vertical // get passed on to the message view - return abs(vx) < abs(vy) - */ + if (abs(vx) > abs(vy)) { + return false + } else { + return super.onInterceptTouchEvent(e) + } } - override fun onTouchEvent(e: MotionEvent): Boolean { + override fun dispatchTouchEvent(e: MotionEvent): Boolean { when (e.action) { MotionEvent.ACTION_DOWN -> velocityTracker = VelocityTracker.obtain() MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> velocityTracker = null } velocityTracker?.addMovement(e) - return super.onTouchEvent(e) + return super.dispatchTouchEvent(e) } } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index 627004761d..cda12828a9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -153,7 +153,7 @@ class VisibleMessageView : LinearLayout { private fun handleIsSelectedChanged() { background = if (snIsSelected) { - ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme)) + ColorDrawable(context.resources.getColorWithID(R.color.message_selected, context.theme)) } else { null } diff --git a/app/src/main/res/layout/view_visible_message.xml b/app/src/main/res/layout/view_visible_message.xml index 964857aaf2..661c72d6f4 100644 --- a/app/src/main/res/layout/view_visible_message.xml +++ b/app/src/main/res/layout/view_visible_message.xml @@ -82,7 +82,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:maxLines="1" - android:textSize="@dimen/very_small_font_size" /> + android:textSize="10dp" /> diff --git a/app/src/main/res/values-notnight-v21/colors.xml b/app/src/main/res/values-notnight-v21/colors.xml index d45ccd039b..edfb18a33b 100644 --- a/app/src/main/res/values-notnight-v21/colors.xml +++ b/app/src/main/res/values-notnight-v21/colors.xml @@ -19,6 +19,7 @@ #4D077C44 #FCFCFC #0D000000 + #FFFFFF #ffffff #fcfcfd diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f619f42c42..2eea313b33 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -26,6 +26,7 @@ #212121 #FFCE3A #0DFFFFFF + #000000 #5ff8b0