Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
047d519e80 | ||
|
|
b4041cc8ea | ||
|
|
fc57f14d2a | ||
|
|
4fd1e06b8e | ||
|
|
6a08e0eff9 | ||
|
|
d7edb40a9b | ||
|
|
ac889ed7b1 | ||
|
|
c97f9f7e3d | ||
|
|
4429355a1e | ||
|
|
00fbdf1e42 | ||
|
|
48aefd2aaa | ||
|
|
2c3330742e | ||
|
|
8022aa0f01 | ||
|
|
10397bbbbf | ||
|
|
379d6b21be | ||
|
|
41b32f3154 | ||
|
|
1906a3f170 | ||
|
|
f9207309a8 | ||
|
|
ca31e655ac | ||
|
|
047b2197e0 | ||
|
|
685168b0a6 | ||
|
|
d0fd31cf8c | ||
|
|
30783c6806 |
No files matched your search
@@ -0,0 +1,43 @@
|
||||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static content to Pages
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: '.'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -1,8 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AppInsightsSettings">
|
||||
<option name="selectedTabId" value="Android Vitals" />
|
||||
<option name="tabSettings">
|
||||
<map>
|
||||
<entry key="Android Vitals">
|
||||
<value>
|
||||
<InsightsFilterSettings>
|
||||
<option name="connection">
|
||||
<ConnectionSetting>
|
||||
<option name="appId" value="com.anthonyla.paperize" />
|
||||
</ConnectionSetting>
|
||||
</option>
|
||||
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||
<option name="timeIntervalDays" value="SEVEN_DAYS" />
|
||||
<option name="visibilityType" value="ALL" />
|
||||
</InsightsFilterSettings>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="Firebase Crashlytics">
|
||||
<value>
|
||||
<InsightsFilterSettings>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.0" />
|
||||
<option name="version" value="1.9.22" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
<div align="center">
|
||||
<img width="300" height="300" style="display: block; border-radius: 9999px;" src="https://github.com/Anthonyy232/Paperize/assets/60626873/e170d5da-9e82-4632-99c8-715b98408b3a">
|
||||
<img width="300" height="300" style="display: block; border-radius: 9999px;" src="https://github.com/Anthonyy232/Paperize/assets/60626873/c40018a1-bc0a-4efd-bd4a-bc83fb23589e">
|
||||
<h1>Paperize</h1>
|
||||
<p align="center">
|
||||
</p>
|
||||
@@ -10,7 +11,8 @@
|
||||
|
||||
## Features
|
||||
- **Dynamic Wallpaper Changer**: Set your wallpaper to change at specific time intervals
|
||||
- **Supports Various Image Types**: Paperize can handle a wide range of image types, offering you flexibility in your wallpaper choices
|
||||
- **Supports Various Image Types**: Paperize can handle a wide range of image types
|
||||
- JPEG, PNG, AVIF, WEBP
|
||||
- **Folder Support**: Organize your wallpapers into folders for auto-updating
|
||||
- **Home and Lock Screen Wallpaper**: Choose to change either your home screen, lock screen, or both
|
||||
- **On-Device Storage**: All your wallpapers and settings are stored on your device
|
||||
@@ -42,6 +44,7 @@ Playstore and F-Droid will be added soon
|
||||
- [Lottie Compose](https://github.com/airbnb/lottie) - A library that provides Lottie animation support for Jetpack Compose
|
||||
- [Landscapist](https://github.com/skydoves/landscapist) - A Compose and KPP image loading library that streamlines Glide, Coil, and Fresco
|
||||
- [Zoomable](https://github.com/usuiat/Zoomable) - A library that provides a zoomable and pannable view, which can be used with any view you want
|
||||
- [AnimatedFABMenu](https://github.com/rajaumair7890/AnimatedFABMenu) - A animated floating action button with Material 3 design
|
||||
|
||||
Thanks to the creators and maintainers of the open-source libraries used in this project.
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ plugins {
|
||||
id("com.google.devtools.ksp")
|
||||
id("com.google.dagger.hilt.android")
|
||||
id ("com.mikepenz.aboutlibraries.plugin")
|
||||
id ("org.jetbrains.kotlin.plugin.serialization")
|
||||
}
|
||||
ksp {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
@@ -16,8 +17,8 @@ android {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 2
|
||||
versionName = "0.3.0"
|
||||
versionCode = 7
|
||||
versionName = "1.1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
@@ -47,7 +48,7 @@ android {
|
||||
viewBinding = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.1"
|
||||
kotlinCompilerExtensionVersion = "1.5.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,22 +59,22 @@ androidComponents {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.core:core-ktx:1.13.0")
|
||||
implementation("androidx.core:core-ktx:1.13.1")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
||||
implementation("androidx.activity:activity-compose:1.9.0")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.04.01"))
|
||||
implementation("androidx.compose.ui:ui:1.7.0-alpha07")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.7.0-alpha07")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-alpha07")
|
||||
implementation("androidx.compose.material3:material3:1.3.0-alpha05")
|
||||
implementation("androidx.navigation:navigation-compose:2.8.0-alpha07")
|
||||
implementation("androidx.compose.material:material:1.7.0-alpha07")
|
||||
implementation("androidx.datastore:datastore:1.1.0")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.0")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.7.0-alpha07")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.05.00"))
|
||||
implementation("androidx.compose.ui:ui:1.7.0-alpha08")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.7.0-alpha08")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-alpha08")
|
||||
implementation("androidx.compose.material3:material3:1.3.0-alpha06")
|
||||
implementation("androidx.navigation:navigation-compose:2.8.0-alpha08")
|
||||
implementation("androidx.compose.material:material:1.7.0-alpha08")
|
||||
implementation("androidx.datastore:datastore:1.1.1")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.1")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.7.0-alpha08")
|
||||
implementation("com.google.accompanist:accompanist-adaptive:0.34.0")
|
||||
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
|
||||
implementation("androidx.compose.animation:animation:1.7.0-alpha07")
|
||||
implementation("androidx.compose.animation:animation:1.7.0-alpha08")
|
||||
implementation("androidx.core:core-splashscreen:1.2.0-alpha01")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
@@ -84,19 +85,20 @@ dependencies {
|
||||
implementation("androidx.hilt:hilt-work:1.2.0")
|
||||
implementation("com.airbnb.android:lottie-compose:6.4.0")
|
||||
implementation("com.google.accompanist:accompanist-permissions:0.35.0-alpha")
|
||||
implementation("com.mikepenz:aboutlibraries-core:11.1.3")
|
||||
implementation("com.mikepenz:aboutlibraries-compose-m3:11.1.3")
|
||||
implementation("androidx.compose.foundation:foundation:1.7.0-alpha07")
|
||||
implementation("com.mikepenz:aboutlibraries-core:11.1.4")
|
||||
implementation("com.mikepenz:aboutlibraries-compose-m3:11.1.4")
|
||||
implementation("androidx.compose.foundation:foundation:1.7.0-alpha08")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha04")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-alpha07")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-alpha07")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-alpha07")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-alpha08")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-alpha08")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-alpha08")
|
||||
implementation("com.google.dagger:hilt-android:2.51.1")
|
||||
ksp("com.google.dagger:hilt-android-compiler:2.51.1")
|
||||
implementation("androidx.room:room-runtime:2.6.1")
|
||||
ksp("androidx.room:room-compiler:2.6.1")
|
||||
implementation("androidx.room:room-ktx:2.6.1")
|
||||
implementation("com.lazygeniouz:dfc:1.0.8")
|
||||
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
|
||||
}
|
||||
@@ -2,10 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.paperize"
|
||||
android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.app.Application
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,8 @@ object SettingsConstants {
|
||||
const val WALLPAPER_CHANGE_INTERVAL_DEFAULT = 15
|
||||
const val SET_LOCK_WITH_HOME = "set_lock_with_home"
|
||||
const val FIRST_LAUNCH = "first_launch"
|
||||
const val FIRST_ALBUM_SET = "first_album_set"
|
||||
const val LAST_SET_TIME = "last_set_time"
|
||||
const val NEXT_SET_TIME = "next_set_time"
|
||||
const val ENABLE_CHANGER = "enable_changer"
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.anthonyla.paperize.di
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStoreImpl
|
||||
import com.anthonyla.paperize.feature.wallpaper.data.data_source.AlbumDatabase
|
||||
@@ -31,7 +33,7 @@ object AppModule {
|
||||
app,
|
||||
AlbumDatabase::class.java,
|
||||
AlbumDatabase.DATABASE_NAME
|
||||
).build()
|
||||
).addMigrations(MIGRATION_1_2).build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -41,7 +43,7 @@ object AppModule {
|
||||
app,
|
||||
SelectedAlbumDatabase::class.java,
|
||||
SelectedAlbumDatabase.DATABASE_NAME
|
||||
).build()
|
||||
).addMigrations(MIGRATION_1_2).build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -79,4 +81,10 @@ object AppModule {
|
||||
fun provideContext(
|
||||
@ApplicationContext context: Context,
|
||||
): Context { return context }
|
||||
}
|
||||
|
||||
val MIGRATION_1_2 = object : Migration(1, 2) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL("ALTER TABLE Album ADD COLUMN currentWallpaper TEXT")
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,20 @@ interface AlbumDao {
|
||||
|
||||
@Update
|
||||
suspend fun updateFolder(folder: Folder)
|
||||
|
||||
@Query("DELETE FROM album")
|
||||
suspend fun deleteAllAlbums()
|
||||
|
||||
@Query("DELETE FROM wallpaper")
|
||||
suspend fun deleteAllWallpapers()
|
||||
|
||||
@Query("DELETE FROM folder")
|
||||
suspend fun deleteAllFolders()
|
||||
|
||||
@Transaction
|
||||
suspend fun deleteAllData() {
|
||||
deleteAllWallpapers()
|
||||
deleteAllFolders()
|
||||
deleteAllAlbums()
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class, Folder::class],
|
||||
version = 1
|
||||
version = 2
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AlbumDatabase: RoomDatabase() {
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class],
|
||||
version = 1
|
||||
version = 2
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class SelectedAlbumDatabase: RoomDatabase() {
|
||||
|
||||
@@ -86,4 +86,8 @@ class AlbumRepositoryImpl(
|
||||
override suspend fun deleteWallpaperList(wallpapers: List<Wallpaper>) {
|
||||
dao.deleteWallpaperList(wallpapers)
|
||||
}
|
||||
|
||||
override suspend fun deleteAllData() {
|
||||
dao.deleteAllData()
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,5 @@ data class Album(
|
||||
val coverUri: String?,
|
||||
val initialized: Boolean = false,
|
||||
val wallpapersInQueue: List<String> = emptyList(),
|
||||
val currentWallpaper: String? = null
|
||||
)
|
||||
@@ -96,4 +96,9 @@ interface AlbumRepository {
|
||||
* Delete folder list in one transaction
|
||||
*/
|
||||
suspend fun deleteFolderList(folders: List<Folder>)
|
||||
|
||||
/**
|
||||
* Delete all data in database
|
||||
*/
|
||||
suspend fun deleteAllData()
|
||||
}
|
||||
@@ -1,21 +1,26 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation
|
||||
|
||||
import android.Manifest
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.material3.Surface
|
||||
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.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
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.WallpaperScreenViewModel
|
||||
@@ -23,10 +28,8 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@AndroidEntryPoint
|
||||
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
|
||||
@@ -38,10 +41,26 @@ class MainActivity : ComponentActivity() {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
val splashScreen = installSplashScreen()
|
||||
splashScreen.setKeepOnScreenCondition { settingsViewModel.setKeepOnScreenCondition }
|
||||
splashScreen.setOnExitAnimationListener { splashScreenViewProvider ->
|
||||
val fadeOut = ObjectAnimator.ofFloat(splashScreenViewProvider.view, View.ALPHA, 1f, 0f)
|
||||
fadeOut.interpolator = AccelerateInterpolator()
|
||||
fadeOut.duration = 300L
|
||||
fadeOut.doOnEnd { splashScreenViewProvider.remove() }
|
||||
fadeOut.start()
|
||||
}
|
||||
setContent {
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
||||
splashScreen.setKeepOnScreenCondition { settingsState.value.isDataLoaded && selectedState.value.isDataLoaded }
|
||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
||||
PaperizeTheme(settingsViewModel.state) {
|
||||
if (isFirstLaunch) {
|
||||
val contentResolver = context.contentResolver
|
||||
val persistedUris = contentResolver.persistedUriPermissions
|
||||
for (permission in persistedUris) {
|
||||
contentResolver.releasePersistableUriPermission(permission.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||
}
|
||||
}
|
||||
PaperizeTheme(settingsState) {
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
PaperizeApp(isFirstLaunch)
|
||||
}
|
||||
|
||||
@@ -16,9 +16,12 @@ import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import androidx.navigation.toRoute
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumScreen
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.AddAlbumViewModel
|
||||
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.album_view_screen.AlbumViewScreen
|
||||
@@ -34,8 +37,17 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.startup_screen.Star
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen.WallpaperViewScreen
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AddEdit
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.AlbumView
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Home
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Licenses
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavConstants.INITIAL_OFFSET
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavScreens
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Notification
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Privacy
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Settings
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.Startup
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.WallpaperView
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionIn
|
||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionOut
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaperservice.WallpaperService
|
||||
@@ -52,6 +64,7 @@ fun PaperizeApp(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
||||
addAlbumViewModel: AddAlbumViewModel = hiltViewModel(),
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
@@ -64,62 +77,62 @@ fun PaperizeApp(
|
||||
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)
|
||||
}
|
||||
else if (albumWithWallpapers.wallpapers.isEmpty() && albumWithWallpapers.folders.isEmpty() && albumWithWallpapers.album.initialized) {
|
||||
if (navController.currentDestination?.route == Home::class.simpleName) {
|
||||
navController.popBackStack<Home>(inclusive = false)
|
||||
}
|
||||
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
|
||||
}
|
||||
}
|
||||
|
||||
selectedState.value.selectedAlbum?.let { selectedAlbum ->
|
||||
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }
|
||||
?.let { foundAlbum ->
|
||||
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,
|
||||
)
|
||||
}
|
||||
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }?.let { foundAlbum ->
|
||||
val albumNameHashCode = foundAlbum.album.initialAlbumName.hashCode()
|
||||
val wallpapers: List<Wallpaper> =
|
||||
foundAlbum.wallpapers + foundAlbum.folders.flatMap { folder ->
|
||||
folder.wallpapers.map { wallpaper ->
|
||||
Wallpaper(
|
||||
initialAlbumName = foundAlbum.album.initialAlbumName,
|
||||
wallpaperUri = wallpaper,
|
||||
key = wallpaper.hashCode() + albumNameHashCode,
|
||||
)
|
||||
}
|
||||
val wallpaperUriSet = wallpapers.map { it.wallpaperUri }.toSet()
|
||||
val newSelectedAlbum = SelectedAlbum(
|
||||
album = foundAlbum.album.copy(
|
||||
wallpapersInQueue = selectedAlbum.album.wallpapersInQueue.filter { it in wallpaperUriSet }
|
||||
),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
||||
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(settingsState.value.interval))
|
||||
}
|
||||
val wallpaperUriSet = wallpapers.map { it.wallpaperUri }.toSet()
|
||||
val newSelectedAlbum = SelectedAlbum(
|
||||
album = foundAlbum.album.copy(
|
||||
wallpapersInQueue = selectedAlbum.album.wallpapersInQueue.filter { it in wallpaperUriSet },
|
||||
currentWallpaper = selectedAlbum.album.currentWallpaper
|
||||
),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
||||
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(settingsState.value.interval))
|
||||
if (settingsState.value.enableChanger) { // Not ideal but no other option to check if service is running (thanks Android)
|
||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||
action = WallpaperService.Actions.START.toString()
|
||||
putExtra("timeInMinutes", settingsState.value.interval)
|
||||
}
|
||||
context.startForegroundService(intent)
|
||||
}
|
||||
?: run {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
Intent(context, WallpaperService::class.java).also {
|
||||
it.action = WallpaperService.Actions.STOP.toString()
|
||||
context.startForegroundService(it)
|
||||
}
|
||||
} ?: run {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
Intent(context, WallpaperService::class.java).also {
|
||||
it.action = WallpaperService.Actions.STOP.toString()
|
||||
context.startForegroundService(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = if (firstLaunch) NavScreens.Startup.route else NavScreens.Home.route,
|
||||
startDestination = if (firstLaunch) Startup else Home,
|
||||
modifier = Modifier.navigationBarsPadding()
|
||||
) {
|
||||
// Navigate to the startup screen to show the privacy policy and notification screen
|
||||
composable(
|
||||
route = NavScreens.Startup.route,
|
||||
composable<Startup> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -137,20 +150,16 @@ fun PaperizeApp(
|
||||
onAgree = {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
||||
navController.navigate(NavScreens.Home.route) {
|
||||
popUpTo(NavScreens.Startup.route) { inclusive = true }
|
||||
popUpTo(NavScreens.Notification.route) { inclusive = true }
|
||||
navController.navigate(Home) {
|
||||
popUpTo<Startup> { inclusive = true }
|
||||
}
|
||||
}
|
||||
else {
|
||||
navController.navigate(NavScreens.Notification.route)
|
||||
}
|
||||
else { navController.navigate(Notification) }
|
||||
}
|
||||
)
|
||||
}
|
||||
// Navigate to the notification screen to ask for notification permission
|
||||
composable(
|
||||
route = NavScreens.Notification.route,
|
||||
composable<Notification> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -167,16 +176,14 @@ fun PaperizeApp(
|
||||
NotificationScreen(
|
||||
onAgree = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
||||
navController.navigate(NavScreens.Home.route) {
|
||||
popUpTo(NavScreens.Startup.route) { inclusive = true }
|
||||
popUpTo(NavScreens.Notification.route) { inclusive = true }
|
||||
navController.navigate(Home) {
|
||||
popUpTo<Notification> { inclusive = true }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// Navigate to the home screen to view all albums and wallpapers
|
||||
composable(
|
||||
route = NavScreens.Home.route,
|
||||
composable<Home> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -191,33 +198,61 @@ fun PaperizeApp(
|
||||
},
|
||||
) {
|
||||
HomeScreen(
|
||||
onSettingsClick = { navController.navigate(NavScreens.Settings.route) },
|
||||
onSettingsClick = { navController.navigate(Settings) },
|
||||
navigateToAddWallpaperScreen = {
|
||||
navController.navigate("${NavScreens.AddEdit.route}/$it")
|
||||
navController.navigate(AddEdit(it))
|
||||
},
|
||||
onAlbumViewClick = {
|
||||
navController.navigate("${NavScreens.AlbumView.route}/$it")
|
||||
navController.navigate(AlbumView(it))
|
||||
},
|
||||
onScheduleWallpaperChanger = { timeInMinutes ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(timeInMinutes))
|
||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||
action = WallpaperService.Actions.START.toString()
|
||||
putExtra("timeInMinutes", timeInMinutes)
|
||||
if (settingsState.value.enableChanger) {
|
||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||
action = WallpaperService.Actions.START.toString()
|
||||
putExtra("timeInMinutes", timeInMinutes)
|
||||
}
|
||||
context.startForegroundService(intent)
|
||||
}
|
||||
context.startForegroundService(intent)
|
||||
},
|
||||
onStop = {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
settingsViewModel.onEvent(SettingsEvent.SetChangerToggle(false))
|
||||
Intent(context, WallpaperService::class.java).also {
|
||||
it.action = WallpaperService.Actions.STOP.toString()
|
||||
context.startForegroundService(it)
|
||||
}
|
||||
},
|
||||
animate = settingsState.value.animate,
|
||||
interval = settingsState.value.interval,
|
||||
setLockWithHome = settingsState.value.setLockWithHome,
|
||||
lastSetTime = settingsState.value.lastSetTime,
|
||||
nextSetTime = settingsState.value.nextSetTime,
|
||||
onSetLockWithHome = {
|
||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(it))
|
||||
},
|
||||
selectedAlbum = selectedState.value.selectedAlbum,
|
||||
enableChanger = settingsState.value.enableChanger,
|
||||
onToggleChanger = { enableWallpaperChanger ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetChangerToggle(enableWallpaperChanger))
|
||||
if (enableWallpaperChanger) {
|
||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||
action = WallpaperService.Actions.START.toString()
|
||||
putExtra("timeInMinutes", settingsState.value.interval)
|
||||
}
|
||||
context.startForegroundService(intent)
|
||||
}
|
||||
else {
|
||||
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 }),
|
||||
composable<AddEdit>(
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -231,31 +266,28 @@ fun PaperizeApp(
|
||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||
}
|
||||
) {backStackEntry ->
|
||||
backStackEntry.arguments?.getString("initialAlbumName").let {
|
||||
if (it != null) {
|
||||
AddAlbumScreen(
|
||||
initialAlbumName = it,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onConfirmation = {
|
||||
navController.navigateUp()
|
||||
},
|
||||
onShowWallpaperView = { wallpaper ->
|
||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
||||
},
|
||||
onShowFolderView = { folder, folderName, wallpapers ->
|
||||
val encodedFolder = runBlocking { encodeUri(uri = folder) }
|
||||
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
||||
navController.navigate("${NavScreens.FolderView.route}/$encodedFolder/$folderName/$encodedWallpapers")
|
||||
}
|
||||
)
|
||||
val addEdit: AddEdit = backStackEntry.toRoute()
|
||||
AddAlbumScreen(
|
||||
initialAlbumName = addEdit.wallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onConfirmation = { navController.navigateUp() },
|
||||
onShowWallpaperView = {
|
||||
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")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 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 }),
|
||||
composable<WallpaperView> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -269,16 +301,41 @@ fun PaperizeApp(
|
||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
) { backStackEntry ->
|
||||
backStackEntry.arguments?.getString("wallpaperUri").let { wallpaper ->
|
||||
if (wallpaper != null) {
|
||||
WallpaperViewScreen(
|
||||
wallpaperUri = wallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
)
|
||||
}
|
||||
}
|
||||
val wallpaperView: WallpaperView = backStackEntry.toRoute()
|
||||
WallpaperViewScreen(
|
||||
wallpaperUri = wallpaperView.wallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
animate = settingsState.value.animate
|
||||
)
|
||||
}
|
||||
// Navigate to folder view screen to view wallpapers in a particular folder
|
||||
/*composable<FolderView> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
exitTransition = {
|
||||
sharedXTransitionOut(target = { -(it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
popEnterTransition = {
|
||||
sharedXTransitionIn(initial = { -(it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
popExitTransition = {
|
||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
) { backStackEntry ->
|
||||
val folderView: FolderView = backStackEntry.toRoute()
|
||||
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(
|
||||
@@ -303,22 +360,20 @@ fun PaperizeApp(
|
||||
backStackEntry.arguments?.getString("wallpapers"),
|
||||
Array<String>::class.java
|
||||
).toList()
|
||||
FolderViewScreen(
|
||||
folderName = folderName,
|
||||
wallpapers = wallpapers,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = { wallpaper ->
|
||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
||||
}
|
||||
)
|
||||
if (wallpapers.isNotEmpty()) {
|
||||
FolderViewScreen(
|
||||
folderName = folderName,
|
||||
wallpapers = wallpapers,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = {
|
||||
navController.navigate(WallpaperView(it))
|
||||
},
|
||||
animate = settingsState.value.animate
|
||||
)
|
||||
} else { navController.navigateUp() }
|
||||
}
|
||||
// Navigate to the album view screen to view folders and wallpapers in an album
|
||||
composable(
|
||||
route = NavScreens.AlbumView.route.plus("/{initialAlbumName}"),
|
||||
arguments = listOf(
|
||||
navArgument("initialAlbumName") { type = NavType.StringType },
|
||||
),
|
||||
composable<AlbumView> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -332,17 +387,22 @@ fun PaperizeApp(
|
||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
) { backStackEntry ->
|
||||
val initialAlbumName = backStackEntry.arguments?.getString("initialAlbumName")
|
||||
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == initialAlbumName }
|
||||
if (initialAlbumName != null && albumWithWallpaper != null) {
|
||||
val albumView: AlbumView = backStackEntry.toRoute()
|
||||
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == albumView.initialAlbumName }
|
||||
if (albumWithWallpaper != null) {
|
||||
AlbumViewScreen(
|
||||
album = albumWithWallpaper,
|
||||
onBackClick = { navController.navigateUp() },
|
||||
onShowWallpaperView = { wallpaper ->
|
||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
||||
onShowWallpaperView = {
|
||||
navController.navigate(WallpaperView(it))
|
||||
},
|
||||
onShowFolderView = { folderName, wallpapers ->
|
||||
/*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")
|
||||
},
|
||||
@@ -357,11 +417,10 @@ fun PaperizeApp(
|
||||
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
|
||||
}
|
||||
)
|
||||
}
|
||||
} else { navController.navigateUp() }
|
||||
}
|
||||
// Navigate to the settings screen to change app settings
|
||||
composable(
|
||||
route = NavScreens.Settings.route,
|
||||
composable<Settings> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -388,16 +447,33 @@ fun PaperizeApp(
|
||||
settingsViewModel.onEvent(SettingsEvent.SetAnimate(it))
|
||||
},
|
||||
onPrivacyClick = {
|
||||
navController.navigate(NavScreens.Privacy.route)
|
||||
navController.navigate(Privacy)
|
||||
},
|
||||
onLicenseClick = {
|
||||
navController.navigate(NavScreens.Licenses.route)
|
||||
navController.navigate(Licenses)
|
||||
},
|
||||
onResetClick = {
|
||||
navController.navigate(Startup) {
|
||||
popUpTo<Settings> { inclusive = true }
|
||||
}
|
||||
settingsViewModel.onEvent(SettingsEvent.Reset)
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
albumsViewModel.onEvent(AlbumsEvent.Reset)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
Intent(context, WallpaperService::class.java).also {
|
||||
it.action = WallpaperService.Actions.STOP.toString()
|
||||
context.startForegroundService(it)
|
||||
}
|
||||
val contentResolver = context.contentResolver
|
||||
val persistedUris = contentResolver.persistedUriPermissions
|
||||
for (permission in persistedUris) {
|
||||
contentResolver.releasePersistableUriPermission(permission.uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// Navigate to the privacy screen to view the privacy policy
|
||||
composable(
|
||||
route = NavScreens.Privacy.route,
|
||||
composable<Privacy> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -416,8 +492,7 @@ fun PaperizeApp(
|
||||
)
|
||||
}
|
||||
// Navigate to the licenses screen to view the licenses of the libraries used
|
||||
composable(
|
||||
route = NavScreens.Licenses.route,
|
||||
composable<Licenses> (
|
||||
enterTransition = {
|
||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||
},
|
||||
@@ -442,4 +517,4 @@ fun PaperizeApp(
|
||||
suspend fun encodeUri(uri: String): String =
|
||||
withContext(Dispatchers.IO) {
|
||||
URLEncoder.encode(uri, StandardCharsets.UTF_8.toString())
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
||||
|
||||
sealed class AddAlbumEvent {
|
||||
data object SaveAlbum: AddAlbumEvent()
|
||||
data object ClearState: AddAlbumEvent()
|
||||
data object Reset: AddAlbumEvent()
|
||||
data object DeleteSelected: AddAlbumEvent()
|
||||
data object SelectAll: AddAlbumEvent()
|
||||
data object DeselectAll: AddAlbumEvent()
|
||||
|
||||
@@ -44,7 +44,7 @@ fun AddAlbumScreen(
|
||||
onBackClick: () -> Unit,
|
||||
onConfirmation: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
onShowFolderView: (String, String?, List<String>) -> Unit
|
||||
onShowFolderView: (String?, List<String>) -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val lazyGridState = rememberLazyStaggeredGridState()
|
||||
@@ -54,6 +54,7 @@ fun AddAlbumScreen(
|
||||
if (addAlbumState.value.initialAlbumName.isEmpty()) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName))
|
||||
}
|
||||
var showSpotlight by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
BackHandler {
|
||||
if (selectionMode) {
|
||||
@@ -61,7 +62,8 @@ fun AddAlbumScreen(
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.DeselectAll)
|
||||
} else {
|
||||
onBackClick()
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
showSpotlight = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,14 +105,17 @@ fun AddAlbumScreen(
|
||||
isEmpty = addAlbumState.value.isEmpty,
|
||||
selectionMode = selectionMode,
|
||||
albumState = addAlbumViewModel.state,
|
||||
showSpotlight = showSpotlight,
|
||||
onBackClick = {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
showSpotlight = false
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
onBackClick()
|
||||
},
|
||||
onConfirmationClick = {
|
||||
showSpotlight = false
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ReflectAlbumName(it))
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SaveAlbum)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
onConfirmation()
|
||||
},
|
||||
onSelectAllClick = {
|
||||
@@ -151,10 +156,12 @@ fun AddAlbumScreen(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
showSpotlight = true
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
showSpotlight = true
|
||||
},
|
||||
animate = false
|
||||
)
|
||||
@@ -187,7 +194,7 @@ fun AddAlbumScreen(
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderUri, folder.folderName, folder.wallpapers)
|
||||
onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
@@ -223,7 +230,8 @@ fun AddAlbumScreen(
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
)
|
||||
),
|
||||
animate = settingsState.value.animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@@ -228,7 +227,7 @@ class AddAlbumViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.ClearState -> {
|
||||
is AddAlbumEvent.Reset -> {
|
||||
viewModelScope.launch {
|
||||
_state.update { it.copy(
|
||||
initialAlbumName = "",
|
||||
@@ -274,9 +273,8 @@ class AddAlbumViewModel @Inject constructor(
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
||||
if (extension in allowedExtensions) {
|
||||
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||
if (file.extension in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Remove
|
||||
import androidx.compose.material3.CardColors
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LargeFloatingActionButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -34,6 +36,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -82,6 +85,12 @@ fun AddAlbumAnimatedFab(
|
||||
|
||||
if (animate) {
|
||||
ElevatedCard(
|
||||
colors = CardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = Color.Transparent,
|
||||
disabledContentColor = Color.Transparent,
|
||||
disabledContainerColor = Color.Transparent,
|
||||
),
|
||||
shape = RoundedCornerShape(28.dp),
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
@@ -147,6 +156,12 @@ fun AddAlbumAnimatedFab(
|
||||
}
|
||||
else {
|
||||
ElevatedCard(
|
||||
colors = CardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = Color.Transparent,
|
||||
disabledContentColor = Color.Transparent,
|
||||
disabledContainerColor = Color.Transparent,
|
||||
),
|
||||
shape = RoundedCornerShape(28.dp),
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components
|
||||
|
||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
@@ -33,7 +41,9 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
@@ -54,17 +64,45 @@ fun AddAlbumSmallTopBar(
|
||||
title: String,
|
||||
isEmpty: Boolean,
|
||||
selectionMode: Boolean,
|
||||
showSpotlight: Boolean,
|
||||
onSelectAllClick: () -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onDeleteSelected: () -> Unit,
|
||||
onConfirmationClick: (String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
onConfirmationClick: (String) -> Unit
|
||||
) {
|
||||
val state = albumState.collectAsStateWithLifecycle()
|
||||
val focusManager = LocalFocusManager.current
|
||||
var editableTitle by rememberSaveable { mutableStateOf(title) }
|
||||
var showSelectionDeleteDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
val infiniteTransition = rememberInfiniteTransition(label = stringResource(R.string.spotlight_animation))
|
||||
val radius1 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 50f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_1_animation)
|
||||
)
|
||||
val radius2 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 60f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_2_animation)
|
||||
)
|
||||
|
||||
val radius3 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 75f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_3_animation)
|
||||
)
|
||||
|
||||
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||
title = {
|
||||
@@ -109,9 +147,7 @@ fun AddAlbumSmallTopBar(
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
IconButton(
|
||||
onClick = onSelectAllClick
|
||||
) {
|
||||
IconButton(onClick = onSelectAllClick) {
|
||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||
if (state.value.allSelected) {
|
||||
Icon(
|
||||
@@ -139,12 +175,38 @@ fun AddAlbumSmallTopBar(
|
||||
actions = {
|
||||
if(!selectionMode) {
|
||||
if (!isEmpty) {
|
||||
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Add,
|
||||
contentDescription = stringResource(R.string.add_album),
|
||||
modifier = Modifier.padding(6.dp)
|
||||
)
|
||||
Box {
|
||||
val primaryColor = MaterialTheme.colorScheme.inversePrimary
|
||||
val secondaryColor = MaterialTheme.colorScheme.secondary
|
||||
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Add,
|
||||
contentDescription = stringResource(R.string.add_album),
|
||||
modifier = Modifier.padding(6.dp)
|
||||
)
|
||||
}
|
||||
if (!showSpotlight) {
|
||||
Canvas(modifier = Modifier.matchParentSize()) {
|
||||
drawCircle(
|
||||
color = primaryColor,
|
||||
radius = radius1,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
drawCircle(
|
||||
color = secondaryColor,
|
||||
radius = radius2,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
drawCircle(
|
||||
color = primaryColor,
|
||||
radius = radius3,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
sealed class AlbumsEvent {
|
||||
data object RefreshAlbums: AlbumsEvent()
|
||||
data object Reset: AlbumsEvent()
|
||||
|
||||
data class DeleteAlbumWithWallpapers(
|
||||
val albumWithWallpaperAndFolder: AlbumWithWallpaperAndFolder
|
||||
|
||||
@@ -2,12 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.core.net.toUri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
@@ -15,6 +10,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.first
|
||||
@@ -37,22 +33,20 @@ class AlbumsViewModel @Inject constructor (
|
||||
)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
|
||||
|
||||
fun onEvent(event: AlbumsEvent) {
|
||||
when (event) {
|
||||
is AlbumsEvent.DeleteAlbumWithWallpapers -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.cascadeDeleteAlbum(event.albumWithWallpaperAndFolder.album)
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.ChangeAlbumName -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (!(_state.value.albumsWithWallpapers.any { it.album.displayedAlbumName == event.title })) {
|
||||
repository.updateAlbum(
|
||||
event.albumWithWallpaperAndFolder.album.copy(displayedAlbumName = event.title)
|
||||
@@ -61,13 +55,11 @@ class AlbumsViewModel @Inject constructor (
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.RefreshAlbums -> {
|
||||
viewModelScope.launch {
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
is AlbumsEvent.InitializeAlbum -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.updateAlbum(
|
||||
event.albumWithWallpaperAndFolder.album.copy(
|
||||
initialized = true
|
||||
@@ -75,6 +67,12 @@ class AlbumsViewModel @Inject constructor (
|
||||
)
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.Reset -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
_state.update { AlbumsState() }
|
||||
repository.deleteAllData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,12 +80,12 @@ class AlbumsViewModel @Inject constructor (
|
||||
* Verify and remove stale data in Room database
|
||||
*/
|
||||
private fun updateAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
var albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||
// Delete wallpaper if the URI is invalid
|
||||
val invalidWallpapers = albumWithWallpaper.wallpapers.filterNot { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
file?.exists() == true
|
||||
}
|
||||
if (invalidWallpapers.isNotEmpty()) {
|
||||
@@ -96,12 +94,12 @@ class AlbumsViewModel @Inject constructor (
|
||||
|
||||
// Update folder cover uri and children uri
|
||||
albumWithWallpaper.folders.forEach { folder ->
|
||||
DocumentFile.fromTreeUri(context, folder.folderUri.toUri())?.let { folderDirectory ->
|
||||
if (!folderDirectory.isDirectory) {
|
||||
DocumentFileCompat.fromTreeUri(context, folder.folderUri.toUri())?.let { folderDirectory ->
|
||||
if (!folderDirectory.isDirectory()) {
|
||||
repository.deleteFolder(folder)
|
||||
} else {
|
||||
val wallpapers = getWallpaperFromFolder(folder.folderUri, context)
|
||||
val folderCoverFile = folder.coverUri?.let { DocumentFile.fromSingleUri(context, it.toUri()) }
|
||||
val folderCoverFile = folder.coverUri?.let { DocumentFileCompat.fromSingleUri(context, it.toUri()) }
|
||||
val folderCover = folderCoverFile?.takeIf { it.exists() }?.uri?.toString() ?: wallpapers.randomOrNull()
|
||||
repository.updateFolder(folder.copy(coverUri = folderCover, wallpapers = wallpapers))
|
||||
}
|
||||
@@ -111,7 +109,7 @@ class AlbumsViewModel @Inject constructor (
|
||||
albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||
// Update album cover uri if null or invalid
|
||||
val albumCoverFile = albumWithWallpaper.album.coverUri?.toUri()?.let { DocumentFile.fromSingleUri(context, it) }
|
||||
val albumCoverFile = albumWithWallpaper.album.coverUri?.toUri()?.let { DocumentFileCompat.fromSingleUri(context, it) }
|
||||
if (albumCoverFile == null || !albumCoverFile.exists()) {
|
||||
val newCoverUri = findFirstValidUri(albumWithWallpaper.wallpapers, albumWithWallpaper.folders)
|
||||
repository.updateAlbum(albumWithWallpaper.album.copy(coverUri = newCoverUri))
|
||||
@@ -124,7 +122,7 @@ class AlbumsViewModel @Inject constructor (
|
||||
* Retrieve albums from database into viewModel
|
||||
*/
|
||||
private fun refreshAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getAlbumsWithWallpaperAndFolder().collect { albumWithWallpapers ->
|
||||
_state.update { it.copy(
|
||||
albumsWithWallpapers = albumWithWallpapers
|
||||
@@ -150,9 +148,8 @@ class AlbumsViewModel @Inject constructor (
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
||||
if (extension in allowedExtensions) {
|
||||
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||
if (file.extension in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
@@ -166,14 +163,14 @@ class AlbumsViewModel @Inject constructor (
|
||||
*/
|
||||
private fun findFirstValidUri(wallpapers: List<Wallpaper>, folders: List<Folder>): String? {
|
||||
wallpapers.forEach { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper.wallpaperUri
|
||||
}
|
||||
}
|
||||
folders.forEach { folder ->
|
||||
folder.wallpapers.forEach { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.toUri())
|
||||
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -21,6 +22,7 @@ import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
@@ -34,8 +36,22 @@ import com.skydoves.landscapist.glide.GlideImage
|
||||
fun AlbumItem(
|
||||
album: Album,
|
||||
onAlbumViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = album.coverUri != null && isValidUri(LocalContext.current, album.coverUri)
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
modifier = modifier
|
||||
@@ -49,27 +65,31 @@ fun AlbumItem(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box {
|
||||
GlideImage(
|
||||
imageModel = { album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
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))
|
||||
)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.padding(6.dp))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.animation.core.animateDp
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
@@ -59,7 +60,8 @@ fun FolderItem(
|
||||
onActivateSelectionMode: (Boolean) -> Unit,
|
||||
onItemSelection: () -> Unit,
|
||||
onFolderViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val haptics = LocalHapticFeedback.current
|
||||
@@ -73,6 +75,19 @@ fun FolderItem(
|
||||
if (selected) 24.dp else 16.dp
|
||||
}
|
||||
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = folder.coverUri != null && isValidUri(LocalContext.current, folder.coverUri)
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
modifier = modifier
|
||||
@@ -99,9 +114,9 @@ fun FolderItem(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box {
|
||||
if (folder.coverUri != null) {
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { folder.coverUri.toUri() },
|
||||
imageModel = { folder.coverUri?.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
@@ -113,8 +128,10 @@ fun FolderItem(
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.core.animateDp
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
@@ -37,7 +38,7 @@ import androidx.core.net.toUri
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.anthonyla.paperize.R
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions.withCrossFade
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -54,7 +55,10 @@ fun WallpaperItem(
|
||||
onItemSelection: () -> Unit,
|
||||
onWallpaperViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
wallpaperDrawable : Bitmap? = null
|
||||
wallpaperDrawable : Bitmap? = null,
|
||||
aspectRatio: Float? = null,
|
||||
clickable: Boolean = true,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val haptics = LocalHapticFeedback.current
|
||||
@@ -67,11 +71,20 @@ fun WallpaperItem(
|
||||
if (selected) 24.dp else 16.dp
|
||||
}
|
||||
|
||||
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
|
||||
val aspectRatio = (dimension.first.toFloat()/dimension.second.toFloat())
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
val showUri = isValidUri(LocalContext.current, wallpaperUri)
|
||||
val boxModifier = if (clickable) {
|
||||
modifier
|
||||
.padding(paddingTransition)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
.combinedClickable(
|
||||
@@ -87,26 +100,37 @@ fun WallpaperItem(
|
||||
}
|
||||
}
|
||||
)
|
||||
) {
|
||||
GlideImage(
|
||||
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
},
|
||||
modifier = Modifier.aspectRatio(aspectRatio)
|
||||
)
|
||||
} else {
|
||||
modifier
|
||||
.padding(paddingTransition)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
}
|
||||
Box(modifier = boxModifier) {
|
||||
if (showUri) {
|
||||
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
|
||||
val imageAspectRatio = aspectRatio ?: (dimension.first.toFloat() / dimension.second.toFloat())
|
||||
GlideImage(
|
||||
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier.aspectRatio(imageAspectRatio)
|
||||
)
|
||||
}
|
||||
if (selectionMode) {
|
||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||
if (itemSelected) {
|
||||
@@ -135,8 +159,17 @@ fun Uri.getImageDimensions(context: Context): Pair<Int, Int> {
|
||||
val inputStream = context.contentResolver.openInputStream(this)!!
|
||||
val exif = ExifInterface(inputStream)
|
||||
|
||||
val width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0)
|
||||
val height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0)
|
||||
var width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0)
|
||||
var height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0)
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
val options = BitmapFactory.Options().apply {
|
||||
inJustDecodeBounds = true
|
||||
}
|
||||
BitmapFactory.decodeStream(context.contentResolver.openInputStream(this), null, options)
|
||||
width = options.outWidth
|
||||
height = options.outHeight
|
||||
}
|
||||
|
||||
return Pair(width, height)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ fun AlbumViewScreen(
|
||||
onShowFolderView: (String?, List<String>) -> Unit,
|
||||
onDeleteAlbum: () -> Unit,
|
||||
onTitleChange: (String, AlbumWithWallpaperAndFolder) -> Unit,
|
||||
onSelectionDeleted: () -> Unit
|
||||
onSelectionDeleted: () -> Unit,
|
||||
) {
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
|
||||
val lazyListState = rememberLazyStaggeredGridState()
|
||||
@@ -153,7 +153,7 @@ fun AlbumViewScreen(
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = true
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -169,61 +169,111 @@ fun AlbumViewScreen(
|
||||
content = {
|
||||
items (items = album.folders, key = { folder -> folder.folderUri.hashCode() }
|
||||
) { folder ->
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
|
||||
) { wallpaper ->
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
|
||||
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.animateItem(
|
||||
if (settingsState.value.animate) {
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
|
||||
) { wallpaper ->
|
||||
if (settingsState.value.animate) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
|
||||
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
)
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
|
||||
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -23,7 +23,8 @@ fun FolderViewScreen(
|
||||
folderName: String?,
|
||||
wallpapers: List<String>,
|
||||
onBackClick: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val lazyListState = rememberLazyStaggeredGridState()
|
||||
BackHandler { onBackClick() }
|
||||
@@ -32,9 +33,8 @@ fun FolderViewScreen(
|
||||
topBar = {
|
||||
FolderViewTopBar(
|
||||
title = folderName ?: "",
|
||||
) {
|
||||
onBackClick()
|
||||
}
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
},
|
||||
content = {
|
||||
LazyVerticalStaggeredGrid(
|
||||
@@ -48,23 +48,40 @@ fun FolderViewScreen(
|
||||
content = {
|
||||
items (items = wallpapers, key = { wallpaper -> wallpaper }
|
||||
) { wallpaper ->
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
if (animate) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
)
|
||||
}
|
||||
else {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
@@ -23,20 +22,29 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumDialog
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.components.HomeTopBar
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.LibraryScreen
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.tabItems
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreen
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun HomeScreen(
|
||||
onSettingsClick: () -> Unit,
|
||||
navigateToAddWallpaperScreen: (String) -> Unit,
|
||||
onAlbumViewClick: (String) -> Unit,
|
||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||
onStop: () -> Unit
|
||||
onSetLockWithHome: (Boolean) -> Unit,
|
||||
onToggleChanger: (Boolean) -> Unit,
|
||||
onStop: () -> Unit,
|
||||
animate : Boolean,
|
||||
interval: Int,
|
||||
setLockWithHome: Boolean,
|
||||
lastSetTime: String?,
|
||||
nextSetTime: String?,
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
enableChanger: Boolean
|
||||
) {
|
||||
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
|
||||
val pagerState = rememberPagerState { tabItems.size }
|
||||
@@ -104,11 +112,21 @@ fun HomeScreen(
|
||||
when(index) {
|
||||
0 -> WallpaperScreen(
|
||||
onScheduleWallpaperChanger = onScheduleWallpaperChanger,
|
||||
onStop = onStop
|
||||
onStop = onStop,
|
||||
animate = animate,
|
||||
interval = interval,
|
||||
setLockWithHome = setLockWithHome,
|
||||
lastSetTime = lastSetTime,
|
||||
nextSetTime = nextSetTime,
|
||||
onSetLockWithHome = onSetLockWithHome,
|
||||
selectedAlbum = selectedAlbum,
|
||||
enableChanger = enableChanger,
|
||||
onToggleChanger = onToggleChanger
|
||||
)
|
||||
1 -> LibraryScreen(
|
||||
onAddNewAlbumClick = { addAlbumDialog = true },
|
||||
onViewAlbum = onAlbumViewClick
|
||||
onViewAlbum = onAlbumViewClick,
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.Al
|
||||
fun LibraryScreen(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
onAddNewAlbumClick: () -> Unit,
|
||||
onViewAlbum: (String) -> Unit
|
||||
onViewAlbum: (String) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val lazyListState = rememberLazyGridState()
|
||||
val state = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
@@ -68,7 +69,8 @@ fun LibraryScreen(
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
)
|
||||
),
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ArrowCircleRight
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
@@ -111,7 +112,8 @@ fun NotificationScreen(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp, vertical = 8.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp, vertical = 8.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||
|
||||
sealed class SettingsEvent {
|
||||
data object Refresh: SettingsEvent()
|
||||
data object Reset: SettingsEvent()
|
||||
data object SetFirstLaunch: SettingsEvent()
|
||||
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
|
||||
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
|
||||
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
||||
data class SetWallpaperInterval(val interval: Int): SettingsEvent()
|
||||
data class SetLockWithHome(val lockWithHome: Boolean): SettingsEvent()
|
||||
data class SetChangerToggle(val toggle: Boolean): SettingsEvent()
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsScrollableSettings
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsTitle
|
||||
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
|
||||
|
||||
@Composable
|
||||
@@ -20,7 +20,8 @@ fun SettingsScreen(
|
||||
onDynamicThemingClick: (Boolean) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
onLicenseClick: () -> Unit
|
||||
onLicenseClick: () -> Unit,
|
||||
onResetClick: () -> Unit
|
||||
) {
|
||||
val scroll: ScrollState = rememberScrollState(0)
|
||||
val largeTopAppBarHeight = 152.dp
|
||||
@@ -36,7 +37,8 @@ fun SettingsScreen(
|
||||
onDynamicThemingClick = onDynamicThemingClick,
|
||||
onAnimateClick = onAnimateClick,
|
||||
onPrivacyClick = onPrivacyClick,
|
||||
onLicenseClick = onLicenseClick
|
||||
onLicenseClick = onLicenseClick,
|
||||
onResetClick = onResetClick
|
||||
)
|
||||
SettingsSmallTopAppBar(onBackClick = onBackClick)
|
||||
SettingsTitle(
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||
import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||
|
||||
data class SettingsState (
|
||||
val isDataLoaded: Boolean = false,
|
||||
val firstLaunch: Boolean = true,
|
||||
val darkMode: Boolean? = null,
|
||||
val dynamicTheming: Boolean = false,
|
||||
@@ -9,5 +10,6 @@ data class SettingsState (
|
||||
val interval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
val setLockWithHome: Boolean = false,
|
||||
val lastSetTime: String? = null,
|
||||
val nextSetTime: String? = null
|
||||
val nextSetTime: String? = null,
|
||||
val enableChanger: Boolean = false
|
||||
)
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
@@ -14,7 +13,6 @@ import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import javax.inject.Inject
|
||||
@@ -30,10 +28,9 @@ class SettingsViewModel @Inject constructor (
|
||||
)
|
||||
|
||||
private var currentGetJob: Job? = null
|
||||
var setKeepOnScreenCondition: Boolean = true
|
||||
|
||||
init {
|
||||
currentGetJob = viewModelScope.launch {
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
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 }
|
||||
@@ -42,33 +39,54 @@ class SettingsViewModel @Inject constructor (
|
||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false }
|
||||
|
||||
_state.update { it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await()
|
||||
) }
|
||||
setKeepOnScreenCondition = false
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await(),
|
||||
enableChanger = enableChanger.await(),
|
||||
isDataLoaded = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onEvent(event: SettingsEvent) {
|
||||
when (event) {
|
||||
is SettingsEvent.SetFirstLaunch -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_LAUNCH, false)
|
||||
_state.update { it.copy(
|
||||
firstLaunch = false
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
firstLaunch = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetChangerToggle -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (event.toggle) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ENABLE_CHANGER, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ENABLE_CHANGER, false) }
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
enableChanger = event.toggle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.Refresh -> {
|
||||
currentGetJob = viewModelScope.launch {
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
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 }
|
||||
@@ -77,55 +95,69 @@ class SettingsViewModel @Inject constructor (
|
||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false }
|
||||
|
||||
_state.update { it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await()
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await(),
|
||||
enableChanger = enableChanger.await()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetDarkMode -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (event.darkMode) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) }
|
||||
null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
}
|
||||
_state.update { it.copy(
|
||||
darkMode = event.darkMode
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = event.darkMode
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetDynamicTheming -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (event.dynamicTheming) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) }
|
||||
}
|
||||
_state.update { it.copy(
|
||||
dynamicTheming = event.dynamicTheming
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
dynamicTheming = event.dynamicTheming
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetAnimate -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (event.animate) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) }
|
||||
}
|
||||
_state.update { it.copy(
|
||||
animate = event.animate
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
animate = event.animate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetWallpaperInterval -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val formatter = DateTimeFormatter.ofPattern("MM/dd/yy hh:mm\na")
|
||||
val time = LocalDateTime.now()
|
||||
val formattedLastSetTime = time.format(formatter)
|
||||
@@ -133,22 +165,54 @@ class SettingsViewModel @Inject constructor (
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, formattedLastSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, formattedNextSetTime)
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval)
|
||||
_state.update { it.copy(
|
||||
interval = event.interval,
|
||||
lastSetTime = formattedLastSetTime,
|
||||
nextSetTime = formattedNextSetTime
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
interval = event.interval,
|
||||
lastSetTime = formattedLastSetTime,
|
||||
nextSetTime = formattedNextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetLockWithHome -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
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
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
setLockWithHome = event.lockWithHome
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.Reset -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DYNAMIC_THEME_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_LAUNCH)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.SET_LOCK_WITH_HOME)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.LAST_SET_TIME)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_SET_TIME)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.ANIMATE_TYPE)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.ENABLE_CHANGER)
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = null,
|
||||
dynamicTheming = false,
|
||||
interval = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
setLockWithHome = false,
|
||||
firstLaunch = true,
|
||||
lastSetTime = null,
|
||||
nextSetTime = null,
|
||||
animate = true,
|
||||
enableChanger = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
@@ -53,7 +54,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
|
||||
Icon(
|
||||
imageVector = ImageVector.vectorResource(id = R.drawable.app_icon_foreground),
|
||||
contentDescription = stringResource(id = R.string.appname),
|
||||
modifier = Modifier.size(160.dp),
|
||||
modifier = Modifier.size(160.dp).scale(1.5f),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Text(
|
||||
@@ -62,7 +63,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
|
||||
fontSize = MaterialTheme.typography.titleLarge.fontSize
|
||||
)
|
||||
Text(
|
||||
text = "Version: 0.3.0",
|
||||
text = "Version: 1.1.0",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
fontSize = MaterialTheme.typography.bodyMedium.fontSize
|
||||
)
|
||||
@@ -79,7 +80,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
|
||||
IconButton(
|
||||
onClick = onGitHubClick,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
.size(60.dp)
|
||||
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||
) {
|
||||
Icon(
|
||||
@@ -95,7 +96,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
|
||||
IconButton(
|
||||
onClick = onPlaystoreClick,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
.size(60.dp)
|
||||
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||
) {
|
||||
Icon(
|
||||
@@ -111,7 +112,7 @@ fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, on
|
||||
IconButton(
|
||||
onClick = onFdroidClick,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
.size(60.dp)
|
||||
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||
) {
|
||||
Icon(
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
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.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
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.draw.clip
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* List item to reset all settings and data to default
|
||||
*/
|
||||
@Composable
|
||||
fun ResetListItem(onResetClick: () -> Unit) {
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
|
||||
if (showDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showDialog = false },
|
||||
title = { Text(stringResource(R.string.reset_all_data)) },
|
||||
text = { Text(stringResource(R.string.are_you_sure_you_want_to_reset_all_settings_and_data_to_default)) },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
onResetClick()
|
||||
showDialog = false
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.confirm))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(
|
||||
onClick = { showDialog = false }
|
||||
) {
|
||||
Text(stringResource(R.string.cancel))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Box (
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
){
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.align(Alignment.Center)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.clickable(onClick = { showDialog = true }),
|
||||
elevation = CardDefaults.cardElevation(10.dp),
|
||||
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.errorContainer)
|
||||
) {
|
||||
Row (
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.reset_to_default),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontSize = MaterialTheme.typography.titleSmall.fontSize,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ 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.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Snackbar
|
||||
@@ -46,7 +47,8 @@ fun SettingsScrollableSettings(
|
||||
onDarkModeClick: (Boolean?) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
onLicenseClick: () -> Unit
|
||||
onLicenseClick: () -> Unit,
|
||||
onResetClick: () -> Unit,
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
@@ -68,7 +70,8 @@ fun SettingsScrollableSettings(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
@@ -142,6 +145,8 @@ fun SettingsScrollableSettings(
|
||||
},
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ResetListItem(onResetClick = onResetClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.startup_screen
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
@@ -9,6 +11,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.sharp.CheckCircleOutline
|
||||
@@ -32,6 +35,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||
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.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -58,6 +62,12 @@ fun StartupScreen(
|
||||
var showToS by remember { mutableStateOf(false) }
|
||||
var seenToS by remember { mutableStateOf(false) }
|
||||
|
||||
val context = LocalContext.current
|
||||
val activity = context as? Activity
|
||||
BackHandler {
|
||||
activity?.moveTaskToBack(true)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
@@ -65,7 +75,8 @@ fun StartupScreen(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
|
||||
@@ -6,18 +6,17 @@ import android.os.Build
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
|
||||
private val LightColors = lightColorScheme(
|
||||
@@ -91,14 +90,13 @@ private val DarkColors = darkColorScheme(
|
||||
*/
|
||||
@Composable
|
||||
fun PaperizeTheme(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
settingsState: State<SettingsState>,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
|
||||
val isDarkMode = isDarkMode(darkMode = state.value.darkMode)
|
||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = state.value.dynamicTheming)
|
||||
val isDarkMode = isDarkMode(darkMode = settingsState.value.darkMode)
|
||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = settingsState.value.dynamicTheming)
|
||||
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
val colors = when {
|
||||
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
|
||||
import android.os.Build
|
||||
import android.view.HapticFeedbackConstants
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
@@ -9,6 +7,7 @@ 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.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
@@ -23,10 +22,11 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
@@ -45,14 +45,22 @@ fun WallpaperScreen(
|
||||
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||
onStop: () -> Unit
|
||||
onSetLockWithHome: (Boolean) -> Unit,
|
||||
onToggleChanger: (Boolean) -> Unit,
|
||||
onStop: () -> Unit,
|
||||
animate: Boolean,
|
||||
interval: Int,
|
||||
setLockWithHome: Boolean,
|
||||
lastSetTime: String?,
|
||||
nextSetTime: String?,
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
enableChanger: Boolean
|
||||
) {
|
||||
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() }
|
||||
val context = LocalContext.current
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
@@ -61,12 +69,13 @@ fun WallpaperScreen(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
content = { it
|
||||
content = { padding ->
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@@ -75,139 +84,145 @@ fun WallpaperScreen(
|
||||
) {
|
||||
item {
|
||||
CurrentSelectedAlbum(
|
||||
selectedAlbum = selectedState.value.selectedAlbum,
|
||||
selectedAlbum = selectedAlbum,
|
||||
onOpenBottomSheet = {
|
||||
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) openBottomSheet = true
|
||||
},
|
||||
onStop = {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
if (selectedAlbum != null) {
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = "${selectedState.value.selectedAlbum?.album?.displayedAlbumName} has been unselected.",
|
||||
actionLabel = "Dismiss",
|
||||
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)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (settingsState.value.animate) {
|
||||
item {
|
||||
item {
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
visible = selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
CurrentAndNextChange(
|
||||
settingsState.value.lastSetTime,
|
||||
settingsState.value.nextSetTime
|
||||
)
|
||||
if (selectedAlbum != null) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (selectedAlbum != null) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
item {
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
visible = selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
if (selectedAlbum != null) {
|
||||
SetLockScreenSwitch(
|
||||
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
|
||||
checked = settingsState.value.setLockWithHome,
|
||||
onCheckedChange = { isChecked ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
|
||||
}
|
||||
albumUri = selectedAlbum.album.currentWallpaper,
|
||||
checked = setLockWithHome,
|
||||
onCheckedChange = { onSetLockWithHome(it) },
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (selectedAlbum != null) {
|
||||
SetLockScreenSwitch(
|
||||
albumUri = selectedAlbum.album.currentWallpaper,
|
||||
checked = setLockWithHome,
|
||||
onCheckedChange = { onSetLockWithHome(it) },
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
item {
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
visible = selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
TimeSliders(
|
||||
timeInMinutes = settingsState.value.interval,
|
||||
timeInMinutes = interval,
|
||||
onTimeChange = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
settingsViewModel.onEvent(
|
||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
||||
)
|
||||
onScheduleWallpaperChanger(totalMinutes)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
CurrentAndNextChange(
|
||||
settingsState.value.lastSetTime,
|
||||
settingsState.value.nextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
SetLockScreenSwitch(
|
||||
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
|
||||
checked = settingsState.value.setLockWithHome,
|
||||
onCheckedChange = { isChecked ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
|
||||
else {
|
||||
if (selectedAlbum != null) {
|
||||
TimeSliders(
|
||||
timeInMinutes = interval,
|
||||
onTimeChange = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
onScheduleWallpaperChanger(totalMinutes)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
TimeSliders(
|
||||
timeInMinutes = settingsState.value.interval,
|
||||
onTimeChange = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
settingsViewModel.onEvent(
|
||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
||||
)
|
||||
onScheduleWallpaperChanger(totalMinutes)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (openBottomSheet) {
|
||||
AlbumBottomSheet(
|
||||
albums = albumState.value.albumsWithWallpapers,
|
||||
currentSelectedAlbum = selectedState.value.selectedAlbum,
|
||||
currentSelectedAlbum = selectedAlbum,
|
||||
onDismiss = { openBottomSheet = false },
|
||||
onSelect = { album ->
|
||||
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.flatMap { folder ->
|
||||
folder.wallpapers.map { wallpaper ->
|
||||
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.asSequence().flatMap { folder ->
|
||||
folder.wallpapers.asSequence().map { wallpaper ->
|
||||
Wallpaper(
|
||||
initialAlbumName = album.album.initialAlbumName,
|
||||
wallpaperUri = wallpaper,
|
||||
key = wallpaper.hashCode() + album.album.initialAlbumName.hashCode(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}.toList()
|
||||
val shuffledWallpapers = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
val newSelectedAlbum = SelectedAlbum(
|
||||
album = album.album.copy(
|
||||
wallpapersInQueue = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
wallpapersInQueue = shuffledWallpapers,
|
||||
currentWallpaper = shuffledWallpapers.firstOrNull()
|
||||
),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
openBottomSheet = false
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = "${album.album.displayedAlbumName} has been selected.",
|
||||
actionLabel = "Dismiss",
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
settingsViewModel.onEvent(SettingsEvent.SetChangerToggle(true))
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
||||
onScheduleWallpaperChanger(settingsState.value.interval)
|
||||
}
|
||||
openBottomSheet = false
|
||||
onScheduleWallpaperChanger(interval)
|
||||
onToggleChanger(true)
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
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
|
||||
@@ -33,31 +25,36 @@ class WallpaperScreenViewModel @Inject constructor (
|
||||
)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
refreshAlbums()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||
isDataLoaded = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onEvent(event: WallpaperEvent) {
|
||||
when (event) {
|
||||
is WallpaperEvent.UpdateSelectedAlbum -> {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
repository.upsertSelectedAlbum(event.selectedAlbum)
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
repository.upsertSelectedAlbum(event.selectedAlbum)
|
||||
}
|
||||
}
|
||||
is WallpaperEvent.Refresh -> {
|
||||
refreshAlbums()
|
||||
}
|
||||
is WallpaperEvent.Reset -> {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
_state.update {
|
||||
it.copy(selectedAlbum = null)
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,10 +63,10 @@ class WallpaperScreenViewModel @Inject constructor (
|
||||
|
||||
// Retrieve album from database into viewModel
|
||||
private fun refreshAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||
_state.update { it.copy(
|
||||
selectedAlbum = selectedAlbum.firstOrNull()
|
||||
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||
) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
|
||||
data class WallpaperState (
|
||||
val isDataLoaded: Boolean = false,
|
||||
val selectedAlbum: SelectedAlbum? = null
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
@@ -47,17 +48,31 @@ fun AlbumBottomSheet(
|
||||
onDismiss: () -> Unit,
|
||||
currentSelectedAlbum: SelectedAlbum?,
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
onSelect: (AlbumWithWallpaperAndFolder) -> Unit
|
||||
onSelect: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val modalBottomSheetState = rememberModalBottomSheetState()
|
||||
val scope = rememberCoroutineScope()
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { onDismiss() },
|
||||
sheetState = modalBottomSheetState,
|
||||
dragHandle = { BottomSheetDefaults.DragHandle() },
|
||||
windowInsets = WindowInsets(0.dp)
|
||||
containerColor = MaterialTheme.colorScheme.background,
|
||||
tonalElevation = 5.dp
|
||||
) {
|
||||
albums.forEach {
|
||||
if (it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size == 0) return@forEach
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
@@ -84,28 +99,36 @@ fun AlbumBottomSheet(
|
||||
Box (
|
||||
modifier = Modifier.size(60.dp)
|
||||
) {
|
||||
GlideImage(
|
||||
imageModel = { it.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))
|
||||
)
|
||||
val showCoverUri = isValidUri(LocalContext.current, it.album.coverUri)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { it.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.FillBounds,
|
||||
alignment = Alignment.Center,
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.align(
|
||||
Alignment.Center
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
trailingContent = {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -18,16 +21,20 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.bumptech.glide.Glide
|
||||
@@ -41,14 +48,36 @@ import com.skydoves.landscapist.glide.GlideImage
|
||||
@Composable
|
||||
fun CurrentSelectedAlbum(
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
enableChanger: Boolean,
|
||||
onOpenBottomSheet: () -> Unit,
|
||||
onStop: () -> Unit
|
||||
onStop: () -> Unit,
|
||||
animate: Boolean,
|
||||
onToggleChanger: (Boolean) -> Unit
|
||||
) {
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = isValidUri(LocalContext.current, selectedAlbum?.album?.coverUri)
|
||||
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.padding(PaddingValues(vertical = 8.dp, horizontal = 16.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.clickable { onOpenBottomSheet() },
|
||||
.clickable {
|
||||
if (selectedAlbum != null) {
|
||||
onToggleChanger(!enableChanger)
|
||||
} else {
|
||||
onOpenBottomSheet()
|
||||
}
|
||||
},
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
|
||||
@@ -65,31 +94,34 @@ fun CurrentSelectedAlbum(
|
||||
)
|
||||
} },
|
||||
leadingContent = {
|
||||
Box (
|
||||
modifier = Modifier.size(60.dp)
|
||||
) {
|
||||
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))
|
||||
)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { selectedAlbum.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.FillBounds,
|
||||
alignment = Alignment.Center,
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(
|
||||
Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Image(
|
||||
imageVector = Icons.Default.RadioButtonUnchecked,
|
||||
@@ -100,7 +132,10 @@ fun CurrentSelectedAlbum(
|
||||
}
|
||||
},
|
||||
trailingContent = {
|
||||
Row {
|
||||
Row (
|
||||
horizontalArrangement = Arrangement.spacedBy((-8).dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (selectedAlbum != null) {
|
||||
IconButton(onClick = { onStop() }) {
|
||||
Icon(imageVector = Icons.Default.Stop, contentDescription = stringResource(R.string.stop_the_album))
|
||||
@@ -112,6 +147,15 @@ fun CurrentSelectedAlbum(
|
||||
imageVector = Icons.Filled.ArrowDropDown,
|
||||
)
|
||||
}
|
||||
if (selectedAlbum != null) {
|
||||
Switch(
|
||||
checked = enableChanger,
|
||||
onCheckedChange = onToggleChanger,
|
||||
modifier = Modifier
|
||||
.rotate(270f)
|
||||
.scale(0.75f)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
tonalElevation = 10.dp
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
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.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||
|
||||
@Composable
|
||||
fun SetLockScreenSwitch(
|
||||
albumUri : String?,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
) {
|
||||
Column (horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
|
||||
Row (horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
text = stringResource(R.string.set_as_lock_screen),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
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 = stringResource(R.string.lock_screen), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier.padding(4.dp).border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = stringResource(R.string.home), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier.padding(4.dp).border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
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.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||
|
||||
@Composable
|
||||
fun SetLockScreenSwitch(
|
||||
albumUri : String?,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
) {
|
||||
Column (horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
|
||||
Row (horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
text = stringResource(R.string.set_as_lock_screen),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = onCheckedChange
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = checked && albumUri != null,
|
||||
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||
exit = shrinkVertically(animationSpec = tween(durationMillis = 700, easing = LinearOutSlowInEasing))
|
||||
) {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = stringResource(R.string.lock_screen), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
|
||||
aspectRatio = 9f / 19.5f,
|
||||
clickable = false,
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = stringResource(R.string.home), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
|
||||
aspectRatio = 9f / 19.5f,
|
||||
clickable = false,
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
if (checked) {
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = stringResource(R.string.lock_screen), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
|
||||
aspectRatio = 9f / 19.5f,
|
||||
clickable = false,
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = stringResource(R.string.home), fontWeight = FontWeight.W500)
|
||||
if (albumUri != null) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = albumUri,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.border(3.dp, color = Color.Black, shape = RoundedCornerShape(16.dp)),
|
||||
aspectRatio = 9f / 19.5f,
|
||||
clickable = false,
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,10 @@ 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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -51,21 +52,25 @@ fun TimeSliders(
|
||||
val displayHours = (totalMinutes % (24 * 60)) / 60
|
||||
val displayMinutes = totalMinutes % 60
|
||||
val formattedDays = when {
|
||||
displayDays > 1 -> "$displayDays days"
|
||||
displayDays == 1 -> "$displayDays day"
|
||||
displayDays > 1 -> stringResource(R.string.days, displayDays)
|
||||
displayDays == 1 -> stringResource(R.string.day, displayDays)
|
||||
else -> ""
|
||||
}
|
||||
val formattedHours = when {
|
||||
displayHours > 1 -> "$displayHours hours"
|
||||
displayHours == 1 -> "$displayHours hour"
|
||||
displayHours > 1 -> stringResource(R.string.hours, displayHours)
|
||||
displayHours == 1 -> stringResource(R.string.hour, displayHours)
|
||||
else -> ""
|
||||
}
|
||||
val formattedMinutes = when {
|
||||
displayMinutes > 1 -> "$displayMinutes minutes"
|
||||
displayMinutes == 1 -> "$displayMinutes minute"
|
||||
displayMinutes > 1 -> stringResource(R.string.minutes, displayMinutes)
|
||||
displayMinutes == 1 -> stringResource(R.string.minute, displayMinutes)
|
||||
else -> ""
|
||||
}
|
||||
val formattedTime = "Interval | ${listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")}"
|
||||
val formattedTime = stringResource(
|
||||
R.string.interval,
|
||||
listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }
|
||||
.joinToString(", ")
|
||||
)
|
||||
|
||||
Text(
|
||||
text = formattedTime,
|
||||
@@ -78,8 +83,8 @@ fun TimeSliders(
|
||||
onValueChange = { newDays ->
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
days = newDays
|
||||
val totalMinutes = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
||||
if (totalMinutes < 15) {
|
||||
val totalMinute = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
||||
if (totalMinute < 15) {
|
||||
minutes = 15f - (hours.toInt() * 60)
|
||||
}
|
||||
job?.cancel()
|
||||
@@ -98,8 +103,8 @@ fun TimeSliders(
|
||||
onValueChange = { newHours ->
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
hours = newHours
|
||||
val totalMinutes = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
|
||||
if (totalMinutes < 15) {
|
||||
val totalMinute = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
|
||||
if (totalMinute < 15) {
|
||||
minutes = 15f - (newHours.toInt() * 60)
|
||||
}
|
||||
job?.cancel()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen
|
||||
|
||||
import android.content.Context
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -43,7 +44,20 @@ import net.engawapg.lib.zoomable.zoomable
|
||||
fun WallpaperViewScreen(
|
||||
wallpaperUri: String,
|
||||
onBackClick: () -> Unit,
|
||||
animate : Boolean
|
||||
) {
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showUri = isValidUri(LocalContext.current, wallpaperUri)
|
||||
val zoomState = rememberZoomState()
|
||||
BackHandler { onBackClick() }
|
||||
Scaffold(
|
||||
@@ -85,24 +99,28 @@ fun WallpaperViewScreen(
|
||||
.padding(padding)
|
||||
.zoomable(zoomState)
|
||||
) {
|
||||
GlideImage(
|
||||
imageModel = { wallpaperUri.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
if (showUri) {
|
||||
GlideImage(
|
||||
imageModel = { wallpaperUri.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +1,67 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.util.navigation
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.BrowseGallery
|
||||
import androidx.compose.material.icons.filled.Image
|
||||
import androidx.compose.material.icons.filled.Newspaper
|
||||
import androidx.compose.material.icons.filled.Notifications
|
||||
import androidx.compose.material.icons.filled.PrivacyTip
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Start
|
||||
import androidx.compose.material.icons.outlined.Add
|
||||
import androidx.compose.material.icons.outlined.BrowseGallery
|
||||
import androidx.compose.material.icons.outlined.Image
|
||||
import androidx.compose.material.icons.outlined.Newspaper
|
||||
import androidx.compose.material.icons.outlined.Notifications
|
||||
import androidx.compose.material.icons.outlined.PrivacyTip
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Start
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
/**
|
||||
* Enum class for navigation screens in application
|
||||
* Data class for Startup screen
|
||||
*/
|
||||
sealed class NavScreens(val route: String, @StringRes val resourceId: Int, val unfilledIcon: ImageVector, val filledIcon: ImageVector) {
|
||||
/**
|
||||
* Home screen that the user lands on initially
|
||||
*/
|
||||
object Startup : NavScreens("startup_screen", R.string.startup, Icons.Outlined.Start, Icons.Filled.Start)
|
||||
@Serializable
|
||||
object Startup
|
||||
|
||||
/**
|
||||
* Notification screen for the application to ask for permission
|
||||
*/
|
||||
object Notification : NavScreens("notification_screen", R.string.notifications, Icons.Outlined.Notifications, Icons.Filled.Notifications)
|
||||
/**
|
||||
* Object for Notification screen
|
||||
*/
|
||||
@Serializable
|
||||
object Notification
|
||||
|
||||
/**
|
||||
* Home screen that the user lands on initially containing the wallpapers and albums
|
||||
*/
|
||||
object Home : NavScreens("home_screen", R.string.home_screen, Icons.Outlined.Image, Icons.Filled.Image)
|
||||
/**
|
||||
* Object for Home screen
|
||||
*/
|
||||
@Serializable
|
||||
object Home
|
||||
|
||||
/**
|
||||
* Settings screen for the application
|
||||
*/
|
||||
object Settings : NavScreens("settings_screen", R.string.settings_screen, Icons.Outlined.Settings, Icons.Filled.Settings)
|
||||
/**
|
||||
* Object for Settings screen
|
||||
*/
|
||||
@Serializable
|
||||
object Settings
|
||||
|
||||
/**
|
||||
* License screen for the application
|
||||
*/
|
||||
object Licenses : NavScreens("licenses_screen", R.string.licenses_screen, Icons.Outlined.Newspaper, Icons.Filled.Newspaper)
|
||||
/**
|
||||
* Object for Licenses screen
|
||||
*/
|
||||
@Serializable
|
||||
object Licenses
|
||||
|
||||
/**
|
||||
* Settings screen for the application
|
||||
*/
|
||||
object Privacy : NavScreens("privacy_screen", R.string.privacy_screen, Icons.Outlined.PrivacyTip, Icons.Filled.PrivacyTip)
|
||||
/**
|
||||
* Object for Privacy screen
|
||||
*/
|
||||
@Serializable
|
||||
object Privacy
|
||||
|
||||
/**
|
||||
* Add/Edit screen for album when adding or editing
|
||||
*/
|
||||
object AddEdit : NavScreens("add_edit_screen", R.string.add_wallpaper_screen, Icons.Outlined.Add, Icons.Filled.Add)
|
||||
/**
|
||||
* Data class for AlbumView screen
|
||||
*/
|
||||
@Serializable
|
||||
data class AlbumView(val initialAlbumName: String)
|
||||
|
||||
/**
|
||||
* Wallpaper view screen for viewing wallpapers when clicking on a wallpaper
|
||||
*/
|
||||
object WallpaperView : NavScreens("wallpaper_view_screen", R.string.wallpaper_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
/**
|
||||
* Data class for AddEdit screen
|
||||
*/
|
||||
@Serializable
|
||||
data class AddEdit(val wallpaper: String)
|
||||
|
||||
/**
|
||||
* Folder view screen for viewing wallpapers in a folder when clicking on a folder
|
||||
*/
|
||||
object FolderView : NavScreens("folder_view_screen", R.string.folder_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
/**
|
||||
* Data class for WallpaperView screen
|
||||
*/
|
||||
@Serializable
|
||||
data class WallpaperView(val wallpaper: String)
|
||||
|
||||
/**
|
||||
* Album view screen for viewing albums when clicking on an album. Shows wallpapers and folders of the album
|
||||
*/
|
||||
object AlbumView : NavScreens("album_view_screen", R.string.album_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
||||
/** Reverted back to passing JSON due to bug in navigation compose causing crash
|
||||
* Data class for FolderView screen
|
||||
@Serializable
|
||||
data class FolderView(val folderName: String?, val wallpapers: List<String>)
|
||||
*/
|
||||
sealed class NavScreens(val route: String) {
|
||||
data object FolderView : NavScreens("folder_view_screen")
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.wallpaperservice
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.app.WallpaperManager
|
||||
import android.content.Context
|
||||
@@ -19,7 +20,9 @@ import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -33,7 +36,8 @@ import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class WallpaperService: Service() {
|
||||
@Inject lateinit var repository: SelectedAlbumRepository
|
||||
@Inject lateinit var selectedRepository: SelectedAlbumRepository
|
||||
@Inject lateinit var albumRepository: AlbumRepository
|
||||
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private lateinit var runnableCode: Runnable
|
||||
@@ -110,7 +114,6 @@ class WallpaperService: Service() {
|
||||
* Clean up the service when it is destroyed
|
||||
*/
|
||||
override fun onDestroy() {
|
||||
Log.d("PaperizeWallpaperChanger", "Service destroyed")
|
||||
super.onDestroy()
|
||||
handler.removeCallbacks(runnableCode)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
@@ -123,10 +126,13 @@ class WallpaperService: Service() {
|
||||
* Creates a notification for the wallpaper service
|
||||
*/
|
||||
private fun createNotification(current: Int = 0, total: Int = 0): Notification {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
return NotificationCompat.Builder(this, "wallpaper_service_channel")
|
||||
.setContentTitle("Paperize")
|
||||
.setContentText("Rotation: $current/$total wallpapers\nInterval: ${formatTime(timeInMinutes)}")
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentIntent(pendingIntent)
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -140,43 +146,84 @@ class WallpaperService: Service() {
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, time.format(formatter))
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, time.plusMinutes(timeInMinutes.toLong()).format(formatter))
|
||||
val setLockWithHome = settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false
|
||||
val album = repository.getSelectedAlbum().first().firstOrNull()
|
||||
album?.let {
|
||||
val notification = createNotification(it.album.wallpapersInQueue.size, it.wallpapers.size)
|
||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.notify(1, notification)
|
||||
val selectedAlbum = selectedRepository.getSelectedAlbum().first().firstOrNull()
|
||||
selectedAlbum?.let { it ->
|
||||
var wallpaper = it.album.wallpapersInQueue.firstOrNull()
|
||||
// Pick the next wallpaper in the queue
|
||||
if (wallpaper != null) {
|
||||
setWallpaper(context, wallpaper.toUri(), setLockWithHome)
|
||||
repository.upsertSelectedAlbum(
|
||||
it.copy(
|
||||
album = it.album.copy(
|
||||
wallpapersInQueue = it.album.wallpapersInQueue.drop(1)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
else {
|
||||
val newWallpaperInQueue = it.wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
wallpaper = newWallpaperInQueue.firstOrNull()
|
||||
if (wallpaper != null) {
|
||||
setWallpaper(context, wallpaper.toUri(), setLockWithHome)
|
||||
repository.upsertSelectedAlbum(
|
||||
val notification = createNotification(it.album.wallpapersInQueue.size, it.wallpapers.size)
|
||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.notify(1, notification)
|
||||
if (!setWallpaper(context, wallpaper.toUri(), setLockWithHome)) {
|
||||
selectedAlbum.wallpapers.firstOrNull{ it.wallpaperUri == wallpaper }
|
||||
?.let { it1 ->
|
||||
selectedRepository.deleteWallpaper(it1)
|
||||
selectedRepository.upsertSelectedAlbum(
|
||||
it.copy(
|
||||
album = it.album.copy(
|
||||
wallpapersInQueue = it.album.wallpapersInQueue.drop(1),
|
||||
currentWallpaper = null
|
||||
),
|
||||
wallpapers = it.wallpapers.filter { it == it1 },
|
||||
)
|
||||
)
|
||||
albumRepository.deleteWallpaper(it1)
|
||||
}
|
||||
}
|
||||
else {
|
||||
selectedRepository.upsertSelectedAlbum(
|
||||
it.copy(
|
||||
album = it.album.copy(
|
||||
wallpapersInQueue = newWallpaperInQueue.drop(1)
|
||||
wallpapersInQueue = it.album.wallpapersInQueue.drop(1),
|
||||
currentWallpaper = wallpaper
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
// No more wallpapers in the queue -- reshuffle the wallpapers
|
||||
else {
|
||||
val notification = createNotification(it.wallpapers.size, it.wallpapers.size)
|
||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.notify(1, notification)
|
||||
val newWallpaperInQueue = it.wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
wallpaper = newWallpaperInQueue.firstOrNull()
|
||||
if (wallpaper != null) {
|
||||
if (!setWallpaper(context, wallpaper.toUri(), setLockWithHome)) {
|
||||
selectedAlbum.wallpapers.firstOrNull{ it.wallpaperUri == wallpaper }
|
||||
?.let { it1 ->
|
||||
selectedRepository.deleteWallpaper(it1)
|
||||
selectedRepository.upsertSelectedAlbum(
|
||||
it.copy(
|
||||
album = it.album.copy(
|
||||
wallpapersInQueue = it.album.wallpapersInQueue.drop(1),
|
||||
currentWallpaper = null
|
||||
),
|
||||
wallpapers = it.wallpapers.filter { it == it1 }
|
||||
)
|
||||
)
|
||||
albumRepository.deleteWallpaper(it1)
|
||||
}
|
||||
}
|
||||
else {
|
||||
selectedRepository.upsertSelectedAlbum(
|
||||
it.copy(
|
||||
album = it.album.copy(
|
||||
wallpapersInQueue = newWallpaperInQueue.drop(1),
|
||||
currentWallpaper = wallpaper
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
} else { onDestroy() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wallpaper to the given uri
|
||||
*/
|
||||
private fun setWallpaper(context: Context, wallpaper: Uri, setLockWithHome: Boolean) {
|
||||
private fun setWallpaper(context: Context, wallpaper: Uri, setLockWithHome: Boolean): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
try {
|
||||
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
@@ -198,9 +245,8 @@ class WallpaperService: Service() {
|
||||
false -> WallpaperManager.FLAG_SYSTEM
|
||||
})
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("PaperizeWallpaperChanger", "Error changing wallpaper", e)
|
||||
}
|
||||
return true
|
||||
} catch (e: IOException) { return false }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
@@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -1,30 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -2,4 +2,5 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/app_icon_background"/>
|
||||
<foreground android:drawable="@drawable/app_icon_foreground"/>
|
||||
<monochrome android:drawable="@drawable/app_icon_foreground"/>
|
||||
</adaptive-icon>
|
||||
@@ -2,4 +2,5 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/app_icon_background"/>
|
||||
<foreground android:drawable="@drawable/app_icon_foreground"/>
|
||||
<monochrome android:drawable="@drawable/app_icon_foreground"/>
|
||||
</adaptive-icon>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.6 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" xml:space="preserve"><path d="M350.966 343.969c.168 2.899-.765 4.827-4.048 5.066-2.337.17-3.664 1.567-3.522 3.984.148 2.54 2.053 3.211 4.144 3.514 5.899.853 11.657-.007 17.264-1.772 10.505-3.306 21.456-4.695 32.041-7.627 2.954-.818 6.91-.884 7.621-4.572.653-3.386-1.845-5.818-4.702-7.6-.484-.302-.693-1.042-1.365-2.115 6.798-2.813 13.733-3.33 20.547-4.135 28.216-3.337 56.58-5.4 84.647-10.016 3.714-.61 7.281-2.238 11.45-1.271-10.231 6.72-20.53 13.236-32.006 18.281 3.77-.474 7.554-.854 11.305-1.448 3.77-.597 7.494-1.49 11.263-2.11 48.341-7.957 91.973-28.448 135.03-50.54 12.454-6.39 25.326-11.857 38.764-15.945 7.543-2.294 14.525-1.816 21.648 1.861 15.955 8.236 26.57 21.285 34.563 36.879.464.905.734 1.863.18 3.185-2.613.493-5.644 1.88-5.303-3.18.084-1.238-.373-2.512-1.416-3.043-8.02-4.083-14.966-11.294-25.636-6.565-7.383 3.272-15.618 4.54-22.97 8.505 1.64 3.15 4.03 3.835 7.135 3.097 1.28-.304 2.64-.345 3.965-.362 2.947-.037 4.7 1.472 5.147 4.37.485 3.15-1.76 4.004-4.13 4.595-8.558 2.138-17.13 4.218-25.692 6.342-20.371 5.056-40.04 12.528-60.334 17.794-29.138 7.56-58.328 15.039-88.65 16.302-4.417.184-8.815.833-13.261 1.718 6.61 1.542 12.768 4.577 20.065 3.098 5.985-1.214 12.247-1.114 18.394-1.468 19.517-1.123 38.648-4.384 57.328-10.189 2.371-.736 4.713-1.567 7.074-2.335.113-.037.288.114 1.186.507-4.644 5.46-11.05 8.006-17.996 11.778 4.938 1.46 8.269.183 11.517-.426 25.375-4.758 49.97-12.67 75.037-18.693 21.437-5.15 43.013-8.7 65.174-7.828 5.702.225 11.25 1.1 16.762 2.36 3.143.718 5.707 2.377 7.912 4.889 11.418 13.007 16.849 28.494 19.17 45.322.519 3.764 1.044 7.527 1.776 12.792l-22.726-9.878c1.552-1.833 3.147-1.06 4.518-1.275 2.02-.317 4.986.617 5.325-2.305.284-2.453-.96-5.06-3.576-6.068-4.028-1.551-8.108-3.085-12.295-4.084-24.104-5.752-48.215-4.433-72.287.318-15.347 3.029-30.59 6.495-45.469 11.402-.946.312-1.922.571-2.817.997-2.05.977-3.984 2.318-3.326 4.902.702 2.757 3.21 2.016 5.034 1.689 8.845-1.589 17.632-3.452 26.155-6.397 1.34-.464 2.68-1.378 4.84-.485-6.38 6.628-15.19 9.538-22.537 16.673 11.106-1.874 20.851-3.492 30.587-5.166 25.679-4.414 51.473-5.345 76.687 1.703 31.825 8.895 45.997 27.58 47.117 58.899.535 14.958-1.956 29.5-7.382 43.488-.501 1.291-.363 3.084-2.189 3.58-1.085-.425-.962-1.37-.823-2.102 4.01-21.033-10.556-43.725-30.056-53.351-16.805-8.296-34.744-9.858-53.062-9.019-3.681.169-7.15 1.613-9.862 4.356-1.134 1.146-2.886 2.078-2.15 4.105.804 2.218 2.738 2.725 4.863 2.729 6.998.01 13.974.334 20.958.873 7.482.577 14.82 1.966 22.21 3.087 3.763.57 5.513 2.569 6.325 6.331 4.316 20.014 5.21 40.158 3.38 60.524-2.765 30.754-11.325 59.788-26.064 86.85-19.873 36.487-46.996 66.415-81.857 89.332-34.175 22.467-71.812 34.886-112.262 38.244-24.413 2.027-48.9.827-72.876-5.459-3.992-1.047-5.761-2.546-5.747-7.004.144-46.662.127-93.325-.019-139.988-.015-4.785 1.883-5.888 6.254-5.862 23.997.144 47.997.199 71.994.01 24.725-.193 48.807-4.158 71.093-15.306 23.731-11.872 39.945-30.519 45.825-56.739 6.075-27.093-.73-51.11-19.711-71.52-19-20.428-43.188-31.793-69.361-39.764-22.042-6.712-44.685-10.134-67.463-13.043-33.676-4.302-67.489-3.12-101.285-3.107-4.699.002-5.985 1.796-5.979 6.201.075 51.162.024 102.324-.007 153.486-.044 74.826-.099 149.652-.149 224.477-.003 5.443 0 10.885 0 16.071-2.14.536-2.797-.33-3.436-1.045-7.216-8.073-14.386-16.187-21.616-24.247-2.232-2.489-3.154-5.266-3.146-8.641.06-25.467-.025-50.935-.021-76.402.012-91.31.045-182.62.054-273.93 0-5.348-2.74-7.74-10.531-9.355-1.58 1.845-.925 4.109-.927 6.177-.068 103.659-.094 207.317-.14 310.976 0 2.162.016 4.354-.32 6.477-.29 1.83.025 4.5-2.763 4.613-2.587.105-4.951-.98-6.127-3.532-1.29-2.798-1.176-5.835-1.176-8.843-.006-70.494-.025-140.988-.038-211.483-.006-33.164-.226-66.33.176-99.49.082-6.735-1.685-11.09-7.764-13.734-1.34-.582-2.25-2.022-4.082-2.063-2.683 1.557-1.784 4.325-1.786 6.644-.038 59.828-.023 119.657-.002 179.485.012 33.33.054 66.66.067 99.99.001 1.31-.158 2.619-.247 4.011-.674 0-1.327.202-1.573-.03-7.788-7.311-14.764-15.382-21.546-23.605-2.213-2.684-2.11-6.418-1.857-9.625 1.2-15.154-2.454-28.809-8.96-42.66-9.965-21.22-13.97-44.222-15.645-67.684-2.137-29.93.849-59.146 10.14-87.66 1.952-5.993 4.687-11.743 7.266-17.514 1.037-2.32 1.87-4.865 5.379-5.158 2.535-.211 1.628-2.937 1.643-4.559.123-13.665.96-27.395-.07-40.98-1.32-17.386 5.189-29.918 18.874-40.25 17.153-12.949 35.735-23.19 55.108-32.192 33.537-15.584 69.222-24.657 104.68-34.403 33.024-9.077 65.26-20.04 94.222-38.937 1.116-.728 2.394-1.314 3.286-2.26 5.658-6.003 12.263-5.503 19.341-3.244 5.644 1.8 11.381 3.287 16.938 6.416-.72.93-.994 1.592-1.485 1.87-25.504 14.418-50.377 30.026-77.846 40.714-23.97 9.327-48.734 15.746-73.832 21.148-33.59 7.23-66.797 15.74-96.916 33.144-8.8 5.085-17.596 10.27-24.123 18.357-3.108 3.85-5.335 7.963-2.752 13.33 5.598-1.605 10.369-4.596 16.28-5.178.387-.033.367-.052.367-.052z"/><path d="M509.538 440.136c10.077 1.097 19.494 2.94 28.44 6.817 22.129 9.59 31.329 34.09 19.826 53.675-6.846 11.657-18.35 16.147-30Line truncated
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
@@ -57,4 +57,23 @@
|
||||
<string name="licenses_screen">Licenses Screen</string>
|
||||
<string name="contact">Contact</string>
|
||||
<string name="contact_the_author_by_email">Contact the author by email</string>
|
||||
<string name="reset_to_default">Reset to default</string>
|
||||
<string name="reset_all_data">Reset all data</string>
|
||||
<string name="are_you_sure_you_want_to_reset_all_settings_and_data_to_default">Are you sure you want to reset all settings and data to default?</string>
|
||||
<string name="confirm">Confirm</string>
|
||||
<string name="spotlight_animation">Spotlight animation</string>
|
||||
<string name="circle_2_animation">Circle 2 animation</string>
|
||||
<string name="circle_1_animation">Circle 1 animation</string>
|
||||
<string name="circle_3_animation">Circle 3 animation</string>
|
||||
<string name="wallpaper_changer_has_been_enabled">Wallpaper changer has been enabled.</string>
|
||||
<string name="wallpaper_changer_has_been_disabled">Wallpaper changer has been disabled.</string>
|
||||
<string name="dismiss">Dismiss</string>
|
||||
<string name="has_been_unselected">%1$s has been unselected.</string>
|
||||
<string name="interval">Interval | %1$s</string>
|
||||
<string name="minutes">%1$s minutes</string>
|
||||
<string name="minute">%1$s minute</string>
|
||||
<string name="hour">%1$s hour</string>
|
||||
<string name="hours">%1$s hours</string>
|
||||
<string name="day">%1$s day</string>
|
||||
<string name="days">%1$s days</string>
|
||||
</resources>
|
||||
@@ -5,7 +5,7 @@
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<!--
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +12,7 @@ plugins {
|
||||
id("com.google.dagger.hilt.android") version "2.50" apply false
|
||||
id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false
|
||||
id ("com.mikepenz.aboutlibraries.plugin") version "11.1.3" apply false
|
||||
id ("org.jetbrains.kotlin.plugin.serialization") version "1.9.22" apply false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Paperize Privacy Notice</title>
|
||||
<style>
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-top: 20px;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Introduction</h2>
|
||||
<p>Welcome to Paperize! This privacy notice outlines how we collect, use, and protect your personal information when you use our mobile application. By using Paperize, you agree to the terms described in this notice.</p>
|
||||
|
||||
<h2>Data Collection</h2>
|
||||
<p>Notification Access: Paperize requests notification access to provide you with personalized wallpaper recommendations based on your notifications. We do not store any notification content or personally identifiable information (PII) outside of your device.</p>
|
||||
<p>Local Files: Paperize accesses files stored on your device to allow you to set them as wallpapers. We do not upload or transfer these files to any external servers.</p>
|
||||
|
||||
<h2>Information Usage</h2>
|
||||
<p>Personal Data: We do not collect or store any personal data such as names, email addresses, or phone numbers.</p>
|
||||
<p>Usage Analytics: Paperize does not track your usage behavior or collect analytics data.</p>
|
||||
|
||||
<h2>Data Security</h2>
|
||||
<p>On-Device Storage: All data used by Paperize remains on your device. We do not transmit or store any data externally.</p>
|
||||
|
||||
<h2>Third-Party Services</h2>
|
||||
<p>Advertisements: Paperize does not display third-party ads.</p>
|
||||
<p>External Links: Our app may contain links to external websites. Please note that we are not responsible for the privacy practices of these sites.</p>
|
||||
|
||||
<h2>Children’s Privacy</h2>
|
||||
<p>Paperize is not intended for children under the age of 13. We do not knowingly collect any information from children.</p>
|
||||
|
||||
<h2>Changes to this notice</h2>
|
||||
<p>We may update this privacy notice from time to time. Any changes will be reflected in the app and on our website.</p>
|
||||
|
||||
<h2>Contact Us</h2>
|
||||
<p>If you have any questions or concerns about this privacy notice, please contact me at anthonyyla.dev@gmail.com.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -20,4 +20,5 @@ kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonTransitiveRClass=true
|
||||
org.gradle.configuration-cache=true
|
||||
@@ -0,0 +1,4 @@
|
||||
v0.1.0-alpha
|
||||
The main feature of the app is operational and ready for use
|
||||
There are a few minor features that are missing that will be added in v1.0.0 stable release
|
||||
Create an issue if there are any bugs
|
||||
@@ -0,0 +1,9 @@
|
||||
v0.2.0-alpha
|
||||
Cleaned code and allow adding to previously created albums.
|
||||
|
||||
Added functionality to add more wallpapers and folders to already created albums
|
||||
Refactored some old code to be cleaner
|
||||
Create an issue if there are any bugs or email me (GitHub profile)
|
||||
Planning
|
||||
Add an app icon 😆
|
||||
Look into whether live wallpaper using WallpaperManager (WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER) would work well/be realistic
|
||||
@@ -0,0 +1,6 @@
|
||||
v0.3.0
|
||||
Added app icon and GitHub redirect in settings page
|
||||
|
||||
Planning
|
||||
Look into whether live wallpaper using WallpaperManager (WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER) would work well/be realistic
|
||||
It would drain too much battery. Video/GIF wallpaper is also not possible with current WallpaperManager APIs without using live wallpaper
|
||||
@@ -0,0 +1,7 @@
|
||||
v1.0.0
|
||||
Updated dependencies, refactored code for more efficient and cleaner code
|
||||
Added reset option in the settings
|
||||
Fixed issue with using other images format other than JPG (now supports JPEG, PNG, AVIF, WEBP and perhaps more, untested)
|
||||
Fixed issue where the app would instantly crash if the content URIs were not cleared when uninstalling and reinstalling
|
||||
Planning
|
||||
Nothing at the moment. Give me your suggestions!
|
||||
@@ -0,0 +1,8 @@
|
||||
v1.1.0
|
||||
Added toggle for enabling wallpaper changer
|
||||
Added current set wallpaper preview
|
||||
Added adaptive icon support
|
||||
Updated splash screen loading animation
|
||||
Refactored code to be more performant
|
||||
Fixed an issue when trying to change wallpaper to an invalid one
|
||||
Fixed an issue where users could select an empty album
|
||||
@@ -0,0 +1,42 @@
|
||||
Paperize is a dynamic wallpaper changer application designed to keep your device's aesthetic fresh and exciting
|
||||
------
|
||||
Dynamic Wallpaper Changer: Set your wallpaper to change at specific time intervals
|
||||
Supports Various Image Types: Paperize can handle a wide range of image types
|
||||
JPEG, PNG, AVIF, WEBP
|
||||
Folder Support: Organize your wallpapers into folders for auto-updating
|
||||
Home and Lock Screen Wallpaper: Choose to change either your home screen, lock screen, or both
|
||||
On-Device Storage: All your wallpapers and settings are stored on your device
|
||||
------
|
||||
Technologies
|
||||
Kotlin - A programming language that is used for Android app development
|
||||
Jetpack Compose - A declarative UI toolkit for building native Android UI
|
||||
Material 3 - A UI design system git for modern UI guidelines
|
||||
Dagger Hilt - A dependency injection library
|
||||
Room - A persistence library that provides an abstraction layer over SQLite interfacing with Kotlin
|
||||
AboutLibraries - A library to offer some information of libraries
|
||||
Lottie Compose - A library that provides Lottie animation support for Jetpack Compose
|
||||
Landscapist - A Compose and KPP image loading library that streamlines Glide, Coil, and Fresco
|
||||
Zoomable - A library that provides a zoomable and pannable view, which can be used with any view you want
|
||||
AnimatedFABMenu - A animated floating action button with Material 3 design
|
||||
Thanks to the creators and maintainers of the open-source libraries used in this project.
|
||||
------
|
||||
Build
|
||||
This project is built using Kotlin, Java, and Gradle. Here are the steps to build the project:
|
||||
Prerequisites
|
||||
Java 8 (1.8)
|
||||
Android Studio Jellyfish | 2023.3.1 or later
|
||||
Gradle 8.4.0 or later
|
||||
Minimum SDK 26
|
||||
Steps
|
||||
Open a terminal and run the following git command:
|
||||
git clone https://github.com/Anthonyy232/Paperize.git
|
||||
Launch Android Studio and choose Open an existing Android Studio project. Navigate to the cloned repository and select the root folder of the project.
|
||||
In Android Studio, click on Build -> Generate Signed Bundle / APK and follow the instructions to generate an APK
|
||||
Alternatively, click ▶ Run and build the app and run it immediately
|
||||
------
|
||||
Contributions
|
||||
All contributions to the app is welcome. Feel free to report any issues and create pull requests for any issues or pull requests.
|
||||
------
|
||||
License
|
||||
Contact on my GitHub profile
|
||||
Paperize © GNU GPL v3.0
|
||||
|
After Width: | Height: | Size: 274 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 187 KiB |
@@ -0,0 +1 @@
|
||||
Paperize is a dynamic wallpaper changer application designed to keep your device's aesthetic fresh and exciting
|
||||