Skip to content

Commit

Permalink
Merge pull request #89 from itszechs/extend_support
Browse files Browse the repository at this point in the history
Added support for Android 8 (Oreo)
  • Loading branch information
itszechs authored Feb 9, 2023
2 parents 63ad7a9 + 9dbfa48 commit b4c35f9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {

defaultConfig {
applicationId "zechs.drive.stream"
minSdk 28
minSdk 21
targetSdk 33
versionCode 8
versionName "1.2.3"
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/zechs/drive/stream/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
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>
2 changes: 1 addition & 1 deletion mpv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
compileSdk 32

defaultConfig {
minSdk 28
minSdk 21
targetSdk 32
}

Expand Down

0 comments on commit b4c35f9

Please sign in to comment.