From 338477c36bc0d9be3ae64c9392b0662906e18869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kosmaty?= Date: Mon, 6 May 2024 10:49:07 +0200 Subject: [PATCH] [video][Android] Remove Kotlin warnings (#28628) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Why Removes Kotlin warnings. Most of them can be just ignored because we already migrated to new APIs. # Test Plan - NCL ✅ --- .../java/expo/modules/video/FullscreenPlayerActivity.kt | 3 ++- .../expo/modules/video/VideoPlayerAudioFocusManager.kt | 2 ++ .../android/src/main/java/expo/modules/video/VideoView.kt | 1 + .../java/expo/modules/video/drawing/OutlineProvider.kt | 7 ++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/expo-video/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt b/packages/expo-video/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt index 7217be0dbbdf90..2893c7370d0fa7 100644 --- a/packages/expo-video/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt +++ b/packages/expo-video/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt @@ -46,9 +46,10 @@ class FullscreenPlayerActivity : Activity() { VideoManager.getVideoView(videoViewId).exitFullscreen() // Disable the exit transition - if (Build.VERSION.SDK_INT >= 34) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, 0, 0) } else { + @Suppress("DEPRECATION") overridePendingTransition(0, 0) } } diff --git a/packages/expo-video/android/src/main/java/expo/modules/video/VideoPlayerAudioFocusManager.kt b/packages/expo-video/android/src/main/java/expo/modules/video/VideoPlayerAudioFocusManager.kt index d377ebe271e692..d79fa9d6d0ae75 100644 --- a/packages/expo-video/android/src/main/java/expo/modules/video/VideoPlayerAudioFocusManager.kt +++ b/packages/expo-video/android/src/main/java/expo/modules/video/VideoPlayerAudioFocusManager.kt @@ -51,6 +51,7 @@ class VideoPlayerAudioFocusManager(val context: Context, private val player: Wea this.currentFocusRequest = newFocusRequest audioManager.requestAudioFocus(newFocusRequest) } else { + @Suppress("DEPRECATION") audioManager.requestAudioFocus( this, AudioManager.STREAM_MUSIC, @@ -64,6 +65,7 @@ class VideoPlayerAudioFocusManager(val context: Context, private val player: Wea if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { audioManager.abandonAudioFocusRequest(it) } else { + @Suppress("DEPRECATION") audioManager.abandonAudioFocus(this) } } diff --git a/packages/expo-video/android/src/main/java/expo/modules/video/VideoView.kt b/packages/expo-video/android/src/main/java/expo/modules/video/VideoView.kt index ae01a0a47976a3..2d046c70df1ad4 100644 --- a/packages/expo-video/android/src/main/java/expo/modules/video/VideoView.kt +++ b/packages/expo-video/android/src/main/java/expo/modules/video/VideoView.kt @@ -146,6 +146,7 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap if (Build.VERSION.SDK_INT >= 34) { currentActivity.overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN, 0, 0) } else { + @Suppress("DEPRECATION") currentActivity.overridePendingTransition(0, 0) } isInFullscreen = true diff --git a/packages/expo-video/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt b/packages/expo-video/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt index 6ebf112316ed71..e8b3021c4d1cd9 100644 --- a/packages/expo-video/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt +++ b/packages/expo-video/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt @@ -5,6 +5,7 @@ import android.graphics.Canvas import android.graphics.Outline import android.graphics.Path import android.graphics.RectF +import android.os.Build import android.view.View import android.view.ViewOutlineProvider import com.facebook.react.modules.i18nmanager.I18nUtil @@ -197,7 +198,11 @@ class OutlineProvider(private val mContext: Context) : ViewOutlineProvider() { // shadow is. For the particular case, we fallback to canvas clipping in the view // which is supposed to call `clipCanvasIfNeeded` in its `draw` method. updateConvexPathIfNeeded() - outline.setConvexPath(mConvexPath) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + outline.setPath(mConvexPath) + } else { + outline.setConvexPath(mConvexPath) + } } }