From 868d0c47efe2681dc38c4e11171c7ee9fb3010cd Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Tue, 9 Jul 2024 05:18:30 +0530 Subject: [PATCH] Fix cutout mode crashes for full screen players --- app/src/main/AndroidManifest.xml | 6 +++--- .../image_viewer/ImageViewerActivity.kt | 12 +++++++++++- .../image_viewer/editor/EditImageActivity.kt | 9 +++++++++ .../video_player/VideoPlayerActivity.kt | 9 +++++++++ .../main/res/{values-v27 => values-v28}/themes.xml | 0 app/src/main/res/values/themes.xml | 6 ++++++ 6 files changed, 38 insertions(+), 4 deletions(-) rename app/src/main/res/{values-v27 => values-v28}/themes.xml (100%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 278da6d2..fe21e9a8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -94,7 +94,7 @@ = Build.VERSION_CODES.P) { + try { + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark) + } catch (e: Exception) { + log.warn("failed to set theme Theme_AmazeFileUtilities_FullScreen_Dark") + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark_Fallback) + } + } super.onCreate(savedInstanceState) setContentView(viewBinding.root) diff --git a/app/src/main/java/com/amaze/fileutilities/image_viewer/editor/EditImageActivity.kt b/app/src/main/java/com/amaze/fileutilities/image_viewer/editor/EditImageActivity.kt index ca7a717e..84edc5cb 100644 --- a/app/src/main/java/com/amaze/fileutilities/image_viewer/editor/EditImageActivity.kt +++ b/app/src/main/java/com/amaze/fileutilities/image_viewer/editor/EditImageActivity.kt @@ -30,6 +30,7 @@ import android.graphics.Bitmap import android.graphics.Typeface import android.graphics.drawable.Drawable import android.net.Uri +import android.os.Build import android.os.Bundle import android.provider.MediaStore import android.view.MotionEvent @@ -143,6 +144,14 @@ class EditImageActivity : ) override fun onCreate(savedInstanceState: Bundle?) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + try { + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark) + } catch (e: Exception) { + log.warn("failed to set theme Theme_AmazeFileUtilities_FullScreen_Dark") + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark_Fallback) + } + } super.onCreate(savedInstanceState) setContentView(R.layout.activity_edit_image) initViews() diff --git a/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt b/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt index 3abcf5b6..3e611a4f 100644 --- a/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt +++ b/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt @@ -27,6 +27,7 @@ import android.view.View import android.view.WindowInsets import android.view.WindowInsetsController import android.view.WindowManager +import com.amaze.fileutilities.R class VideoPlayerActivity : BaseVideoPlayerActivity() { @@ -39,6 +40,14 @@ class VideoPlayerActivity : BaseVideoPlayerActivity() { } override fun onCreate(savedInstanceState: Bundle?) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + try { + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark) + } catch (e: Exception) { + log.warn("failed to set theme Theme_AmazeFileUtilities_FullScreen_Dark", e) + setTheme(R.style.Theme_AmazeFileUtilities_FullScreen_Dark_Fallback) + } + } initLocalVideoModel(intent) super.onCreate(savedInstanceState) handleVideoPlayerActivityResources() diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v28/themes.xml similarity index 100% rename from app/src/main/res/values-v27/themes.xml rename to app/src/main/res/values-v28/themes.xml diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index bdc0c588..d4fd73a8 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -66,6 +66,12 @@ @color/black + +