Added play-store link

Fixed settings page appearing wrong on Pixel devices
Fixed bottom sheet on SDK less than 28
Updated project to Kotlin compiler 2.0
Updated AGP to 8.4.1
This commit is contained in:
Anthonyy232 committed 2024-05-26 20:45:49 -07:00
1 parent 25717d83fd
commit 46d1284550
26 files changed
+461 -468

No files matched your search

+1
View File
@@ -25,6 +25,7 @@
android:theme="@style/Theme.Paperize" tools:targetApi="tiramisu">
<activity
android:name=".feature.wallpaper.presentation.MainActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true"
android:theme="@style/Theme.Paperize">
<intent-filter>
@@ -6,20 +6,26 @@ import android.app.Activity
import android.app.ActivityManager
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.animation.AccelerateInterpolator
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.compose.material3.Surface
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.animation.doOnEnd
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -44,13 +50,18 @@ class MainActivity : ComponentActivity() {
private val settingsViewModel: SettingsViewModel by viewModels()
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
private val context = this
private var topInset = 0.dp
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (ContextCompat.checkSelfPermission(context, Manifest.permission.SET_WALLPAPER) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(context as Activity, arrayOf(Manifest.permission.SET_WALLPAPER), 0)
}
enableEdgeToEdge()
super.onCreate(savedInstanceState)
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT),
navigationBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT)
)
WindowCompat.setDecorFitsSystemWindows(window, false)
val splashScreen = installSplashScreen()
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
@@ -107,12 +118,17 @@ class MainActivity : ComponentActivity() {
}
}
}
PaperizeTheme(settingsState.value.darkMode, settingsState.value.dynamicTheming) {
Surface(tonalElevation = 5.dp) {
PaperizeApp(isFirstLaunch)
PaperizeApp(isFirstLaunch, topInset)
}
}
}
}
@RequiresApi(Build.VERSION_CODES.P)
override fun onAttachedToWindow() {
super.onAttachedToWindow()
topInset = window.decorView.rootWindowInsets.stableInsetTop.dp
}
}
@@ -13,6 +13,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.Dp
import androidx.core.content.ContextCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -69,6 +70,7 @@ import java.nio.charset.StandardCharsets
@Composable
fun PaperizeApp(
firstLaunch: Boolean,
topInsets: Dp,
albumsViewModel: AlbumsViewModel = hiltViewModel(),
settingsViewModel: SettingsViewModel = hiltViewModel(),
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
@@ -550,7 +552,7 @@ fun PaperizeApp(
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
} else { null }
}
) {backStackEntry ->
) { backStackEntry ->
val addEdit: AddEdit = backStackEntry.toRoute()
AddAlbumScreen(
initialAlbumName = addEdit.wallpaper,
@@ -560,12 +562,6 @@ fun PaperizeApp(
navController.navigate(WallpaperView(it))
},
onShowFolderView = { folderName, wallpapers ->
/*navController.navigate(
FolderView(
folderName,
wallpapers
)
)*/
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
}
@@ -601,42 +597,6 @@ fun PaperizeApp(
animate = settingsState.value.animate
)
}
// Navigate to folder view screen to view wallpapers in a particular folder
/*composable<FolderView> (
enterTransition = {
if (settingsState.value.animate) {
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
} else { null }
},
exitTransition = {
if (settingsState.value.animate) {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
} else { null }
},
popEnterTransition = {
if (settingsState.value.animate) {
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
} else { null }
},
popExitTransition = {
if (settingsState.value.animate) {
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
} else { null }
}
) { backStackEntry ->
val folderView: FolderView = backStackEntry.toRoute()
if (folderView.wallpapers.isNotEmpty()) {
FolderViewScreen(
folderName = folderView.folderName,
wallpapers = folderView.wallpapers,
onBackClick = { navController.navigateUp() },
onShowWallpaperView = {
navController.navigate(WallpaperView(it))
},
animate = settingsState.value.animate
)
} else { navController.navigateUp() }
}*/
composable(
route = NavScreens.FolderView.route.plus("/{folderName}/{wallpapers}"),
arguments = listOf(
@@ -714,18 +674,12 @@ fun PaperizeApp(
navController.navigate(WallpaperView(it))
},
onShowFolderView = { folderName, wallpapers ->
/*navController.navigate(
com.anthonyla.paperize.feature.wallpaper.util.navigation.FolderView(
folderName,
wallpapers
)
)*/
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
},
onDeleteAlbum = {
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpaper))
navController.navigateUp()
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpaper))
},
onTitleChange = { title, originalAlbumWithWallpaper ->
albumsViewModel.onEvent(AlbumsEvent.ChangeAlbumName(title, originalAlbumWithWallpaper))
@@ -761,6 +715,7 @@ fun PaperizeApp(
) {
SettingsScreen(
settingsState = settingsViewModel.state,
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
onDarkModeClick = {
settingsViewModel.onEvent(SettingsEvent.SetDarkMode(it))
@@ -821,6 +776,7 @@ fun PaperizeApp(
}
) {
PrivacyScreen(
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
)
}
@@ -848,6 +804,7 @@ fun PaperizeApp(
}
) {
LicensesScreen(
topInsets = topInsets,
onBackClick = { navController.navigateUp() },
)
}
@@ -5,14 +5,15 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.data.rememberCurrentOffset
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseScrollableSettings
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseSmallTopAppBar
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseTitle
@Composable
fun LicensesScreen(
topInsets: Dp,
onBackClick: () -> Unit,
) {
val lazyListState = rememberLazyListState()
@@ -25,14 +26,15 @@ fun LicensesScreen(
LicenseScrollableSettings(
largeTopAppBarHeightPx = largeTopAppBarHeight,
lazyListState = lazyListState,
offset = offset
offset = offset,
onBackClick = onBackClick
)
LicenseSmallTopAppBar(onBackClick = onBackClick)
LicenseTitle(
largeTopAppBarHeight = largeTopAppBarHeight,
smallTopAppBarHeight = smallTopAppBarHeight,
paddingMedium = paddingMedium,
offset = offset
offset = offset,
topInset = topInsets
)
}
}
@@ -6,50 +6,85 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
import com.mikepenz.aboutlibraries.ui.compose.m3.LibraryDefaults
/**
* Scrollable license screen to display open source licenses
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LicenseScrollableSettings(
largeTopAppBarHeightPx: Dp,
lazyListState: LazyListState,
offset: State<Int>
offset: State<Int>,
onBackClick: () -> Unit
) {
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp),
) {
val offsetInDp = offset.value.toFloat() / 2f.dp.value
val newHeight = largeTopAppBarHeightPx - offsetInDp.dp
Spacer(Modifier.height(newHeight))
Spacer(modifier = Modifier.height(16.dp))
LibrariesContainer(
modifier = Modifier.fillMaxSize(),
lazyListState = lazyListState,
showVersion = false,
colors = LibraryDefaults.libraryColors(
backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
contentColor = MaterialTheme.colorScheme.onSurface,
badgeBackgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
badgeContentColor = MaterialTheme.colorScheme.primary,
dialogConfirmButtonColor = MaterialTheme.colorScheme.onSurface
Scaffold (
topBar = {
TopAppBar(
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
)
}
) { it
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp),
) {
val offsetInDp = offset.value.toFloat() / 2f.dp.value
val newHeight = largeTopAppBarHeightPx - offsetInDp.dp
Spacer(Modifier.height(newHeight))
Spacer(modifier = Modifier.height(16.dp))
LibrariesContainer(
modifier = Modifier.fillMaxSize(),
lazyListState = lazyListState,
showVersion = false,
colors = LibraryDefaults.libraryColors(
backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
contentColor = MaterialTheme.colorScheme.onSurface,
badgeBackgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
badgeContentColor = MaterialTheme.colorScheme.primary,
dialogConfirmButtonColor = MaterialTheme.colorScheme.onSurface
)
)
}
}
}
@@ -1,45 +0,0 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
/**
* Small top app bar for license screen to replace [LicenseLargeTopAppBar] when scrolling down
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LicenseSmallTopAppBar(onBackClick: () -> Unit) {
Surface {
TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
}
}
@@ -27,7 +27,8 @@ fun LicenseTitle(
smallTopAppBarHeight: Dp,
paddingMedium: Dp,
modifier: Modifier = Modifier,
offset: State<Int>
offset: State<Int>,
topInset: Dp,
) {
val titlePaddingStart = 16.dp
val titlePaddingEnd = 64.dp
@@ -36,6 +37,9 @@ fun LicenseTitle(
var titleHeightPx by remember { mutableFloatStateOf(0f) }
var titleWidthPx by remember { mutableFloatStateOf(0f) }
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
Text(
text = stringResource(R.string.licenses),
style = MaterialTheme.typography.headlineMedium,
@@ -55,7 +59,7 @@ fun LicenseTitle(
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
val titleYFirstInterpolatedPoint = lerp(
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
largeTopAppBarHeight / 2,
collapseFraction
)
@@ -68,7 +72,7 @@ fun LicenseTitle(
val titleYSecondInterpolatedPoint = lerp(
largeTopAppBarHeight / 2,
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
collapseFraction
)
@@ -6,13 +6,14 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacyScrollableSettings
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacySmallTopAppBar
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacyTitle
@Composable
fun PrivacyScreen(
topInsets: Dp,
onBackClick: () -> Unit,
) {
val scroll: ScrollState = rememberScrollState(0)
@@ -24,13 +25,14 @@ fun PrivacyScreen(
PrivacyScrollableSettings(
largeTopAppBarHeightPx = largeTopAppBarHeight,
scroll = scroll,
onBackClick = onBackClick
)
PrivacySmallTopAppBar(onBackClick = onBackClick)
PrivacyTitle(
scroll = scroll,
largeTopAppBarHeight = largeTopAppBarHeight,
smallTopAppBarHeight = smallTopAppBarHeight,
paddingMedium = paddingMedium
paddingMedium = paddingMedium,
topInset = topInsets
)
}
}
@@ -7,12 +7,22 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -21,22 +31,45 @@ import com.anthonyla.paperize.R
/**
* Scrollable privacy screen to display privacy note
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PrivacyScrollableSettings(
largeTopAppBarHeightPx: Dp,
scroll: ScrollState,
onBackClick: () -> Unit
) {
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.fillMaxSize()
.verticalScroll(scroll)
.padding(horizontal = 24.dp),
) {
Spacer(Modifier.height(largeTopAppBarHeightPx))
Spacer(modifier = Modifier.height(16.dp))
PrivacyNoticeText()
Scaffold(
topBar = {
TopAppBar(
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
}
) { it
Column(
horizontalAlignment = Alignment.Start,
verticalArrangement = Arrangement.Top,
modifier = Modifier
.fillMaxSize()
.verticalScroll(scroll)
.padding(horizontal = 24.dp),
) {
Spacer(Modifier.height(largeTopAppBarHeightPx))
Spacer(modifier = Modifier.height(16.dp))
PrivacyNoticeText()
}
}
}
@@ -1,45 +0,0 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
/**
* Small top app bar for privacy screen to replace [PrivacyLargeTopAppBar] when scrolling down
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PrivacySmallTopAppBar(onBackClick: () -> Unit) {
Surface {
TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
}
}
@@ -27,7 +27,8 @@ fun PrivacyTitle(
smallTopAppBarHeight: Dp,
paddingMedium: Dp,
scroll: ScrollState,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
topInset: Dp,
) {
val titlePaddingStart = 16.dp
val titlePaddingEnd = 64.dp
@@ -36,6 +37,9 @@ fun PrivacyTitle(
var titleHeightPx by remember { mutableFloatStateOf(0f) }
var titleWidthPx by remember { mutableFloatStateOf(0f) }
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
Text(
text = stringResource(id = R.string.privacy_policy),
style = MaterialTheme.typography.headlineMedium,
@@ -55,7 +59,7 @@ fun PrivacyTitle(
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
val titleYFirstInterpolatedPoint = lerp(
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
largeTopAppBarHeight / 2,
collapseFraction
)
@@ -68,7 +72,7 @@ fun PrivacyTitle(
val titleYSecondInterpolatedPoint = lerp(
largeTopAppBarHeight / 2,
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
collapseFraction
)
@@ -1,20 +1,28 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
import android.content.res.Resources
import android.util.Log
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.lerp
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsScrollableSettings
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsSmallTopAppBar
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsTitle
import kotlinx.coroutines.flow.StateFlow
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(
settingsState: StateFlow<SettingsState>,
topInsets: Dp,
onBackClick: () -> Unit,
onDarkModeClick: (Boolean?) -> Unit,
onDynamicThemingClick: (Boolean) -> Unit,
@@ -24,8 +32,8 @@ fun SettingsScreen(
onResetClick: () -> Unit
) {
val scroll: ScrollState = rememberScrollState(0)
val largeTopAppBarHeight = 152.dp
val smallTopAppBarHeight = 64.dp
val largeTopAppBarHeight = TopAppBarDefaults.LargeAppBarExpandedHeight
val smallTopAppBarHeight = TopAppBarDefaults.LargeAppBarCollapsedHeight
val paddingMedium = 16.dp
Box(modifier = Modifier.fillMaxSize()) {
@@ -38,14 +46,15 @@ fun SettingsScreen(
onAnimateClick = onAnimateClick,
onPrivacyClick = onPrivacyClick,
onLicenseClick = onLicenseClick,
onResetClick = onResetClick
onResetClick = onResetClick,
onBackClick = onBackClick,
)
SettingsSmallTopAppBar(onBackClick = onBackClick)
SettingsTitle(
scroll = scroll,
largeTopAppBarHeight = largeTopAppBarHeight,
smallTopAppBarHeight = smallTopAppBarHeight,
paddingMedium = paddingMedium
paddingMedium = paddingMedium,
topInset = topInsets
)
}
}
@@ -1,13 +1,11 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
import android.icu.util.UniversalTimeScale.toLong
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.anthonyla.paperize.core.ScalingConstants
import com.anthonyla.paperize.core.SettingsConstants
import com.anthonyla.paperize.data.settings.SettingsDataStore
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
@@ -4,6 +4,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -10,13 +10,22 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
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.material3.Surface
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -26,6 +35,7 @@ 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.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
@@ -40,6 +50,7 @@ import kotlinx.coroutines.launch
/**
* Scrollable settings screen to wrap all settings components
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScrollableSettings(
settingsState: StateFlow<SettingsState>,
@@ -51,6 +62,7 @@ fun SettingsScrollableSettings(
onPrivacyClick: () -> Unit,
onLicenseClick: () -> Unit,
onResetClick: () -> Unit,
onBackClick: () -> Unit
) {
val state = settingsState.collectAsStateWithLifecycle()
val context = LocalContext.current
@@ -64,7 +76,7 @@ fun SettingsScrollableSettings(
}
val githubLink = "https://github.com/Anthonyy232/Paperize"
val playstoreLink = ""
val playstoreLink = "https://play.google.com/store/apps/details?id=com.anthonyla.paperize"
val fdroidLink = ""
val translateLink = "https://crowdin.com/project/paperize/invite?h=d8d7a7513d2beb0c96ba9b2a5f85473e2084922"
@@ -80,6 +92,24 @@ fun SettingsScrollableSettings(
)
}
) },
topBar = {
TopAppBar(
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
},
modifier = Modifier.fillMaxSize(),
content = { it
Column(
@@ -1,45 +0,0 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.anthonyla.paperize.R
/**
* Small top app bar for settings screen to replace [SettingsLargeTopAppBar] when scrolling down
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsSmallTopAppBar(onBackClick: () -> Unit) {
Surface {
TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
title = {},
navigationIcon = {
IconButton(
onClick = onBackClick,
modifier = Modifier
.padding(16.dp)
.size(24.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.home_screen)
)
}
}
)
}
}
@@ -1,8 +1,19 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
import android.graphics.Color
import android.os.Build
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
@@ -27,6 +38,7 @@ fun SettingsTitle(
smallTopAppBarHeight: Dp,
paddingMedium: Dp,
scroll: ScrollState,
topInset: Dp,
modifier: Modifier = Modifier
) {
val titlePaddingStart = 16.dp
@@ -35,6 +47,8 @@ fun SettingsTitle(
val titleFontScaleEnd = 0.7f
var titleHeightPx by remember { mutableFloatStateOf(0f) }
var titleWidthPx by remember { mutableFloatStateOf(0f) }
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
Text(
text = stringResource(id = R.string.settings_screen),
@@ -55,7 +69,7 @@ fun SettingsTitle(
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
val titleYFirstInterpolatedPoint = lerp(
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
largeTopAppBarHeight / 2,
collapseFraction
)
@@ -68,7 +82,7 @@ fun SettingsTitle(
val titleYSecondInterpolatedPoint = lerp(
largeTopAppBarHeight / 2,
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
collapseFraction
)
@@ -7,6 +7,7 @@ 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.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@@ -161,7 +162,7 @@ fun StartupScreen(
if (showToS) {
seenToS = true
AlertDialog(
modifier = Modifier.fillMaxHeight(0.8f),
modifier = Modifier.fillMaxHeight(0.7f),
onDismissRequest = { showToS = false },
title = {
Box(modifier = Modifier.fillMaxWidth()) {
@@ -93,7 +93,6 @@ fun PaperizeTheme(
content: @Composable () -> Unit
) {
val context = LocalContext.current
val isDarkMode = isDarkMode(darkMode = darkMode)
val isDynamicTheming = isDynamicTheming(dynamicTheming = dynamicTheming)
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
@@ -109,9 +108,8 @@ fun PaperizeTheme(
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = TRANSPARENT
SystemBarStyle.light(TRANSPARENT, TRANSPARENT)
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !isDarkMode
WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = !isDarkMode
}
}
@@ -5,11 +5,15 @@ import android.content.Context
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.foundation.gestures.ScrollableState
import androidx.compose.foundation.layout.Column
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.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarDuration
@@ -85,12 +89,12 @@ fun WallpaperScreen(
val snackbarHostState = remember { SnackbarHostState() }
val openDialog = rememberSaveable { mutableStateOf(false) }
val showInterval = rememberSaveable { mutableStateOf(false) }
if (openDialog.value) {
ShowLiveWallpaperEnabledDialog(
onDismissRequest = { openDialog.value = false }
)
}
val scrollState = rememberScrollState()
Scaffold(
snackbarHost = {
@@ -106,122 +110,100 @@ fun WallpaperScreen(
) },
modifier = Modifier.fillMaxSize(),
content = { padding ->
LazyColumn(
modifier = Modifier.fillMaxSize().padding(8.dp),
Column(
modifier = Modifier
.fillMaxSize()
.padding(8.dp)
.verticalScroll(scrollState),
horizontalAlignment = Alignment.CenterHorizontally
) {
item {
ChangerSelectionRow(
homeEnabled = homeEnabled,
lockEnabled = lockEnabled,
onHomeCheckedChange = onHomeCheckedChange,
onLockCheckedChange = onLockCheckedChange
ChangerSelectionRow(
homeEnabled = homeEnabled,
lockEnabled = lockEnabled,
onHomeCheckedChange = onHomeCheckedChange,
onLockCheckedChange = onLockCheckedChange
)
if (homeEnabled || lockEnabled) {
CurrentSelectedAlbum(
selectedAlbum = selectedAlbum,
onOpenBottomSheet = {
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) {
if (isLiveWallpaperSet(context)) {
openDialog.value = true
} else {
openBottomSheet = true
}
} else {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(R.string.no_albums_found),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
}
},
onStop = {
if (selectedAlbum != null) {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(
R.string.has_been_unselected,
selectedAlbum.album.displayedAlbumName
),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
onStop()
}
},
animate = animate,
enableChanger = enableChanger,
onToggleChanger = {
if (!it) {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(R.string.wallpaper_changer_has_been_disabled),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
}
onToggleChanger(it)
}
)
}
item {
if (homeEnabled || lockEnabled) {
CurrentSelectedAlbum(
selectedAlbum = selectedAlbum,
onOpenBottomSheet = {
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) {
if (isLiveWallpaperSet(context)) {
openDialog.value = true
} else {
openBottomSheet = true
}
} else {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(R.string.no_albums_found),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
}
},
onStop = {
if (selectedAlbum != null) {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(
R.string.has_been_unselected,
selectedAlbum.album.displayedAlbumName
),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
onStop()
}
},
animate = animate,
enableChanger = enableChanger,
onToggleChanger = {
if (!it) {
scope.launch {
snackbarHostState.currentSnackbarData?.dismiss()
snackbarHostState.showSnackbar(
message = context.getString(R.string.wallpaper_changer_has_been_disabled),
actionLabel = context.getString(R.string.dismiss),
duration = SnackbarDuration.Short
)
}
}
onToggleChanger(it)
}
)
}
}
item {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
CurrentAndNextChange(lastSetTime, nextSetTime)
}
}
}
else {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
CurrentAndNextChange(lastSetTime, nextSetTime)
}
}
}
item {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
WallpaperPreviewAndScale(
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
animate = true,
darken = darken,
darkenPercentage = darkenPercentage,
scaling = scaling,
onScalingChange = onScalingChange,
homeEnabled = homeEnabled,
lockEnabled = lockEnabled,
blur = blur,
blurPercentage = blurPercentage
)
}
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
CurrentAndNextChange(lastSetTime, nextSetTime)
}
else {
}
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
WallpaperPreviewAndScale(
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
animate = false,
animate = true,
darken = darken,
darkenPercentage = darkenPercentage,
scaling = scaling,
@@ -234,112 +216,123 @@ fun WallpaperScreen(
}
}
}
item {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
TimeSliders(
timeInMinutes1 = interval1,
timeInMinutes2 = interval2,
onTimeChange1 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onTimeChange1(totalMinutes)
},
onTimeChange2 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onTimeChange2(totalMinutes)
},
showInterval = showInterval.value,
animate = true,
onShowIntervalChange = { showInterval.value = it },
scheduleSeparately = scheduleSeparately,
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
lockEnabled = lockEnabled,
homeEnabled = homeEnabled
)
}
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
TimeSliders(
timeInMinutes1 = interval1,
timeInMinutes2 = interval2,
onTimeChange1 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onScheduleWallpaperChanger1(totalMinutes)
},
onTimeChange2 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onScheduleWallpaperChanger2(totalMinutes)
},
showInterval = showInterval.value,
animate = false,
onShowIntervalChange = { showInterval.value = it },
scheduleSeparately = scheduleSeparately,
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
lockEnabled = lockEnabled,
homeEnabled = homeEnabled,
)
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
WallpaperPreviewAndScale(
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
animate = false,
darken = darken,
darkenPercentage = darkenPercentage,
scaling = scaling,
onScalingChange = onScalingChange,
homeEnabled = homeEnabled,
lockEnabled = lockEnabled,
blur = blur,
blurPercentage = blurPercentage
)
}
}
item {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
DarkenSwitchAndSlider(
onDarkCheck = onDarkCheck,
darken = darken,
onDarkenChange = onDarkenPercentage,
darkenPercentage = darkenPercentage,
animate = true
)
}
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
DarkenSwitchAndSlider(
onDarkCheck = onDarkCheck,
darken = darken,
onDarkenChange = onDarkenPercentage,
darkenPercentage = darkenPercentage,
animate = false
)
}
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
TimeSliders(
timeInMinutes1 = interval1,
timeInMinutes2 = interval2,
onTimeChange1 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onTimeChange1(totalMinutes)
},
onTimeChange2 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onTimeChange2(totalMinutes)
},
showInterval = showInterval.value,
animate = true,
onShowIntervalChange = { showInterval.value = it },
scheduleSeparately = scheduleSeparately,
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
lockEnabled = lockEnabled,
homeEnabled = homeEnabled
)
}
}
item {
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
BlurSwitchAndSlider(
onBlurPercentageChange = onBlurPercentageChange,
onBlurChange = onBlurChange,
blur = blur,
blurPercentage = blurPercentage,
animate = true
)
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
TimeSliders(
timeInMinutes1 = interval1,
timeInMinutes2 = interval2,
onTimeChange1 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onScheduleWallpaperChanger1(totalMinutes)
},
onTimeChange2 = { days, hours, minutes ->
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
onScheduleWallpaperChanger2(totalMinutes)
},
showInterval = showInterval.value,
animate = false,
onShowIntervalChange = { showInterval.value = it },
scheduleSeparately = scheduleSeparately,
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
lockEnabled = lockEnabled,
homeEnabled = homeEnabled,
)
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
BlurSwitchAndSlider(
onBlurPercentageChange = onBlurPercentageChange,
onBlurChange = onBlurChange,
blur = blur,
blurPercentage = blurPercentage,
animate = false
)
}
}
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
DarkenSwitchAndSlider(
onDarkCheck = onDarkCheck,
darken = darken,
onDarkenChange = onDarkenPercentage,
darkenPercentage = darkenPercentage,
animate = true
)
}
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
DarkenSwitchAndSlider(
onDarkCheck = onDarkCheck,
darken = darken,
onDarkenChange = onDarkenPercentage,
darkenPercentage = darkenPercentage,
animate = false
)
}
}
if (animate) {
AnimatedVisibility(
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
enter = slideInVertically(initialOffsetY = { -it }),
exit = fadeOut()
) {
BlurSwitchAndSlider(
onBlurPercentageChange = onBlurPercentageChange,
onBlurChange = onBlurChange,
blur = blur,
blurPercentage = blurPercentage,
animate = true
)
}
}
else {
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
BlurSwitchAndSlider(
onBlurPercentageChange = onBlurPercentageChange,
onBlurChange = onBlurChange,
blur = blur,
blurPercentage = blurPercentage,
animate = false
)
}
}
}
@@ -1,11 +1,23 @@
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
import android.content.Context
import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.RadioButtonChecked
@@ -13,6 +25,7 @@ import androidx.compose.material.icons.filled.RadioButtonUnchecked
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
@@ -24,6 +37,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
@@ -68,13 +82,17 @@ fun AlbumBottomSheet(
sheetState = modalBottomSheetState,
dragHandle = { BottomSheetDefaults.DragHandle() },
containerColor = MaterialTheme.colorScheme.background,
tonalElevation = 5.dp
tonalElevation = 5.dp,
modifier = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
Modifier.fillMaxSize().padding(bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding())
} else {
Modifier.padding(bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding())
}
) {
albums.forEach {
if (it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size == 0) return@forEach
ListItem(
modifier = Modifier
.padding(4.dp)
.clickable {
scope.launch {
modalBottomSheetState.hide()
@@ -14,12 +14,15 @@ class WallpaperBootReceiver : BroadcastReceiver() {
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
override fun onReceive(context: Context, intent: Intent) {
if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
Log.d("PaperizeWallpaperChanger", "Boot completed")
val serviceIntent = Intent(context, WallpaperService::class.java)
serviceIntent.action = WallpaperService.Actions.START.toString()
runBlocking {
val timeInMinutes = settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
serviceIntent.putExtra("timeInMinutes", timeInMinutes)
val timeInMinutes1 = settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
val timeInMinutes2 = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
val scheduleSeparately = settingsDataStoreImpl.getBoolean(SettingsConstants.SCHEDULE_SEPARATELY) ?: false
serviceIntent.putExtra("timeInMinutes1", timeInMinutes1)
serviceIntent.putExtra("timeInMinutes2", timeInMinutes2)
serviceIntent.putExtra("scheduleSeparately", scheduleSeparately)
}
context.startForegroundService(serviceIntent)
}
@@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import java.io.IOException
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
import javax.inject.Inject
@@ -60,6 +61,8 @@ class WallpaperService: Service() {
private var nextSetTime1: LocalDateTime? = null
private var nextSetTime2: LocalDateTime? = null
private var scheduleSeparately: Boolean = false
private var lastRan1: LocalDateTime? = null
private var lastRan2: LocalDateTime? = null
enum class Actions {
START,
@@ -119,6 +122,10 @@ class WallpaperService: Service() {
timeInMinutes1 = intent.getIntExtra("timeInMinutes1", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
timeInMinutes2 = intent.getIntExtra("timeInMinutes2", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
scheduleSeparately = intent.getBooleanExtra("scheduleSeparately", false)
nextSetTime1 = null
nextSetTime2 = null
lastRan1 = null
lastRan2 = null
if (!scheduleSeparately) {
runnableCode1 = object : Runnable {
@@ -176,6 +183,10 @@ class WallpaperService: Service() {
timeInMinutes1 = intent.getIntExtra("timeInMinutes1", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
timeInMinutes2 = intent.getIntExtra("timeInMinutes2", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
scheduleSeparately = intent.getBooleanExtra("scheduleSeparately", false)
nextSetTime1 = null
nextSetTime2 = null
lastRan1 = null
lastRan2 = null
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
@@ -310,7 +321,6 @@ class WallpaperService: Service() {
* If none left, reshuffle the wallpapers and pick the first one
*/
private suspend fun changeWallpaper(context: Context, setHomeOrLock: Boolean? = null) {
Log.d("PaperizeWallpaperChanger", "Changing wallpaper set: {$setHomeOrLock}")
try {
val selectedAlbum = selectedRepository.getSelectedAlbum().first().firstOrNull()
if (selectedAlbum == null) {
@@ -678,7 +688,8 @@ class WallpaperService: Service() {
decoder.setTargetSize(targetWidth, targetHeight)
decoder.isMutableRequired = true
}
} else {
}
else {
context.contentResolver.openInputStream(wallpaper)?.use { inputStream ->
val options = BitmapFactory.Options().apply {
inSampleSize = calculateInSampleSize(imageSize, targetWidth, targetHeight)
-2
View File
@@ -2,7 +2,5 @@
<resources>
<style name="Theme.Paperize" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@drawable/splash_background</item>
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:navigationBarColor">@color/transparent</item>
</style>
</resources>