From 0f1ad36b705d005615bd2d5e1754922598a9c9e7 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:30:38 +0100 Subject: [PATCH 1/8] Target Android API 34 --- android/build.gradle | 4 ++-- example/android/build.gradle | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index f875c5dd0..990ca4fdf 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -29,11 +29,11 @@ def enabledCast = safeExtGet("THEOplayer_extensionCast", 'false').toBoolean() def enabledMediaSession = safeExtGet("THEOplayer_extensionMediaSession", 'true').toBoolean() android { - compileSdk safeExtGet('THEOplayer_compileSdkVersion', 33) + compileSdk safeExtGet('THEOplayer_compileSdkVersion', 34) defaultConfig { minSdkVersion safeExtGet('THEOplayer_minSdkVersion', 21) - targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion', 33) + targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion', 34) versionCode 1 versionName "1.0" diff --git a/example/android/build.gradle b/example/android/build.gradle index 20302e15b..c755d175f 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -2,12 +2,12 @@ buildscript { ext { - buildToolsVersion = "30.0.3" + buildToolsVersion = "34.0.0" minSdkVersion = 24 - compileSdkVersion = 33 - targetSdkVersion = 33 + compileSdkVersion = 34 + targetSdkVersion = 34 ndkVersion = "23.1.7779620" - castFrameworkVersion = "21.0.1" + castFrameworkVersion = "21.4.0" } repositories { google() From c81bf4a170bd6c4ea544a4558c9779493e98919e Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:30:56 +0100 Subject: [PATCH 2/8] Remove unused dependency --- example/android/app/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 11dcce428..689c5dbd8 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -155,7 +155,6 @@ android { dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation project(path: ':reactnativetheoplayer') implementation "com.google.android.gms:play-services-cast-framework:${safeExtGet('castFrameworkVersion', '+')}" From 3723841029f64bbea8f4f0914f7ec2c9c2c8e233 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:31:19 +0100 Subject: [PATCH 3/8] Upgrade flipper --- example/android/app/build.gradle | 6 +++--- example/android/gradle.properties | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 689c5dbd8..d01f04a66 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -158,12 +158,12 @@ dependencies { implementation project(path: ':reactnativetheoplayer') implementation "com.google.android.gms:play-services-cast-framework:${safeExtGet('castFrameworkVersion', '+')}" - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") - debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { + debugImplementation("com.facebook.flipper:flipper:0.242.0") + debugImplementation("com.facebook.flipper:flipper-network-plugin:0.242.0") { exclude group: 'com.squareup.okhttp3', module: 'okhttp' } - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:0.182.0") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 5d4a31a0d..d918516b3 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -24,9 +24,6 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -# Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.142.0 - # Use this property to specify which architecture you want to build. # You can also override it from the CLI using # ./gradlew -PreactNativeArchitectures=x86_64 From 2d106d3c157c7c992e0636c11366ab2a3566ebae Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:31:35 +0100 Subject: [PATCH 4/8] Upgrade dependencies --- android/build.gradle | 6 +++--- example/android/build.gradle | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 990ca4fdf..0569eb089 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,8 +5,8 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21' + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21' } } @@ -101,7 +101,7 @@ repositories { dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3" implementation "androidx.appcompat:appcompat:1.6.1" // The minimum supported THEOplayer version is 6.0.0 diff --git a/example/android/build.gradle b/example/android/build.gradle index c755d175f..e393a00a3 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -14,8 +14,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:4.2.2") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") + classpath("com.android.tools.build:gradle:7.4.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21") classpath("com.facebook.react:react-native-gradle-plugin") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From e47f120b678a83e84fe690ea9f72d514fa5631b4 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:31:52 +0100 Subject: [PATCH 5/8] Declare android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK permission --- android/src/main/AndroidManifest.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index f2406d42d..9c5689bef 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -25,6 +25,15 @@ --> + + + From 8d2129b056adad175b4426309668eee4cf1ccc4a Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:32:13 +0100 Subject: [PATCH 6/8] Apply registerReceiver flag --- .../com/theoplayer/presentation/PipUtils.kt | 19 +++++++++--- .../presentation/PresentationManager.kt | 29 +++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/android/src/main/java/com/theoplayer/presentation/PipUtils.kt b/android/src/main/java/com/theoplayer/presentation/PipUtils.kt index 25d1688db..f0e9b5727 100644 --- a/android/src/main/java/com/theoplayer/presentation/PipUtils.kt +++ b/android/src/main/java/com/theoplayer/presentation/PipUtils.kt @@ -1,5 +1,6 @@ package com.theoplayer.presentation +import android.annotation.SuppressLint import android.app.PendingIntent import android.app.PictureInPictureParams import android.app.RemoteAction @@ -68,6 +69,7 @@ class PipUtils( } } + @SuppressLint("UnspecifiedRegisterReceiverFlag") fun enable() { if (enabled) { return @@ -78,10 +80,19 @@ class PipUtils( adEvents.forEach { action -> player.ads.addEventListener(action, onAdAction) } - reactContext.currentActivity?.registerReceiver( - broadcastReceiver, - IntentFilter(ACTION_MEDIA_CONTROL) - ) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + reactContext.currentActivity?.registerReceiver( + broadcastReceiver, + IntentFilter(ACTION_MEDIA_CONTROL), Context.RECEIVER_EXPORTED + ) + } else { + reactContext.currentActivity?.registerReceiver( + broadcastReceiver, + IntentFilter(ACTION_MEDIA_CONTROL) + ) + } + enabled = true } diff --git a/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt b/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt index 24f3ef928..eb33b3418 100644 --- a/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt +++ b/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt @@ -1,5 +1,6 @@ package com.theoplayer.presentation +import android.annotation.SuppressLint import android.app.AppOpsManager import android.content.BroadcastReceiver import android.content.Context @@ -18,6 +19,7 @@ import com.theoplayer.android.api.error.ErrorCode import com.theoplayer.android.api.error.THEOplayerException import com.theoplayer.android.api.player.PresentationMode +@SuppressLint("UnspecifiedRegisterReceiverFlag") class PresentationManager( private val viewCtx: ReactTHEOplayerContext, private val reactContext: ThemedReactContext, @@ -58,12 +60,27 @@ class PresentationManager( supportsPip = reactContext.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) } - reactContext.currentActivity?.registerReceiver( - onUserLeaveHintReceiver, IntentFilter("onUserLeaveHint") - ) - reactContext.currentActivity?.registerReceiver( - onPictureInPictureModeChanged, IntentFilter("onPictureInPictureModeChanged") - ) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + reactContext.currentActivity?.registerReceiver( + onUserLeaveHintReceiver, IntentFilter("onUserLeaveHint"), Context.RECEIVER_EXPORTED + ) + } else { + reactContext.currentActivity?.registerReceiver( + onUserLeaveHintReceiver, IntentFilter("onUserLeaveHint") + ) + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + reactContext.currentActivity?.registerReceiver( + onPictureInPictureModeChanged, IntentFilter("onPictureInPictureModeChanged"), + Context.RECEIVER_EXPORTED + ) + } else { + reactContext.currentActivity?.registerReceiver( + onPictureInPictureModeChanged, IntentFilter("onPictureInPictureModeChanged") + ) + } } fun destroy() { From f7f9ed82b8f281b5357892de525d26adf543c277 Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 10:39:19 +0100 Subject: [PATCH 7/8] Fix trivial warnings --- .../java/com/reactnativetheoplayer/MainActivity.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/example/android/app/src/main/java/com/reactnativetheoplayer/MainActivity.java b/example/android/app/src/main/java/com/reactnativetheoplayer/MainActivity.java index 46464b707..44df51969 100644 --- a/example/android/app/src/main/java/com/reactnativetheoplayer/MainActivity.java +++ b/example/android/app/src/main/java/com/reactnativetheoplayer/MainActivity.java @@ -3,8 +3,11 @@ import android.content.Intent; import android.content.res.Configuration; import android.media.AudioManager; +import android.os.Build; import android.os.Bundle; +import androidx.annotation.NonNull; + import com.facebook.react.ReactActivity; import com.google.android.gms.cast.framework.CastContext; @@ -40,8 +43,10 @@ public void onUserLeaveHint () { } @Override - public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) { - super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig); + public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, @NonNull Configuration newConfig) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig); + } Intent intent = new Intent("onPictureInPictureModeChanged"); intent.putExtra("isInPictureInPictureMode", isInPictureInPictureMode); this.sendBroadcast(intent); From 402a62f99fb214a10f4f5497b53f384c69100cef Mon Sep 17 00:00:00 2001 From: Tom Van Laerhoven Date: Wed, 20 Dec 2023 11:02:57 +0100 Subject: [PATCH 8/8] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a4d07cd2..9aa6b869e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Changed the Android notification channel name to `Notification channel`. It can be renamed by defining the `notification_channel_name` resource string. +### Added + +- Added support for Android 14. + ## [3.3.2] - 23-12-12 ### Fixed