mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +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 {
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "tag", "--list", "v*")
|
||||
commandLine = listOf("git", "tag", "--list", "v*", "p*")
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,72 +765,84 @@ val basicPreferences =
|
|||
val uiPreferences = listOf<PreferenceGroup>()
|
||||
|
||||
val advancedPreferences =
|
||||
listOf(
|
||||
PreferenceGroup(
|
||||
title = R.string.ui_interface,
|
||||
preferences =
|
||||
listOf(
|
||||
AppPreference.ShowClock,
|
||||
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418
|
||||
buildList {
|
||||
add(
|
||||
PreferenceGroup(
|
||||
title = R.string.ui_interface,
|
||||
preferences =
|
||||
listOf(
|
||||
AppPreference.ShowClock,
|
||||
// Temporarily disabled, see https://github.com/damontecres/Wholphin/pull/127#issuecomment-3478058418
|
||||
// AppPreference.NavDrawerSwitchOnFocus,
|
||||
AppPreference.ControllerTimeout,
|
||||
),
|
||||
),
|
||||
PreferenceGroup(
|
||||
title = R.string.playback,
|
||||
preferences =
|
||||
listOf(
|
||||
AppPreference.OneClickPause,
|
||||
AppPreference.GlobalContentScale,
|
||||
AppPreference.SkipIntros,
|
||||
AppPreference.SkipOutros,
|
||||
AppPreference.SkipCommercials,
|
||||
AppPreference.SkipPreviews,
|
||||
AppPreference.SkipRecaps,
|
||||
AppPreference.MaxBitrate,
|
||||
AppPreference.PlaybackDebugInfo,
|
||||
),
|
||||
),
|
||||
PreferenceGroup(
|
||||
title = R.string.player_backend,
|
||||
preferences = listOf(AppPreference.PlayerBackendPref),
|
||||
conditionalPreferences =
|
||||
listOf(
|
||||
ConditionalPreferences(
|
||||
{ it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER },
|
||||
listOf(
|
||||
AppPreference.FfmpegPreference,
|
||||
AppPreference.DownMixStereo,
|
||||
AppPreference.Ac3Supported,
|
||||
AppPreference.DirectPlayAss,
|
||||
AppPreference.DirectPlayPgs,
|
||||
AppPreference.ControllerTimeout,
|
||||
),
|
||||
),
|
||||
)
|
||||
add(
|
||||
PreferenceGroup(
|
||||
title = R.string.playback,
|
||||
preferences =
|
||||
listOf(
|
||||
AppPreference.OneClickPause,
|
||||
AppPreference.GlobalContentScale,
|
||||
AppPreference.SkipIntros,
|
||||
AppPreference.SkipOutros,
|
||||
AppPreference.SkipCommercials,
|
||||
AppPreference.SkipPreviews,
|
||||
AppPreference.SkipRecaps,
|
||||
AppPreference.MaxBitrate,
|
||||
AppPreference.PlaybackDebugInfo,
|
||||
),
|
||||
),
|
||||
)
|
||||
add(
|
||||
PreferenceGroup(
|
||||
title = R.string.player_backend,
|
||||
preferences = listOf(AppPreference.PlayerBackendPref),
|
||||
conditionalPreferences =
|
||||
listOf(
|
||||
ConditionalPreferences(
|
||||
{ it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER },
|
||||
listOf(
|
||||
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(
|
||||
@get:StringRes override val title: Int,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,15 +197,28 @@ fun DebugPage(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = "AppPreferences",
|
||||
text = "App Information",
|
||||
style = MaterialTheme.typography.displaySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
Text(
|
||||
text = preferences.appPreferences.toString(),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
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 = it,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
item {
|
||||
|
|
@ -211,22 +227,12 @@ fun DebugPage(
|
|||
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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue