Skip to content

Commit

Permalink
disable unsupported features on Android O
Browse files Browse the repository at this point in the history
  • Loading branch information
itszechs committed Feb 9, 2023
1 parent 63e6868 commit 86c4d2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 19 additions & 3 deletions app/src/main/java/zechs/drive/stream/ui/player/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
<string name="theme_dark">Dark</string>
<string name="theme_system">Follow system</string>
<string name="no_files_found">No files found</string>
<string name="pip_not_supported">PiP mode is not supported on your device</string>
</resources>

0 comments on commit 86c4d2a

Please sign in to comment.