Prep work for play store distribution (#301)

Allows for disabling in-app updates and more flexible tag/version codes
This commit is contained in:
damontecres 2025-11-22 12:57:47 -05:00 committed by GitHub
parent df78b42bac
commit 78e6304571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 113 additions and 88 deletions

View file

@ -24,7 +24,7 @@ val ffmpegModuleExists = project.file("libs/lib-decoder-ffmpeg-release.aar").exi
fun getVersionCode(): Int { fun getVersionCode(): Int {
val stdout = ByteArrayOutputStream() val stdout = ByteArrayOutputStream()
exec { exec {
commandLine = listOf("git", "tag", "--list", "v*") commandLine = listOf("git", "tag", "--list", "v*", "p*")
standardOutput = stdout standardOutput = stdout
} }
return stdout return stdout

View file

@ -140,7 +140,7 @@ class MainActivity : AppCompatActivity() {
} }
val backStack = rememberNavBackStack(initialDestination) val backStack = rememberNavBackStack(initialDestination)
navigationManager.backStack = backStack navigationManager.backStack = backStack
if (appPreferences.autoCheckForUpdates) { if (UpdateChecker.ACTIVE && appPreferences.autoCheckForUpdates) {
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
try { try {
updateChecker.maybeShowUpdateToast(appPreferences.updateUrl) updateChecker.maybeShowUpdateToast(appPreferences.updateUrl)

View file

@ -7,6 +7,7 @@ import androidx.core.content.edit
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.github.damontecres.wholphin.R import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.WholphinApplication import com.github.damontecres.wholphin.WholphinApplication
import com.github.damontecres.wholphin.services.UpdateChecker
import com.github.damontecres.wholphin.ui.nav.Destination import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.preferences.ConditionalPreferences import com.github.damontecres.wholphin.ui.preferences.ConditionalPreferences
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
@ -745,10 +746,12 @@ val basicPreferences =
PreferenceGroup( PreferenceGroup(
title = R.string.about, title = R.string.about,
preferences = preferences =
listOf( buildList {
AppPreference.InstalledVersion, add(AppPreference.InstalledVersion)
AppPreference.Update, if (UpdateChecker.ACTIVE) {
), add(AppPreference.Update)
}
},
), ),
PreferenceGroup( PreferenceGroup(
title = R.string.more, title = R.string.more,
@ -762,72 +765,84 @@ val basicPreferences =
val uiPreferences = listOf<PreferenceGroup>() val uiPreferences = listOf<PreferenceGroup>()
val advancedPreferences = val advancedPreferences =
listOf( buildList {
PreferenceGroup( add(
title = R.string.ui_interface, PreferenceGroup(
preferences = title = R.string.ui_interface,
listOf( preferences =
AppPreference.ShowClock, listOf(
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418 AppPreference.ShowClock,
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418
// AppPreference.NavDrawerSwitchOnFocus, // AppPreference.NavDrawerSwitchOnFocus,
AppPreference.ControllerTimeout, AppPreference.ControllerTimeout,
), ),
), ),
PreferenceGroup( )
title = R.string.playback, add(
preferences = PreferenceGroup(
listOf( title = R.string.playback,
AppPreference.OneClickPause, preferences =
AppPreference.GlobalContentScale, listOf(
AppPreference.SkipIntros, AppPreference.OneClickPause,
AppPreference.SkipOutros, AppPreference.GlobalContentScale,
AppPreference.SkipCommercials, AppPreference.SkipIntros,
AppPreference.SkipPreviews, AppPreference.SkipOutros,
AppPreference.SkipRecaps, AppPreference.SkipCommercials,
AppPreference.MaxBitrate, AppPreference.SkipPreviews,
AppPreference.PlaybackDebugInfo, AppPreference.SkipRecaps,
), AppPreference.MaxBitrate,
), AppPreference.PlaybackDebugInfo,
PreferenceGroup( ),
title = R.string.player_backend, ),
preferences = listOf(AppPreference.PlayerBackendPref), )
conditionalPreferences = add(
listOf( PreferenceGroup(
ConditionalPreferences( title = R.string.player_backend,
{ it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER }, preferences = listOf(AppPreference.PlayerBackendPref),
listOf( conditionalPreferences =
AppPreference.FfmpegPreference, listOf(
AppPreference.DownMixStereo, ConditionalPreferences(
AppPreference.Ac3Supported, { it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER },
AppPreference.DirectPlayAss, listOf(
AppPreference.DirectPlayPgs, AppPreference.FfmpegPreference,
AppPreference.DownMixStereo,
AppPreference.Ac3Supported,
AppPreference.DirectPlayAss,
AppPreference.DirectPlayPgs,
),
),
ConditionalPreferences(
{ it.playbackPreferences.playerBackend == PlayerBackend.MPV },
listOf(AppPreference.MpvHardwareDecoding),
), ),
), ),
ConditionalPreferences( ),
{ it.playbackPreferences.playerBackend == PlayerBackend.MPV }, )
listOf(AppPreference.MpvHardwareDecoding), if (UpdateChecker.ACTIVE) {
add(
PreferenceGroup(
title = R.string.updates,
preferences =
listOf(
AppPreference.AutoCheckForUpdates,
AppPreference.UpdateUrl,
),
),
)
}
add(
PreferenceGroup(
title = R.string.more,
preferences =
listOf(
AppPreference.SendAppLogs,
AppPreference.SendCrashReports,
AppPreference.ClearImageCache,
AppPreference.OssLicenseInfo,
), ),
), ),
), )
PreferenceGroup( }
title = R.string.updates,
preferences =
listOf(
AppPreference.AutoCheckForUpdates,
AppPreference.UpdateUrl,
),
),
PreferenceGroup(
title = R.string.more,
preferences =
listOf(
AppPreference.SendAppLogs,
AppPreference.SendCrashReports,
AppPreference.ClearImageCache,
AppPreference.OssLicenseInfo,
),
),
)
data class AppSwitchPreference( data class AppSwitchPreference(
@get:StringRes override val title: Int, @get:StringRes override val title: Int,

View file

@ -61,6 +61,8 @@ class UpdateChecker
private const val PERMISSION_REQUEST_CODE = 123456 private const val PERMISSION_REQUEST_CODE = 123456
private val NOTE_REGEX = Regex("<!-- app-note:(.+) -->") private val NOTE_REGEX = Regex("<!-- app-note:(.+) -->")
val ACTIVE = true
} }
suspend fun maybeShowUpdateToast( suspend fun maybeShowUpdateToast(

View file

@ -23,6 +23,7 @@ import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
@ -42,6 +43,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.acra.util.versionCodeLong
import org.jellyfin.sdk.api.client.ApiClient import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.clientLogApi import org.jellyfin.sdk.api.client.extensions.clientLogApi
import org.jellyfin.sdk.model.ClientInfo import org.jellyfin.sdk.model.ClientInfo
@ -151,6 +153,7 @@ fun DebugPage(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
viewModel: DebugViewModel = hiltViewModel(), viewModel: DebugViewModel = hiltViewModel(),
) { ) {
val context = LocalContext.current
val scrollAmount = 100f val scrollAmount = 100f
val columnState = rememberLazyListState() val columnState = rememberLazyListState()
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
@ -194,15 +197,28 @@ fun DebugPage(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
) { ) {
Text( Text(
text = "AppPreferences", text = "App Information",
style = MaterialTheme.typography.displaySmall, style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )
Text( val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0)
text = preferences.appPreferences.toString(), val installSource = context.packageManager.getInstallSourceInfo(context.packageName)
style = MaterialTheme.typography.bodySmall, listOf(
color = MaterialTheme.colorScheme.onSurface, "Version Name: ${pkgInfo.versionName}",
) "Version Code: ${pkgInfo.versionCodeLong}",
"Build type: ${BuildConfig.BUILD_TYPE}",
"Debug enabled: ${BuildConfig.DEBUG}",
"ABIs: ${Build.SUPPORTED_ABIS.toList()}",
"Install source: ${installSource.packageSource}",
"Installer: ${installSource.installingPackageName}",
"Initiator: ${installSource.initiatingPackageName}",
).forEach {
Text(
text = it,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)
}
} }
} }
item { item {
@ -211,22 +227,12 @@ fun DebugPage(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
) { ) {
Text( Text(
text = "App Information", text = "AppPreferences",
style = MaterialTheme.typography.displaySmall, style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )
Text( Text(
text = "Build type: ${BuildConfig.BUILD_TYPE}", text = preferences.appPreferences.toString(),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = "Debug enabled: ${BuildConfig.DEBUG}",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = "ABIs: ${Build.SUPPORTED_ABIS.toList()}",
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )

View file

@ -48,6 +48,7 @@ import com.github.damontecres.wholphin.preferences.advancedPreferences
import com.github.damontecres.wholphin.preferences.basicPreferences import com.github.damontecres.wholphin.preferences.basicPreferences
import com.github.damontecres.wholphin.preferences.uiPreferences import com.github.damontecres.wholphin.preferences.uiPreferences
import com.github.damontecres.wholphin.preferences.updatePlaybackPreferences import com.github.damontecres.wholphin.preferences.updatePlaybackPreferences
import com.github.damontecres.wholphin.services.UpdateChecker
import com.github.damontecres.wholphin.ui.ifElse import com.github.damontecres.wholphin.ui.ifElse
import com.github.damontecres.wholphin.ui.nav.Destination import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.playOnClickSound import com.github.damontecres.wholphin.ui.playOnClickSound
@ -86,7 +87,7 @@ fun PreferencesContent(
val release by updateVM.release.observeAsState(null) val release by updateVM.release.observeAsState(null)
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
if (preferences.autoCheckForUpdates) { if (UpdateChecker.ACTIVE && preferences.autoCheckForUpdates) {
updateVM.init(preferences.updateUrl) updateVM.init(preferences.updateUrl)
} }
} }
@ -160,7 +161,8 @@ fun PreferencesContent(
.padding(vertical = 8.dp), .padding(vertical = 8.dp),
) )
} }
if (preferenceScreenOption == PreferenceScreenOption.BASIC && if (UpdateChecker.ACTIVE &&
preferenceScreenOption == PreferenceScreenOption.BASIC &&
preferences.autoCheckForUpdates && preferences.autoCheckForUpdates &&
updateAvailable updateAvailable
) { ) {