diff --git a/app/src/main/java/com/automattic/loop/photopicker/PhotoPickerActivity.java b/app/src/main/java/com/automattic/loop/photopicker/PhotoPickerActivity.java index 3dc9ea47..b915839d 100644 --- a/app/src/main/java/com/automattic/loop/photopicker/PhotoPickerActivity.java +++ b/app/src/main/java/com/automattic/loop/photopicker/PhotoPickerActivity.java @@ -405,8 +405,8 @@ private class FlingGestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_THRESHOLD_VELOCITY = 200; - @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (e1 != null && e2 != null) { + @Override public boolean onFling(MotionEvent e1, @NonNull MotionEvent e2, float velocityX, float velocityY) { + if (e1 != null) { if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { // Top to bottom diff --git a/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt b/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt index 9f37b4ee..f05262ae 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt @@ -2292,7 +2292,9 @@ abstract class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelec } private inner class FlingGestureListener : GestureDetector.SimpleOnGestureListener() { - override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { + override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { + if (e1 == null) return super.onFling(null, e2, velocityX, velocityY) + if (e1.y - e2.y > SWIPE_MIN_DISTANCE && abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { // Bottom to top val ycoordStart = e1.y diff --git a/stories/src/main/java/com/wordpress/stories/compose/VideoRecordingControlView.kt b/stories/src/main/java/com/wordpress/stories/compose/VideoRecordingControlView.kt index b5d564a4..f9bab230 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/VideoRecordingControlView.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/VideoRecordingControlView.kt @@ -61,7 +61,7 @@ class VideoRecordingControlView @JvmOverloads constructor( override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { if (w != oldw || h != oldh) { - bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)?.apply { + bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888).apply { eraseColor(Color.TRANSPARENT) viewCanvas = Canvas(this) } diff --git a/stories/src/main/java/com/wordpress/stories/compose/text/TextSizeSlider.kt b/stories/src/main/java/com/wordpress/stories/compose/text/TextSizeSlider.kt index 05fd6f47..50fec1b2 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/text/TextSizeSlider.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/text/TextSizeSlider.kt @@ -1,6 +1,7 @@ package com.wordpress.stories.compose.text import android.content.res.Resources +import android.os.Build import android.util.TypedValue import android.widget.SeekBar import android.widget.SeekBar.OnSeekBarChangeListener @@ -29,9 +30,19 @@ class TextSizeSlider( }) } + @Suppress("DEPRECATION") fun update() { - val fontSizeSp = (textView.textSize / resources.displayMetrics.scaledDensity).toInt() - seekBar.progress = (fontSizeSp - TEXT_SIZE_SLIDER_MIN_VALUE) / TEXT_SIZE_SLIDER_STEP + val fontSizeSp = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + // this takes into account text specifics (such as font size multipliers in system settings) + TypedValue.deriveDimension( + TypedValue.COMPLEX_UNIT_SP, + textView.textSize, + resources.displayMetrics + ) + } else { + (textView.textSize / resources.displayMetrics.scaledDensity) + } + seekBar.progress = (fontSizeSp.toInt() - TEXT_SIZE_SLIDER_MIN_VALUE) / TEXT_SIZE_SLIDER_STEP } companion object {