From 560cf12a4d83839d2dcb613a4d2453f8d54393c5 Mon Sep 17 00:00:00 2001 From: mattcarter11 <38189440+mattcarter11@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:27:51 +0100 Subject: [PATCH] force sync: add more info when trigger --- .../screens/settings/ExperimentalSettings.kt | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt b/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt index 55e6316a9..71645e89e 100644 --- a/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt +++ b/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt @@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll @@ -18,6 +20,7 @@ import androidx.compose.material.icons.rounded.DeveloperMode import androidx.compose.material.icons.rounded.ErrorOutline import androidx.compose.material.icons.rounded.Sync import androidx.compose.material.icons.rounded.WarningAmber +import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -30,6 +33,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue +import androidx.compose.runtime.collectAsState +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -72,6 +77,12 @@ fun ExperimentalSettings( val (devSettings, onDevSettingsChange) = rememberPreference(DevSettingsKey, defaultValue = false) val (firstSetupPassed, onFirstSetupPassedChange) = rememberPreference(FirstSetupPassed, defaultValue = false) + val isSyncingRemotePlaylists by syncUtils.isSyncingRemotePlaylists.collectAsState() + val isSyncingRemoteAlbums by syncUtils.isSyncingRemoteAlbums.collectAsState() + val isSyncingRemoteArtists by syncUtils.isSyncingRemoteArtists.collectAsState() + val isSyncingRemoteSongs by syncUtils.isSyncingRemoteSongs.collectAsState() + val isSyncingRemoteLikedSongs by syncUtils.isSyncingRemoteLikedSongs.collectAsState() + val (scannerImpl) = rememberEnumPreference( key = ScannerImplKey, defaultValue = ScannerImpl.TAGLIB @@ -96,6 +107,7 @@ fun ExperimentalSettings( onCheckedChange = onDevSettingsChange ) + // TODO: move to home screen as button? PreferenceEntry( title = { Text("Trigger manual sync") }, icon = { Icon(Icons.Rounded.Sync, null) }, @@ -108,6 +120,12 @@ fun ExperimentalSettings( } ) + SyncProgressItem(stringResource(R.string.songs), isSyncingRemoteSongs) + SyncProgressItem(stringResource(R.string.liked_songs), isSyncingRemoteLikedSongs) + SyncProgressItem(stringResource(R.string.artists), isSyncingRemoteArtists) + SyncProgressItem(stringResource(R.string.albums), isSyncingRemoteAlbums) + SyncProgressItem(stringResource(R.string.playlists), isSyncingRemotePlaylists) + if (devSettings) { PreferenceGroupTitle( title = stringResource(R.string.settings_debug) @@ -230,9 +248,6 @@ fun ExperimentalSettings( } } - - - TopAppBar( title = { Text(stringResource(R.string.experimental_settings_title)) }, navigationIcon = { @@ -249,3 +264,17 @@ fun ExperimentalSettings( scrollBehavior = scrollBehavior ) } + +@Composable +fun SyncProgressItem(text: String, isSyncing: Boolean) { + if (isSyncing) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp) + ) { + CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp) + Spacer(Modifier.width(12.dp)) + Text(text) + } + } +}