Implement non-shuffle setting

This commit is contained in:
Anthony La committed 2025-01-25 15:32:15 -08:00
1 parent 7f039fa2b4
commit e30056eb5d
18 files changed
+219 -72

No files matched your search

@@ -45,4 +45,5 @@ object SettingsConstants {
const val CHANGE_START_TIME = "change_start_time"
const val START_HOUR = "start_hour"
const val START_MINUTE = "start_minute"
const val SHUFFLE = "shuffle"
}
@@ -403,7 +403,7 @@ suspend fun getWallpaperFromFolder(folderUri: String, context: Context): List<Wa
wallpaperUri = documentUri.toString().compress("content://com.android.externalstorage.documents/"),
fileName = displayName.substringBeforeLast('.', displayName),
dateModified = dateModified,
order = wallpapers.size + 1,
order = wallpapers.size,
key = 0
)
)
@@ -26,6 +26,9 @@ interface AlbumDao {
@Query("SELECT * FROM album WHERE selected = 1")
fun getSelectedAlbums(): Flow<List<AlbumWithWallpaperAndFolder>>
/*@Query("UPDATE album SET selected = :selected WHERE initialAlbumName = :albumName")
suspend fun updateAlbumSelection(albumName: String, selected: Boolean)*/
@Query("UPDATE album SET selected = :selected WHERE initialAlbumName = :albumName")
suspend fun updateAlbumSelection(albumName: String, selected: Boolean)
@@ -22,7 +22,6 @@ class AlbumRepositoryImpl(
it.copy(
wallpapers = it.sortedWallpapers,
folders = it.sortedFolders,
totalWallpapers = it.sortedTotalWallpapers
)
}
}
@@ -34,7 +33,6 @@ class AlbumRepositoryImpl(
it.copy(
wallpapers = it.sortedWallpapers,
folders = it.sortedFolders,
totalWallpapers = it.sortedTotalWallpapers
)
}
}
@@ -8,8 +8,7 @@ import androidx.room.Relation
* @param album The album.
* @param wallpapers The wallpapers.
* @param folders The folders.
* @param totalWallpapers The total wallpapers from wallpapers and folders
*/
* */
data class AlbumWithWallpaperAndFolder(
@Embedded val album: Album,
@Relation(
@@ -24,13 +23,9 @@ data class AlbumWithWallpaperAndFolder(
entity = Folder::class
)
val folders: List<Folder> = emptyList(),
@Relation(
parentColumn = "initialAlbumName",
entityColumn = "initialAlbumName",
entity = Wallpaper::class
)
val totalWallpapers: List<Wallpaper> = emptyList()
) {
val totalWallpapers: List<Wallpaper>
get() = folders.flatMap { it.wallpapers } + wallpapers
val sortedFolders: List<Folder>
get() = folders.map { folder ->
folder.copy(wallpapers = folder.wallpapers.sortedBy { it.order })
@@ -38,5 +33,5 @@ data class AlbumWithWallpaperAndFolder(
val sortedWallpapers: List<Wallpaper>
get() = wallpapers.sortedBy { it.order }
val sortedTotalWallpapers: List<Wallpaper>
get() = totalWallpapers.sortedBy { it.order }
get() = (folders.flatMap { it.wallpapers } + wallpapers).sortedBy { it.order }
}
@@ -198,9 +198,9 @@ fun PaperizeApp(
}
},
onSelectAlbum = { album, lock, home ->
val currentSettings = settingsState.value.wallpaperSettings
val currentSettings = settingsState.value
val albumName = album.album.initialAlbumName
val notSameAlbum = currentSettings.homeAlbumName != currentSettings.lockAlbumName
val notSameAlbum = currentSettings.wallpaperSettings.homeAlbumName != currentSettings.wallpaperSettings.lockAlbumName
val newHomeAlbum = if (home) albumName else null
val newLockAlbum = if (lock) albumName else null
settingsViewModel.onEvent(SettingsEvent.SetAlbum(
@@ -208,26 +208,29 @@ fun PaperizeApp(
lockAlbumName = newLockAlbum
))
val deselectName = when {
notSameAlbum && home -> currentSettings.homeAlbumName
notSameAlbum && lock -> currentSettings.lockAlbumName
notSameAlbum && home -> currentSettings.wallpaperSettings.homeAlbumName
notSameAlbum && lock -> currentSettings.wallpaperSettings.lockAlbumName
else -> null
}
albumsViewModel.onEvent(AlbumsEvent.AddSelectedAlbum(
album = album,
deselectAlbumName = deselectName
))
albumsViewModel.onEvent(
AlbumsEvent.AddSelectedAlbum(
album = album,
deselectAlbumName = deselectName,
shuffle = currentSettings.scheduleSettings.shuffle
)
)
val shouldSchedule = (home && !currentSettings.lockAlbumName.isNullOrEmpty()) ||
(lock && !currentSettings.homeAlbumName.isNullOrEmpty()) ||
val shouldSchedule = (home && !currentSettings.wallpaperSettings.lockAlbumName.isNullOrEmpty()) ||
(lock && !currentSettings.wallpaperSettings.homeAlbumName.isNullOrEmpty()) ||
(lock && home)
if (shouldSchedule) {
job = scope.scheduleWallpaperUpdate(
job = job,
settingsState = settingsState.value.copy(
wallpaperSettings = currentSettings.copy(
homeAlbumName = newHomeAlbum ?: currentSettings.homeAlbumName,
lockAlbumName = newLockAlbum ?: currentSettings.lockAlbumName
wallpaperSettings = currentSettings.wallpaperSettings.copy(
homeAlbumName = newHomeAlbum ?: currentSettings.wallpaperSettings.homeAlbumName,
lockAlbumName = newLockAlbum ?: currentSettings.wallpaperSettings.lockAlbumName
)
),
settingsViewModel = settingsViewModel,
@@ -490,6 +493,20 @@ fun PaperizeApp(
)
}
},
onShuffleCheck = { shuffle ->
settingsViewModel.onEvent(SettingsEvent.SetShuffle(shuffle))
if (settingsState.value.wallpaperSettings.enableChanger) {
job = scope.updateWallpaperAlarm(
job = job,
settingsState = settingsState.value.copy(
scheduleSettings = settingsState.value.scheduleSettings.copy(
shuffle = shuffle
)
),
scheduler = scheduler
)
}
},
)
}
@@ -697,7 +714,8 @@ private fun CoroutineScope.scheduleWallpaperUpdate(
setHome = settingsState.wallpaperSettings.setHomeWallpaper,
setLock = settingsState.wallpaperSettings.setLockWallpaper,
changeStartTime = settingsState.scheduleSettings.changeStartTime,
startTime = settingsState.scheduleSettings.startTime
startTime = settingsState.scheduleSettings.startTime,
shuffle = settingsState.scheduleSettings.shuffle
)
scheduler.scheduleWallpaperAlarm(
@@ -726,7 +744,8 @@ private fun CoroutineScope.updateWallpaperAlarm(
setHome = settingsState.wallpaperSettings.setHomeWallpaper,
setLock = settingsState.wallpaperSettings.setLockWallpaper,
changeStartTime = settingsState.scheduleSettings.changeStartTime,
startTime = settingsState.scheduleSettings.startTime
startTime = settingsState.scheduleSettings.startTime,
shuffle = settingsState.scheduleSettings.shuffle
)
scheduler.updateWallpaperAlarm(
@@ -44,23 +44,25 @@ class AddAlbumViewModel @Inject constructor(
initialAlbumName = event.initialAlbumName,
key = event.initialAlbumName.hashCode() + it.wallpaperUri.hashCode()
)
}.sortedBy { it.order }
}
var totalWallpapers = _state.value.wallpapers.size
val folders = _state.value.folders.map { folder ->
val updatedWallpapers = folder.wallpapers.map {
it.copy(
initialAlbumName = event.initialAlbumName,
key = event.initialAlbumName.hashCode() + folder.folderUri.hashCode() + it.wallpaperUri.hashCode(),
order = it.order + totalWallpapers
)
}
totalWallpapers += folder.wallpapers.size
folder.copy(
initialAlbumName = event.initialAlbumName,
key = event.initialAlbumName.hashCode() + folder.hashCode(),
coverUri = folder.wallpapers.firstOrNull()?.wallpaperUri ?: folder.coverUri,
wallpapers = folder.wallpapers.map {
it.copy(
initialAlbumName = event.initialAlbumName,
key = event.initialAlbumName.hashCode() + folder.folderUri.hashCode() + it.wallpaperUri.hashCode(),
order = it.order + _state.value.wallpapers.size
)
}.sortedBy { it.order }
coverUri = updatedWallpapers.firstOrNull()?.wallpaperUri ?: folder.coverUri,
wallpapers = updatedWallpapers
)
}.sortedBy { it.order }
}
val totalWallpapers = folders.flatMap { it.wallpapers } + wallpapers
val albumWithWallpaperAndFolder = AlbumWithWallpaperAndFolder(
album = Album(
initialAlbumName = event.initialAlbumName,
@@ -71,8 +73,7 @@ class AddAlbumViewModel @Inject constructor(
selected = false
),
wallpapers = wallpapers,
folders = folders,
totalWallpapers = totalWallpapers
folders = folders
)
repository.upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder)
_state.update { AddAlbumState() }
@@ -145,7 +146,7 @@ class AddAlbumViewModel @Inject constructor(
wallpapers = wallpapers,
coverUri = wallpapers.firstOrNull()?.wallpaperUri ?: "",
dateModified = metadata.lastModified,
order = _state.value.folders.size + 1,
order = if (_state.value.folders.isEmpty()) 0 else _state.value.folders.size,
key = 0
)
_state.update {
@@ -162,13 +163,13 @@ class AddAlbumViewModel @Inject constructor(
is AddAlbumEvent.SelectAll -> {
viewModelScope.launch {
if (!_state.value.selectionState.allSelected) {
_state.update {
it.copy(
_state.update { state ->
state.copy(
selectionState = SelectionState(
selectedFolders = it.folders.map { it.folderUri },
selectedWallpapers = it.wallpapers.map { it.wallpaperUri },
selectedFolders = state.folders.map { it.folderUri },
selectedWallpapers = state.wallpapers.map { it.wallpaperUri },
allSelected = true,
selectedCount = it.folders.size + it.wallpapers.size
selectedCount = state.folders.size + state.wallpapers.size
)
)
}
@@ -7,6 +7,10 @@ sealed class AlbumsEvent {
data object Reset: AlbumsEvent()
data object Refresh: AlbumsEvent()
data class AddSelectedAlbum(val album: AlbumWithWallpaperAndFolder, val deselectAlbumName: String? = null): AlbumsEvent()
data class AddSelectedAlbum(
val album: AlbumWithWallpaperAndFolder,
val deselectAlbumName: String? = null,
val shuffle: Boolean = true
): AlbumsEvent()
data class RemoveSelectedAlbum(val deselectAlbumName: String): AlbumsEvent()
}
@@ -2,6 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
import android.app.Application
import android.content.Context
import androidx.compose.ui.util.fastMap
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.anthonyla.paperize.core.findFirstValidUri
@@ -58,10 +59,18 @@ class AlbumsViewModel @Inject constructor (
when (event) {
is AlbumsEvent.AddSelectedAlbum -> {
viewModelScope.launch {
event.deselectAlbumName?.let {
repository.updateAlbumSelection(it, false)
}
repository.updateAlbumSelection(event.album.album.initialAlbumName, true)
event.deselectAlbumName?.let { repository.updateAlbumSelection(it, false) }
val homeWallpapers = if (event.shuffle) event.album.totalWallpapers.shuffled().map { it.wallpaperUri }
else event.album.sortedTotalWallpapers.map { it.wallpaperUri }
val lockWallpapers = if (event.shuffle) event.album.totalWallpapers.shuffled().map { it.wallpaperUri }
else event.album.sortedTotalWallpapers.map { it.wallpaperUri }
repository.updateAlbum(
event.album.album.copy(
selected = true,
homeWallpapersInQueue = homeWallpapers,
lockWallpapersInQueue = lockWallpapers
)
)
}
}
@@ -99,7 +108,6 @@ class AlbumsViewModel @Inject constructor (
album.wallpapers
.asSequence()
.filter { isValidUri(context, it.wallpaperUri) }
.sortedBy { it.order }
.mapIndexed { index, wallpaper -> wallpaper.copy(order = index) }
.toList()
}
@@ -131,7 +139,7 @@ class AlbumsViewModel @Inject constructor (
wallpaper.wallpaperUri.hashCode()
)
}.toList()
val combinedWallpapers = (existingWallpapers + newWallpapers).sortedBy { it.order }
val combinedWallpapers = existingWallpapers + newWallpapers
folder.copy(
coverUri = combinedWallpapers.firstOrNull()?.wallpaperUri ?: "",
wallpapers = combinedWallpapers,
@@ -146,16 +154,14 @@ class AlbumsViewModel @Inject constructor (
.awaitAll()
}
val folders = validFolders.await().sortedBy { it.order }
val folders = validFolders.await()
val wallpapers = validWallpapers.await()
val coverUri = findFirstValidUri(context, folders, wallpapers)
val totalWallpapers = folders.flatMap { it.wallpapers } + wallpapers
repository.upsertAlbumWithWallpaperAndFolder(
album.copy(
album = album.album.copy(coverUri = coverUri),
wallpapers = wallpapers,
folders = folders,
totalWallpapers = totalWallpapers
folders = folders
)
)
}
@@ -69,18 +69,34 @@ class AlbumScreenViewModel @Inject constructor(
val existingUris = album.wallpapers.map { it.wallpaperUri }
val newUris = event.wallpaperUris.filter { it !in existingUris }
if (newUris.isEmpty()) { return@launch }
val wallpapers = newUris.map { uri ->
val wallpapers = newUris.mapIndexed { index, uri ->
val metadata = getImageMetadata(context, uri)
Wallpaper(
initialAlbumName = _state.value.initialAlbumName,
wallpaperUri = uri.compress("content://com.android.externalstorage.documents/"),
fileName = metadata.filename,
dateModified = metadata.lastModified,
order = album.wallpapers.size + 1,
order = if (album.wallpapers.isEmpty()) 0 else album.wallpapers.size + index,
key = _state.value.initialAlbumName.hashCode() + uri.hashCode()
)
}
repository.upsertWallpaperList(wallpapers)
var totalWallpapers = album.wallpapers.size + wallpapers.size
val folders = album.folders.map { folder ->
val updatedWallpapers = folder.wallpapers.mapIndexed { index, wallpaper ->
wallpaper.copy(
order = index + totalWallpapers
)
}
totalWallpapers += folder.wallpapers.size
folder.copy(
wallpapers = updatedWallpapers
)
}
val albumWithWallpaperAndFolder = album.copy(
wallpapers = album.wallpapers + wallpapers,
folders = folders
)
repository.upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder)
_state.update {
it.copy(
isEmpty = false,
@@ -96,10 +112,11 @@ class AlbumScreenViewModel @Inject constructor(
val album = _state.value.albums.find { it.album.initialAlbumName == _state.value.initialAlbumName }
if (album == null || album.folders.any { it.folderUri == event.directoryUri }) { return@launch }
_state.update { it.copy(isLoading = true) }
val wallpapers = getWallpaperFromFolder(event.directoryUri, context).map {
it.copy(
val wallpapers = getWallpaperFromFolder(event.directoryUri, context).mapIndexed { index, wallpaper ->
wallpaper.copy(
initialAlbumName = _state.value.initialAlbumName,
key = _state.value.initialAlbumName.hashCode() + event.directoryUri.hashCode() + it.wallpaperUri.hashCode()
key = _state.value.initialAlbumName.hashCode() + event.directoryUri.hashCode() + wallpaper.wallpaperUri.hashCode(),
order = index + album.wallpapers.size + album.folders.sumOf { it.wallpapers.size }
)
}
val metadata = getFolderMetadata(event.directoryUri, context)
@@ -110,7 +127,7 @@ class AlbumScreenViewModel @Inject constructor(
coverUri = wallpapers.map { it.wallpaperUri }.firstOrNull() ?: "",
dateModified = metadata.lastModified,
wallpapers = wallpapers,
order = album.folders.size + 1,
order = album.folders.size,
key = _state.value.initialAlbumName.hashCode() + event.directoryUri.hashCode()
)
repository.upsertFolder(folder)
@@ -227,6 +244,31 @@ class AlbumScreenViewModel @Inject constructor(
).firstOrNull()?.wallpaperUri ?: ""
repository.updateAlbum(album.album.copy(coverUri = newCover))
}
val remainingWallpapers = album.wallpapers.minus(wallpapersToDelete.toSet())
val newWallpapers = remainingWallpapers.sortedBy { it.order }.mapIndexed { index, wallpaper ->
wallpaper.copy(order = index)
}
val remainingFolders = album.folders.minus(foldersToDelete.toSet())
var totalWallpaper = newWallpapers.size
val newFolders = remainingFolders.sortedBy { it.order }.mapIndexed { folderIndex, folder ->
val updatedWallpapers = folder.wallpapers.mapIndexed { index, wallpaper ->
wallpaper.copy(order = index + totalWallpaper)
}
totalWallpaper += folder.wallpapers.size
folder.copy(
wallpapers = updatedWallpapers,
order = folderIndex
)
}
repository.upsertAlbumWithWallpaperAndFolder(
album.copy(
folders = newFolders,
wallpapers = newWallpapers
)
)
}
_state.update {
it.copy(
@@ -67,7 +67,8 @@ fun HomeScreen(
onGrayscalePercentageChange: (Int, Int) -> Unit,
onGrayscaleChange: (Boolean) -> Unit,
onChangeStartTimeToggle: (Boolean) -> Unit,
onStartTimeChange: (TimePickerState) -> Unit
onStartTimeChange: (TimePickerState) -> Unit,
onShuffleCheck: (Boolean) -> Unit
) {
val tabItems = getTabItems()
val pagerState = rememberPagerState(0) { tabItems.size }
@@ -157,7 +158,8 @@ fun HomeScreen(
onGrayscalePercentageChange = onGrayscalePercentageChange,
onGrayscaleChange = onGrayscaleChange,
onChangeStartTimeToggle = onChangeStartTimeToggle,
onStartTimeChange = onStartTimeChange
onStartTimeChange = onStartTimeChange,
onShuffleCheck = onShuffleCheck,
)
else -> LibraryScreen(
albums = albums,
@@ -32,4 +32,5 @@ sealed class SettingsEvent {
data class SetChangerToggle(val toggle: Boolean): SettingsEvent()
data class SetWallpaperScaling(val scaling: ScalingConstants): SettingsEvent()
data class SetStartTime(val hour: Int, val minute: Int): SettingsEvent()
data class SetShuffle(val shuffle: Boolean): SettingsEvent()
}
@@ -33,6 +33,7 @@ data class SettingsState(
data class ScheduleSettings(
val scheduleSeparately: Boolean = false,
val shuffle: Boolean = true,
val homeInterval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
val lockInterval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
val lastSetTime: String? = null,
@@ -106,7 +106,8 @@ class SettingsViewModel @Inject constructor(
settingsDataStoreImpl.getStringFlow(SettingsConstants.NEXT_SET_TIME),
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.CHANGE_START_TIME),
settingsDataStoreImpl.getIntFlow(SettingsConstants.START_HOUR),
settingsDataStoreImpl.getIntFlow(SettingsConstants.START_MINUTE)
settingsDataStoreImpl.getIntFlow(SettingsConstants.START_MINUTE),
settingsDataStoreImpl.getBooleanFlow(SettingsConstants.SHUFFLE)
) { flows ->
ScheduleSettings(
scheduleSeparately = flows[0] as Boolean? ?: false,
@@ -115,7 +116,8 @@ class SettingsViewModel @Inject constructor(
lastSetTime = flows[3] as String?,
nextSetTime = flows[4] as String?,
changeStartTime = flows[5] as Boolean? ?: false,
startTime = Pair(flows[6] as Int? ?: 0, flows[7] as Int? ?: 0)
startTime = Pair(flows[6] as Int? ?: 0, flows[7] as Int? ?: 0),
shuffle = flows[8] as Boolean? ?: true
)
}
@@ -535,6 +537,12 @@ class SettingsViewModel @Inject constructor(
}
}
is SettingsEvent.SetShuffle -> {
viewModelScope.launch {
settingsDataStoreImpl.putBoolean(SettingsConstants.SHUFFLE, event.shuffle)
}
}
is SettingsEvent.Reset -> {
viewModelScope.launch {
val keysToDelete = listOf(
@@ -575,7 +583,8 @@ class SettingsViewModel @Inject constructor(
SettingsConstants.LOCK_GRAYSCALE_PERCENTAGE,
SettingsConstants.CHANGE_START_TIME,
SettingsConstants.START_HOUR,
SettingsConstants.START_MINUTE
SettingsConstants.START_MINUTE,
SettingsConstants.SHUFFLE
)
settingsDataStoreImpl.clear(keysToDelete)
}
@@ -16,6 +16,7 @@ import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TimePickerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -44,6 +45,7 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.co
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.DarkenSwitchAndSlider
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.GrayscaleSwitchAndSlider
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.IndividualSchedulingAndToggleRow
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ShuffleSwitch
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.VignetteSwitchAndSlider
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.WallpaperPreviewAndScale
@@ -77,7 +79,8 @@ fun WallpaperScreen(
onGrayscalePercentageChange: (Int, Int) -> Unit,
onGrayscaleChange: (Boolean) -> Unit,
onChangeStartTimeToggle: (Boolean) -> Unit,
onStartTimeChange: (TimePickerState) -> Unit
onStartTimeChange: (TimePickerState) -> Unit,
onShuffleCheck: (Boolean) -> Unit
) {
val shouldShowScreen = wallpaperSettings.setHomeWallpaper || wallpaperSettings.setLockWallpaper
val shouldShowSettings = shouldShowScreen && homeSelectedAlbum != null && lockSelectedAlbum != null
@@ -226,6 +229,10 @@ fun WallpaperScreen(
changeStartTime = scheduleSettings.changeStartTime,
animate = themeSettings.animate
)
ShuffleSwitch(
shuffle = scheduleSettings.shuffle,
onShuffleCheck = { onShuffleCheck(it) },
)
DarkenSwitchAndSlider(
homeDarkenPercentage = effectSettings.homeDarkenPercentage,
lockDarkenPercentage = effectSettings.lockDarkenPercentage,
@@ -0,0 +1,56 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
@Composable
fun ShuffleSwitch(
shuffle: Boolean,
onShuffleCheck: (Boolean) -> Unit
) {
Surface(
tonalElevation = 10.dp,
shape = RoundedCornerShape(16.dp),
modifier = Modifier
.fillMaxWidth()
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Row(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.shuffle_wallpaper),
modifier = Modifier.padding(16.dp),
fontWeight = FontWeight.W500
)
Switch(
checked = shuffle,
onCheckedChange = onShuffleCheck,
)
}
}
}
}
@@ -14,8 +14,9 @@ data class WallpaperAlarmItem(
val homeInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
val lockInterval: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
val scheduleSeparately: Boolean = false,
val setHome : Boolean = false,
val setLock : Boolean = false,
val setHome: Boolean = false,
val setLock: Boolean = false,
val changeStartTime: Boolean = false,
val startTime: Pair<Int, Int> = Pair(0, 0),
val shuffle: Boolean = true
)
+1
View File
@@ -178,4 +178,5 @@
<string name="sort_alphabetically_z_a">Sort Alphabetically (Z-A)</string>
<string name="sort_by_last_modified_newest">Sort by Last Modified (Newest)</string>
<string name="sort_by_last_modified_oldest">Sort by Last Modified (Oldest)</string>
<string name="shuffle_wallpaper">Shuffle Wallpapers</string>
</resources>