diff --git a/app/src/main/java/com/anthonyla/paperize/core/SettingsConstants.kt b/app/src/main/java/com/anthonyla/paperize/core/SettingsConstants.kt index cde6a96..5ebcc91 100644 --- a/app/src/main/java/com/anthonyla/paperize/core/SettingsConstants.kt +++ b/app/src/main/java/com/anthonyla/paperize/core/SettingsConstants.kt @@ -12,6 +12,7 @@ object SettingsConstants { const val WALLPAPER_CHANGE_INTERVAL_DEFAULT = 15 const val SET_LOCK_WITH_HOME = "set_lock_with_home" const val FIRST_LAUNCH = "first_launch" + const val FIRST_ALBUM_SET = "first_album_set" const val LAST_SET_TIME = "last_set_time" const val NEXT_SET_TIME = "next_set_time" } \ No newline at end of file diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/PaperizeApp.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/PaperizeApp.kt index 76e3845..e456519 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/PaperizeApp.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/PaperizeApp.kt @@ -249,7 +249,10 @@ fun PaperizeApp( AddAlbumScreen( initialAlbumName = addEdit.wallpaper, onBackClick = { navController.navigateUp() }, - onConfirmation = { navController.navigateUp() }, + onConfirmation = { + navController.navigateUp() + settingsViewModel.onEvent(SettingsEvent.SetFirstAlbum) + }, onShowWallpaperView = { navController.navigate(WallpaperView(it)) }, diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/AddAlbumScreen.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/AddAlbumScreen.kt index 1af0080..f75d467 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/AddAlbumScreen.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/AddAlbumScreen.kt @@ -54,6 +54,7 @@ fun AddAlbumScreen( if (addAlbumState.value.initialAlbumName.isEmpty()) { addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName)) } + var showSpotlight by rememberSaveable { mutableStateOf(false) } BackHandler { if (selectionMode) { @@ -78,6 +79,7 @@ fun AddAlbumScreen( if (uriList.isNotEmpty()) { addAlbumViewModel.onEvent(AddAlbumEvent.AddWallpapers(uriList)) } + showSpotlight = true } ) @@ -93,6 +95,7 @@ fun AddAlbumScreen( addAlbumViewModel.onEvent(AddAlbumEvent.AddFolder(uri.toString())) } } + showSpotlight = true } ) @@ -103,6 +106,8 @@ fun AddAlbumScreen( isEmpty = addAlbumState.value.isEmpty, selectionMode = selectionMode, albumState = addAlbumViewModel.state, + showSpotlight = showSpotlight, + albumFirstSet = settingsState.value.firstAlbumSet, onBackClick = { addAlbumViewModel.onEvent(AddAlbumEvent.Reset) onBackClick() diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/components/AddAlbumSmallTopBar.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/components/AddAlbumSmallTopBar.kt index b1e5146..47d19c6 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/components/AddAlbumSmallTopBar.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/add_album_screen/components/AddAlbumSmallTopBar.kt @@ -1,8 +1,16 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components +import androidx.compose.animation.core.LinearOutSlowInEasing +import androidx.compose.animation.core.RepeatMode +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween +import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.requiredSize @@ -33,7 +41,9 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction @@ -54,17 +64,46 @@ fun AddAlbumSmallTopBar( title: String, isEmpty: Boolean, selectionMode: Boolean, + showSpotlight: Boolean, + albumFirstSet: Boolean, onSelectAllClick: () -> Unit, onBackClick: () -> Unit, onDeleteSelected: () -> Unit, - onConfirmationClick: (String) -> Unit, - modifier: Modifier = Modifier - ) { + onConfirmationClick: (String) -> Unit +) { val state = albumState.collectAsStateWithLifecycle() val focusManager = LocalFocusManager.current var editableTitle by rememberSaveable { mutableStateOf(title) } var showSelectionDeleteDialog by rememberSaveable { mutableStateOf(false) } + val infiniteTransition = rememberInfiniteTransition(label = stringResource(R.string.spotlight_animation)) + val radius1 by infiniteTransition.animateFloat( + initialValue = 25f, + targetValue = 50f, + animationSpec = infiniteRepeatable( + animation = tween(2000, easing = LinearOutSlowInEasing), + repeatMode = RepeatMode.Reverse + ), label = stringResource(R.string.circle_1_animation) + ) + val radius2 by infiniteTransition.animateFloat( + initialValue = 25f, + targetValue = 60f, + animationSpec = infiniteRepeatable( + animation = tween(2000, easing = LinearOutSlowInEasing), + repeatMode = RepeatMode.Reverse + ), label = stringResource(R.string.circle_2_animation) + ) + + val radius3 by infiniteTransition.animateFloat( + initialValue = 25f, + targetValue = 75f, + animationSpec = infiniteRepeatable( + animation = tween(2000, easing = LinearOutSlowInEasing), + repeatMode = RepeatMode.Reverse + ), label = stringResource(R.string.circle_3_animation) + ) + + TopAppBar( colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface), title = { @@ -109,9 +148,7 @@ fun AddAlbumSmallTopBar( horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically ) { - IconButton( - onClick = onSelectAllClick - ) { + IconButton(onClick = onSelectAllClick) { val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp) if (state.value.allSelected) { Icon( @@ -139,12 +176,38 @@ fun AddAlbumSmallTopBar( actions = { if(!selectionMode) { if (!isEmpty) { - IconButton(onClick = { onConfirmationClick(editableTitle) }) { - Icon( - imageVector = Icons.Outlined.Add, - contentDescription = stringResource(R.string.add_album), - modifier = Modifier.padding(6.dp) - ) + Box { + val primaryColor = MaterialTheme.colorScheme.inversePrimary + val secondaryColor = MaterialTheme.colorScheme.secondary + IconButton(onClick = { onConfirmationClick(editableTitle) }) { + Icon( + imageVector = Icons.Outlined.Add, + contentDescription = stringResource(R.string.add_album), + modifier = Modifier.padding(6.dp) + ) + } + if (!albumFirstSet && showSpotlight) { + Canvas(modifier = Modifier.matchParentSize()) { + drawCircle( + color = primaryColor, + radius = radius1, + center = Offset(size.width / 2, size.height / 2), + style = Stroke(width = 5f) + ) + drawCircle( + color = secondaryColor, + radius = radius2, + center = Offset(size.width / 2, size.height / 2), + style = Stroke(width = 5f) + ) + drawCircle( + color = primaryColor, + radius = radius3, + center = Offset(size.width / 2, size.height / 2), + style = Stroke(width = 5f) + ) + } + } } } } diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/notifications_screen/NotificationScreen.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/notifications_screen/NotificationScreen.kt index 8d07c3b..68e7725 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/notifications_screen/NotificationScreen.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/notifications_screen/NotificationScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.ArrowCircleRight import androidx.compose.material.icons.outlined.Info @@ -111,7 +112,8 @@ fun NotificationScreen( snackbar = { data -> Snackbar( snackbarData = data, - modifier = Modifier.padding(PaddingValues(horizontal = 8.dp, vertical = 8.dp)) + modifier = Modifier.padding(PaddingValues(horizontal = 8.dp, vertical = 8.dp)), + shape = RoundedCornerShape(24.dp) ) } ) }, diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsEvent.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsEvent.kt index 1856771..8ca5315 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsEvent.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsEvent.kt @@ -5,6 +5,7 @@ sealed class SettingsEvent { data object Refresh: SettingsEvent() data object Reset: SettingsEvent() data object SetFirstLaunch: SettingsEvent() + data object SetFirstAlbum: SettingsEvent() data class SetDarkMode(val darkMode: Boolean?): SettingsEvent() data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent() data class SetAnimate(val animate: Boolean): SettingsEvent() diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsState.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsState.kt index d4e4015..8019cd6 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsState.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsState.kt @@ -3,6 +3,7 @@ import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_D data class SettingsState ( val firstLaunch: Boolean = true, + val firstAlbumSet: Boolean = false, val darkMode: Boolean? = null, val dynamicTheming: Boolean = false, val animate: Boolean = true, diff --git a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsViewModel.kt b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsViewModel.kt index 09a8d0d..024fdc0 100644 --- a/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsViewModel.kt +++ b/app/src/main/java/com/anthonyla/paperize/feature/wallpaper/presentation/settings_screen/SettingsViewModel.kt @@ -31,26 +31,15 @@ class SettingsViewModel @Inject constructor ( init { currentGetJob = viewModelScope.launch { - val darkMode = - async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) } - val dynamicTheming = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false - } - val wallpaperInterval = async { - settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) - ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT - } - val firstLaunch = - async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true } - val setLockWithHome = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false - } - val lastSetTime = - async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) } - val nextSetTime = - async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) } - val animate = - async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true } + val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) } + val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false } + val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT } + val firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true } + val firstAlbumSet = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_ALBUM_SET) ?: false } + val setLockWithHome = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false } + val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) } + val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) } + val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true } _state.update { it.copy( @@ -59,6 +48,7 @@ class SettingsViewModel @Inject constructor ( interval = wallpaperInterval.await(), setLockWithHome = setLockWithHome.await(), firstLaunch = firstLaunch.await(), + firstAlbumSet = firstAlbumSet.await(), lastSetTime = lastSetTime.await(), nextSetTime = nextSetTime.await(), animate = animate.await() @@ -80,33 +70,28 @@ class SettingsViewModel @Inject constructor ( } } } + is SettingsEvent.SetFirstAlbum -> { + viewModelScope.launch { + settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_ALBUM_SET, true) + _state.update { + it.copy( + firstAlbumSet = true + ) + } + } + } is SettingsEvent.Refresh -> { currentGetJob = viewModelScope.launch { - val darkMode = - async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) } - val dynamicTheming = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) - ?: false - } - val wallpaperInterval = async { - settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) - ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT - } - val firstLaunch = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true - } - val setLockWithHome = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) - ?: false - } - val lastSetTime = - async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) } - val nextSetTime = - async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) } - val animate = async { - settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true - } + val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) } + val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false } + val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT } + val firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true } + val firstAlbumSet = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_ALBUM_SET) ?: false } + val setLockWithHome = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false } + val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) } + val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) } + val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true } _state.update { it.copy( @@ -115,6 +100,7 @@ class SettingsViewModel @Inject constructor ( interval = wallpaperInterval.await(), setLockWithHome = setLockWithHome.await(), firstLaunch = firstLaunch.await(), + firstAlbumSet = firstAlbumSet.await(), lastSetTime = lastSetTime.await(), nextSetTime = nextSetTime.await(), animate = animate.await() @@ -126,20 +112,9 @@ class SettingsViewModel @Inject constructor ( is SettingsEvent.SetDarkMode -> { viewModelScope.launch { when (event.darkMode) { - true -> { - settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) - } - - false -> { - settingsDataStoreImpl.putBoolean( - SettingsConstants.DARK_MODE_TYPE, - false - ) - } - - null -> { - settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) - } + true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) } + false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) } + null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) } } _state.update { it.copy( @@ -152,19 +127,8 @@ class SettingsViewModel @Inject constructor ( is SettingsEvent.SetDynamicTheming -> { viewModelScope.launch { when (event.dynamicTheming) { - true -> { - settingsDataStoreImpl.putBoolean( - SettingsConstants.DYNAMIC_THEME_TYPE, - true - ) - } - - false -> { - settingsDataStoreImpl.putBoolean( - SettingsConstants.DYNAMIC_THEME_TYPE, - false - ) - } + true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) } + false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) } } _state.update { it.copy( @@ -177,13 +141,8 @@ class SettingsViewModel @Inject constructor ( is SettingsEvent.SetAnimate -> { viewModelScope.launch { when (event.animate) { - true -> { - settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) - } - - false -> { - settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) - } + true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) } + false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) } } _state.update { it.copy( @@ -198,20 +157,10 @@ class SettingsViewModel @Inject constructor ( val formatter = DateTimeFormatter.ofPattern("MM/dd/yy hh:mm\na") val time = LocalDateTime.now() val formattedLastSetTime = time.format(formatter) - val formattedNextSetTime = - time.plusMinutes(event.interval.toLong()).format(formatter) - settingsDataStoreImpl.putString( - SettingsConstants.LAST_SET_TIME, - formattedLastSetTime - ) - settingsDataStoreImpl.putString( - SettingsConstants.NEXT_SET_TIME, - formattedNextSetTime - ) - settingsDataStoreImpl.putInt( - SettingsConstants.WALLPAPER_CHANGE_INTERVAL, - event.interval - ) + val formattedNextSetTime = time.plusMinutes(event.interval.toLong()).format(formatter) + settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, formattedLastSetTime) + settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, formattedNextSetTime) + settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval) _state.update { it.copy( interval = event.interval, @@ -225,19 +174,8 @@ class SettingsViewModel @Inject constructor ( is SettingsEvent.SetLockWithHome -> { viewModelScope.launch { when (event.lockWithHome) { - true -> { - settingsDataStoreImpl.putBoolean( - SettingsConstants.SET_LOCK_WITH_HOME, - true - ) - } - - false -> { - settingsDataStoreImpl.putBoolean( - SettingsConstants.SET_LOCK_WITH_HOME, - false - ) - } + true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, true) } + false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, false) } } _state.update { it.copy( @@ -252,6 +190,7 @@ class SettingsViewModel @Inject constructor ( settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) settingsDataStoreImpl.deleteBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_LAUNCH) + settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_ALBUM_SET) settingsDataStoreImpl.deleteBoolean(SettingsConstants.SET_LOCK_WITH_HOME) settingsDataStoreImpl.deleteString(SettingsConstants.LAST_SET_TIME) settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_SET_TIME) @@ -264,6 +203,7 @@ class SettingsViewModel @Inject constructor ( interval = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT, setLockWithHome = false, firstLaunch = true, + firstAlbumSet = false, lastSetTime = null, nextSetTime = null, animate = true diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ec66890..1a89fba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -61,4 +61,8 @@ Reset all data Are you sure you want to reset all settings and data to default? Confirm + Spotlight animation + Circle 2 animation + Circle 1 animation + Circle 3 animation \ No newline at end of file