From 63e68683bc876de1e7533e817316c4528b1c9c3b Mon Sep 17 00:00:00 2001 From: zechs Date: Sun, 21 Aug 2022 13:38:08 +0530 Subject: [PATCH 1/3] Skipping notification channel on Android O and below --- app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt b/app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt index 39595ca..73dc64d 100644 --- a/app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt +++ b/app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt @@ -7,6 +7,7 @@ import android.app.PendingIntent import android.content.Intent import android.media.RingtoneManager import android.net.Uri +import android.os.Build import android.os.Bundle import android.util.Log import androidx.activity.viewModels @@ -53,7 +54,9 @@ class MainActivity : AppCompatActivity() { binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) - createUpdateNotificationChannel() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + createUpdateNotificationChannel() + } val navHostFragment = supportFragmentManager.findFragmentById( R.id.mainNavHostFragment From 86c4d2a7b0c66f17ba16ff902b70fcb6d1f15816 Mon Sep 17 00:00:00 2001 From: zechs Date: Sun, 21 Aug 2022 13:39:40 +0530 Subject: [PATCH 2/3] disable unsupported features on Android O --- .../drive/stream/ui/player/PlayerActivity.kt | 22 ++++++++++++++++--- .../drive/stream/ui/player2/MPVActivity.kt | 9 ++++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt b/app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt index 992d303..fbb02d4 100644 --- a/app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt +++ b/app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt @@ -5,12 +5,14 @@ import android.app.PictureInPictureParams import android.content.Intent import android.content.res.Configuration import android.net.Uri +import android.os.Build import android.os.Bundle import android.util.Log import android.view.View import android.view.animation.AccelerateInterpolator import android.widget.HorizontalScrollView import android.widget.LinearLayout +import android.widget.Toast import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat @@ -186,7 +188,17 @@ class PlayerActivity : AppCompatActivity() { } } - btnPip.setOnClickListener { enterPIPMode() } + btnPip.setOnClickListener { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + enterPIPMode() + } else { + Toast.makeText( + this, + getString(R.string.pip_not_supported), + Toast.LENGTH_SHORT + ).show() + } + } btnSpeed.setOnClickListener { MaterialAlertDialogBuilder(this).apply { @@ -469,7 +481,9 @@ class PlayerActivity : AppCompatActivity() { Configuration.ORIENTATION_PORTRAIT -> { btnRotate.apply { orientation = Orientation.PORTRAIT - tooltipText = getString(R.string.landscape) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + tooltipText = getString(R.string.landscape) + } icon = ContextCompat.getDrawable( /* context */ this@PlayerActivity, /* drawableId */ R.drawable.ic_landscape_24 @@ -479,7 +493,9 @@ class PlayerActivity : AppCompatActivity() { else -> { btnRotate.apply { orientation = Orientation.LANDSCAPE - tooltipText = getString(R.string.portrait) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + tooltipText = getString(R.string.portrait) + } icon = ContextCompat.getDrawable( /* context */ this@PlayerActivity, /* drawableId */ R.drawable.ic_portrait_24 diff --git a/app/src/main/java/zechs/drive/stream/ui/player2/MPVActivity.kt b/app/src/main/java/zechs/drive/stream/ui/player2/MPVActivity.kt index b64209e..ee6279b 100644 --- a/app/src/main/java/zechs/drive/stream/ui/player2/MPVActivity.kt +++ b/app/src/main/java/zechs/drive/stream/ui/player2/MPVActivity.kt @@ -6,6 +6,7 @@ import android.content.res.Configuration import android.media.AudioManager import android.media.AudioManager.* import android.net.Uri +import android.os.Build import android.os.Bundle import android.util.Log import android.view.View @@ -453,7 +454,9 @@ class MPVActivity : AppCompatActivity(), MPVLib.EventObserver { Configuration.ORIENTATION_PORTRAIT -> { controller.btnRotate.apply { orientation = Orientation.PORTRAIT - tooltipText = getString(R.string.landscape) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + tooltipText = getString(R.string.landscape) + } icon = ContextCompat.getDrawable( /* context */ this@MPVActivity, /* drawableId */ R.drawable.ic_landscape_24 @@ -463,7 +466,9 @@ class MPVActivity : AppCompatActivity(), MPVLib.EventObserver { else -> { controller.btnRotate.apply { orientation = Orientation.LANDSCAPE - tooltipText = getString(R.string.portrait) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + tooltipText = getString(R.string.portrait) + } icon = ContextCompat.getDrawable( /* context */ this@MPVActivity, /* drawableId */ R.drawable.ic_portrait_24 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 348470c..6c23092 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,4 +51,5 @@ Dark Follow system No files found + PiP mode is not supported on your device \ No newline at end of file From 9dbfa4841c1518f4befb9ce1dc170c8bc4313296 Mon Sep 17 00:00:00 2001 From: zechs Date: Sun, 21 Aug 2022 13:39:40 +0530 Subject: [PATCH 3/3] changed minSdk version to 21 --- app/build.gradle | 2 +- mpv/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3e5ce48..3f9210d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { defaultConfig { applicationId "zechs.drive.stream" - minSdk 28 + minSdk 21 targetSdk 33 versionCode 8 versionName "1.2.3" diff --git a/mpv/build.gradle b/mpv/build.gradle index 2125ecc..6f6593a 100644 --- a/mpv/build.gradle +++ b/mpv/build.gradle @@ -7,7 +7,7 @@ android { compileSdk 32 defaultConfig { - minSdk 28 + minSdk 21 targetSdk 32 }