Skip to content

Commit

Permalink
Fix compilation errors for SDK 34
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Horta committed Sep 1, 2023
1 parent 4e8585f commit 0e21f06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0e21f06

Please sign in to comment.