release 0.4.0 #34

Merged
Seil0 merged 29 commits from develop into master 2021-03-04 20:38:30 +01:00
2 changed files with 33 additions and 1 deletions
Showing only changes of commit 86e07ba2cf - Show all commits

View File

@ -32,6 +32,9 @@
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/PlayerTheme" android:theme="@style/PlayerTheme"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:launchMode="singleTask"
android:excludeFromRecents="true"
android:taskAffinity=".player.PlayerActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|layoutDirection"> android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|layoutDirection">
</activity> </activity>
</application> </application>

View File

@ -3,7 +3,10 @@ package org.mosad.teapod.player
import android.animation.Animator import android.animation.Animator
import android.animation.AnimatorListenerAdapter import android.animation.AnimatorListenerAdapter
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.ActivityManager
import android.app.PictureInPictureParams import android.app.PictureInPictureParams
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.Configuration import android.content.res.Configuration
import android.os.Build import android.os.Build
@ -35,6 +38,7 @@ import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.concurrent.scheduleAtFixedRate import kotlin.concurrent.scheduleAtFixedRate
class PlayerActivity : AppCompatActivity() { class PlayerActivity : AppCompatActivity() {
private val model: PlayerViewModel by viewModels() private val model: PlayerViewModel by viewModels()
@ -43,6 +47,7 @@ class PlayerActivity : AppCompatActivity() {
private lateinit var gestureDetector: GestureDetectorCompat private lateinit var gestureDetector: GestureDetectorCompat
private lateinit var timerUpdates: TimerTask private lateinit var timerUpdates: TimerTask
private var wasInPIP = false
private var playWhenReady = true private var playWhenReady = true
private var currentWindow = 0 private var currentWindow = 0
private var playbackPosition: Long = 0 private var playbackPosition: Long = 0
@ -117,6 +122,10 @@ class PlayerActivity : AppCompatActivity() {
video_view?.onPause() video_view?.onPause()
releasePlayer() releasePlayer()
} }
if (wasInPIP) {
navToLauncherTask()
}
} }
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
@ -146,10 +155,15 @@ class PlayerActivity : AppCompatActivity() {
.build() .build()
enterPictureInPictureMode(params) enterPictureInPictureMode(params)
} }
wasInPIP = isInPiPMode()
} }
} }
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) { override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean,
newConfig: Configuration?
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig) super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
// Hide the full-screen UI (controls, etc.) while in picture-in-picture mode. // Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.
@ -434,6 +448,21 @@ class PlayerActivity : AppCompatActivity() {
} }
} }
/**
* Bring up launcher task to front
*/
private fun navToLauncherTask() {
val activityManager = (this.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager)
activityManager.appTasks.forEach { task ->
val baseIntent = task.taskInfo.baseIntent
val categories = baseIntent.categories
if (categories != null && categories.contains(Intent.CATEGORY_LAUNCHER)) {
task.moveToFront()
return
}
}
}
/** /**
* pause playback and hide controls * pause playback and hide controls
*/ */