mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Prep work for play store distribution (#301)
Allows for disabling in-app updates and more flexible tag/version codes
This commit is contained in:
parent
df78b42bac
commit
78e6304571
6 changed files with 113 additions and 88 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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,7 +765,8 @@ val basicPreferences =
|
||||||
val uiPreferences = listOf<PreferenceGroup>()
|
val uiPreferences = listOf<PreferenceGroup>()
|
||||||
|
|
||||||
val advancedPreferences =
|
val advancedPreferences =
|
||||||
listOf(
|
buildList {
|
||||||
|
add(
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.ui_interface,
|
title = R.string.ui_interface,
|
||||||
preferences =
|
preferences =
|
||||||
|
|
@ -773,6 +777,8 @@ val advancedPreferences =
|
||||||
AppPreference.ControllerTimeout,
|
AppPreference.ControllerTimeout,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
add(
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.playback,
|
title = R.string.playback,
|
||||||
preferences =
|
preferences =
|
||||||
|
|
@ -788,6 +794,8 @@ val advancedPreferences =
|
||||||
AppPreference.PlaybackDebugInfo,
|
AppPreference.PlaybackDebugInfo,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
add(
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.player_backend,
|
title = R.string.player_backend,
|
||||||
preferences = listOf(AppPreference.PlayerBackendPref),
|
preferences = listOf(AppPreference.PlayerBackendPref),
|
||||||
|
|
@ -809,6 +817,9 @@ val advancedPreferences =
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
if (UpdateChecker.ACTIVE) {
|
||||||
|
add(
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.updates,
|
title = R.string.updates,
|
||||||
preferences =
|
preferences =
|
||||||
|
|
@ -817,6 +828,9 @@ val advancedPreferences =
|
||||||
AppPreference.UpdateUrl,
|
AppPreference.UpdateUrl,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
add(
|
||||||
PreferenceGroup(
|
PreferenceGroup(
|
||||||
title = R.string.more,
|
title = R.string.more,
|
||||||
preferences =
|
preferences =
|
||||||
|
|
@ -828,6 +842,7 @@ val advancedPreferences =
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data class AppSwitchPreference(
|
data class AppSwitchPreference(
|
||||||
@get:StringRes override val title: Int,
|
@get:StringRes override val title: Int,
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
|
|
||||||
|
|
@ -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,39 +197,42 @@ 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,
|
||||||
)
|
)
|
||||||
|
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(
|
||||||
text = preferences.appPreferences.toString(),
|
text = it,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
item {
|
item {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
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,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue