Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force sync: add more info when trigger #186

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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) },
Expand All @@ -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)
Expand Down Expand Up @@ -230,9 +248,6 @@ fun ExperimentalSettings(
}
}




TopAppBar(
title = { Text(stringResource(R.string.experimental_settings_title)) },
navigationIcon = {
Expand All @@ -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)
}
}
}
Loading