Refactored WallpaperScreen and added F-Droid link
This commit is contained in:
1 parent
69e9f91814
commit
e0bc6ccb22
4 files changed
+32
-226
No files matched your search
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 29
|
||||
versionName = "1.6.4"
|
||||
versionCode = 30
|
||||
versionName = "2.0.0"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
|
||||
+4
-32
@@ -6,13 +6,11 @@ import android.net.Uri
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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
|
||||
@@ -20,16 +18,10 @@ 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.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
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.Alignment
|
||||
@@ -43,7 +35,6 @@ import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.data.Contact
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Scrollable settings screen to wrap all settings components
|
||||
@@ -66,9 +57,6 @@ fun SettingsScrollableSettings(
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
var toContact by rememberSaveable { mutableStateOf(false) }
|
||||
if (toContact) {
|
||||
Contact(context)
|
||||
@@ -78,20 +66,9 @@ fun SettingsScrollableSettings(
|
||||
val translateLink = "https://crowdin.com/project/paperize/invite?h=d8d7a7513d2beb0c96ba9b2a5f85473e2084922"
|
||||
val githubLink = "https://github.com/Anthonyy232/Paperize"
|
||||
val playstoreLink = "https://play.google.com/store/apps/details?id=com.anthonyla.paperize"
|
||||
val fdroidLink = ""
|
||||
val fdroidLink = "https://f-droid.org/en/packages/com.anthonyla.paperize/"
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState,
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {},
|
||||
@@ -175,14 +152,9 @@ fun SettingsScrollableSettings(
|
||||
context.startActivity(openURL)
|
||||
},
|
||||
onFdroidClick = {
|
||||
coroutineScope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = context.getString(R.string.coming_soon),
|
||||
actionLabel = context.getString(R.string.dismiss),
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
val openURL = Intent(Intent.ACTION_VIEW)
|
||||
openURL.data = Uri.parse(fdroidLink)
|
||||
context.startActivity(openURL)
|
||||
},
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
+26
-155
@@ -1,14 +1,9 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.WallpaperManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -43,7 +38,6 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.co
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentAndNextChange
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentSelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.DarkenSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ShowLiveWallpaperEnabledDialog
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.WallpaperPreviewAndScale
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -82,20 +76,15 @@ fun WallpaperScreen(
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
blurPercentage: Int
|
||||
) {
|
||||
val shouldShowScreen = homeEnabled || lockEnabled
|
||||
val shouldShowSettings = shouldShowScreen && selectedAlbum != null
|
||||
val scrollState = rememberScrollState()
|
||||
val context = LocalContext.current
|
||||
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val openLiveDialog = rememberSaveable { mutableStateOf(false) }
|
||||
val showInterval = rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
if (openLiveDialog.value) {
|
||||
ShowLiveWallpaperEnabledDialog(
|
||||
onDismissRequest = { openLiveDialog.value = false }
|
||||
)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
@@ -126,13 +115,24 @@ fun WallpaperScreen(
|
||||
if (homeEnabled || lockEnabled) {
|
||||
CurrentSelectedAlbum(
|
||||
selectedAlbum = selectedAlbum,
|
||||
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)
|
||||
},
|
||||
onOpenBottomSheet = {
|
||||
if (albums.firstOrNull() != null) {
|
||||
if (isLiveWallpaperSet(context)) {
|
||||
openLiveDialog.value = true
|
||||
} else {
|
||||
openBottomSheet = true
|
||||
}
|
||||
openBottomSheet = true
|
||||
} else {
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
@@ -159,69 +159,14 @@ fun WallpaperScreen(
|
||||
}
|
||||
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)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
if (shouldShowSettings) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
}
|
||||
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) {
|
||||
WallpaperPreviewAndScale(
|
||||
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
|
||||
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
|
||||
animate = false,
|
||||
currentHomeWallpaper = selectedAlbum!!.album.currentHomeWallpaper,
|
||||
currentLockWallpaper = selectedAlbum!!.album.currentLockWallpaper,
|
||||
animate = animate,
|
||||
darken = darken,
|
||||
darkenPercentage = darkenPercentage,
|
||||
scaling = scaling,
|
||||
@@ -231,14 +176,6 @@ fun WallpaperScreen(
|
||||
blur = blur,
|
||||
blurPercentage = blurPercentage
|
||||
)
|
||||
}
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
TimeSliders(
|
||||
timeInMinutes1 = interval1,
|
||||
timeInMinutes2 = interval2,
|
||||
@@ -251,92 +188,31 @@ fun WallpaperScreen(
|
||||
onTimeChange2(totalMinutes)
|
||||
},
|
||||
showInterval = showInterval.value,
|
||||
animate = true,
|
||||
animate = animate,
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
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
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
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
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((homeEnabled || lockEnabled)) && openBottomSheet) {
|
||||
if (shouldShowScreen && openBottomSheet) {
|
||||
AlbumBottomSheet(
|
||||
albums = albums,
|
||||
currentSelectedAlbum = selectedAlbum,
|
||||
@@ -366,9 +242,4 @@ fun WallpaperScreen(
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fun isLiveWallpaperSet(context: Context): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
return wallpaperManager.wallpaperInfo != null
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ErrorOutline
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Dialog to show when a live wallpaper is detected and ask the user to disable it
|
||||
*/
|
||||
@Composable
|
||||
fun ShowLiveWallpaperEnabledDialog(
|
||||
onDismissRequest: () -> Unit
|
||||
) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { onDismissRequest() },
|
||||
icon = { Icon(Icons.Filled.ErrorOutline, stringResource(R.string.disable_live_wallpaper)) },
|
||||
title = {
|
||||
Text(stringResource(R.string.live_wallpaper_detected))
|
||||
},
|
||||
text = {
|
||||
Text(stringResource(R.string.please_disable_your_live_wallpaper_to_use_the_wallpaper_changer))
|
||||
},
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { onDismissRequest() }
|
||||
) {
|
||||
Text(stringResource(R.string.ok))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user