Skip to content

Commit

Permalink
fix: pip automatically entering even if the setting is off
Browse files Browse the repository at this point in the history
also make preview workflow create seperate artifacts for each apk
  • Loading branch information
abdallahmehiz committed Aug 20, 2024
1 parent f584ba9 commit 4690cc1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,31 @@ jobs:
declare -a apks=("universal" "arm64-v8a" "armeabi-v7a" "x86" "x86_64")
printf "%s\n" "${apks[@]}" | xargs -n 1 -I {} sh -c '
cp app/build/outputs/apk/preview/app-{}-preview-signed.apk mpvKt-{}-r${{ env.COMMIT_COUNT }}.apk'
cp app/build/outputs/apk/preview/app-{}-preview-signed.apk mpvKt-{}-r${{ env.COMMIT_COUNT }}.apk
echo "{}=mpv-{}-r${{ env.COMMIT_COUNT}}.apk" >> $GITHUB_ENV'
- name: Upload the APK artifact
uses: actions/upload-artifact@v4
with:
path: ./mpvKt-*.apk
name: packages
retention-days: 14
path: ${{ env.universal }}
name: ${{ env.universal }}
- name: Upload the APK artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.arm64-v8a }}
name: ${{ env.arm64-v8a }}
- name: Upload the APK artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.armeabi-v7a }}
name: ${{ env.armeabi-v7a }}
- name: Upload the APK artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.x86 }}
name: ${{ env.x86 }}
- name: Upload the APK artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.x86_64 }}
name: ${{ env.x86_64 }}
28 changes: 16 additions & 12 deletions app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package live.mehiz.mpvkt.ui.player

import android.annotation.SuppressLint
import android.app.PictureInPictureParams
import android.content.BroadcastReceiver
import android.content.Context
Expand Down Expand Up @@ -81,7 +82,7 @@ class PlayerActivity : AppCompatActivity() {
private var restoreAudioFocus: () -> Unit = {}

private var pipRect: android.graphics.Rect? = null
private val isPipSupported by lazy {
val isPipSupported by lazy {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
false
} else {
Expand Down Expand Up @@ -133,23 +134,26 @@ class PlayerActivity : AppCompatActivity() {
}

override fun onPause() {
super.onPause()
CoroutineScope(Dispatchers.IO).launch {
saveVideoPlaybackState()
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !isInPictureInPictureMode) {
viewModel.pause()
} else {
return
}
CoroutineScope(Dispatchers.IO).launch {
saveVideoPlaybackState()
}
super.onPause()
}

override fun onStop() {
viewModel.pause()
super.onStop()
}

@SuppressLint("NewApi")
override fun onUserLeaveHint() {
if (!isPipSupported) {
super.onUserLeaveHint()
return
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && player.paused == false) {
if (isPipSupported &&
player.paused == false &&
playerPreferences.automaticallyEnterPip.get()
) {
enterPictureInPictureMode()
}
super.onUserLeaveHint()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package live.mehiz.mpvkt.ui.player.controls

import android.annotation.SuppressLint
import android.os.Build
import androidx.compose.foundation.layout.Row
import androidx.compose.material.icons.Icons
Expand All @@ -17,14 +18,15 @@ import live.mehiz.mpvkt.ui.player.VideoAspect
import live.mehiz.mpvkt.ui.player.controls.components.ControlsButton
import org.koin.compose.koinInject

@SuppressLint("NewApi")
@Composable
fun BottomRightPlayerControls(modifier: Modifier = Modifier) {
val viewModel = koinInject<PlayerViewModel>()
val playerPreferences = koinInject<PlayerPreferences>()
val aspect by playerPreferences.videoAspect.collectAsState()
Row(modifier) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val activity = LocalContext.current as PlayerActivity
val activity = LocalContext.current as PlayerActivity
if (activity.isPipSupported) {
ControlsButton(
Icons.Default.PictureInPictureAlt,
onClick = {
Expand Down

0 comments on commit 4690cc1

Please sign in to comment.