Fix scrolling

This commit is contained in:
Niels Andriesse 2021-06-10 11:37:24 +10:00
parent d7204ff921
commit c69d66e6a4
5 changed files with 14 additions and 8 deletions

View File

@ -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)
}
}

View File

@ -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
}

View File

@ -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" />
</LinearLayout>

View File

@ -19,6 +19,7 @@
<color name="new_conversation_button_shadow">#4D077C44</color>
<color name="pn_option_background">#FCFCFC</color>
<color name="open_group_chip_color">#0D000000</color>
<color name="message_selected">#FFFFFF</color>
<color name="default_background_start">#ffffff</color>
<color name="default_background_end">#fcfcfd</color>

View File

@ -26,6 +26,7 @@
<color name="pn_option_border">#212121</color>
<color name="paths_building">#FFCE3A</color>
<color name="open_group_chip_color">#0DFFFFFF</color>
<color name="message_selected">#000000</color>
<array name="profile_picture_placeholder_colors">
<item>#5ff8b0</item>