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 {
val stdout = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "tag", "--list", "v*")
commandLine = listOf("git", "tag", "--list", "v*", "p*")
standardOutput = stdout
}
return stdout

View file

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

View file

@ -7,6 +7,7 @@ import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.github.damontecres.wholphin.R
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.preferences.ConditionalPreferences
import com.github.damontecres.wholphin.ui.preferences.PreferenceGroup
@ -745,10 +746,12 @@ val basicPreferences =
PreferenceGroup(
title = R.string.about,
preferences =
listOf(
AppPreference.InstalledVersion,
AppPreference.Update,
),
buildList {
add(AppPreference.InstalledVersion)
if (UpdateChecker.ACTIVE) {
add(AppPreference.Update)
}
},
),
PreferenceGroup(
title = R.string.more,
@ -762,7 +765,8 @@ val basicPreferences =
val uiPreferences = listOf<PreferenceGroup>()
val advancedPreferences =
listOf(
buildList {
add(
PreferenceGroup(
title = R.string.ui_interface,
preferences =
@ -773,6 +777,8 @@ val advancedPreferences =
AppPreference.ControllerTimeout,
),
),
)
add(
PreferenceGroup(
title = R.string.playback,
preferences =
@ -788,6 +794,8 @@ val advancedPreferences =
AppPreference.PlaybackDebugInfo,
),
),
)
add(
PreferenceGroup(
title = R.string.player_backend,
preferences = listOf(AppPreference.PlayerBackendPref),
@ -809,6 +817,9 @@ val advancedPreferences =
),
),
),
)
if (UpdateChecker.ACTIVE) {
add(
PreferenceGroup(
title = R.string.updates,
preferences =
@ -817,6 +828,9 @@ val advancedPreferences =
AppPreference.UpdateUrl,
),
),
)
}
add(
PreferenceGroup(
title = R.string.more,
preferences =
@ -828,6 +842,7 @@ val advancedPreferences =
),
),
)
}
data class AppSwitchPreference(
@get:StringRes override val title: Int,

View file

@ -61,6 +61,8 @@ class UpdateChecker
private const val PERMISSION_REQUEST_CODE = 123456
private val NOTE_REGEX = Regex("<!-- app-note:(.+) -->")
val ACTIVE = true
}
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.onKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.MutableLiveData
@ -42,6 +43,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.acra.util.versionCodeLong
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.clientLogApi
import org.jellyfin.sdk.model.ClientInfo
@ -151,6 +153,7 @@ fun DebugPage(
modifier: Modifier = Modifier,
viewModel: DebugViewModel = hiltViewModel(),
) {
val context = LocalContext.current
val scrollAmount = 100f
val columnState = rememberLazyListState()
val scope = rememberCoroutineScope()
@ -194,39 +197,42 @@ fun DebugPage(
modifier = Modifier.fillMaxWidth(),
) {
Text(
text = "AppPreferences",
text = "App Information",
style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.onSurface,
)
val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0)
val installSource = context.packageManager.getInstallSourceInfo(context.packageName)
listOf(
"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 = preferences.appPreferences.toString(),
text = it,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)
}
}
}
item {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth(),
) {
Text(
text = "App Information",
text = "AppPreferences",
style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = "Build type: ${BuildConfig.BUILD_TYPE}",
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()}",
text = preferences.appPreferences.toString(),
style = MaterialTheme.typography.bodySmall,
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.uiPreferences
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.nav.Destination
import com.github.damontecres.wholphin.ui.playOnClickSound
@ -86,7 +87,7 @@ fun PreferencesContent(
val release by updateVM.release.observeAsState(null)
LaunchedEffect(Unit) {
if (preferences.autoCheckForUpdates) {
if (UpdateChecker.ACTIVE && preferences.autoCheckForUpdates) {
updateVM.init(preferences.updateUrl)
}
}
@ -160,7 +161,8 @@ fun PreferencesContent(
.padding(vertical = 8.dp),
)
}
if (preferenceScreenOption == PreferenceScreenOption.BASIC &&
if (UpdateChecker.ACTIVE &&
preferenceScreenOption == PreferenceScreenOption.BASIC &&
preferences.autoCheckForUpdates &&
updateAvailable
) {