Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5fab5cb5e | ||
|
|
5fd233e790 | ||
|
|
48a730e4a9 | ||
|
|
4c3d5af7f7 | ||
|
|
829d982d23 |
No files matched your search
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 26
|
||||
versionName = "1.6.1"
|
||||
versionCode = 28
|
||||
versionName = "1.6.3"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.anthonyla.paperize.core
|
||||
object SettingsConstants {
|
||||
const val SETTINGS_DATASTORE = "settings_datastore"
|
||||
const val DARK_MODE_TYPE = "dark_mode_type"
|
||||
const val AMOLED_THEME_TYPE = "amoled_theme_type"
|
||||
const val DYNAMIC_THEME_TYPE = "dynamic_theme_type"
|
||||
const val ANIMATE_TYPE = "animate_type"
|
||||
const val ENABLE_CHANGER = "enable_changer"
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.Wa
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperScheduler
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmSchedulerImpl
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
@@ -81,7 +81,7 @@ class MainActivity : ComponentActivity() {
|
||||
splashScreen.setKeepOnScreenCondition { settingsViewModel.setKeepOnScreenCondition }
|
||||
|
||||
setContent {
|
||||
val scheduler = WallpaperScheduler(context)
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context)
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
||||
if (isFirstLaunch) {
|
||||
@@ -117,7 +117,7 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
PaperizeTheme(settingsState.value.darkMode, settingsState.value.dynamicTheming) {
|
||||
PaperizeTheme(settingsState.value.darkMode, settingsState.value.amoledTheme, settingsState.value.dynamicTheming) {
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
PaperizeApp(isFirstLaunch, scheduler, topInset)
|
||||
}
|
||||
|
||||
+9
-3
@@ -55,7 +55,7 @@ import com.anthonyla.paperize.feature.wallpaper.util.navigation.WallpaperView
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionIn
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionOut
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperScheduler
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmSchedulerImpl
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -65,7 +65,7 @@ import kotlinx.coroutines.withContext
|
||||
@Composable
|
||||
fun PaperizeApp(
|
||||
firstLaunch: Boolean,
|
||||
scheduler : WallpaperScheduler,
|
||||
scheduler : WallpaperAlarmSchedulerImpl,
|
||||
topInsets: Dp,
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
@@ -232,6 +232,7 @@ fun PaperizeApp(
|
||||
}
|
||||
) {
|
||||
HomeScreen(
|
||||
albums = albumState.value.albumsWithWallpapers,
|
||||
onSettingsClick = { navController.navigate(Settings) },
|
||||
navigateToAddWallpaperScreen = {
|
||||
navController.navigate(AddEdit(it))
|
||||
@@ -558,7 +559,8 @@ fun PaperizeApp(
|
||||
},
|
||||
onShowFolderView = { folderName, wallpapers ->
|
||||
navController.navigate(FolderView(folderName, wallpapers))
|
||||
}
|
||||
},
|
||||
animate = settingsState.value.animate
|
||||
)
|
||||
}
|
||||
// Navigate to wallpaper view screen to view individual wallpapers in full screen
|
||||
@@ -654,6 +656,7 @@ fun PaperizeApp(
|
||||
if (albumWithWallpaper != null) {
|
||||
AlbumViewScreen(
|
||||
album = albumWithWallpaper,
|
||||
animate = settingsState.value.animate,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = {
|
||||
navController.navigate(WallpaperView(it))
|
||||
@@ -704,6 +707,9 @@ fun PaperizeApp(
|
||||
onDarkModeClick = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetDarkMode(it))
|
||||
},
|
||||
onAmoledClick = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetAmoledTheme(it))
|
||||
},
|
||||
onDynamicThemingClick = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetDynamicTheming(it))
|
||||
},
|
||||
|
||||
+14
-45
@@ -5,11 +5,8 @@ import android.net.Uri
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.scaleIn
|
||||
import androidx.compose.animation.scaleOut
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -33,26 +30,21 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.co
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumSmallTopBar
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
|
||||
@Composable
|
||||
fun AddAlbumScreen(
|
||||
addAlbumViewModel: AddAlbumViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
initialAlbumName: String,
|
||||
onBackClick: () -> Unit,
|
||||
onConfirmation: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
onShowFolderView: (String?, List<String>) -> Unit
|
||||
onShowFolderView: (String?, List<String>) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val lazyGridState = rememberLazyStaggeredGridState()
|
||||
val addAlbumState = addAlbumViewModel.state.collectAsStateWithLifecycle()
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
var selectionMode by rememberSaveable { mutableStateOf(false) }
|
||||
if (addAlbumState.value.initialAlbumName.isEmpty()) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName))
|
||||
}
|
||||
var showSpotlight by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
BackHandler(
|
||||
@@ -126,40 +118,17 @@ fun AddAlbumScreen(
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (settingsState.value.animate) {
|
||||
AnimatedVisibility(
|
||||
visible = !lazyGridState.isScrollInProgress || lazyGridState.firstVisibleItemScrollOffset < 0,
|
||||
enter = scaleIn(tween(400, 50, FastOutSlowInEasing)),
|
||||
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
||||
) {
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
showSpotlight = true
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
showSpotlight = true
|
||||
},
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
},
|
||||
content = {
|
||||
LazyVerticalStaggeredGrid(
|
||||
@@ -225,7 +194,7 @@ fun AddAlbumScreen(
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = settingsState.value.animate
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -15,6 +15,9 @@ import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@@ -38,6 +41,7 @@ fun AlbumItem(
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
@@ -48,8 +52,7 @@ fun AlbumItem(
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = album.coverUri != null && isValidUri(LocalContext.current, album.coverUri)
|
||||
val showCoverUri by remember { mutableStateOf(album.coverUri != null && isValidUri(context, album.coverUri)) }
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
@@ -70,7 +73,7 @@ fun AlbumItem(
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(300, 300),
|
||||
requestSize = IntSize(250, 250),
|
||||
),
|
||||
loading = {
|
||||
if (animate) {
|
||||
|
||||
+5
-5
@@ -28,13 +28,14 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -62,7 +63,7 @@ fun FolderItem(
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val context = LocalContext.current
|
||||
val haptics = LocalHapticFeedback.current
|
||||
val transition = updateTransition(itemSelected, label = "")
|
||||
|
||||
@@ -84,8 +85,7 @@ fun FolderItem(
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = folder.coverUri != null && isValidUri(LocalContext.current, folder.coverUri)
|
||||
val showCoverUri by remember { mutableStateOf(folder.coverUri != null && isValidUri(context, folder.coverUri)) }
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
@@ -122,7 +122,7 @@ fun FolderItem(
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(300, 300),
|
||||
requestSize = IntSize(250, 250),
|
||||
),
|
||||
loading = {
|
||||
if (animate) {
|
||||
|
||||
+5
-10
@@ -21,6 +21,8 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.blur
|
||||
@@ -40,8 +42,6 @@ import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.getImageDimensions
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -88,8 +88,8 @@ fun WallpaperItem(
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
val showUri by remember { mutableStateOf(isValidUri(context, wallpaperUri)) }
|
||||
|
||||
val showUri = isValidUri(LocalContext.current, wallpaperUri)
|
||||
val boxModifier = if (clickable) {
|
||||
modifier
|
||||
.padding(paddingTransition)
|
||||
@@ -115,6 +115,7 @@ fun WallpaperItem(
|
||||
.padding(paddingTransition)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
}
|
||||
|
||||
Box(modifier = boxModifier) {
|
||||
if (showUri) {
|
||||
val dimension = wallpaperUri.toUri().getImageDimensions(context)
|
||||
@@ -129,7 +130,7 @@ fun WallpaperItem(
|
||||
ScalingConstants.STRETCH -> ContentScale.FillBounds
|
||||
}
|
||||
} else { ContentScale.Crop },
|
||||
requestSize = IntSize(300, 300),
|
||||
requestSize = IntSize(250, 250),
|
||||
alignment = Alignment.Center,
|
||||
colorFilter = if (darken && darkenPercentage != null && darkenPercentage < 100) {
|
||||
ColorFilter.tint(
|
||||
@@ -145,12 +146,6 @@ fun WallpaperItem(
|
||||
}
|
||||
}
|
||||
},
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.format(DecodeFormat.PREFER_RGB_565)
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(imageAspectRatio)
|
||||
.background(if (scaling != null) Color.Black else Color.Transparent)
|
||||
|
||||
+18
-42
@@ -5,11 +5,8 @@ import android.net.Uri
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.scaleIn
|
||||
import androidx.compose.animation.scaleOut
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -34,13 +31,12 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.co
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.components.AlbumViewTopBar
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
|
||||
@Composable
|
||||
fun AlbumViewScreen(
|
||||
albumViewScreenViewModel: AlbumViewScreenViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
album: AlbumWithWallpaperAndFolder,
|
||||
animate: Boolean,
|
||||
onBackClick: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
onShowFolderView: (String?, List<String>) -> Unit,
|
||||
@@ -51,7 +47,6 @@ fun AlbumViewScreen(
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
|
||||
val lazyListState = rememberLazyStaggeredGridState()
|
||||
val albumState = albumViewScreenViewModel.state.collectAsStateWithLifecycle()
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
var selectionMode by rememberSaveable { mutableStateOf(false) }
|
||||
val context = LocalContext.current
|
||||
|
||||
@@ -119,38 +114,17 @@ fun AlbumViewScreen(
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (settingsState.value.animate) {
|
||||
AnimatedVisibility(
|
||||
visible = !lazyListState.isScrollInProgress || lazyListState.firstVisibleItemScrollOffset < 0,
|
||||
enter = scaleIn(tween(400, 50, FastOutSlowInEasing)),
|
||||
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
||||
) {
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
},
|
||||
content = { it ->
|
||||
LazyVerticalStaggeredGrid(
|
||||
@@ -164,7 +138,7 @@ fun AlbumViewScreen(
|
||||
content = {
|
||||
items (items = album.folders, key = { folder -> folder.folderUri }
|
||||
) { folder ->
|
||||
if (settingsState.value.animate) {
|
||||
if (animate) {
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
@@ -182,8 +156,10 @@ fun AlbumViewScreen(
|
||||
onFolderViewClick = {
|
||||
if (folder.wallpapers.isNotEmpty()) onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
@@ -217,7 +193,7 @@ fun AlbumViewScreen(
|
||||
}
|
||||
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri }
|
||||
) { wallpaper ->
|
||||
if (settingsState.value.animate) {
|
||||
if (animate) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
|
||||
+3
@@ -32,6 +32,7 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.Wa
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
animate : Boolean,
|
||||
darken: Boolean,
|
||||
darkenPercentage: Int,
|
||||
@@ -131,6 +132,7 @@ fun HomeScreen(
|
||||
) { index ->
|
||||
when(index.coerceIn(tabItems.indices)) {
|
||||
0 -> WallpaperScreen(
|
||||
albums = albums,
|
||||
animate = animate,
|
||||
darken = darken,
|
||||
darkenPercentage = darkenPercentage,
|
||||
@@ -163,6 +165,7 @@ fun HomeScreen(
|
||||
blurPercentage = blurPercentage
|
||||
)
|
||||
else -> LibraryScreen(
|
||||
albums = albums,
|
||||
onAddNewAlbumClick = { addAlbumDialog = true },
|
||||
onViewAlbum = onAlbumViewClick,
|
||||
animate = animate
|
||||
|
||||
+3
-6
@@ -18,21 +18,18 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.AlbumItem
|
||||
|
||||
@Composable
|
||||
fun LibraryScreen(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
onAddNewAlbumClick: () -> Unit,
|
||||
onViewAlbum: (String) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val lazyListState = rememberLazyGridState()
|
||||
val state = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
floatingActionButton = {
|
||||
@@ -56,7 +53,7 @@ fun LibraryScreen(
|
||||
contentPadding = PaddingValues(4.dp, 4.dp),
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
content = {
|
||||
items (state.value.albumsWithWallpapers, key = { album -> album.album.initialAlbumName}
|
||||
items (albums, key = { album -> album.album.initialAlbumName}
|
||||
) { album ->
|
||||
AlbumItem(
|
||||
album = album.album,
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ sealed class SettingsEvent {
|
||||
data object SetFirstLaunch: SettingsEvent()
|
||||
data object RefreshNextSetTime: SettingsEvent()
|
||||
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
|
||||
data class SetAmoledTheme(val amoledTheme: Boolean): SettingsEvent()
|
||||
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
|
||||
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
||||
data class SetDarken(val darken: Boolean): SettingsEvent()
|
||||
|
||||
+3
-1
@@ -22,6 +22,7 @@ fun SettingsScreen(
|
||||
topInsets: Dp,
|
||||
onBackClick: () -> Unit,
|
||||
onDarkModeClick: (Boolean?) -> Unit,
|
||||
onAmoledClick: (Boolean) -> Unit,
|
||||
onDynamicThemingClick: (Boolean) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
@@ -39,12 +40,13 @@ fun SettingsScreen(
|
||||
largeTopAppBarHeightPx = largeTopAppBarHeight,
|
||||
scroll = scroll,
|
||||
onDarkModeClick = onDarkModeClick,
|
||||
onAmoledClick = onAmoledClick,
|
||||
onDynamicThemingClick = onDynamicThemingClick,
|
||||
onAnimateClick = onAnimateClick,
|
||||
onPrivacyClick = onPrivacyClick,
|
||||
onLicenseClick = onLicenseClick,
|
||||
onResetClick = onResetClick,
|
||||
onBackClick = onBackClick,
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
SettingsTitle(
|
||||
scroll = scroll,
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ data class SettingsState(
|
||||
val firstLaunch: Boolean = true,
|
||||
// App settings
|
||||
val darkMode: Boolean? = null,
|
||||
val amoledTheme: Boolean = false,
|
||||
val dynamicTheming: Boolean = false,
|
||||
val animate: Boolean = true,
|
||||
// Wallpaper settings
|
||||
|
||||
+25
@@ -36,6 +36,7 @@ class SettingsViewModel @Inject constructor (
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
val firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true }
|
||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
val amoledTheme = async { settingsDataStoreImpl.getBoolean(SettingsConstants.AMOLED_THEME_TYPE) ?: false }
|
||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: true }
|
||||
val setHomeWallpaper = async { settingsDataStoreImpl.getBoolean(SettingsConstants.HOME_WALLPAPER) ?: false }
|
||||
@@ -55,6 +56,7 @@ class SettingsViewModel @Inject constructor (
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
amoledTheme = amoledTheme.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
homeInterval = homeWallpaperInterval.await(),
|
||||
lockInterval = lockWallpaperInterval.await(),
|
||||
@@ -104,6 +106,7 @@ class SettingsViewModel @Inject constructor (
|
||||
is SettingsEvent.Refresh -> {
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
val amoledTheme = async { settingsDataStoreImpl.getBoolean(SettingsConstants.AMOLED_THEME_TYPE) ?: false }
|
||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||
val firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true }
|
||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||
@@ -122,6 +125,7 @@ class SettingsViewModel @Inject constructor (
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
amoledTheme = amoledTheme.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
@@ -157,11 +161,30 @@ class SettingsViewModel @Inject constructor (
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetAmoledTheme -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.AMOLED_THEME_TYPE, event.amoledTheme)
|
||||
if (event.amoledTheme) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
amoledTheme = event.amoledTheme,
|
||||
dynamicTheming = if (event.amoledTheme) false else it.dynamicTheming
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetDynamicTheming -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, event.dynamicTheming)
|
||||
if (event.dynamicTheming) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.AMOLED_THEME_TYPE, false)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
amoledTheme = if (event.dynamicTheming) false else it.amoledTheme,
|
||||
dynamicTheming = event.dynamicTheming
|
||||
)
|
||||
}
|
||||
@@ -354,6 +377,7 @@ class SettingsViewModel @Inject constructor (
|
||||
is SettingsEvent.Reset -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.AMOLED_THEME_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DYNAMIC_THEME_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_LAUNCH)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.LAST_SET_TIME)
|
||||
@@ -377,6 +401,7 @@ class SettingsViewModel @Inject constructor (
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = null,
|
||||
amoledTheme = false,
|
||||
dynamicTheming = false,
|
||||
firstLaunch = true,
|
||||
lastSetTime = null,
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.DarkMode
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* AMOLED list item to enable AMOLED mode
|
||||
*/
|
||||
@Composable
|
||||
fun AmoledListItem(amoledMode: Boolean, onAmoledClick: (Boolean) -> Unit) {
|
||||
val context = LocalContext.current
|
||||
Row {
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.clickable { onAmoledClick(!amoledMode) },
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.amoled_mode),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.full_dark_mode),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
trailingContent = {
|
||||
Switch(
|
||||
modifier = Modifier.semantics { contentDescription = context.getString(R.string.amoled_mode) },
|
||||
checked = amoledMode,
|
||||
onCheckedChange = onAmoledClick,
|
||||
enabled = true
|
||||
) },
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Filled.DarkMode,
|
||||
contentDescription = stringResource(R.string.amoled_mode),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
) },
|
||||
tonalElevation = 5.dp
|
||||
)
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -15,7 +15,6 @@ import androidx.compose.material.icons.outlined.Brightness6
|
||||
import androidx.compose.material.icons.outlined.BrightnessAuto
|
||||
import androidx.compose.material.icons.outlined.DarkMode
|
||||
import androidx.compose.material.icons.outlined.LightMode
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -38,7 +37,6 @@ import com.anthonyla.paperize.R
|
||||
/**
|
||||
* Three-state selector for dark mode in settings
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
val options = listOf(
|
||||
@@ -77,7 +75,7 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
},
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.dark_mode),
|
||||
text = stringResource(R.string.theme),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
|
||||
) },
|
||||
|
||||
+12
-3
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.ScrollState
|
||||
@@ -47,6 +48,7 @@ import kotlinx.coroutines.launch
|
||||
/**
|
||||
* Scrollable settings screen to wrap all settings components
|
||||
*/
|
||||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScrollableSettings(
|
||||
@@ -55,11 +57,12 @@ fun SettingsScrollableSettings(
|
||||
scroll: ScrollState,
|
||||
onDynamicThemingClick: (Boolean) -> Unit,
|
||||
onDarkModeClick: (Boolean?) -> Unit,
|
||||
onAmoledClick: (Boolean) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
onLicenseClick: () -> Unit,
|
||||
onResetClick: () -> Unit,
|
||||
onBackClick: () -> Unit
|
||||
onBackClick: () -> Unit,
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
@@ -108,7 +111,7 @@ fun SettingsScrollableSettings(
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
content = { it
|
||||
content = {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
@@ -127,11 +130,17 @@ fun SettingsScrollableSettings(
|
||||
onDarkModeClick = { onDarkModeClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
if (state.value.darkMode == null || state.value.darkMode == true) {
|
||||
AmoledListItem(
|
||||
amoledMode = state.value.amoledTheme,
|
||||
onAmoledClick = { onAmoledClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
DynamicThemingListItem(
|
||||
dynamicTheming = state.value.dynamicTheming,
|
||||
onDynamicThemingClick = { onDynamicThemingClick(it) }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
AnimationListItem(
|
||||
animate = state.value.animate,
|
||||
|
||||
+36
-1
@@ -10,6 +10,7 @@ import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
@@ -80,6 +81,38 @@ private val DarkColors = darkColorScheme(
|
||||
scrim = md_theme_dark_scrim,
|
||||
)
|
||||
|
||||
private val AmoledDarkColors = darkColorScheme(
|
||||
primary = md_theme_light_primary,
|
||||
onPrimary = md_theme_light_onPrimary,
|
||||
primaryContainer = md_theme_light_primaryContainer,
|
||||
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
||||
secondary = Color.Black,
|
||||
onSecondary = Color.White,
|
||||
secondaryContainer = Color.Black,
|
||||
onSecondaryContainer = Color.White,
|
||||
tertiary = md_theme_light_tertiary,
|
||||
onTertiary = md_theme_light_onTertiary,
|
||||
tertiaryContainer = Color.Black,
|
||||
onTertiaryContainer = Color.White,
|
||||
error = Color.Red,
|
||||
errorContainer = Color.Black,
|
||||
onError = Color.White,
|
||||
onErrorContainer = Color.Black,
|
||||
background = Color.Black,
|
||||
onBackground = Color.White,
|
||||
surface = Color.Black,
|
||||
onSurface = Color.White,
|
||||
surfaceVariant = Color.Black,
|
||||
onSurfaceVariant = Color.White,
|
||||
outline = Color.White,
|
||||
inverseOnSurface = Color.Black,
|
||||
inverseSurface = Color.White,
|
||||
inversePrimary = Color.White,
|
||||
surfaceTint = Color.Black,
|
||||
outlineVariant = md_theme_dark_outlineVariant,
|
||||
scrim = md_theme_dark_scrim,
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* App theming for dynamic theming when supported and dark mode.
|
||||
@@ -87,6 +120,7 @@ private val DarkColors = darkColorScheme(
|
||||
@Composable
|
||||
fun PaperizeTheme(
|
||||
darkMode: Boolean?,
|
||||
amoledMode: Boolean,
|
||||
dynamicTheming: Boolean,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
@@ -97,7 +131,8 @@ fun PaperizeTheme(
|
||||
val colors = when {
|
||||
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
||||
isDynamicTheming && dynamicThemingSupported && !isDarkMode -> dynamicLightColorScheme(context)
|
||||
isDarkMode -> DarkColors
|
||||
isDarkMode && amoledMode -> AmoledDarkColors
|
||||
isDarkMode && !amoledMode -> DarkColors
|
||||
else -> LightColors
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -33,13 +33,10 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.AlbumBottomSheet
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.BlurSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ChangerSelectionRow
|
||||
@@ -53,7 +50,7 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun WallpaperScreen(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
animate: Boolean,
|
||||
darken: Boolean,
|
||||
darkenPercentage: Int,
|
||||
@@ -85,14 +82,13 @@ fun WallpaperScreen(
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
blurPercentage: Int
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
val context = LocalContext.current
|
||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val openLiveDialog = rememberSaveable { mutableStateOf(false) }
|
||||
val showInterval = rememberSaveable { mutableStateOf(false) }
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
if (openLiveDialog.value) {
|
||||
ShowLiveWallpaperEnabledDialog(
|
||||
@@ -116,9 +112,9 @@ fun WallpaperScreen(
|
||||
content = { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(scrollState)
|
||||
.fillMaxSize()
|
||||
.padding(8.dp)
|
||||
.verticalScroll(scrollState),
|
||||
.padding(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
ChangerSelectionRow(
|
||||
@@ -131,7 +127,7 @@ fun WallpaperScreen(
|
||||
CurrentSelectedAlbum(
|
||||
selectedAlbum = selectedAlbum,
|
||||
onOpenBottomSheet = {
|
||||
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) {
|
||||
if (albums.firstOrNull() != null) {
|
||||
if (isLiveWallpaperSet(context)) {
|
||||
openLiveDialog.value = true
|
||||
} else {
|
||||
@@ -342,7 +338,7 @@ fun WallpaperScreen(
|
||||
}
|
||||
if (((homeEnabled || lockEnabled)) && openBottomSheet) {
|
||||
AlbumBottomSheet(
|
||||
albums = albumState.value.albumsWithWallpapers,
|
||||
albums = albums,
|
||||
currentSelectedAlbum = selectedAlbum,
|
||||
onDismiss = { openBottomSheet = false },
|
||||
onSelect = { album ->
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import java.time.ZoneId
|
||||
* It uses the AlarmManager to schedule alarms for the WallpaperReceiver.
|
||||
* It also uses the WallpaperService to change the wallpaper due to receiver limitations.
|
||||
*/
|
||||
class WallpaperScheduler (
|
||||
class WallpaperAlarmSchedulerImpl (
|
||||
private val context: Context,
|
||||
): WallpaperAlarmScheduler {
|
||||
private val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
+2
-3
@@ -23,7 +23,7 @@ class WallpaperBootAndChangeReceiver : BroadcastReceiver() {
|
||||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||
override fun onReceive(context: Context, intent: Intent) = goAsync {
|
||||
try {
|
||||
val scheduler = WallpaperScheduler(context)
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context)
|
||||
val toggleChanger = settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false
|
||||
if (toggleChanger) {
|
||||
val timeInMinutes1 = settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
@@ -34,8 +34,7 @@ class WallpaperBootAndChangeReceiver : BroadcastReceiver() {
|
||||
timeInMinutes2 = timeInMinutes2,
|
||||
scheduleSeparately = scheduleSeparately
|
||||
)
|
||||
val changeImmediate = intent.getBooleanExtra("changeImmediate", false)
|
||||
alarmItem.let{scheduler.scheduleWallpaperAlarm(it, null, changeImmediate, true)}
|
||||
alarmItem.let{scheduler.scheduleWallpaperAlarm(it, null, true, true)}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ class WallpaperReceiver: BroadcastReceiver() {
|
||||
action = WallpaperService1.Actions.REFRESH.toString()
|
||||
}
|
||||
context.startService(serviceIntent)
|
||||
WallpaperScheduler(context).scheduleRefresh()
|
||||
WallpaperAlarmSchedulerImpl(context).scheduleRefresh()
|
||||
}
|
||||
else {
|
||||
val timeInMinutes1 = intent?.getIntExtra("timeInMinutes1", WALLPAPER_CHANGE_INTERVAL_DEFAULT) ?: WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
@@ -48,7 +48,7 @@ class WallpaperReceiver: BroadcastReceiver() {
|
||||
|
||||
// Schedule next alarm for next wallpaper change
|
||||
val origin = intent?.getIntExtra("origin", -1)?.takeIf { it != -1 }
|
||||
WallpaperScheduler(context).scheduleWallpaperAlarm(
|
||||
WallpaperAlarmSchedulerImpl(context).scheduleWallpaperAlarm(
|
||||
WallpaperAlarmItem(
|
||||
timeInMinutes1 = timeInMinutes1,
|
||||
timeInMinutes2 = timeInMinutes2,
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class ChangeWallpaperTileService: TileService() {
|
||||
|
||||
override fun onClick() {
|
||||
super.onClick()
|
||||
val intent = Intent(this, WallpaperBootAndChangeReceiver::class.java).putExtra("changeImmediate", true)
|
||||
val intent = Intent(this, WallpaperBootAndChangeReceiver::class.java)
|
||||
sendBroadcast(intent)
|
||||
}
|
||||
|
||||
|
||||
@@ -153,4 +153,7 @@
|
||||
<string name="delay_notice_dialog">Delay Notice</string>
|
||||
<string name="to_minimize_battery_usage_changing_wallpapers_may_have_some_delays_once_scheduled_when_the_device_is_asleep_the_wallpaper_may_take_longer_to_apply">To minimize battery usage, changing wallpapers may have some delays once scheduled. When the device is asleep, the wallpaper may take longer to apply.</string>
|
||||
<string name="change_wallpaper">Change wallpaper</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="amoled_mode">AMOLED Mode</string>
|
||||
<string name="full_dark_mode">Full dark mode</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user