Added startup page for ToS and privacy. Modified top app bar for settings navigation. Completed time scheduling functionality for wallpaper changing and also implemented lock screen toggle for wallpaper changer.

This commit is contained in:
Anthonyy232 committed 2024-04-27 20:10:25 -07:00
1 parent 71b57b9f8c
commit c8c8bd2fd3
30 files changed
+902 -354

No files matched your search

+1
View File
@@ -81,6 +81,7 @@ dependencies {
implementation("com.github.skydoves:landscapist-glide:2.3.3")
implementation("androidx.work:work-runtime-ktx:2.10.0-alpha02")
implementation("androidx.hilt:hilt-work:1.2.0")
implementation("com.airbnb.android:lottie-compose:6.4.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha03")
-1
View File
@@ -10,7 +10,6 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:name=".App"
@@ -8,5 +8,7 @@ object SettingsConstants {
const val DARK_MODE_TYPE = "dark_mode_type"
const val DYNAMIC_THEME_TYPE = "dynamic_theme_type"
const val WALLPAPER_CHANGE_INTERVAL = "wallpaper_change_interval"
const val WALLPAPER_CHANGE_INTERVAL_DEFAULT = 30
const val WALLPAPER_CHANGE_INTERVAL_DEFAULT = 15
const val SET_LOCK_WITH_HOME = "set_lock_with_home"
const val FIRST_LAUNCH = "first_launch"
}
@@ -1,8 +1,12 @@
package com.anthonyla.paperize.feature.wallpaper.presentation
import android.Manifest
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
@@ -18,6 +22,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.unit.dp
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
@@ -26,12 +31,14 @@ import com.anthonyla.paperize.core.SettingsConstants
import com.anthonyla.paperize.data.settings.SettingsDataStore
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsEvent
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeTheme
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.wallpaperservice.WallpaperService
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
@AndroidEntryPoint
@@ -39,21 +46,19 @@ class MainActivity : ComponentActivity() {
private val albumsViewModel: AlbumsViewModel by viewModels()
private val settingsViewModel: SettingsViewModel by viewModels()
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
private val context = this
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.POST_NOTIFICATIONS), 0)
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0)
}
if (ContextCompat.checkSelfPermission(context, Manifest.permission.SET_WALLPAPER) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(context as Activity, arrayOf(Manifest.permission.SET_WALLPAPER), 0)
}
enableEdgeToEdge()
// Show splash screen until app data is fully loaded and ready to be displayed
val splashScreen = installSplashScreen()
super.onCreate(savedInstanceState)
splashScreen.setKeepOnScreenCondition {
settingsViewModel.shouldNotBypassSplashScreen
|| albumsViewModel.shouldNotBypassSplashScreen
|| wallpaperScreenViewModel.shouldNotBypassSplashScreen
}
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { settingsViewModel.setKeepOnScreenCondition }
setContent {
// Refresh albums when the app is resumed
val lifecycleEvent = rememberLifecycleEvent()
@@ -71,10 +76,10 @@ class MainActivity : ComponentActivity() {
}
}
}
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
PaperizeTheme(settingsViewModel.state) {
Surface(tonalElevation = 5.dp) {
PaperizeApp(albumsViewModel, settingsViewModel, wallpaperScreenViewModel)
PaperizeApp(isFirstLaunch)
}
}
}
@@ -88,9 +93,7 @@ class MainActivity : ComponentActivity() {
fun rememberLifecycleEvent(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current): Lifecycle.Event {
var state by remember { mutableStateOf(Lifecycle.Event.ON_ANY) }
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
state = event
}
val observer = LifecycleEventObserver { _, event -> state = event }
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
@@ -1,31 +1,18 @@
package com.anthonyla.paperize.feature.wallpaper.presentation
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.PowerManager
import android.provider.Settings
import android.util.Log
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
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 com.anthonyla.paperize.data.Contact
import com.anthonyla.paperize.data.settings.SettingsDataStore
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
@@ -38,11 +25,16 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.Set
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen.WallpaperViewScreen
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsScreen
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.startup.StartupScreen
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.util.navigation.NavConstants.INITIAL_OFFSET
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavScreens
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 dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
@@ -51,9 +43,10 @@ import java.nio.charset.StandardCharsets
@Composable
fun PaperizeApp(
albumsViewModel: AlbumsViewModel,
settingsViewModel: SettingsViewModel,
wallpaperScreenViewModel: WallpaperScreenViewModel,
firstLaunch: Boolean,
albumsViewModel: AlbumsViewModel = hiltViewModel(),
settingsViewModel: SettingsViewModel = hiltViewModel(),
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
) {
val navController = rememberNavController()
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
@@ -62,30 +55,32 @@ fun PaperizeApp(
// React to albumState changes and change selectedAlbum's details to keep it from being stale
LaunchedEffect(albumState.value.albumsWithWallpapers) {
albumState.value.albumsWithWallpapers.forEach {
if (!it.album.initialized && (it.wallpapers.isNotEmpty() || it.folders.isNotEmpty())) {
albumsViewModel.onEvent(AlbumsEvent.InitializeAlbum(it))
}
else if (it.album.initialized && it.wallpapers.isEmpty() && it.folders.isEmpty()) {
albumState.value.albumsWithWallpapers.asSequence().forEach { albumWithWallpapers ->
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)
}
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(it))
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
}
}
selectedState.value.selectedAlbum?.let { selectedAlbum ->
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }
?.let { foundAlbum ->
val wallpapers: List<Wallpaper> = foundAlbum.wallpapers + foundAlbum.folders.flatMap { folder ->
folder.wallpapers.map { wallpaper ->
Wallpaper(
initialAlbumName = foundAlbum.album.initialAlbumName,
wallpaperUri = wallpaper,
key = wallpaper.hashCode() + foundAlbum.album.initialAlbumName.hashCode(),
)
val albumNameHashCode = foundAlbum.album.initialAlbumName.hashCode()
val wallpapers: List<Wallpaper> =
foundAlbum.wallpapers + foundAlbum.folders.flatMap { folder ->
folder.wallpapers.map { wallpaper ->
val wallpaperHashCode = wallpaper.hashCode()
Wallpaper(
initialAlbumName = foundAlbum.album.initialAlbumName,
wallpaperUri = wallpaper,
key = wallpaperHashCode + albumNameHashCode,
)
}
}
}
val wallpaperUriSet = wallpapers.map { it.wallpaperUri }.toSet()
val newSelectedAlbum = SelectedAlbum(
album = foundAlbum.album.copy(
@@ -93,7 +88,9 @@ fun PaperizeApp(
),
wallpapers = wallpapers
)
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
wallpaperScreenViewModel.onEvent(
WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum)
)
}
?: run {
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
@@ -102,28 +99,53 @@ fun PaperizeApp(
context.startForegroundService(it)
}
}
}
}
// Contact author popup with email
var toContact by rememberSaveable { mutableStateOf(false) }
if (toContact) {
Contact(LocalContext.current)
toContact = false
}
NavHost(
navController = navController,
startDestination = NavScreens.Home.route,
startDestination = if (firstLaunch) NavScreens.Startup.route else NavScreens.Home.route,
modifier = Modifier.navigationBarsPadding()
) {
// Navigate to the home screen with the navbar and top bar
composable(
route = NavScreens.Startup.route,
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() })
},
) {
StartupScreen(
onAgree = {
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
navController.navigate(NavScreens.Home.route)
}
)
}
composable(
route = NavScreens.Home.route,
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() })
},
) {
HomeScreen(
onSettingsClick = { navController.navigate(NavScreens.Settings.route) },
onContactClick = { toContact = true },
navigateToAddWallpaperScreen = {
navController.navigate("${NavScreens.AddEdit.route}/$it")
},
@@ -135,15 +157,34 @@ fun PaperizeApp(
val intent = Intent(context, WallpaperService::class.java).apply {
action = WallpaperService.Actions.START.toString()
putExtra("timeInMinutes", timeInMinutes)
putExtra("setLockWithHome", settingsViewModel.state.value.setLockWithHome)
}
context.startForegroundService(intent)
}
},
onStop = {
Intent(context, WallpaperService::class.java).also {
it.action = WallpaperService.Actions.STOP.toString()
context.startForegroundService(it)
}
},
)
}
// 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 })
arguments = listOf(navArgument("initialAlbumName") { 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("initialAlbumName").let {
if (it != null) {
@@ -169,7 +210,19 @@ fun PaperizeApp(
// 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 })
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) {
@@ -187,7 +240,19 @@ fun PaperizeApp(
navArgument("folderUri") { type = NavType.StringType },
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 folderUri = backStackEntry.arguments?.getString("folderUri")
val folderName = backStackEntry.arguments?.getString("folderName")
@@ -213,7 +278,19 @@ fun PaperizeApp(
route = NavScreens.AlbumView.route.plus("/{initialAlbumName}"),
arguments = listOf(
navArgument("initialAlbumName") { 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 initialAlbumName = backStackEntry.arguments?.getString("initialAlbumName")
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == initialAlbumName }
@@ -247,25 +324,17 @@ fun PaperizeApp(
composable(
route = NavScreens.Settings.route,
enterTransition = {
slideInHorizontally(
initialOffsetX = { fullWidth -> fullWidth },
)
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
},
exitTransition = {
slideOutHorizontally(
targetOffsetX = { fullWidth -> fullWidth },
)
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
},
popEnterTransition = {
slideInHorizontally(
initialOffsetX = { fullWidth -> fullWidth },
)
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
},
popExitTransition = {
slideOutHorizontally(
targetOffsetX = { fullWidth -> fullWidth },
)
}
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
},
) {
SettingsScreen(
settingsState = settingsViewModel.state,
@@ -162,7 +162,6 @@ fun AddAlbumSmallTopBar(
Icon(
imageVector = Icons.Outlined.Delete,
contentDescription = stringResource(R.string.select_all_images_for_deletion),
tint = Color.White.copy(alpha = 0.7f),
modifier = Modifier.padding(6.dp)
)
}
@@ -28,7 +28,6 @@ class AlbumsViewModel @Inject constructor (
application: Application,
private val repository: AlbumRepository
) : AndroidViewModel(application) {
var shouldNotBypassSplashScreen by mutableStateOf(true)
private val context: Context
get() = getApplication<Application>().applicationContext
private val _state = MutableStateFlow(AlbumsState())
@@ -41,7 +40,6 @@ class AlbumsViewModel @Inject constructor (
viewModelScope.launch {
updateAlbums()
refreshAlbums()
shouldNotBypassSplashScreen = false
}
}
@@ -53,7 +53,8 @@ fun WallpaperItem(
onActivateSelectionMode: (Boolean) -> Unit,
onItemSelection: () -> Unit,
onWallpaperViewClick: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
wallpaperDrawable : Bitmap? = null
) {
val context = LocalContext.current
val haptics = LocalHapticFeedback.current
@@ -66,7 +67,7 @@ fun WallpaperItem(
if (selected) 24.dp else 16.dp
}
val dimension = wallpaperUri.toUri().getImageDimensions(context)
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
val aspectRatio = (dimension.first.toFloat()/dimension.second.toFloat())
Box(
@@ -88,7 +89,7 @@ fun WallpaperItem(
)
) {
GlideImage(
imageModel = { wallpaperUri.toUri() },
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
imageOptions = ImageOptions(
contentScale = ContentScale.Crop,
alignment = Alignment.Center
@@ -130,7 +131,6 @@ fun WallpaperItem(
}
}
//https://stackoverflow.com/a/73214367
fun Uri.getImageDimensions(context: Context): Pair<Int, Int> {
val inputStream = context.contentResolver.openInputStream(this)!!
val exif = ExifInterface(inputStream)
@@ -132,7 +132,7 @@ fun AlbumViewTopBar(
IconButton(onClick = { menuExpanded = true }) {
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = stringResource(R.string.MoreVertIcon)
contentDescription = stringResource(R.string.more_options),
)
MaterialTheme(
shapes = MaterialTheme.shapes.copy(extraSmall = RoundedCornerShape(16.dp))
@@ -31,10 +31,9 @@ fun FolderViewScreen(
topBar = {
FolderViewTopBar(
title = folderName ?: "",
onBackClick = {
onBackClick()
},
)
) {
onBackClick()
}
},
content = {
LazyVerticalStaggeredGrid(
@@ -24,8 +24,7 @@ import com.anthonyla.paperize.R
@Composable
fun FolderViewTopBar(
title: String,
onBackClick: () -> Unit,
modifier: Modifier = Modifier
onBackClick: () -> Unit
) {
TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
@@ -6,10 +6,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SecondaryTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.TabRowDefaults
@@ -35,10 +33,10 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.Wa
@Composable
fun HomeScreen(
onSettingsClick: () -> Unit,
onContactClick: () -> Unit,
navigateToAddWallpaperScreen: (String) -> Unit,
onAlbumViewClick: (String) -> Unit,
onScheduleWallpaperChanger: (Int) -> Unit
onScheduleWallpaperChanger: (Int) -> Unit,
onStop: () -> Unit
) {
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
val pagerState = rememberPagerState { tabItems.size }
@@ -52,10 +50,9 @@ fun HomeScreen(
Scaffold (
topBar = {
HomeTopBar(
onSettingsClick = onSettingsClick,
onContactClick = onContactClick,
showSelectionModeAppBar = false,
selectionCount = 0,
onSettingsClick = onSettingsClick,
)
}
) { padding ->
@@ -102,7 +99,8 @@ fun HomeScreen(
HorizontalPager(state = pagerState, beyondBoundsPageCount = 1) { index ->
when(index) {
0 -> WallpaperScreen(
onScheduleWallpaperChanger = { onScheduleWallpaperChanger(it) }
onScheduleWallpaperChanger = { onScheduleWallpaperChanger(it) },
onStop = { onStop() }
)
1 -> LibraryScreen(
onAddNewAlbumClick = { addAlbumDialog = true },
@@ -5,16 +5,13 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.RadioButtonUnchecked
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -32,7 +29,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.DeleteImagesAlertDialog
@@ -45,54 +41,18 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.co
fun HomeTopBar (
showSelectionModeAppBar: Boolean,
selectionCount: Int,
modifier: Modifier = Modifier,
onSettingsClick: () -> Unit,
onContactClick: () -> Unit,
) {
CenterAlignedTopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
title = { if (!showSelectionModeAppBar) Text(stringResource(R.string.appname)) },
actions = {
if (!showSelectionModeAppBar) {
var menuExpanded by rememberSaveable { mutableStateOf(false) }
IconButton(onClick = { menuExpanded = true }) {
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = stringResource(R.string.MoreVertIcon)
)
MaterialTheme(
shapes = MaterialTheme.shapes.copy(extraSmall = RoundedCornerShape(16.dp))
) {
DropdownMenu(
expanded = menuExpanded,
onDismissRequest = { menuExpanded = false },
offset = DpOffset(0.dp, 5.dp),
) {
DropdownMenuItem(
text = { Text(text = stringResource(R.string.dropdownmenu_settings)) },
onClick = {
menuExpanded = false
onSettingsClick()
}
)
DropdownMenuItem(
text = { Text(stringResource(R.string.contact_button)) },
onClick = {
menuExpanded = false
onContactClick()
}
)
}
}
}
}
else {
if (showSelectionModeAppBar) {
var showAlertDialog by rememberSaveable { mutableStateOf(false) }
if (showAlertDialog) DeleteImagesAlertDialog (
onDismissRequest = { showAlertDialog = false },
onConfirmation = {
showAlertDialog = false
//deleteImagesOnClick()
}
)
IconButton(
@@ -117,27 +77,27 @@ fun HomeTopBar (
onClick = { }
) {
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
if (true) {
Icon(
imageVector = Icons.Default.CheckCircle,
contentDescription = stringResource(R.string.all_images_selected_for_deletion),
modifier = Modifier
.padding(4.dp)
.border(2.dp, bgColor, CircleShape)
.clip(CircleShape)
.background(bgColor)
)
} else {
Icon(
imageVector = Icons.Default.RadioButtonUnchecked,
contentDescription = stringResource(R.string.select_all_images_for_deletion),
tint = Color.White.copy(alpha = 0.7f),
modifier = Modifier.padding(6.dp)
)
}
Icon(
imageVector = Icons.Default.CheckCircle,
contentDescription = stringResource(R.string.all_images_selected_for_deletion),
modifier = Modifier
.padding(4.dp)
.border(2.dp, bgColor, CircleShape)
.clip(CircleShape)
.background(bgColor)
)
}
Text("$selectionCount selected")
}
} else {
IconButton(
onClick = { onSettingsClick() },
) {
Icon(
imageVector = Icons.Outlined.Settings,
contentDescription = stringResource(R.string.SettingsIcon),
)
}
}
}
)
@@ -4,7 +4,9 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
sealed class SettingsEvent {
data object RefreshUiState: SettingsEvent()
data object RefreshWallpaperState: SettingsEvent()
data object SetFirstLaunch: SettingsEvent()
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
data class SetWallpaperInterval(val interval: Int): SettingsEvent()
data class SetLockWithHome(val lockWithHome: Boolean): SettingsEvent()
}
@@ -2,8 +2,9 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
data class SettingsState (
val firstLaunch: Boolean = true,
val darkMode: Boolean? = null,
val dynamicTheming: Boolean = false,
val loaded: Boolean = false,
val interval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
val setLockWithHome: Boolean = false,
)
@@ -22,7 +22,6 @@ import javax.inject.Inject
class SettingsViewModel @Inject constructor (
private val settingsDataStoreImpl: SettingsDataStore
): ViewModel() {
var shouldNotBypassSplashScreen by mutableStateOf(true)
private val _state = MutableStateFlow(SettingsState())
val state = _state.stateIn(
viewModelScope,
@@ -30,31 +29,37 @@ class SettingsViewModel @Inject constructor (
)
private var currentGetJob: Job? = null
var setKeepOnScreenCondition: Boolean = true
init {
viewModelScope.launch {
currentGetJob?.cancel()
currentGetJob = async {
val darkMode = settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE)
val dynamicTheming = settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false
val wallpaperInterval = settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
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 }
_state.update { it.copy(
darkMode = darkMode,
dynamicTheming = dynamicTheming,
loaded = true,
interval = wallpaperInterval
) }
if (_state.value.loaded) {
shouldNotBypassSplashScreen = false
}
}
_state.update { it.copy(
darkMode = darkMode.await(),
dynamicTheming = dynamicTheming.await(),
interval = wallpaperInterval.await(),
setLockWithHome = setLockWithHome.await(),
firstLaunch = firstLaunch.await()
) }
setKeepOnScreenCondition = false
}
}
fun onEvent(event: SettingsEvent) {
when (event) {
is SettingsEvent.SetFirstLaunch -> {
viewModelScope.launch {
settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_LAUNCH, false)
_state.update { it.copy(
firstLaunch = false
) }
}
}
is SettingsEvent.RefreshUiState -> {
viewModelScope.launch {
currentGetJob?.cancel()
@@ -76,7 +81,9 @@ class SettingsViewModel @Inject constructor (
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) }
null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) }
}
refreshSettings()
_state.update { it.copy(
darkMode = event.darkMode
) }
}
}
is SettingsEvent.SetDynamicTheming -> {
@@ -85,13 +92,28 @@ class SettingsViewModel @Inject constructor (
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) }
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) }
}
refreshSettings()
_state.update { it.copy(
dynamicTheming = event.dynamicTheming
) }
}
}
is SettingsEvent.SetWallpaperInterval -> {
viewModelScope.launch {
settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval)
refreshSettings()
_state.update { it.copy(
interval = event.interval
) }
}
}
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) }
}
_state.update { it.copy(
setLockWithHome = event.lockWithHome
) }
}
}
is SettingsEvent.RefreshWallpaperState -> {
@@ -99,7 +121,8 @@ class SettingsViewModel @Inject constructor (
currentGetJob?.cancel()
currentGetJob = viewModelScope.launch {
_state.update { it.copy(
interval = settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
interval = settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
setLockWithHome = settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false
) }
}
}
@@ -0,0 +1,118 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.startup
import android.view.textclassifier.TextLinks.TextLink
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.sharp.CheckCircleOutline
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
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.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.anthonyla.paperize.R
@Composable
fun StartupScreen(
onAgree: () -> Unit
) {
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.onboarding_animation))
val progress by animateLottieCompositionAsState(
composition = composition,
iterations = LottieConstants.IterateForever,
)
var showToS by remember { mutableStateOf(false) }
Scaffold(
content = { it
Column (modifier = Modifier.padding(32.dp)) {
Spacer(modifier = Modifier.height(120.dp))
Text(text = stringResource(R.string.welcome), style = MaterialTheme.typography.headlineLarge)
Spacer(modifier = Modifier.height(16.dp))
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.fillMaxHeight(0.5f)
)
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = stringResource(R.string.agree),
modifier = Modifier.padding(PaddingValues(vertical = 16.dp))
)
Text(
text = "Please read and agree to the following terms of service and privacy policy to use the app.",
style = MaterialTheme.typography.bodySmall
)
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxWidth()
) {
Button(
onClick = { showToS = true },
modifier = Modifier.padding(PaddingValues(vertical = 16.dp)),
) {
Text(text = "Terms of Service and Privacy Policy", textAlign = TextAlign.Start)
}
}
}
},
floatingActionButton = {
ExtendedFloatingActionButton(
modifier = Modifier.padding(8.dp),
onClick = onAgree,
icon = {
Icon(
imageVector = Icons.Sharp.CheckCircleOutline,
contentDescription = stringResource(R.string.agree),
)
},
text = { Text(text = stringResource(R.string.agree)) },
)
}
)
if (showToS) {
AlertDialog(
onDismissRequest = { showToS = false },
title = {
Box(modifier = Modifier.fillMaxWidth()) {
Text(
text = "Terms of Service\nPrivacy Policy",
textAlign = TextAlign.Center,
modifier = Modifier.align(Alignment.Center)
)
}
},
text = { Text(text = "ToS, Privacy TBD") },
confirmButton = {
Button(onClick = { showToS = false }) {
Text("Dismiss")
}
}
)
}
}
@@ -1,34 +0,0 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.themes
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
@@ -1,17 +1,18 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import androidx.compose.foundation.layout.Column
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -20,75 +21,143 @@ 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.LocalContext
import androidx.compose.ui.unit.dp
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
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.album.AlbumsViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.AlbumBottomSheet
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentSelectedAlbum
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.SetLockScreenSwitch
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
import kotlinx.coroutines.launch
@Composable
fun WallpaperScreen(
albumsViewModel: AlbumsViewModel = hiltViewModel(),
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
onScheduleWallpaperChanger: (Int) -> Unit
settingsViewModel: SettingsViewModel = hiltViewModel(),
onScheduleWallpaperChanger: (Int) -> Unit,
onStop: () -> Unit
) {
val context = LocalContext.current
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
val scope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }
Scaffold(
snackbarHost = {
SnackbarHost(
hostState = snackbarHostState,
snackbar = { data ->
Snackbar(
snackbarData = data,
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp))
)
}
) },
modifier = Modifier.fillMaxSize(),
content = { padding ->
Column(
content = { it
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(8.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
CurrentSelectedAlbum(
selectedAlbum = selectedState.value.selectedAlbum,
onOpenBottomSheet = {
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) openBottomSheet = true
}
)
if (openBottomSheet) {
AlbumBottomSheet(
albums = albumState.value.albumsWithWallpapers,
currentSelectedAlbum = selectedState.value.selectedAlbum,
onDismiss = { openBottomSheet = false },
onSelect = { album ->
if (ContextCompat.checkSelfPermission(context, Manifest.permission.SET_WALLPAPER) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(context as Activity, arrayOf(Manifest.permission.SET_WALLPAPER), 0)
}
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.flatMap { folder ->
folder.wallpapers.map { wallpaper ->
Wallpaper(
initialAlbumName = album.album.initialAlbumName,
wallpaperUri = wallpaper,
key = wallpaper.hashCode() + album.album.initialAlbumName.hashCode(),
item {
CurrentSelectedAlbum(
selectedAlbum = selectedState.value.selectedAlbum,
onOpenBottomSheet = {
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) openBottomSheet = true
},
onStop = {
if (selectedState.value.selectedAlbum != null) {
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = "${selectedState.value.selectedAlbum?.album?.displayedAlbumName} has been unselected.",
actionLabel = "Dismiss",
duration = SnackbarDuration.Short
)
}
onStop()
}
val newSelectedAlbum = SelectedAlbum(
album = album.album.copy(
wallpapersInQueue = wallpapers.map { it.wallpaperUri }.shuffled()
),
wallpapers = wallpapers
)
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
onScheduleWallpaperChanger(1)
openBottomSheet = false
}
)
}
item {
AnimatedVisibility(
visible = selectedState.value.selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
TimeSliders(
timeInMinutes = settingsState.value.interval,
onTimeChange = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(totalMinutes))
onScheduleWallpaperChanger(totalMinutes)
}
)
}
AnimatedVisibility(
visible = selectedState.value.selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
if (selectedState.value.selectedAlbum != null) {
SetLockScreenSwitch(
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
checked = settingsState.value.setLockWithHome,
onCheckedChange = { isChecked ->
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
}
)
}
}
}
}
if (openBottomSheet) {
AlbumBottomSheet(
albums = albumState.value.albumsWithWallpapers,
currentSelectedAlbum = selectedState.value.selectedAlbum,
onDismiss = { openBottomSheet = false },
onSelect = { album ->
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.flatMap { folder ->
folder.wallpapers.map { wallpaper ->
Wallpaper(
initialAlbumName = album.album.initialAlbumName,
wallpaperUri = wallpaper,
key = wallpaper.hashCode() + album.album.initialAlbumName.hashCode(),
)
}
}
val newSelectedAlbum = SelectedAlbum(
album = album.album.copy(
wallpapersInQueue = wallpapers.map { it.wallpaperUri }.shuffled()
),
wallpapers = wallpapers
)
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
onScheduleWallpaperChanger(settingsState.value.interval)
openBottomSheet = false
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = "${album.album.displayedAlbumName} has been selected.",
actionLabel = "Dismiss",
duration = SnackbarDuration.Short
)
}
}
)
}
},
)
@@ -11,12 +11,14 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject
@HiltViewModel
@@ -24,8 +26,6 @@ class WallpaperScreenViewModel @Inject constructor (
application: Application,
private val repository: SelectedAlbumRepository,
) : AndroidViewModel(application) {
var shouldNotBypassSplashScreen by mutableStateOf(true)
private val context: Context get() = getApplication<Application>().applicationContext
private var _state = MutableStateFlow(WallpaperState())
val state = _state.stateIn(
viewModelScope,
@@ -35,7 +35,6 @@ class WallpaperScreenViewModel @Inject constructor (
init {
viewModelScope.launch {
refreshAlbums()
shouldNotBypassSplashScreen = false
}
}
@@ -43,8 +42,10 @@ class WallpaperScreenViewModel @Inject constructor (
when (event) {
is WallpaperEvent.UpdateSelectedAlbum -> {
viewModelScope.launch {
repository.deleteAll()
repository.upsertSelectedAlbum(event.selectedAlbum)
withContext(Dispatchers.IO) {
repository.deleteAll()
repository.upsertSelectedAlbum(event.selectedAlbum)
}
}
}
is WallpaperEvent.Refresh -> {
@@ -52,7 +53,12 @@ class WallpaperScreenViewModel @Inject constructor (
}
is WallpaperEvent.Reset -> {
viewModelScope.launch {
repository.deleteAll()
withContext(Dispatchers.IO) {
repository.deleteAll()
_state.update {
it.copy(selectedAlbum = null)
}
}
}
}
}
@@ -12,8 +12,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.filled.RadioButtonUnchecked
import androidx.compose.material.icons.filled.Stop
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -40,72 +42,77 @@ import com.skydoves.landscapist.glide.GlideImage
@Composable
fun CurrentSelectedAlbum(
selectedAlbum: SelectedAlbum?,
onOpenBottomSheet: () -> Unit
onOpenBottomSheet: () -> Unit,
onStop: () -> Unit
) {
Row(
ListItem(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
) {
ListItem(
modifier = Modifier
.clip(RoundedCornerShape(16.dp))
.clickable { onOpenBottomSheet() },
headlineContent = {
.padding(16.dp)
.clip(RoundedCornerShape(16.dp))
.clickable { onOpenBottomSheet() },
headlineContent = {
Text(
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
style = MaterialTheme.typography.titleMedium
) },
supportingContent = {
if (selectedAlbum != null) {
Text(
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
style = MaterialTheme.typography.titleMedium
) },
supportingContent = {
text = (selectedAlbum.wallpapers.size.toString()) + stringResource(R.string.wallpaper),
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis
)
} },
leadingContent = {
Box (
modifier = Modifier.size(60.dp)
) {
if (selectedAlbum != null) {
Text(
text = (selectedAlbum.wallpapers.size.toString()) + stringResource(R.string.wallpaper),
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis
GlideImage(
imageModel = { selectedAlbum.album.coverUri },
imageOptions = ImageOptions(
contentScale = ContentScale.FillBounds,
alignment = Alignment.Center,
),
requestBuilder = {
Glide
.with(LocalContext.current)
.asBitmap()
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
},
modifier = Modifier
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp))
)
} },
leadingContent = {
Box (
modifier = Modifier.size(60.dp)
) {
if (selectedAlbum != null) {
GlideImage(
imageModel = { selectedAlbum.album.coverUri },
imageOptions = ImageOptions(
contentScale = ContentScale.FillBounds,
alignment = Alignment.Center,
),
requestBuilder = {
Glide
.with(LocalContext.current)
.asBitmap()
.transition(BitmapTransitionOptions.withCrossFade())
},
loading = {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
},
modifier = Modifier
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp))
)
} else {
Image(
imageVector = Icons.Default.RadioButtonUnchecked,
contentDescription = stringResource(R.string.no_icon),
modifier = Modifier.fillMaxSize()
)
} else {
Image(
imageVector = Icons.Default.RadioButtonUnchecked,
contentDescription = stringResource(R.string.no_icon),
modifier = Modifier.fillMaxSize()
)
}
}
},
trailingContent = {
Row {
if (selectedAlbum != null) {
IconButton(onClick = { onStop() }) {
Icon(imageVector = Icons.Default.Stop, contentDescription = stringResource(R.string.stop_the_album))
}
}
},
trailingContent = {
Icon(
contentDescription = stringResource(R.string.click_to_select_a_different_album),
imageVector = Icons.Filled.ArrowDropDown,
)
},
tonalElevation = 5.dp
)
}
IconButton(onClick = { onOpenBottomSheet() }) {
Icon(
contentDescription = stringResource(R.string.click_to_select_a_different_album),
imageVector = Icons.Filled.ArrowDropDown,
)
}
}
},
tonalElevation = 5.dp
)
}
@@ -0,0 +1,100 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
@Composable
fun SetLockScreenSwitch(
albumUri : String?,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit
) {
Surface(
tonalElevation = 5.dp,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.clip(RoundedCornerShape(16.dp))
) {
Column (horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
Row {
Text(
text = "Set as lock screen",
modifier = Modifier.padding(16.dp)
)
Switch(
checked = checked,
onCheckedChange = onCheckedChange
)
}
AnimatedVisibility(
visible = checked,
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
exit = shrinkVertically(animationSpec = tween(durationMillis = 500, easing = LinearOutSlowInEasing))
) {
Row(Modifier.fillMaxWidth()) {
Column(
Modifier
.weight(1f)
.padding(4.dp),
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
) {
Text(text = "Lock screen")
if (albumUri != null) {
WallpaperItem(
wallpaperUri = albumUri,
itemSelected = false,
selectionMode = false,
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {},
modifier = Modifier.padding(4.dp)
)
}
}
Column(
Modifier
.weight(1f)
.padding(4.dp),
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
) {
Text(text = "Home screen")
if (albumUri != null) {
WallpaperItem(
wallpaperUri = albumUri,
itemSelected = false,
selectionMode = false,
onActivateSelectionMode = {},
onItemSelection = {},
onWallpaperViewClick = {},
modifier = Modifier.padding(4.dp)
)
}
}
}
}
}
}
}
@@ -0,0 +1,136 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
import android.view.HapticFeedbackConstants
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Slider
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@Composable
fun TimeSliders(
onTimeChange: (Int, Int, Int) -> Unit,
timeInMinutes: Int
) {
val view = LocalView.current
var days by rememberSaveable { mutableFloatStateOf((timeInMinutes / (24 * 60)).toFloat()) }
var hours by rememberSaveable { mutableFloatStateOf(((timeInMinutes % (24 * 60)) / 60).toFloat()) }
var minutes by rememberSaveable { mutableFloatStateOf((timeInMinutes % 60).toFloat()) }
val scope = rememberCoroutineScope()
var job by remember { mutableStateOf<Job?>(null) }
Surface(
tonalElevation = 5.dp,
modifier = Modifier
.padding(16.dp)
.clip(RoundedCornerShape(16.dp))
) {
Column {
val totalMinutes = (days.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
val displayDays = totalMinutes / (24 * 60)
val displayHours = (totalMinutes % (24 * 60)) / 60
val displayMinutes = totalMinutes % 60
val formattedDays = when {
displayDays > 1 -> "$displayDays days"
displayDays == 1 -> "$displayDays day"
else -> ""
}
val formattedHours = when {
displayHours > 1 -> "$displayHours hours"
displayHours == 1 -> "$displayHours hour"
else -> ""
}
val formattedMinutes = when {
displayMinutes > 1 -> "$displayMinutes minutes"
displayMinutes == 1 -> "$displayMinutes minute"
else -> ""
}
val formattedTime = "Interval | ${listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")}"
Text(
text = formattedTime,
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp, vertical = 12.dp))
)
Slider(
value = days,
onValueChange = { newDays ->
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
days = newDays
val totalMinutes = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
if (totalMinutes < 15) {
minutes = 15f - (hours.toInt() * 60)
}
job?.cancel()
job = scope.launch {
delay(500)
onTimeChange(newDays.toInt(), hours.toInt(), minutes.toInt())
}
},
valueRange = 0f..30f,
steps = 30,
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
)
Slider(
value = hours,
onValueChange = { newHours ->
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
hours = newHours
val totalMinutes = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
if (totalMinutes < 15) {
minutes = 15f - (newHours.toInt() * 60)
}
job?.cancel()
job = scope.launch {
delay(500)
onTimeChange(days.toInt(), newHours.toInt(), minutes.toInt())
}
},
valueRange = 0f..24f,
steps = 24,
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
)
Slider(
value = minutes,
onValueChange = { newMinutes ->
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
minutes = if (days.toInt() == 0 && hours.toInt() == 0 && newMinutes < 15) {
15f
} else {
newMinutes
}
job?.cancel()
job = scope.launch {
delay(500)
onTimeChange(days.toInt(), hours.toInt(), minutes.toInt())
}
},
valueRange = 0f..60f,
steps = 60,
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
)
}
}
}
@@ -0,0 +1,7 @@
package com.anthonyla.paperize.feature.wallpaper.util.navigation
object NavConstants {
const val NAVIGATION_TIME: Int = 300
const val INITIAL_OFFSET = 0.15f
const val OFFSET_LIMIT = 0.4f
}
@@ -6,10 +6,12 @@ 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.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.Settings
import androidx.compose.material.icons.outlined.Start
import androidx.compose.ui.graphics.vector.ImageVector
import com.anthonyla.paperize.R
@@ -20,6 +22,7 @@ sealed class NavScreens(val route: String, @StringRes val resourceId: Int, val u
/**
* Home screen that the user lands on initially
*/
object Startup : NavScreens("startup_screen", R.string.startup, Icons.Outlined.Start, Icons.Filled.Start)
object Home : NavScreens("home_screen", R.string.home_screen, Icons.Outlined.Image, Icons.Filled.Image)
/**
@@ -0,0 +1,55 @@
package com.anthonyla.paperize.feature.wallpaper.util.navigation
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.FastOutLinearInEasing
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavConstants.NAVIGATION_TIME
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavConstants.OFFSET_LIMIT
fun sharedXTransitionIn(
initial: (fullWidth: Int) -> Int,
durationMillis: Int = NAVIGATION_TIME,
): EnterTransition {
val outgoingDuration = (durationMillis * OFFSET_LIMIT).toInt()
val incomingDuration = durationMillis - outgoingDuration
return slideInHorizontally(
animationSpec = tween(
durationMillis = durationMillis,
easing = FastOutSlowInEasing
), initialOffsetX = initial
) + fadeIn(
animationSpec = tween(
durationMillis = incomingDuration,
delayMillis = outgoingDuration,
easing = LinearOutSlowInEasing
)
)
}
fun sharedXTransitionOut(
target: (fullWidth: Int) -> Int,
durationMillis: Int = NAVIGATION_TIME,
): ExitTransition {
val outgoingDuration = (durationMillis * OFFSET_LIMIT).toInt()
return slideOutHorizontally(
animationSpec = tween(
durationMillis = durationMillis,
easing = FastOutSlowInEasing
), targetOffsetX = target
) + fadeOut(
animationSpec = tween(
durationMillis = outgoingDuration,
delayMillis = 0,
easing = FastOutLinearInEasing
)
)
}
@@ -18,8 +18,12 @@ class WallpaperBootReceiver : BroadcastReceiver() {
Log.d("PaperizeWallpaperChanger", "Boot completed")
val serviceIntent = Intent(context, WallpaperService::class.java)
serviceIntent.action = WallpaperService.Actions.START.toString()
val timeInMinutes = runBlocking { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
serviceIntent.putExtra("timeInMinutes", timeInMinutes)
runBlocking {
val timeInMinutes = settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
val setLockWithHome = settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false
serviceIntent.putExtra("timeInMinutes", timeInMinutes)
serviceIntent.putExtra("setLockWithHome", setLockWithHome)
}
context.startForegroundService(serviceIntent);
}
}
@@ -34,6 +34,7 @@ class WallpaperService: Service() {
private val handler = Handler(Looper.getMainLooper())
private lateinit var runnableCode: Runnable
private var timeInMinutes: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
private var setLockWithHome: Boolean = false
companion object {
var isRunning = false
@@ -56,7 +57,6 @@ class WallpaperService: Service() {
isRunning = true
runnableCode = object : Runnable {
override fun run() {
Log.d("PaperizeWallpaperChanger", "Scheduled in: $timeInMinutes")
val self = this
CoroutineScope(Dispatchers.IO).launch {
try {
@@ -75,14 +75,16 @@ class WallpaperService: Service() {
* Start the service and schedule the wallpaper change
*/
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
isRunning = true
handler.removeCallbacks(runnableCode)
when(intent?.action) {
Actions.START.toString() -> {
timeInMinutes = intent.getIntExtra("timeInMinutes", 1)
isRunning = true
timeInMinutes = intent.getIntExtra("timeInMinutes", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
setLockWithHome = intent.getBooleanExtra("setLockWithHome", false)
Log.d("PaperizeWallpaperChanger", "Service started with interval $timeInMinutes minutes")
// Schedule the next wallpaper change
runnableCode = object : Runnable {
override fun run() {
Log.d("PaperizeWallpaperChanger", "Scheduled in: $timeInMinutes")
val self = this
CoroutineScope(Dispatchers.IO).launch {
try {
@@ -98,7 +100,7 @@ class WallpaperService: Service() {
handler.post(runnableCode)
}
Actions.STOP.toString() -> {
handler.removeCallbacks(runnableCode)
isRunning = false
stopSelf()
}
}
@@ -108,7 +110,6 @@ class WallpaperService: Service() {
/**
* Clean up the service when it is destroyed
*/
override fun onDestroy() {
Log.d("PaperizeWallpaperChanger", "Service destroyed")
super.onDestroy()
@@ -116,29 +117,14 @@ class WallpaperService: Service() {
handler.removeCallbacks(runnableCode)
}
/**
* Restart the service if it is removed
override fun onTaskRemoved(rootIntent: Intent?) {
Log.d("PaperizeWallpaperChanger", "Service removed by swipe")
isRunning = false
handler.removeCallbacks(runnableCode)
val restartServiceIntent = Intent(applicationContext, this::class.java).apply {
action = Actions.START.toString()
putExtra("timeInMinutes", timeInMinutes)
}
restartServiceIntent.setPackage(packageName)
applicationContext.startForegroundService(restartServiceIntent)
super.onTaskRemoved(rootIntent)
} */
/**
* Creates a notification for the wallpaper service
*/
private fun createNotification(current: Int = 0, total: Int = 0): Notification {
return NotificationCompat.Builder(this, "wallpaper_service_channel")
.setContentTitle("Paperize")
.setContentText("Changing wallpaper... Album: $current/$total")
.setContentText("Rotation: $current/$total wallpapers\nInterval: ${formatTime(timeInMinutes)}")
.setSmallIcon(R.drawable.ic_launcher_foreground)
.build()
}
@@ -155,7 +141,7 @@ class WallpaperService: Service() {
notificationManager.notify(1, notification)
var wallpaper = it.album.wallpapersInQueue.firstOrNull()
if (wallpaper != null) {
setWallpaper(context, wallpaper.toUri())
setWallpaper(context, wallpaper.toUri(), setLockWithHome)
repository.upsertSelectedAlbum(
it.copy(
album = it.album.copy(
@@ -168,7 +154,7 @@ class WallpaperService: Service() {
val newWallpaperInQueue = it.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpaperInQueue.firstOrNull()
if (wallpaper != null) {
setWallpaper(context, wallpaper.toUri())
setWallpaper(context, wallpaper.toUri(), setLockWithHome)
repository.upsertSelectedAlbum(
it.copy(
album = it.album.copy(
@@ -184,7 +170,7 @@ class WallpaperService: Service() {
/**
* Sets the wallpaper to the given uri
*/
private fun setWallpaper(context: Context, wallpaper: Uri) {
private fun setWallpaper(context: Context, wallpaper: Uri, setLockWithHome: Boolean) {
val wallpaperManager = WallpaperManager.getInstance(context)
try {
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@@ -200,9 +186,41 @@ class WallpaperService: Service() {
BitmapFactory.decodeStream(inputStream)
}
}
bitmap?.let { image -> wallpaperManager.setBitmap(image) }
bitmap?.let {
image -> wallpaperManager.setBitmap(image, null, true, when (setLockWithHome) {
true -> WallpaperManager.FLAG_LOCK or WallpaperManager.FLAG_SYSTEM
false -> WallpaperManager.FLAG_SYSTEM
})
}
} catch (e: IOException) {
Log.e("PaperizeWallpaperChanger", "Error changing wallpaper", e)
}
}
/**
* Formats the time in minutes to a human readable format
*/
private fun formatTime(timeInMinutes: Int): String {
val days = timeInMinutes / (24 * 60)
val hours = (timeInMinutes % (24 * 60)) / 60
val minutes = timeInMinutes % 60
val formattedDays = when {
days > 1 -> "$days days"
days == 1 -> "$days day"
else -> ""
}
val formattedHours = when {
hours > 1 -> "$hours hours"
hours == 1 -> "$hours hour"
else -> ""
}
val formattedMinutes = when {
minutes > 1 -> "$minutes minutes"
minutes == 1 -> "$minutes minute"
else -> ""
}
return listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")
}
}
@@ -0,0 +1 @@
{"v":"4.8.0","meta":{"g":"LottieFiles AE 3.0.2","a":"","k":"","d":"","tc":""},"fr":30,"ip":0,"op":150,"w":1080,"h":1080,"nm":"Panda","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Mouth","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[576.5,451,0],"ix":2},"a":{"a":0,"k":[540,540,0],"ix":1},"s":{"a":0,"k":[10,10,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.612,-33.427],[78.825,-1.443],[0.612,33.427],[-78.826,1.443]],"o":[[0.612,33.427],[-78.825,1.443],[-0.612,-33.427],[78.825,-1.443]],"v":[[142.726,-15.577],[1.107,47.56],[-142.725,-10.352],[-0.568,-44.044]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0,0,0.447000002394,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":10,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[562.476,311.08],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.612,-33.427],[78.825,-1.443],[0.612,33.427],[-78.826,1.443]],"o":[[0.612,33.427],[-78.825,1.443],[-0.612,-33.427],[78.825,-1.443]],"v":[[142.726,-16.933],[1.108,46.204],[-142.725,-11.708],[-0.568,-45.401]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[562.476,312.436],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":4,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-2.337,-127.655],[213.468,-3.907],[2.337,127.655],[-213.468,3.908]],"o":[[2.336,127.655],[-213.468,3.907],[-2.336,-127.656],[213.468,-3.906]],"v":[[386.518,-57.234],[4.23,180.982],[-386.518,-43.084],[-2.173,-168.854]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0.447000002394,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[548.678,372.24],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":4,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[8.143,-184.649],[67.328,181.885],[-67.327,184.649],[-32.396,-182.228]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0.447000002394,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[556.96,575.478],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":4,"cix":2,"bm":0,"ix":4,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-11.145,-22.834],[-14.496,-17.449],[-16.555,-8.521],[-18.492,0.646],[-34.81,29.713],[-13.94,39.047],[0,0],[0,0],[-34.908,-29.287],[-37.106,-0.95],[-16.923,8.678],[-14.627,17.975],[-7.044,10.053],[-5.278,11.94],[-9.691,25.604],[0,0],[-18.418,-6.97],[1.593,-15.678],[8.711,-30.416],[18.067,-29.156],[32.039,-21.311],[38.691,-1.645],[33.625,12.282],[27.202,20.837],[25.74,68.431],[0,0],[53.122,-43.206],[33.568,-12.95],[38.863,1.14],[32.424,20.694],[18.672,28.95],[9.487,30.328],[5.091,30.115],[-24.383,4.122],[-6.938,-20.45]],"o":[[8.645,25.382],[10.844,23.082],[14.447,17.508],[16.612,8.473],[36.869,-1.06],[34.719,-29.676],[0,0],[0,0],[14.406,38.995],[35.267,29.092],[18.614,0.756],[16.702,-8.818],[7.542,-8.684],[6.161,-10.867],[11.939,-23.002],[0,0],[6.97,-18.42],[15.444,5.845],[-3.065,30.123],[-8.481,30.233],[-17.674,29.055],[-31.599,21.348],[-38.723,2.041],[-33.845,-12.212],[-54.2,-42.043],[0,0],[-24.318,69.064],[-26.761,21.384],[-33.322,13.072],[-38.83,-0.531],[-32.693,-20.753],[-18.973,-28.974],[-10.451,-30.213],[-4.127,-24.386],[21.972,-3.716],[0,0]],"v":[[-413.548,-82.634],[-384.851,-9.34],[-347.091,52.549],[-300.343,92.501],[-248.243,104.251],[-134.703,53.706],[-57.64,-54.76],[5.017,-230.254],[69.431,-55.873],[148.521,51.058],[262.821,100.478],[315.Line truncated
+6 -1
View File
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">Paperize</string>
<string name="MoreVertIcon">Options</string>
<string name="SettingsIcon">Options</string>
<string name="dropdownmenu_settings">Settings</string>
<string name="home_screen">Home</string>
<string name="wallpaper_screen">Wallpaper</string>
@@ -36,4 +36,9 @@
<string name="no_album_selected">No album selected</string>
<string name="wallpaper">" wallpaper"</string>
<string name="currently_selected_album">Currently selected album</string>
<string name="stop_the_album">Stop the album</string>
<string name="more_options">More options</string>
<string name="startup">Startup</string>
<string name="agree">Agree</string>
<string name="welcome">Welcome</string>
</resources>