Updated dependencies

Updated Kotlin 1.9.22
Updated Compose compiler to 1.5.10
Refactored navigation and implemented type-safe navigation from navigation-compose:2.8.0-alpha08
Updated the version code to 1.1.0
Updated SetLockScreen component to show a fixed aspect ratio of 9:19.5 and disable clicking splash
Updated FAB color due to dependencies update breaking visual design
Added option to disable loading animation for images in the app
Added option to disable grid change animation
This commit is contained in:
Anthonyy232 committed 2024-05-02 14:09:15 -07:00
1 parent f9207309a8
commit 1906a3f170
21 files changed
+439 -343

No files matched your search

@@ -11,11 +11,10 @@ import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import androidx.navigation.toRoute
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumScreen
@@ -34,17 +33,20 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.startup_screen.Star
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperEvent
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen.WallpaperViewScreen
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AddEdit
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AlbumView
import com.anthonyla.paperize.feature.wallpaper.util.navigation.FolderView
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Home
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Licenses
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavConstants.INITIAL_OFFSET
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavScreens
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Notification
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Privacy
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Settings
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Startup
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.wallpaperservice.WallpaperService
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
@Composable
fun PaperizeApp(
@@ -65,8 +67,8 @@ fun PaperizeApp(
if (!albumWithWallpapers.album.initialized && (albumWithWallpapers.wallpapers.isNotEmpty() || albumWithWallpapers.folders.isNotEmpty())) {
albumsViewModel.onEvent(AlbumsEvent.InitializeAlbum(albumWithWallpapers))
} else if (albumWithWallpapers.album.initialized && albumWithWallpapers.wallpapers.isEmpty() && albumWithWallpapers.folders.isEmpty()) {
if (navController.currentDestination?.route != NavScreens.Home.route) {
navController.popBackStack(NavScreens.Home.route, false)
if (navController.currentDestination?.route == Home::class.simpleName) {
navController.popBackStack<Home>(inclusive = false)
}
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
}
@@ -114,12 +116,11 @@ fun PaperizeApp(
NavHost(
navController = navController,
startDestination = if (firstLaunch) NavScreens.Startup.route else NavScreens.Home.route,
startDestination = if (firstLaunch) Startup else Home,
modifier = Modifier.navigationBarsPadding()
) {
// Navigate to the startup screen to show the privacy policy and notification screen
composable(
route = NavScreens.Startup.route,
composable<Startup> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -137,20 +138,17 @@ fun PaperizeApp(
onAgree = {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
navController.navigate(NavScreens.Home.route) {
popUpTo(NavScreens.Startup.route) { inclusive = true }
popUpTo(NavScreens.Notification.route) { inclusive = true }
navController.navigate(Home) {
popUpTo(Startup) { inclusive = true }
popUpTo(Notification) { inclusive = true }
}
}
else {
navController.navigate(NavScreens.Notification.route)
}
else { navController.navigate(Notification) }
}
)
}
// Navigate to the notification screen to ask for notification permission
composable(
route = NavScreens.Notification.route,
composable<Notification> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -167,16 +165,15 @@ fun PaperizeApp(
NotificationScreen(
onAgree = {
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
navController.navigate(NavScreens.Home.route) {
popUpTo(NavScreens.Startup.route) { inclusive = true }
popUpTo(NavScreens.Notification.route) { inclusive = true }
navController.navigate(Home) {
popUpTo(Startup) { inclusive = true }
popUpTo(Notification) { inclusive = true }
}
}
)
}
// Navigate to the home screen to view all albums and wallpapers
composable(
route = NavScreens.Home.route,
composable<Home> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -191,12 +188,12 @@ fun PaperizeApp(
},
) {
HomeScreen(
onSettingsClick = { navController.navigate(NavScreens.Settings.route) },
onSettingsClick = { navController.navigate(Settings) },
navigateToAddWallpaperScreen = {
navController.navigate("${NavScreens.AddEdit.route}/$it")
navController.navigate(AddEdit(it))
},
onAlbumViewClick = {
navController.navigate("${NavScreens.AlbumView.route}/$it")
navController.navigate(AlbumView(it))
},
onScheduleWallpaperChanger = { timeInMinutes ->
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(timeInMinutes))
@@ -212,12 +209,11 @@ fun PaperizeApp(
context.startForegroundService(it)
}
},
animate = settingsState.value.animate
)
}
// Navigate to the add album screen to create a new album and add wallpapers to it
composable(
route = NavScreens.AddEdit.route.plus("/{initialAlbumName}"),
arguments = listOf(navArgument("initialAlbumName") { type = NavType.StringType }),
composable<AddEdit>(
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -231,94 +227,21 @@ fun PaperizeApp(
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
}
) {backStackEntry ->
backStackEntry.arguments?.getString("initialAlbumName").let {
if (it != null) {
AddAlbumScreen(
initialAlbumName = it,
onBackClick = { navController.navigateUp() },
onConfirmation = {
navController.navigateUp()
},
onShowWallpaperView = { wallpaper ->
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
},
onShowFolderView = { folder, folderName, wallpapers ->
val encodedFolder = runBlocking { encodeUri(uri = folder) }
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/$encodedFolder/$folderName/$encodedWallpapers")
}
)
}
}
}
// Navigate to wallpaper view screen to view individual wallpapers in full screen
composable(
route = NavScreens.WallpaperView.route.plus("/{wallpaperUri}"),
arguments = listOf(navArgument("wallpaperUri") { type = NavType.StringType }),
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
exitTransition = {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
},
popEnterTransition = {
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
},
popExitTransition = {
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) { backStackEntry ->
backStackEntry.arguments?.getString("wallpaperUri").let { wallpaper ->
if (wallpaper != null) {
WallpaperViewScreen(
wallpaperUri = wallpaper,
onBackClick = { navController.navigateUp() },
)
}
}
}
// Navigate to folder view screen to view wallpapers in a particular folder
composable(
route = NavScreens.FolderView.route.plus("/{folderName}/{wallpapers}"),
arguments = listOf(
navArgument("folderName") { type = NavType.StringType },
navArgument("wallpapers") { type = NavType.StringType }
),
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
exitTransition = {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
},
popEnterTransition = {
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
},
popExitTransition = {
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) { backStackEntry ->
val folderName = backStackEntry.arguments?.getString("folderName")
val wallpapers = Gson().fromJson(
backStackEntry.arguments?.getString("wallpapers"),
Array<String>::class.java
).toList()
FolderViewScreen(
folderName = folderName,
wallpapers = wallpapers,
val addEdit: AddEdit = backStackEntry.toRoute()
AddAlbumScreen(
initialAlbumName = addEdit.wallpaper,
onBackClick = { navController.navigateUp() },
onConfirmation = { navController.navigateUp() },
onShowWallpaperView = { wallpaper ->
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
navController.navigate(WallpaperView(wallpaper))
},
onShowFolderView = { folderName, wallpapers ->
navController.navigate(FolderView(folderName, wallpapers))
}
)
}
// Navigate to the album view screen to view folders and wallpapers in an album
composable(
route = NavScreens.AlbumView.route.plus("/{initialAlbumName}"),
arguments = listOf(
navArgument("initialAlbumName") { type = NavType.StringType },
),
// Navigate to wallpaper view screen to view individual wallpapers in full screen
composable<WallpaperView> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -332,19 +255,65 @@ fun PaperizeApp(
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) { backStackEntry ->
val initialAlbumName = backStackEntry.arguments?.getString("initialAlbumName")
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == initialAlbumName }
if (initialAlbumName != null && albumWithWallpaper != null) {
val wallpaperView: WallpaperView = backStackEntry.toRoute()
WallpaperViewScreen(
wallpaperUri = wallpaperView.wallpaper,
onBackClick = { navController.navigateUp() },
animate = settingsState.value.animate
)
}
// Navigate to folder view screen to view wallpapers in a particular folder
composable<FolderView> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
exitTransition = {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
},
popEnterTransition = {
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
},
popExitTransition = {
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) { backStackEntry ->
val folderView: FolderView = backStackEntry.toRoute()
FolderViewScreen(
folderName = folderView.folderName,
wallpapers = folderView.wallpapers,
onBackClick = { navController.navigateUp() },
onShowWallpaperView = {
navController.navigate(WallpaperView(it))
},
animate = settingsState.value.animate
)
}
// Navigate to the album view screen to view folders and wallpapers in an album
composable<AlbumView> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
exitTransition = {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
},
popEnterTransition = {
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
},
popExitTransition = {
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) { backStackEntry ->
val albumView: AlbumView = backStackEntry.toRoute()
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == albumView.initialAlbumName }
if (albumWithWallpaper != null) {
AlbumViewScreen(
album = albumWithWallpaper,
onBackClick = { navController.navigateUp() },
onShowWallpaperView = { wallpaper ->
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
onShowWallpaperView = {
navController.navigate(WallpaperView(it))
},
onShowFolderView = { folderName, wallpapers ->
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
navController.navigate(FolderView(folderName, wallpapers))
},
onDeleteAlbum = {
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpaper))
@@ -357,11 +326,10 @@ fun PaperizeApp(
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
}
)
}
} else { navController.navigateUp() }
}
// Navigate to the settings screen to change app settings
composable(
route = NavScreens.Settings.route,
composable<Settings> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -388,16 +356,15 @@ fun PaperizeApp(
settingsViewModel.onEvent(SettingsEvent.SetAnimate(it))
},
onPrivacyClick = {
navController.navigate(NavScreens.Privacy.route)
navController.navigate(Privacy)
},
onLicenseClick = {
navController.navigate(NavScreens.Licenses.route)
navController.navigate(Licenses)
},
)
}
// Navigate to the privacy screen to view the privacy policy
composable(
route = NavScreens.Privacy.route,
composable<Privacy> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -416,8 +383,7 @@ fun PaperizeApp(
)
}
// Navigate to the licenses screen to view the licenses of the libraries used
composable(
route = NavScreens.Licenses.route,
composable<Licenses> (
enterTransition = {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
@@ -436,10 +402,4 @@ fun PaperizeApp(
)
}
}
}
// Encode an URI so it can be passed with navigation
suspend fun encodeUri(uri: String): String =
withContext(Dispatchers.IO) {
URLEncoder.encode(uri, StandardCharsets.UTF_8.toString())
}
@@ -44,7 +44,7 @@ fun AddAlbumScreen(
onBackClick: () -> Unit,
onConfirmation: () -> Unit,
onShowWallpaperView: (String) -> Unit,
onShowFolderView: (String, String?, List<String>) -> Unit
onShowFolderView: (String?, List<String>) -> Unit
) {
val context = LocalContext.current
val lazyGridState = rememberLazyStaggeredGridState()
@@ -187,7 +187,7 @@ fun AddAlbumScreen(
)
},
onFolderViewClick = {
onShowFolderView(folder.folderUri, folder.folderName, folder.wallpapers)
onShowFolderView(folder.folderName, folder.wallpapers)
},
modifier = Modifier.padding(4.dp).animateItem(
placementSpec = tween(
@@ -223,7 +223,8 @@ fun AddAlbumScreen(
delayMillis = 0,
easing = FastOutSlowInEasing
),
)
),
animate = settingsState.value.animate
)
}
}
@@ -22,11 +22,13 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Remove
import androidx.compose.material3.CardColors
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.Icon
import androidx.compose.material3.LargeFloatingActionButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -34,6 +36,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
@@ -82,6 +85,12 @@ fun AddAlbumAnimatedFab(
if (animate) {
ElevatedCard(
colors = CardColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
contentColor = Color.Transparent,
disabledContentColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
),
shape = RoundedCornerShape(28.dp),
modifier = Modifier
.padding(4.dp)
@@ -147,6 +156,12 @@ fun AddAlbumAnimatedFab(
}
else {
ElevatedCard(
colors = CardColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
contentColor = Color.Transparent,
disabledContentColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
),
shape = RoundedCornerShape(28.dp),
modifier = Modifier
.padding(4.dp)
@@ -34,7 +34,8 @@ import com.skydoves.landscapist.glide.GlideImage
fun AlbumItem(
album: Album,
onAlbumViewClick: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
animate: Boolean = true
) {
Card(
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
@@ -62,8 +63,10 @@ fun AlbumItem(
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
},
modifier = Modifier
@@ -59,7 +59,8 @@ fun FolderItem(
onActivateSelectionMode: (Boolean) -> Unit,
onItemSelection: () -> Unit,
onFolderViewClick: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
animate: Boolean = true
) {
val configuration = LocalConfiguration.current
val haptics = LocalHapticFeedback.current
@@ -113,8 +114,10 @@ fun FolderItem(
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
},
modifier = Modifier
@@ -54,7 +54,10 @@ fun WallpaperItem(
onItemSelection: () -> Unit,
onWallpaperViewClick: () -> Unit,
modifier: Modifier = Modifier,
wallpaperDrawable : Bitmap? = null
wallpaperDrawable : Bitmap? = null,
aspectRatio: Float? = null,
clickable: Boolean = true,
animate: Boolean = true
) {
val context = LocalContext.current
val haptics = LocalHapticFeedback.current
@@ -68,10 +71,10 @@ fun WallpaperItem(
}
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
val aspectRatio = (dimension.first.toFloat()/dimension.second.toFloat())
val imageAspectRatio = aspectRatio ?: (dimension.first.toFloat() / dimension.second.toFloat())
Box(
modifier = modifier
val boxModifier = if (clickable) {
modifier
.padding(paddingTransition)
.clip(RoundedCornerShape(roundedCornerShapeTransition))
.combinedClickable(
@@ -87,6 +90,14 @@ fun WallpaperItem(
}
}
)
} else {
modifier
.padding(paddingTransition)
.clip(RoundedCornerShape(roundedCornerShapeTransition))
}
Box(
modifier = boxModifier
) {
GlideImage(
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
@@ -101,11 +112,13 @@ fun WallpaperItem(
.transition(withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
},
modifier = Modifier.aspectRatio(aspectRatio)
modifier = Modifier.aspectRatio(imageAspectRatio)
)
if (selectionMode) {
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
@@ -47,7 +47,7 @@ fun AlbumViewScreen(
onShowFolderView: (String?, List<String>) -> Unit,
onDeleteAlbum: () -> Unit,
onTitleChange: (String, AlbumWithWallpaperAndFolder) -> Unit,
onSelectionDeleted: () -> Unit
onSelectionDeleted: () -> Unit,
) {
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
val lazyListState = rememberLazyStaggeredGridState()
@@ -153,7 +153,7 @@ fun AlbumViewScreen(
selectionMode = false
folderPickerLauncher.launch(null)
},
animate = true
animate = false
)
}
},
@@ -169,61 +169,111 @@ fun AlbumViewScreen(
content = {
items (items = album.folders, key = { folder -> folder.folderUri.hashCode() }
) { folder ->
FolderItem(
folder = folder,
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedFolders.contains(folder.folderUri))
AlbumViewEvent.SelectFolder(folder.folderUri)
else {
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
}
)
},
onFolderViewClick = {
onShowFolderView(folder.folderName, folder.wallpapers)
},
modifier = Modifier.padding(4.dp).animateItem(
placementSpec = tween(
durationMillis = 800,
delayMillis = 0,
easing = FastOutSlowInEasing
),
)
)
}
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
) { wallpaper ->
WallpaperItem(
wallpaperUri = wallpaper.wallpaperUri,
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
else {
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
}
)
},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper.wallpaperUri)
},
modifier = Modifier
.padding(4.dp)
.animateItem(
if (settingsState.value.animate) {
FolderItem(
folder = folder,
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedFolders.contains(folder.folderUri))
AlbumViewEvent.SelectFolder(folder.folderUri)
else {
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
}
)
},
onFolderViewClick = {
onShowFolderView(folder.folderName, folder.wallpapers)
},
modifier = Modifier.padding(4.dp).animateItem(
placementSpec = tween(
durationMillis = 800,
delayMillis = 0,
easing = FastOutSlowInEasing
),
),
animate = true
)
}
else {
FolderItem(
folder = folder,
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedFolders.contains(folder.folderUri))
AlbumViewEvent.SelectFolder(folder.folderUri)
else {
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
}
)
)
)
},
onFolderViewClick = {
onShowFolderView(folder.folderName, folder.wallpapers)
},
modifier = Modifier.padding(4.dp),
animate = false
)
}
}
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
) { wallpaper ->
if (settingsState.value.animate) {
WallpaperItem(
wallpaperUri = wallpaper.wallpaperUri,
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
else {
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
}
)
},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper.wallpaperUri)
},
modifier = Modifier
.padding(4.dp)
.animateItem(
placementSpec = tween(
durationMillis = 800,
delayMillis = 0,
easing = FastOutSlowInEasing
)
),
animate = true
)
}
else {
WallpaperItem(
wallpaperUri = wallpaper.wallpaperUri,
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
selectionMode = selectionMode,
onActivateSelectionMode = { selectionMode = it },
onItemSelection = {
albumViewScreenViewModel.onEvent(
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
else {
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
}
)
},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper.wallpaperUri)
},
modifier = Modifier.padding(4.dp),
animate = false
)
}
}
}
)
@@ -23,7 +23,8 @@ fun FolderViewScreen(
folderName: String?,
wallpapers: List<String>,
onBackClick: () -> Unit,
onShowWallpaperView: (String) -> Unit
onShowWallpaperView: (String) -> Unit,
animate: Boolean
) {
val lazyListState = rememberLazyStaggeredGridState()
BackHandler { onBackClick() }
@@ -32,9 +33,8 @@ fun FolderViewScreen(
topBar = {
FolderViewTopBar(
title = folderName ?: "",
) {
onBackClick()
}
onBackClick = onBackClick
)
},
content = {
LazyVerticalStaggeredGrid(
@@ -48,23 +48,40 @@ fun FolderViewScreen(
content = {
items (items = wallpapers, key = { wallpaper -> wallpaper }
) { wallpaper ->
WallpaperItem(
wallpaperUri = wallpaper,
itemSelected = false,
selectionMode = false,
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper)
},
modifier = Modifier.padding(4.dp).animateItem(
placementSpec = tween(
durationMillis = 800,
delayMillis = 0,
easing = FastOutSlowInEasing
if (animate) {
WallpaperItem(
wallpaperUri = wallpaper,
itemSelected = false,
selectionMode = false,
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper)
},
modifier = Modifier.padding(4.dp).animateItem(
placementSpec = tween(
durationMillis = 800,
delayMillis = 0,
easing = FastOutSlowInEasing
),
),
animate = true
)
)
}
else {
WallpaperItem(
wallpaperUri = wallpaper,
itemSelected = false,
selectionMode = false,
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {
onShowWallpaperView(wallpaper)
},
modifier = Modifier.padding(4.dp),
animate = false
)
}
}
}
)
@@ -1,6 +1,5 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
@@ -29,14 +28,14 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.Libr
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.tabItems
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreen
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun HomeScreen(
onSettingsClick: () -> Unit,
navigateToAddWallpaperScreen: (String) -> Unit,
onAlbumViewClick: (String) -> Unit,
onScheduleWallpaperChanger: (Int) -> Unit,
onStop: () -> Unit
onStop: () -> Unit,
animate : Boolean
) {
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
val pagerState = rememberPagerState { tabItems.size }
@@ -108,7 +107,8 @@ fun HomeScreen(
)
1 -> LibraryScreen(
onAddNewAlbumClick = { addAlbumDialog = true },
onViewAlbum = onAlbumViewClick
onViewAlbum = onAlbumViewClick,
animate = animate
)
}
}
@@ -30,7 +30,8 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.Al
fun LibraryScreen(
albumsViewModel: AlbumsViewModel = hiltViewModel(),
onAddNewAlbumClick: () -> Unit,
onViewAlbum: (String) -> Unit
onViewAlbum: (String) -> Unit,
animate: Boolean
) {
val lazyListState = rememberLazyGridState()
val state = albumsViewModel.state.collectAsStateWithLifecycle()
@@ -68,7 +69,8 @@ fun LibraryScreen(
delayMillis = 0,
easing = FastOutSlowInEasing
),
)
),
animate = animate
)
}
}
@@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
@@ -53,7 +54,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.app_icon_foreground),
contentDescription = stringResource(id = R.string.appname),
modifier = Modifier.size(160.dp),
modifier = Modifier.size(160.dp).scale(1.5f),
tint = MaterialTheme.colorScheme.primary,
)
Text(
@@ -62,7 +63,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
fontSize = MaterialTheme.typography.titleLarge.fontSize
)
Text(
text = "Version: 0.3.0",
text = "Version: 1.1.0",
style = MaterialTheme.typography.bodySmall,
fontSize = MaterialTheme.typography.bodyMedium.fontSize
)
@@ -79,7 +80,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
IconButton(
onClick = onGitHubClick,
modifier = Modifier
.size(64.dp)
.size(60.dp)
.background(MaterialTheme.colorScheme.primary, CircleShape)
) {
Icon(
@@ -95,7 +96,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
IconButton(
onClick = onPlaystoreClick,
modifier = Modifier
.size(64.dp)
.size(60.dp)
.background(MaterialTheme.colorScheme.primary, CircleShape)
) {
Icon(
@@ -111,7 +112,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
IconButton(
onClick = onFdroidClick,
modifier = Modifier
.size(64.dp)
.size(60.dp)
.background(MaterialTheme.colorScheme.primary, CircleShape)
) {
Icon(
@@ -1,7 +1,5 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
import android.os.Build
import android.view.HapticFeedbackConstants
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
@@ -23,7 +21,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -92,7 +89,8 @@ fun WallpaperScreen(
}
onStop()
}
}
},
animate = settingsState.value.animate
)
}
if (settingsState.value.animate) {
@@ -120,7 +118,8 @@ fun WallpaperScreen(
checked = settingsState.value.setLockWithHome,
onCheckedChange = { isChecked ->
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
}
},
animate = settingsState.value.animate
)
}
}
@@ -157,7 +156,8 @@ fun WallpaperScreen(
checked = settingsState.value.setLockWithHome,
onCheckedChange = { isChecked ->
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
}
},
animate = settingsState.value.animate
)
}
}
@@ -207,7 +207,8 @@ fun WallpaperScreen(
}
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
onScheduleWallpaperChanger(settingsState.value.interval)
}
},
animate = settingsState.value.animate
)
}
},
@@ -2,7 +2,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.c
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -47,7 +46,8 @@ fun AlbumBottomSheet(
onDismiss: () -> Unit,
currentSelectedAlbum: SelectedAlbum?,
albums: List<AlbumWithWallpaperAndFolder>,
onSelect: (AlbumWithWallpaperAndFolder) -> Unit
onSelect: (AlbumWithWallpaperAndFolder) -> Unit,
animate: Boolean
) {
val modalBottomSheetState = rememberModalBottomSheetState()
val scope = rememberCoroutineScope()
@@ -55,7 +55,6 @@ fun AlbumBottomSheet(
onDismissRequest = { onDismiss() },
sheetState = modalBottomSheetState,
dragHandle = { BottomSheetDefaults.DragHandle() },
windowInsets = WindowInsets(0.dp)
) {
albums.forEach {
ListItem(
@@ -97,9 +96,14 @@ fun AlbumBottomSheet(
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(
Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(
modifier = Modifier.align(
Alignment.Center
)
)
}
}
},
modifier = Modifier
@@ -42,7 +42,8 @@ import com.skydoves.landscapist.glide.GlideImage
fun CurrentSelectedAlbum(
selectedAlbum: SelectedAlbum?,
onOpenBottomSheet: () -> Unit,
onStop: () -> Unit
onStop: () -> Unit,
animate: Boolean
) {
ListItem(
modifier = Modifier
@@ -82,8 +83,10 @@ fun CurrentSelectedAlbum(
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
},
modifier = Modifier
@@ -33,7 +33,8 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.Wa
fun SetLockScreenSwitch(
albumUri : String?,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit
onCheckedChange: (Boolean) -> Unit,
animate: Boolean
) {
Surface(
tonalElevation = 10.dp,
@@ -75,7 +76,12 @@ fun SetLockScreenSwitch(
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {},
modifier = Modifier.padding(4.dp).border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp))
modifier = Modifier
.padding(4.dp)
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
aspectRatio = 9f / 19.5f,
clickable = false,
animate = animate
)
}
}
@@ -94,7 +100,12 @@ fun SetLockScreenSwitch(
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {},
modifier = Modifier.padding(4.dp).border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp))
modifier = Modifier
.padding(4.dp)
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
aspectRatio = 9f / 19.5f,
clickable = false,
animate = animate
)
}
}
@@ -43,6 +43,7 @@ import net.engawapg.lib.zoomable.zoomable
fun WallpaperViewScreen(
wallpaperUri: String,
onBackClick: () -> Unit,
animate : Boolean
) {
val zoomState = rememberZoomState()
BackHandler { onBackClick() }
@@ -98,8 +99,10 @@ fun WallpaperViewScreen(
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
}
)
@@ -1,77 +1,64 @@
package com.anthonyla.paperize.feature.wallpaper.util.navigation
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.BrowseGallery
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Newspaper
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.PrivacyTip
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Start
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.BrowseGallery
import androidx.compose.material.icons.outlined.Image
import androidx.compose.material.icons.outlined.Newspaper
import androidx.compose.material.icons.outlined.Notifications
import androidx.compose.material.icons.outlined.PrivacyTip
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Start
import androidx.compose.ui.graphics.vector.ImageVector
import com.anthonyla.paperize.R
import kotlinx.serialization.Serializable
/**
* Enum class for navigation screens in application
* Data class for Startup screen
*/
sealed class NavScreens(val route: String, @StringRes val resourceId: Int, val unfilledIcon: ImageVector, val filledIcon: ImageVector) {
/**
* Home screen that the user lands on initially
*/
object Startup : NavScreens("startup_screen", R.string.startup, Icons.Outlined.Start, Icons.Filled.Start)
@Serializable
object Startup
/**
* Notification screen for the application to ask for permission
*/
object Notification : NavScreens("notification_screen", R.string.notifications, Icons.Outlined.Notifications, Icons.Filled.Notifications)
/**
* Object for Notification screen
*/
@Serializable
object Notification
/**
* Home screen that the user lands on initially containing the wallpapers and albums
*/
object Home : NavScreens("home_screen", R.string.home_screen, Icons.Outlined.Image, Icons.Filled.Image)
/**
* Object for Home screen
*/
@Serializable
object Home
/**
* Settings screen for the application
*/
object Settings : NavScreens("settings_screen", R.string.settings_screen, Icons.Outlined.Settings, Icons.Filled.Settings)
/**
* Object for Settings screen
*/
@Serializable
object Settings
/**
* License screen for the application
*/
object Licenses : NavScreens("licenses_screen", R.string.licenses_screen, Icons.Outlined.Newspaper, Icons.Filled.Newspaper)
/**
* Object for Licenses screen
*/
@Serializable
object Licenses
/**
* Settings screen for the application
*/
object Privacy : NavScreens("privacy_screen", R.string.privacy_screen, Icons.Outlined.PrivacyTip, Icons.Filled.PrivacyTip)
/**
* Object for Privacy screen
*/
@Serializable
object Privacy
/**
* Add/Edit screen for album when adding or editing
*/
object AddEdit : NavScreens("add_edit_screen", R.string.add_wallpaper_screen, Icons.Outlined.Add, Icons.Filled.Add)
/**
* Data class for AlbumView screen
*/
@Serializable
data class AlbumView(val initialAlbumName: String)
/**
* Wallpaper view screen for viewing wallpapers when clicking on a wallpaper
*/
object WallpaperView : NavScreens("wallpaper_view_screen", R.string.wallpaper_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
/**
* Data class for AddEdit screen
*/
@Serializable
data class AddEdit(val wallpaper: String)
/**
* Folder view screen for viewing wallpapers in a folder when clicking on a folder
*/
object FolderView : NavScreens("folder_view_screen", R.string.folder_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
/**
* Data class for WallpaperView screen
*/
@Serializable
data class WallpaperView(val wallpaper: String)
/**
* Album view screen for viewing albums when clicking on an album. Shows wallpapers and folders of the album
*/
object AlbumView : NavScreens("album_view_screen", R.string.album_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
}
/**
* Data class for FolderView screen
*/
@Serializable
data class FolderView(val folderName: String?, val wallpapers: List<String>)