From 4c3a46247841f56ccdf79efdd0dde75ff3934da2 Mon Sep 17 00:00:00 2001 From: mcc Date: Sun, 10 Dec 2023 13:34:24 -0500 Subject: [PATCH 1/3] Exoplayer: Set wake mode local --- .../java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 80fe55add6..ca63251e07 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -35,6 +35,7 @@ import android.widget.FrameLayout import android.widget.LinearLayout import androidx.annotation.OptIn import androidx.core.view.GestureDetectorCompat +import androidx.media3.common.C.WAKE_MODE_LOCAL import androidx.media3.common.MediaItem import androidx.media3.common.PlaybackException import androidx.media3.common.Player @@ -340,6 +341,7 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { addListener(mediaPlayerListener) repeatMode = Player.REPEAT_MODE_ONE playWhenReady = true + setWakeMode(WAKE_MODE_LOCAL) seekTo(savedSeekPosition) prepare() player = this From f92ac23369bd3559159d2cb261a80d5f0a22d376 Mon Sep 17 00:00:00 2001 From: mcc Date: Sun, 10 Dec 2023 20:44:44 -0500 Subject: [PATCH 2/3] Correctly wire WAKE_LOCK/KEEP_SCREEN_ON Uses KEEP_SCREEN_ON for video, WAKE_LOCK for audio. Requests WAKE_LOCK permission. --- app/src/main/AndroidManifest.xml | 1 + .../main/java/com/keylesspalace/tusky/ViewMediaActivity.kt | 6 ++++-- .../com/keylesspalace/tusky/fragment/ViewVideoFragment.kt | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8c03d7a9b4..b37aa50ba7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + Date: Sun, 10 Dec 2023 20:46:54 -0500 Subject: [PATCH 3/3] ktLint fix --- app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index e963ea2d19..b176d4ba9c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -159,7 +159,7 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. // Prevent this activity from dimming or sleeping the screen if it is playing video // See also WAKE_MODE in ViewVideoFragment.kt - val attachmentType = attachments!![binding.viewPager.currentItem].attachment.type; + val attachmentType = attachments!![binding.viewPager.currentItem].attachment.type if (attachmentType == Attachment.Type.VIDEO || attachmentType == Attachment.Type.GIFV) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }