Compare commits

...

2 Commits

Author SHA1 Message Date
jiggles
0477674810 android: set audiofocus none in popup video views (#611)
fixed popups interrupting media playback
2026-06-01 16:29:59 +05:30
Kavish Devar
c1093fbe24 android: fix FOSS upgraded being written false on app launch
fixes #610
2026-06-01 12:43:57 +05:30
3 changed files with 39 additions and 33 deletions

View File

@@ -33,6 +33,7 @@ import android.content.IntentFilter
import android.content.res.Resources import android.content.res.Resources
import android.graphics.PixelFormat import android.graphics.PixelFormat
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.media.AudioManager
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
@@ -374,6 +375,7 @@ class IslandWindow(private val context: Context) {
val videoView = islandView.findViewById<VideoView>(R.id.island_video_view) val videoView = islandView.findViewById<VideoView>(R.id.island_video_view)
val videoUri = "android.resource://me.kavishdevar.librepods/${R.raw.island}".toUri() val videoUri = "android.resource://me.kavishdevar.librepods/${R.raw.island}".toUri()
videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE)
videoView.setVideoURI(videoUri) videoView.setVideoURI(videoUri)
videoView.setOnPreparedListener { mediaPlayer -> videoView.setOnPreparedListener { mediaPlayer ->
mediaPlayer.isLooping = true mediaPlayer.isLooping = true

View File

@@ -29,6 +29,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.graphics.PixelFormat import android.graphics.PixelFormat
import android.media.AudioManager
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
@@ -137,6 +138,7 @@ class PopupWindow(
updateBatteryStatus(batteryNotification) updateBatteryStatus(batteryNotification)
val vid = mView.findViewById<VideoView>(R.id.video) val vid = mView.findViewById<VideoView>(R.id.video)
vid.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE)
vid.setVideoPath("android.resource://me.kavishdevar.librepods/" + R.raw.connected) vid.setVideoPath("android.resource://me.kavishdevar.librepods/" + R.raw.connected)
vid.resolveAdjustedSize(vid.width, vid.height) vid.resolveAdjustedSize(vid.width, vid.height)
vid.start() vid.start()

View File

@@ -179,7 +179,7 @@ class AirPodsViewModel(
if (premium) { if (premium) {
sharedPreferences.edit { sharedPreferences.edit {
remove("premium_expiry_time") remove("premium_expiry_time")
remove("foss_upgraded") if (BuildConfig.PLAY_BUILD) remove("foss_upgraded")
} }
_uiState.update { it.copy(isPremium = true, timeUntilFOSSPremiumExpiry = 0L) } _uiState.update { it.copy(isPremium = true, timeUntilFOSSPremiumExpiry = 0L) }
} else { } else {
@@ -399,49 +399,51 @@ class AirPodsViewModel(
// faulty update on Play caused PLAY_BUILD to be false and resulted in use of FOSS billing in Play. since FOSS is not verified, we need to give 2 weeks to verify the purchase // faulty update on Play caused PLAY_BUILD to be false and resulted in use of FOSS billing in Play. since FOSS is not verified, we need to give 2 weeks to verify the purchase
val expiryTime = sharedPreferences.getLong("premium_expiry_time", 0L) if (BuildConfig.PLAY_BUILD) {
val now = System.currentTimeMillis() val expiryTime = sharedPreferences.getLong("premium_expiry_time", 0L)
val now = System.currentTimeMillis()
when {
// existing temporary premium
expiryTime > 0L -> {
if (expiryTime <= now) {
sharedPreferences.edit {
remove("premium_expiry_time")
remove("foss_upgraded")
}
_uiState.update {
it.copy(
timeUntilFOSSPremiumExpiry = 0L,
isPremium = false
)
}
} else {
_uiState.update {
it.copy(
timeUntilFOSSPremiumExpiry = expiryTime - now,
isPremium = true
)
}
}
}
// First migration from accidental FOSS Play build
fossUpgraded && !_uiState.value.isPremium -> {
val newExpiry = now + 28L * 24 * 60 * 60 * 1000
when {
// existing temporary premium
expiryTime > 0L -> {
if (expiryTime <= now) {
sharedPreferences.edit { sharedPreferences.edit {
remove("premium_expiry_time") putLong("premium_expiry_time", newExpiry)
remove("foss_upgraded")
} }
_uiState.update { _uiState.update {
it.copy( it.copy(
timeUntilFOSSPremiumExpiry = 0L, timeUntilFOSSPremiumExpiry = newExpiry - now,
isPremium = false
)
}
} else {
_uiState.update {
it.copy(
timeUntilFOSSPremiumExpiry = expiryTime - now,
isPremium = true isPremium = true
) )
} }
} }
} }
// First migration from accidental FOSS Play build
fossUpgraded && !_uiState.value.isPremium && BuildConfig.PLAY_BUILD -> {
val newExpiry = now + 28L * 24 * 60 * 60 * 1000
sharedPreferences.edit {
putLong("premium_expiry_time", newExpiry)
}
_uiState.update {
it.copy(
timeUntilFOSSPremiumExpiry = newExpiry - now,
isPremium = true
)
}
}
} }
} }