Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d9e87ff63 | ||
|
|
9a5b40ba7f | ||
|
|
dab5e4fe97 | ||
|
|
a635595ade | ||
|
|
f6fb087104 | ||
|
|
e3f56445d8 | ||
|
|
d8d6d4897d | ||
|
|
626b0a4de5 | ||
|
|
742d14ae3b | ||
|
|
a58a0c1e9a | ||
|
|
7b216d5534 | ||
|
|
65e4f38f83 | ||
|
|
fe43b4f631 | ||
|
|
7aab2a39d9 | ||
|
|
162d73e4e0 | ||
|
|
0f49241d7b | ||
|
|
df1bc642fc | ||
|
|
8eb9cb2aaa | ||
|
|
3f412f4724 | ||
|
|
047d519e80 | ||
|
|
b4041cc8ea | ||
|
|
fc57f14d2a | ||
|
|
4fd1e06b8e | ||
|
|
6a08e0eff9 | ||
|
|
d7edb40a9b | ||
|
|
ac889ed7b1 | ||
|
|
c97f9f7e3d | ||
|
|
4429355a1e | ||
|
|
00fbdf1e42 | ||
|
|
48aefd2aaa | ||
|
|
2c3330742e | ||
|
|
8022aa0f01 | ||
|
|
10397bbbbf | ||
|
|
379d6b21be | ||
|
|
41b32f3154 | ||
|
|
1906a3f170 | ||
|
|
f9207309a8 | ||
|
|
ca31e655ac | ||
|
|
047b2197e0 | ||
|
|
685168b0a6 | ||
|
|
d0fd31cf8c | ||
|
|
30783c6806 | ||
|
|
96f2a1337e | ||
|
|
e0c0fee8f0 | ||
|
|
060e1b8a07 | ||
|
|
19fc3a34e3 | ||
|
|
18582c2291 | ||
|
|
ea9977c511 | ||
|
|
c84b1c47ea |
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
|
||||||
Generated
+15
@@ -1,8 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="AppInsightsSettings">
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="selectedTabId" value="Android Vitals" />
|
||||||
<option name="tabSettings">
|
<option name="tabSettings">
|
||||||
<map>
|
<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">
|
<entry key="Firebase Crashlytics">
|
||||||
<value>
|
<value>
|
||||||
<InsightsFilterSettings>
|
<InsightsFilterSettings>
|
||||||
|
|||||||
Generated
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="Kotlin2JvmCompilerArguments">
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
</component>
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.9.0" />
|
<option name="version" value="1.9.22" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
<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>
|
<h1>Paperize</h1>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
</p>
|
|
||||||
</p>
|
</p>
|
||||||
<p>Paperize is a dynamic wallpaper changer application designed to keep your device's aesthetic fresh and exciting</p>
|
<p>Paperize is a dynamic wallpaper changer application designed to keep your device's aesthetic fresh and exciting</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -10,18 +11,21 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
- **Dynamic Wallpaper Changer**: Set your wallpaper to change at specific time intervals
|
- **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
|
- **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
|
- **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
|
- **On-Device Storage**: All your wallpapers and settings are stored on your device
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<br/>
|
<br/>
|
||||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/eebec922-70a6-4d54-97d9-ab02cbfb7a36" width="30%" alt="onboarding" />
|
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/eebec922-70a6-4d54-97d9-ab02cbfb7a36" width="30%" alt="onboarding" />
|
||||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/60a4d68d-5e19-49f2-8822-e702d02651c6" width="30%" alt="wallpaper" />
|
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/e22c1928-81f5-4b9a-822f-2d3c901bab3f" width="30%" alt="wallpaper" />
|
||||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/e106c0dc-23ff-4f4a-adfc-5ebe93219ae0" width="30%" alt="album" />
|
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/e106c0dc-23ff-4f4a-adfc-5ebe93219ae0" width="30%" alt="album" />
|
||||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/7093a1ea-91ab-4da8-a82b-43e24d88d376" width="30%" alt="settings" />
|
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/66b092e5-4af4-4396-b145-63ee506d9257" width="30%" alt="settings" />
|
||||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/54ebd285-8da4-4446-83f1-ba0e7ee9476d" width="30%" alt="adding" />
|
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/54ebd285-8da4-4446-83f1-ba0e7ee9476d" width="30%" alt="adding" />
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<div><video controls src="https://github.com/Anthonyy232/Paperize/assets/60626873/086f27da-1648-456a-8581-79e56f4f4881" muted="false"></video></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -31,6 +35,13 @@
|
|||||||
|
|
||||||
Playstore and F-Droid will be added soon
|
Playstore and F-Droid will be added soon
|
||||||
|
|
||||||
|
## Localization
|
||||||
|
I want to allow more people to use the app. Currently, translations are provided using machine translation and AI -- which is not optimal.
|
||||||
|
|
||||||
|
I would love some help translating the app! Help me out with that [here](https://crowdin.com/project/paperize/invite?h=d8d7a7513d2beb0c96ba9b2a5f85473e2084922)!
|
||||||
|
|
||||||
|
[](https://crowdin.com/project/paperize)
|
||||||
|
|
||||||
## Technologies
|
## Technologies
|
||||||
|
|
||||||
- [Kotlin](https://kotlinlang.org/) - A programming language that is used for Android app development
|
- [Kotlin](https://kotlinlang.org/) - A programming language that is used for Android app development
|
||||||
@@ -42,6 +53,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
|
- [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
|
- [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
|
- [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.
|
Thanks to the creators and maintainers of the open-source libraries used in this project.
|
||||||
|
|
||||||
@@ -52,8 +64,8 @@ This project is built using Kotlin, Java, and Gradle. Here are the steps to buil
|
|||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
- Java 8 (1.8)
|
- Java 8 (1.8)
|
||||||
- Android Studio Iguana | 2023.2.1 or later
|
- Android Studio Jellyfish | 2023.3.1 or later
|
||||||
- Gradle 8.3.2 or later
|
- Gradle 8.4.0 or later
|
||||||
- Minimum SDK 26
|
- Minimum SDK 26
|
||||||
|
|
||||||
### Steps
|
### Steps
|
||||||
@@ -71,4 +83,4 @@ All contributions to the app is welcome. Feel free to report any issues and crea
|
|||||||
## License
|
## License
|
||||||
Contact on my GitHub profile
|
Contact on my GitHub profile
|
||||||
|
|
||||||
Paperize © GNU GPL v3.0
|
Anthony La © GNU GPL v3.0
|
||||||
+39
-23
@@ -4,10 +4,12 @@ plugins {
|
|||||||
id("com.google.devtools.ksp")
|
id("com.google.devtools.ksp")
|
||||||
id("com.google.dagger.hilt.android")
|
id("com.google.dagger.hilt.android")
|
||||||
id ("com.mikepenz.aboutlibraries.plugin")
|
id ("com.mikepenz.aboutlibraries.plugin")
|
||||||
|
id ("org.jetbrains.kotlin.plugin.serialization")
|
||||||
}
|
}
|
||||||
ksp {
|
ksp {
|
||||||
arg("room.schemaLocation", "$projectDir/schemas")
|
arg("room.schemaLocation", "$projectDir/schemas")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.anthonyla.paperize"
|
namespace = "com.anthonyla.paperize"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
@@ -16,8 +18,8 @@ android {
|
|||||||
applicationId = "com.anthonyla.paperize"
|
applicationId = "com.anthonyla.paperize"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 12
|
||||||
versionName = "1.0"
|
versionName = "1.3.0"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
@@ -25,6 +27,7 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
@@ -40,13 +43,19 @@ android {
|
|||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
|
freeCompilerArgs += strongSkippingConfiguration()
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
}
|
}
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion = "1.5.1"
|
kotlinCompilerExtensionVersion = "1.5.10"
|
||||||
|
}
|
||||||
|
|
||||||
|
androidResources {
|
||||||
|
generateLocaleConfig = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,24 +66,24 @@ androidComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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.lifecycle:lifecycle-runtime-ktx:2.8.0")
|
||||||
implementation("androidx.activity:activity-compose:1.9.0")
|
implementation("androidx.activity:activity-compose:1.9.0")
|
||||||
implementation(platform("androidx.compose:compose-bom:2024.04.01"))
|
implementation(platform("androidx.compose:compose-bom:2024.05.00"))
|
||||||
implementation("androidx.compose.ui:ui:1.6.6")
|
implementation("androidx.compose.ui:ui:1.7.0-beta01")
|
||||||
implementation("androidx.compose.ui:ui-graphics:1.6.6")
|
implementation("androidx.compose.ui:ui-graphics:1.7.0-beta01")
|
||||||
implementation("androidx.compose.ui:ui-tooling-preview:1.6.6")
|
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-beta01")
|
||||||
implementation("androidx.compose.material3:material3:1.3.0-alpha05")
|
implementation("androidx.compose.material3:material3:1.3.0-beta01")
|
||||||
implementation("androidx.navigation:navigation-compose:2.8.0-alpha07")
|
implementation("androidx.navigation:navigation-compose:2.8.0-beta01")
|
||||||
implementation("androidx.compose.material:material:1.7.0-alpha07")
|
implementation("androidx.compose.material:material:1.7.0-beta01")
|
||||||
implementation("androidx.datastore:datastore:1.1.0")
|
implementation("androidx.datastore:datastore:1.1.1")
|
||||||
implementation("androidx.datastore:datastore-preferences:1.1.0")
|
implementation("androidx.datastore:datastore-preferences:1.1.1")
|
||||||
implementation("androidx.compose.material:material-icons-extended:1.7.0-alpha07")
|
implementation("androidx.compose.material:material-icons-extended:1.7.0-beta01")
|
||||||
implementation("com.google.accompanist:accompanist-adaptive:0.34.0")
|
implementation("com.google.accompanist:accompanist-adaptive:0.34.0")
|
||||||
implementation("androidx.hilt:hilt-navigation-compose:1.2.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-beta01")
|
||||||
implementation("androidx.core:core-splashscreen:1.2.0-alpha01")
|
implementation("androidx.core:core-splashscreen:1.2.0-alpha01")
|
||||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
|
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.0")
|
||||||
implementation("com.google.code.gson:gson:2.10.1")
|
implementation("com.google.code.gson:gson:2.10.1")
|
||||||
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
|
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
|
||||||
implementation("net.engawapg.lib:zoomable:1.7.0-beta02")
|
implementation("net.engawapg.lib:zoomable:1.7.0-beta02")
|
||||||
@@ -83,18 +92,25 @@ dependencies {
|
|||||||
implementation("androidx.hilt:hilt-work:1.2.0")
|
implementation("androidx.hilt:hilt-work:1.2.0")
|
||||||
implementation("com.airbnb.android:lottie-compose:6.4.0")
|
implementation("com.airbnb.android:lottie-compose:6.4.0")
|
||||||
implementation("com.google.accompanist:accompanist-permissions:0.35.0-alpha")
|
implementation("com.google.accompanist:accompanist-permissions:0.35.0-alpha")
|
||||||
implementation("com.mikepenz:aboutlibraries-core:11.1.3")
|
implementation("com.mikepenz:aboutlibraries-core:11.1.4")
|
||||||
implementation("com.mikepenz:aboutlibraries-compose-m3:11.1.3")
|
implementation("com.mikepenz:aboutlibraries-compose-m3:11.1.4")
|
||||||
|
implementation("androidx.compose.foundation:foundation:1.7.0-beta01")
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha03")
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha04")
|
||||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.6")
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-beta01")
|
||||||
debugImplementation("androidx.compose.ui:ui-tooling:1.6.6")
|
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-beta01")
|
||||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.6")
|
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta01")
|
||||||
implementation("com.google.dagger:hilt-android:2.51.1")
|
implementation("com.google.dagger:hilt-android:2.51.1")
|
||||||
ksp("com.google.dagger:hilt-android-compiler:2.51.1")
|
ksp("com.google.dagger:hilt-android-compiler:2.51.1")
|
||||||
implementation("androidx.room:room-runtime:2.6.1")
|
implementation("androidx.room:room-runtime:2.6.1")
|
||||||
ksp("androidx.room:room-compiler:2.6.1")
|
ksp("androidx.room:room-compiler:2.6.1")
|
||||||
implementation("androidx.room:room-ktx:2.6.1")
|
implementation("androidx.room:room-ktx:2.6.1")
|
||||||
implementation("com.lazygeniouz:dfc:1.0.8")
|
implementation("com.lazygeniouz:dfc:1.0.8")
|
||||||
|
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun strongSkippingConfiguration() = listOf(
|
||||||
|
"-P",
|
||||||
|
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true",
|
||||||
|
)
|
||||||
@@ -2,28 +2,27 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
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.SET_WALLPAPER"/>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.service.wallpaper.WallpaperService" />
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:name=".App"
|
android:name=".App"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/app_icon"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Paperize"
|
android:theme="@style/Theme.Paperize" tools:targetApi="tiramisu">
|
||||||
android:enableOnBackInvokedCallback="true"
|
|
||||||
tools:targetApi="tiramisu">
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".feature.wallpaper.presentation.MainActivity"
|
android:name=".feature.wallpaper.presentation.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -33,8 +32,8 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service android:name=".feature.wallpaper.wallpaperservice.WallpaperService" android:foregroundServiceType="mediaPlayback"/>
|
<service android:name=".feature.wallpaper.wallpaper_service.WallpaperService" android:foregroundServiceType="mediaPlayback"/>
|
||||||
<receiver android:name=".feature.wallpaper.wallpaperservice.WallpaperBootReceiver"
|
<receiver android:name=".feature.wallpaper.wallpaper_service.WallpaperBootReceiver"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.app.Application
|
|||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.anthonyla.paperize.core
|
||||||
|
|
||||||
|
enum class ScalingConstants {
|
||||||
|
FIT,
|
||||||
|
FILL,
|
||||||
|
STRETCH
|
||||||
|
}
|
||||||
@@ -14,4 +14,8 @@ object SettingsConstants {
|
|||||||
const val FIRST_LAUNCH = "first_launch"
|
const val FIRST_LAUNCH = "first_launch"
|
||||||
const val LAST_SET_TIME = "last_set_time"
|
const val LAST_SET_TIME = "last_set_time"
|
||||||
const val NEXT_SET_TIME = "next_set_time"
|
const val NEXT_SET_TIME = "next_set_time"
|
||||||
|
const val ENABLE_CHANGER = "enable_changer"
|
||||||
|
const val DARKEN_PERCENTAGE = "darken_percentage"
|
||||||
|
const val DARKEN = "darken"
|
||||||
|
const val WALLPAPER_SCALING = "wallpaper_scaling"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.anthonyla.paperize.core
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.ColorMatrix
|
||||||
|
import android.graphics.ColorMatrixColorFilter
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.net.Uri
|
||||||
|
import android.util.Log
|
||||||
|
import android.util.Size
|
||||||
|
import androidx.compose.ui.util.fastRoundToInt
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the dimensions of the image from the uri
|
||||||
|
*/
|
||||||
|
fun Uri.getImageDimensions(context: Context): Size {
|
||||||
|
val inputStream = context.contentResolver.openInputStream(this)!!
|
||||||
|
val exif = ExifInterface(inputStream)
|
||||||
|
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 Size(width, height)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the inSampleSize for the image
|
||||||
|
*/
|
||||||
|
fun calculateInSampleSize(imageSize: Size, width: Int, height: Int): Int {
|
||||||
|
return if (imageSize.width <= width && imageSize.height <= height) { 1 }
|
||||||
|
else { (imageSize.width/ width.toFloat()).fastRoundToInt() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale a bitmap using the fit width method
|
||||||
|
* The bitmap will fit into the given width while maintaining the same aspect ratio
|
||||||
|
*/
|
||||||
|
fun fitBitmap(source: Bitmap, width: Int, height: Int): Bitmap {
|
||||||
|
val aspectRatio = source.height.toFloat() / source.width.toFloat()
|
||||||
|
val newHeight = (width * aspectRatio).toInt()
|
||||||
|
val newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(newBitmap)
|
||||||
|
val bitmap = Bitmap.createScaledBitmap(source, width, newHeight, true)
|
||||||
|
val top = (height - newHeight) / 2f
|
||||||
|
canvas.drawBitmap(bitmap, 0f, top, null)
|
||||||
|
return newBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale a bitmap using the fill height method
|
||||||
|
*/
|
||||||
|
fun fillBitmap(source: Bitmap, width: Int, height: Int): Bitmap {
|
||||||
|
try {
|
||||||
|
val aspectRatio = source.width.toFloat() / source.height.toFloat()
|
||||||
|
var newWidth = width
|
||||||
|
var newHeight = (newWidth / aspectRatio).toInt()
|
||||||
|
if (newHeight < height) {
|
||||||
|
newHeight = height
|
||||||
|
newWidth = (newHeight * aspectRatio).toInt()
|
||||||
|
}
|
||||||
|
val scaledBitmap = Bitmap.createScaledBitmap(source, newWidth, newHeight, true)
|
||||||
|
val x = (width - newWidth) / 2f
|
||||||
|
val y = (height - newHeight) / 2f
|
||||||
|
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(bitmap)
|
||||||
|
canvas.drawBitmap(scaledBitmap, x, y, null)
|
||||||
|
return bitmap
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("WallpaperUtil", "Error filling bitmap: $e")
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stretch the bitmap to fit the given width and height
|
||||||
|
*/
|
||||||
|
fun stretchBitmap(source: Bitmap, width: Int, height: Int): Bitmap {
|
||||||
|
try {
|
||||||
|
val newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(newBitmap)
|
||||||
|
val bitmap = Bitmap.createScaledBitmap(source, width, height, true)
|
||||||
|
canvas.drawBitmap(bitmap, 0f, 0f, null)
|
||||||
|
return newBitmap
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("WallpaperUtil", "Error stretching bitmap: $e")
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Darken the bitmap by a certain percentage - 0 is darkest, 100 is original
|
||||||
|
*/
|
||||||
|
fun darkenBitmap(source: Bitmap, percent: Int, width: Int, height: Int): Bitmap {
|
||||||
|
try {
|
||||||
|
val safePercentage = (100 - percent).coerceIn(0, 100)
|
||||||
|
val factor = 1 - safePercentage / 100f
|
||||||
|
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(bitmap)
|
||||||
|
val paint = Paint().apply {
|
||||||
|
colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
||||||
|
setScale(factor, factor, factor, 1f)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
canvas.drawBitmap(source, 0f, 0f, paint)
|
||||||
|
return bitmap
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("WallpaperUtil", "Error darkening bitmap: $e")
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package com.anthonyla.paperize.di
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.room.Room
|
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.SettingsDataStore
|
||||||
import com.anthonyla.paperize.data.settings.SettingsDataStoreImpl
|
import com.anthonyla.paperize.data.settings.SettingsDataStoreImpl
|
||||||
import com.anthonyla.paperize.feature.wallpaper.data.data_source.AlbumDatabase
|
import com.anthonyla.paperize.feature.wallpaper.data.data_source.AlbumDatabase
|
||||||
@@ -31,7 +33,7 @@ object AppModule {
|
|||||||
app,
|
app,
|
||||||
AlbumDatabase::class.java,
|
AlbumDatabase::class.java,
|
||||||
AlbumDatabase.DATABASE_NAME
|
AlbumDatabase.DATABASE_NAME
|
||||||
).build()
|
).addMigrations(MIGRATION_1_2).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -41,7 +43,7 @@ object AppModule {
|
|||||||
app,
|
app,
|
||||||
SelectedAlbumDatabase::class.java,
|
SelectedAlbumDatabase::class.java,
|
||||||
SelectedAlbumDatabase.DATABASE_NAME
|
SelectedAlbumDatabase.DATABASE_NAME
|
||||||
).build()
|
).addMigrations(MIGRATION_1_2).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -80,3 +82,9 @@ object AppModule {
|
|||||||
@ApplicationContext context: Context,
|
@ApplicationContext context: Context,
|
||||||
): Context { return 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -66,4 +66,20 @@ interface AlbumDao {
|
|||||||
|
|
||||||
@Update
|
@Update
|
||||||
suspend fun updateFolder(folder: Folder)
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -13,7 +13,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
|||||||
*/
|
*/
|
||||||
@Database(
|
@Database(
|
||||||
entities = [Album::class, Wallpaper::class, Folder::class],
|
entities = [Album::class, Wallpaper::class, Folder::class],
|
||||||
version = 1
|
version = 2
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class AlbumDatabase: RoomDatabase() {
|
abstract class AlbumDatabase: RoomDatabase() {
|
||||||
|
|||||||
-1
@@ -2,7 +2,6 @@ package com.anthonyla.paperize.feature.wallpaper.data.data_source
|
|||||||
|
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converters for Room database to convert list of strings to json string and vice versa
|
* Converters for Room database to convert list of strings to json string and vice versa
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
|||||||
*/
|
*/
|
||||||
@Database(
|
@Database(
|
||||||
entities = [Album::class, Wallpaper::class],
|
entities = [Album::class, Wallpaper::class],
|
||||||
version = 1
|
version = 2
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class SelectedAlbumDatabase: RoomDatabase() {
|
abstract class SelectedAlbumDatabase: RoomDatabase() {
|
||||||
|
|||||||
+4
@@ -86,4 +86,8 @@ class AlbumRepositoryImpl(
|
|||||||
override suspend fun deleteWallpaperList(wallpapers: List<Wallpaper>) {
|
override suspend fun deleteWallpaperList(wallpapers: List<Wallpaper>) {
|
||||||
dao.deleteWallpaperList(wallpapers)
|
dao.deleteWallpaperList(wallpapers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun deleteAllData() {
|
||||||
|
dao.deleteAllData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -2,8 +2,6 @@ package com.anthonyla.paperize.feature.wallpaper.data.repository
|
|||||||
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.data.data_source.SelectedAlbumDao
|
import com.anthonyla.paperize.feature.wallpaper.data.data_source.SelectedAlbumDao
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
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.model.Wallpaper
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
|
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
|
||||||
@@ -17,6 +15,7 @@ class SelectedAlbumRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun upsertSelectedAlbum(selectedAlbum: SelectedAlbum) {
|
override suspend fun upsertSelectedAlbum(selectedAlbum: SelectedAlbum) {
|
||||||
|
dao.deleteAll()
|
||||||
dao.upsertAlbum(selectedAlbum.album)
|
dao.upsertAlbum(selectedAlbum.album)
|
||||||
dao.upsertWallpaperList(selectedAlbum.wallpapers)
|
dao.upsertWallpaperList(selectedAlbum.wallpapers)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,5 @@ data class Album(
|
|||||||
val coverUri: String?,
|
val coverUri: String?,
|
||||||
val initialized: Boolean = false,
|
val initialized: Boolean = false,
|
||||||
val wallpapersInQueue: List<String> = emptyList(),
|
val wallpapersInQueue: List<String> = emptyList(),
|
||||||
|
val currentWallpaper: String? = null
|
||||||
)
|
)
|
||||||
+5
@@ -96,4 +96,9 @@ interface AlbumRepository {
|
|||||||
* Delete folder list in one transaction
|
* Delete folder list in one transaction
|
||||||
*/
|
*/
|
||||||
suspend fun deleteFolderList(folders: List<Folder>)
|
suspend fun deleteFolderList(folders: List<Folder>)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all data in database
|
||||||
|
*/
|
||||||
|
suspend fun deleteAllData()
|
||||||
}
|
}
|
||||||
+65
-3
@@ -1,32 +1,45 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation
|
package com.anthonyla.paperize.feature.wallpaper.presentation
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.ActivityManager
|
||||||
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.animation.AccelerateInterpolator
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.animation.doOnEnd
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.compose.LifecycleEventEffect
|
||||||
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.anthonyla.paperize.core.SettingsConstants
|
import com.anthonyla.paperize.core.SettingsConstants
|
||||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
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.settings_screen.SettingsViewModel
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeTheme
|
import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeTheme
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.WallpaperService
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
private val albumsViewModel: AlbumsViewModel by viewModels()
|
|
||||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||||
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
|
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
|
||||||
private val context = this
|
private val context = this
|
||||||
@@ -38,14 +51,63 @@ class MainActivity : ComponentActivity() {
|
|||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val splashScreen = installSplashScreen()
|
val splashScreen = installSplashScreen()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
splashScreen.setKeepOnScreenCondition { settingsViewModel.setKeepOnScreenCondition }
|
splashScreen.setKeepOnScreenCondition { settingsViewModel.setKeepOnScreenCondition }
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
|
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||||
|
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
||||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
val serviceIntent = Intent(this@MainActivity, WallpaperService::class.java)
|
||||||
|
val isAlreadyRunning = withContext(Dispatchers.IO) {5
|
||||||
|
val activityManager = getSystemService(ACTIVITY_SERVICE) as? ActivityManager
|
||||||
|
activityManager?.getRunningServices(Integer.MAX_VALUE)?.any {
|
||||||
|
it.service == serviceIntent.component
|
||||||
|
} ?: false
|
||||||
|
}
|
||||||
|
if (selectedState.value.selectedAlbum != null && settingsState.value.enableChanger) {
|
||||||
|
if (!isAlreadyRunning) {
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.START.toString()
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isAlreadyRunning) {
|
||||||
|
Intent(context, WallpaperService::class.java).also {
|
||||||
|
it.action = WallpaperService.Actions.STOP.toString()
|
||||||
|
context.startForegroundService(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PaperizeTheme(settingsState) {
|
||||||
Surface(tonalElevation = 5.dp) {
|
Surface(tonalElevation = 5.dp) {
|
||||||
PaperizeApp(isFirstLaunch)
|
PaperizeApp(isFirstLaunch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+227
-87
@@ -6,6 +6,11 @@ import android.content.pm.PackageManager
|
|||||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -16,9 +21,12 @@ import androidx.navigation.compose.NavHost
|
|||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.navArgument
|
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.SelectedAlbum
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
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.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.AlbumsEvent
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.AlbumViewScreen
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.AlbumViewScreen
|
||||||
@@ -34,13 +42,25 @@ 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.WallpaperEvent
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
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.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.NavConstants.INITIAL_OFFSET
|
||||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.NavScreens
|
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.sharedXTransitionIn
|
||||||
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionOut
|
import com.anthonyla.paperize.feature.wallpaper.util.navigation.sharedXTransitionOut
|
||||||
import com.anthonyla.paperize.feature.wallpaper.wallpaperservice.WallpaperService
|
import com.anthonyla.paperize.feature.wallpaper.wallpaper_service.WallpaperService
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
@@ -52,57 +72,53 @@ fun PaperizeApp(
|
|||||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||||
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
||||||
|
addAlbumViewModel: AddAlbumViewModel = hiltViewModel(),
|
||||||
) {
|
) {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||||
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
||||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
var job by remember { mutableStateOf<Job?>(null) }
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
// React to albumState changes and change selectedAlbum's details to keep it from being stale
|
// React to albumState changes and change selectedAlbum's details to keep it from being stale
|
||||||
LaunchedEffect(albumState.value.albumsWithWallpapers) {
|
LaunchedEffect(albumState.value.albumsWithWallpapers) {
|
||||||
albumState.value.albumsWithWallpapers.asSequence().forEach { albumWithWallpapers ->
|
albumState.value.albumsWithWallpapers.asSequence().forEach { albumWithWallpapers ->
|
||||||
if (!albumWithWallpapers.album.initialized && (albumWithWallpapers.wallpapers.isNotEmpty() || albumWithWallpapers.folders.isNotEmpty())) {
|
if (!albumWithWallpapers.album.initialized && (albumWithWallpapers.wallpapers.isNotEmpty() || albumWithWallpapers.folders.isNotEmpty())) {
|
||||||
albumsViewModel.onEvent(AlbumsEvent.InitializeAlbum(albumWithWallpapers))
|
albumsViewModel.onEvent(AlbumsEvent.InitializeAlbum(albumWithWallpapers))
|
||||||
} else if (albumWithWallpapers.album.initialized && albumWithWallpapers.wallpapers.isEmpty() && albumWithWallpapers.folders.isEmpty()) {
|
}
|
||||||
if (navController.currentDestination?.route != NavScreens.Home.route) {
|
else if (albumWithWallpapers.wallpapers.isEmpty() && albumWithWallpapers.folders.isEmpty() && albumWithWallpapers.album.initialized) {
|
||||||
navController.popBackStack(NavScreens.Home.route, false)
|
if (navController.currentDestination?.route == Home::class.simpleName) {
|
||||||
|
navController.popBackStack<Home>(inclusive = false)
|
||||||
}
|
}
|
||||||
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
|
albumsViewModel.onEvent(AlbumsEvent.DeleteAlbumWithWallpapers(albumWithWallpapers))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedState.value.selectedAlbum?.let { selectedAlbum ->
|
selectedState.value.selectedAlbum?.let { selectedAlbum ->
|
||||||
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }
|
albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == selectedAlbum.album.initialAlbumName }?.let { foundAlbum ->
|
||||||
?.let { foundAlbum ->
|
|
||||||
val albumNameHashCode = foundAlbum.album.initialAlbumName.hashCode()
|
val albumNameHashCode = foundAlbum.album.initialAlbumName.hashCode()
|
||||||
val wallpapers: List<Wallpaper> =
|
val wallpapers: List<Wallpaper> =
|
||||||
foundAlbum.wallpapers + foundAlbum.folders.flatMap { folder ->
|
foundAlbum.wallpapers + foundAlbum.folders.flatMap { folder ->
|
||||||
folder.wallpapers.map { wallpaper ->
|
folder.wallpapers.map { wallpaper ->
|
||||||
val wallpaperHashCode = wallpaper.hashCode()
|
|
||||||
Wallpaper(
|
Wallpaper(
|
||||||
initialAlbumName = foundAlbum.album.initialAlbumName,
|
initialAlbumName = foundAlbum.album.initialAlbumName,
|
||||||
wallpaperUri = wallpaper,
|
wallpaperUri = wallpaper,
|
||||||
key = wallpaperHashCode + albumNameHashCode,
|
key = wallpaper.hashCode() + albumNameHashCode,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val wallpaperUriSet = wallpapers.map { it.wallpaperUri }.toSet()
|
val wallpaperUriSet = wallpapers.map { it.wallpaperUri }.toSet()
|
||||||
val newSelectedAlbum = SelectedAlbum(
|
val newSelectedAlbum = SelectedAlbum(
|
||||||
album = foundAlbum.album.copy(
|
album = foundAlbum.album.copy(
|
||||||
wallpapersInQueue = selectedAlbum.album.wallpapersInQueue.filter { it in wallpaperUriSet }
|
wallpapersInQueue = selectedAlbum.album.wallpapersInQueue.filter { it in wallpaperUriSet },
|
||||||
|
currentWallpaper = selectedAlbum.album.currentWallpaper
|
||||||
),
|
),
|
||||||
wallpapers = wallpapers
|
wallpapers = wallpapers
|
||||||
)
|
)
|
||||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum, null))
|
||||||
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(settingsState.value.interval))
|
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(settingsState.value.interval))
|
||||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
} ?: run {
|
||||||
action = WallpaperService.Actions.START.toString()
|
|
||||||
putExtra("timeInMinutes", settingsState.value.interval)
|
|
||||||
}
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
?: run {
|
|
||||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||||
Intent(context, WallpaperService::class.java).also {
|
Intent(context, WallpaperService::class.java).also {
|
||||||
it.action = WallpaperService.Actions.STOP.toString()
|
it.action = WallpaperService.Actions.STOP.toString()
|
||||||
@@ -114,12 +130,11 @@ fun PaperizeApp(
|
|||||||
|
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = if (firstLaunch) NavScreens.Startup.route else NavScreens.Home.route,
|
startDestination = if (firstLaunch) Startup else Home,
|
||||||
modifier = Modifier.navigationBarsPadding()
|
modifier = Modifier.navigationBarsPadding()
|
||||||
) {
|
) {
|
||||||
// Navigate to the startup screen to show the privacy policy and notification screen
|
// Navigate to the startup screen to show the privacy policy and notification screen
|
||||||
composable(
|
composable<Startup> (
|
||||||
route = NavScreens.Startup.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -137,20 +152,16 @@ fun PaperizeApp(
|
|||||||
onAgree = {
|
onAgree = {
|
||||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
||||||
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
||||||
navController.navigate(NavScreens.Home.route) {
|
navController.navigate(Home) {
|
||||||
popUpTo(NavScreens.Startup.route) { inclusive = true }
|
popUpTo<Startup> { inclusive = true }
|
||||||
popUpTo(NavScreens.Notification.route) { inclusive = true }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else { navController.navigate(Notification) }
|
||||||
navController.navigate(NavScreens.Notification.route)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Navigate to the notification screen to ask for notification permission
|
// Navigate to the notification screen to ask for notification permission
|
||||||
composable(
|
composable<Notification> (
|
||||||
route = NavScreens.Notification.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -167,16 +178,14 @@ fun PaperizeApp(
|
|||||||
NotificationScreen(
|
NotificationScreen(
|
||||||
onAgree = {
|
onAgree = {
|
||||||
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
settingsViewModel.onEvent(SettingsEvent.SetFirstLaunch)
|
||||||
navController.navigate(NavScreens.Home.route) {
|
navController.navigate(Home) {
|
||||||
popUpTo(NavScreens.Startup.route) { inclusive = true }
|
popUpTo<Notification> { inclusive = true }
|
||||||
popUpTo(NavScreens.Notification.route) { inclusive = true }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Navigate to the home screen to view all albums and wallpapers
|
// Navigate to the home screen to view all albums and wallpapers
|
||||||
composable(
|
composable<Home> (
|
||||||
route = NavScreens.Home.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -191,33 +200,124 @@ fun PaperizeApp(
|
|||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
HomeScreen(
|
HomeScreen(
|
||||||
onSettingsClick = { navController.navigate(NavScreens.Settings.route) },
|
onSettingsClick = { navController.navigate(Settings) },
|
||||||
navigateToAddWallpaperScreen = {
|
navigateToAddWallpaperScreen = {
|
||||||
navController.navigate("${NavScreens.AddEdit.route}/$it")
|
navController.navigate(AddEdit(it))
|
||||||
},
|
},
|
||||||
onAlbumViewClick = {
|
onAlbumViewClick = {
|
||||||
navController.navigate("${NavScreens.AlbumView.route}/$it")
|
navController.navigate(AlbumView(it))
|
||||||
},
|
},
|
||||||
onScheduleWallpaperChanger = { timeInMinutes ->
|
onScheduleWallpaperChanger = { timeInMinutes ->
|
||||||
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(timeInMinutes))
|
settingsViewModel.onEvent(SettingsEvent.SetWallpaperInterval(timeInMinutes))
|
||||||
|
if (settingsState.value.enableChanger) {
|
||||||
val intent = Intent(context, WallpaperService::class.java).apply {
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
action = WallpaperService.Actions.START.toString()
|
action = WallpaperService.Actions.START.toString()
|
||||||
putExtra("timeInMinutes", timeInMinutes)
|
putExtra("timeInMinutes", timeInMinutes)
|
||||||
}
|
}
|
||||||
context.startForegroundService(intent)
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onStop = {
|
onStop = {
|
||||||
|
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||||
|
settingsViewModel.onEvent(SettingsEvent.SetChangerToggle(false))
|
||||||
Intent(context, WallpaperService::class.java).also {
|
Intent(context, WallpaperService::class.java).also {
|
||||||
it.action = WallpaperService.Actions.STOP.toString()
|
it.action = WallpaperService.Actions.STOP.toString()
|
||||||
context.startForegroundService(it)
|
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))
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(2000)
|
||||||
|
if (settingsState.value.enableChanger) {
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.UPDATE.toString()
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedAlbum = selectedState.value.selectedAlbum,
|
||||||
|
enableChanger = settingsState.value.enableChanger,
|
||||||
|
darkenPercentage = settingsState.value.darkenPercentage,
|
||||||
|
darken = settingsState.value.darken,
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSelectAlbum = {album ->
|
||||||
|
settingsViewModel.onEvent(SettingsEvent.SetChangerToggle(true))
|
||||||
|
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(null, album))
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.START.toString()
|
||||||
|
putExtra("timeInMinutes", settingsState.value.interval)
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
},
|
||||||
|
onDarkenPercentage = {
|
||||||
|
settingsViewModel.onEvent(SettingsEvent.SetDarkenPercentage(it))
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(2000)
|
||||||
|
if (settingsState.value.enableChanger) {
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.UPDATE.toString()
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDarkCheck = {
|
||||||
|
settingsViewModel.onEvent(SettingsEvent.SetDarken(it))
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(2000)
|
||||||
|
if (settingsState.value.enableChanger) {
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.UPDATE.toString()
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scaling = settingsState.value.wallpaperScaling,
|
||||||
|
onScalingChange = {
|
||||||
|
if (settingsState.value.wallpaperScaling != it) {
|
||||||
|
settingsViewModel.onEvent(SettingsEvent.SetWallpaperScaling(it))
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(2000)
|
||||||
|
if (settingsState.value.enableChanger) {
|
||||||
|
val intent = Intent(context, WallpaperService::class.java).apply {
|
||||||
|
action = WallpaperService.Actions.UPDATE.toString()
|
||||||
|
}
|
||||||
|
context.startForegroundService(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Navigate to the add album screen to create a new album and add wallpapers to it
|
// Navigate to the add album screen to create a new album and add wallpapers to it
|
||||||
composable(
|
composable<AddEdit>(
|
||||||
route = NavScreens.AddEdit.route.plus("/{initialAlbumName}"),
|
|
||||||
arguments = listOf(navArgument("initialAlbumName") { type = NavType.StringType }),
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -231,31 +331,28 @@ fun PaperizeApp(
|
|||||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||||
}
|
}
|
||||||
) {backStackEntry ->
|
) {backStackEntry ->
|
||||||
backStackEntry.arguments?.getString("initialAlbumName").let {
|
val addEdit: AddEdit = backStackEntry.toRoute()
|
||||||
if (it != null) {
|
|
||||||
AddAlbumScreen(
|
AddAlbumScreen(
|
||||||
initialAlbumName = it,
|
initialAlbumName = addEdit.wallpaper,
|
||||||
onBackClick = { navController.navigateUp() },
|
onBackClick = { navController.navigateUp() },
|
||||||
onConfirmation = {
|
onConfirmation = { navController.navigateUp() },
|
||||||
navController.navigateUp()
|
onShowWallpaperView = {
|
||||||
|
navController.navigate(WallpaperView(it))
|
||||||
},
|
},
|
||||||
onShowWallpaperView = { wallpaper ->
|
onShowFolderView = { folderName, wallpapers ->
|
||||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
/*navController.navigate(
|
||||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
FolderView(
|
||||||
},
|
folderName,
|
||||||
onShowFolderView = { folder, folderName, wallpapers ->
|
wallpapers
|
||||||
val encodedFolder = runBlocking { encodeUri(uri = folder) }
|
)
|
||||||
|
)*/
|
||||||
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
||||||
navController.navigate("${NavScreens.FolderView.route}/$encodedFolder/$folderName/$encodedWallpapers")
|
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
// Navigate to wallpaper view screen to view individual wallpapers in full screen
|
// Navigate to wallpaper view screen to view individual wallpapers in full screen
|
||||||
composable(
|
composable<WallpaperView> (
|
||||||
route = NavScreens.WallpaperView.route.plus("/{wallpaperUri}"),
|
|
||||||
arguments = listOf(navArgument("wallpaperUri") { type = NavType.StringType }),
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -269,16 +366,41 @@ fun PaperizeApp(
|
|||||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
) { backStackEntry ->
|
) { backStackEntry ->
|
||||||
backStackEntry.arguments?.getString("wallpaperUri").let { wallpaper ->
|
val wallpaperView: WallpaperView = backStackEntry.toRoute()
|
||||||
if (wallpaper != null) {
|
|
||||||
WallpaperViewScreen(
|
WallpaperViewScreen(
|
||||||
wallpaperUri = wallpaper,
|
wallpaperUri = wallpaperView.wallpaper,
|
||||||
onBackClick = { navController.navigateUp() },
|
onBackClick = { navController.navigateUp() },
|
||||||
|
animate = settingsState.value.animate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
// Navigate to folder view screen to view wallpapers in a particular folder
|
// 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(
|
composable(
|
||||||
route = NavScreens.FolderView.route.plus("/{folderName}/{wallpapers}"),
|
route = NavScreens.FolderView.route.plus("/{folderName}/{wallpapers}"),
|
||||||
arguments = listOf(
|
arguments = listOf(
|
||||||
@@ -303,22 +425,20 @@ fun PaperizeApp(
|
|||||||
backStackEntry.arguments?.getString("wallpapers"),
|
backStackEntry.arguments?.getString("wallpapers"),
|
||||||
Array<String>::class.java
|
Array<String>::class.java
|
||||||
).toList()
|
).toList()
|
||||||
|
if (wallpapers.isNotEmpty()) {
|
||||||
FolderViewScreen(
|
FolderViewScreen(
|
||||||
folderName = folderName,
|
folderName = folderName,
|
||||||
wallpapers = wallpapers,
|
wallpapers = wallpapers,
|
||||||
onBackClick = { navController.navigateUp() },
|
onBackClick = { navController.navigateUp() },
|
||||||
onShowWallpaperView = { wallpaper ->
|
onShowWallpaperView = {
|
||||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
navController.navigate(WallpaperView(it))
|
||||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
},
|
||||||
}
|
animate = settingsState.value.animate
|
||||||
)
|
)
|
||||||
|
} else { navController.navigateUp() }
|
||||||
}
|
}
|
||||||
// Navigate to the album view screen to view folders and wallpapers in an album
|
// Navigate to the album view screen to view folders and wallpapers in an album
|
||||||
composable(
|
composable<AlbumView> (
|
||||||
route = NavScreens.AlbumView.route.plus("/{initialAlbumName}"),
|
|
||||||
arguments = listOf(
|
|
||||||
navArgument("initialAlbumName") { type = NavType.StringType },
|
|
||||||
),
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -332,17 +452,22 @@ fun PaperizeApp(
|
|||||||
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionOut(target = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
) { backStackEntry ->
|
) { backStackEntry ->
|
||||||
val initialAlbumName = backStackEntry.arguments?.getString("initialAlbumName")
|
val albumView: AlbumView = backStackEntry.toRoute()
|
||||||
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == initialAlbumName }
|
val albumWithWallpaper = albumState.value.albumsWithWallpapers.find { it.album.initialAlbumName == albumView.initialAlbumName }
|
||||||
if (initialAlbumName != null && albumWithWallpaper != null) {
|
if (albumWithWallpaper != null) {
|
||||||
AlbumViewScreen(
|
AlbumViewScreen(
|
||||||
album = albumWithWallpaper,
|
album = albumWithWallpaper,
|
||||||
onBackClick = { navController.navigateUp() },
|
onBackClick = { navController.navigateUp() },
|
||||||
onShowWallpaperView = { wallpaper ->
|
onShowWallpaperView = {
|
||||||
val encodedWallpaper = runBlocking { encodeUri(uri = wallpaper) }
|
navController.navigate(WallpaperView(it))
|
||||||
navController.navigate("${NavScreens.WallpaperView.route}/$encodedWallpaper")
|
|
||||||
},
|
},
|
||||||
onShowFolderView = { folderName, wallpapers ->
|
onShowFolderView = { folderName, wallpapers ->
|
||||||
|
/*navController.navigate(
|
||||||
|
com.anthonyla.paperize.feature.wallpaper.util.navigation.FolderView(
|
||||||
|
folderName,
|
||||||
|
wallpapers
|
||||||
|
)
|
||||||
|
)*/
|
||||||
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
val encodedWallpapers = runBlocking { encodeUri(uri = Gson().toJson(wallpapers)) }
|
||||||
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
|
navController.navigate("${NavScreens.FolderView.route}/$folderName/$encodedWallpapers")
|
||||||
},
|
},
|
||||||
@@ -357,11 +482,10 @@ fun PaperizeApp(
|
|||||||
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
|
albumsViewModel.onEvent(AlbumsEvent.RefreshAlbums)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
} else { navController.navigateUp() }
|
||||||
}
|
}
|
||||||
// Navigate to the settings screen to change app settings
|
// Navigate to the settings screen to change app settings
|
||||||
composable(
|
composable<Settings> (
|
||||||
route = NavScreens.Settings.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -388,16 +512,33 @@ fun PaperizeApp(
|
|||||||
settingsViewModel.onEvent(SettingsEvent.SetAnimate(it))
|
settingsViewModel.onEvent(SettingsEvent.SetAnimate(it))
|
||||||
},
|
},
|
||||||
onPrivacyClick = {
|
onPrivacyClick = {
|
||||||
navController.navigate(NavScreens.Privacy.route)
|
navController.navigate(Privacy)
|
||||||
},
|
},
|
||||||
onLicenseClick = {
|
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
|
// Navigate to the privacy screen to view the privacy policy
|
||||||
composable(
|
composable<Privacy> (
|
||||||
route = NavScreens.Privacy.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -416,8 +557,7 @@ fun PaperizeApp(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Navigate to the licenses screen to view the licenses of the libraries used
|
// Navigate to the licenses screen to view the licenses of the libraries used
|
||||||
composable(
|
composable<Licenses> (
|
||||||
route = NavScreens.Licenses.route,
|
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
sharedXTransitionIn(initial = { (it * INITIAL_OFFSET).toInt() })
|
||||||
},
|
},
|
||||||
@@ -442,4 +582,4 @@ fun PaperizeApp(
|
|||||||
suspend fun encodeUri(uri: String): String =
|
suspend fun encodeUri(uri: String): String =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
URLEncoder.encode(uri, StandardCharsets.UTF_8.toString())
|
URLEncoder.encode(uri, StandardCharsets.UTF_8.toString())
|
||||||
}
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
|||||||
|
|
||||||
sealed class AddAlbumEvent {
|
sealed class AddAlbumEvent {
|
||||||
data object SaveAlbum: AddAlbumEvent()
|
data object SaveAlbum: AddAlbumEvent()
|
||||||
data object ClearState: AddAlbumEvent()
|
data object Reset: AddAlbumEvent()
|
||||||
data object DeleteSelected: AddAlbumEvent()
|
data object DeleteSelected: AddAlbumEvent()
|
||||||
data object SelectAll: AddAlbumEvent()
|
data object SelectAll: AddAlbumEvent()
|
||||||
data object DeselectAll: AddAlbumEvent()
|
data object DeselectAll: AddAlbumEvent()
|
||||||
|
|||||||
+14
-9
@@ -30,7 +30,6 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumAnimatedFab
|
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumAnimatedFab
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumFabMenuOptions
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumSmallTopBar
|
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumSmallTopBar
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||||
@@ -44,7 +43,7 @@ fun AddAlbumScreen(
|
|||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onConfirmation: () -> Unit,
|
onConfirmation: () -> Unit,
|
||||||
onShowWallpaperView: (String) -> Unit,
|
onShowWallpaperView: (String) -> Unit,
|
||||||
onShowFolderView: (String, String?, List<String>) -> Unit
|
onShowFolderView: (String?, List<String>) -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val lazyGridState = rememberLazyStaggeredGridState()
|
val lazyGridState = rememberLazyStaggeredGridState()
|
||||||
@@ -54,6 +53,7 @@ fun AddAlbumScreen(
|
|||||||
if (addAlbumState.value.initialAlbumName.isEmpty()) {
|
if (addAlbumState.value.initialAlbumName.isEmpty()) {
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName))
|
addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName))
|
||||||
}
|
}
|
||||||
|
var showSpotlight by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
BackHandler {
|
BackHandler {
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
@@ -61,7 +61,8 @@ fun AddAlbumScreen(
|
|||||||
addAlbumViewModel.onEvent(AddAlbumEvent.DeselectAll)
|
addAlbumViewModel.onEvent(AddAlbumEvent.DeselectAll)
|
||||||
} else {
|
} else {
|
||||||
onBackClick()
|
onBackClick()
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||||
|
showSpotlight = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,14 +104,17 @@ fun AddAlbumScreen(
|
|||||||
isEmpty = addAlbumState.value.isEmpty,
|
isEmpty = addAlbumState.value.isEmpty,
|
||||||
selectionMode = selectionMode,
|
selectionMode = selectionMode,
|
||||||
albumState = addAlbumViewModel.state,
|
albumState = addAlbumViewModel.state,
|
||||||
|
showSpotlight = showSpotlight,
|
||||||
onBackClick = {
|
onBackClick = {
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
showSpotlight = false
|
||||||
|
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||||
onBackClick()
|
onBackClick()
|
||||||
},
|
},
|
||||||
onConfirmationClick = {
|
onConfirmationClick = {
|
||||||
|
showSpotlight = false
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.ReflectAlbumName(it))
|
addAlbumViewModel.onEvent(AddAlbumEvent.ReflectAlbumName(it))
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.SaveAlbum)
|
addAlbumViewModel.onEvent(AddAlbumEvent.SaveAlbum)
|
||||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||||
onConfirmation()
|
onConfirmation()
|
||||||
},
|
},
|
||||||
onSelectAllClick = {
|
onSelectAllClick = {
|
||||||
@@ -132,7 +136,6 @@ fun AddAlbumScreen(
|
|||||||
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
||||||
) {
|
) {
|
||||||
AddAlbumAnimatedFab(
|
AddAlbumAnimatedFab(
|
||||||
menuOptions = AddAlbumFabMenuOptions(),
|
|
||||||
onImageClick = {
|
onImageClick = {
|
||||||
selectionMode = false
|
selectionMode = false
|
||||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||||
@@ -147,14 +150,15 @@ fun AddAlbumScreen(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AddAlbumAnimatedFab(
|
AddAlbumAnimatedFab(
|
||||||
menuOptions = AddAlbumFabMenuOptions(),
|
|
||||||
onImageClick = {
|
onImageClick = {
|
||||||
selectionMode = false
|
selectionMode = false
|
||||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||||
|
showSpotlight = true
|
||||||
},
|
},
|
||||||
onFolderClick = {
|
onFolderClick = {
|
||||||
selectionMode = false
|
selectionMode = false
|
||||||
folderPickerLauncher.launch(null)
|
folderPickerLauncher.launch(null)
|
||||||
|
showSpotlight = true
|
||||||
},
|
},
|
||||||
animate = false
|
animate = false
|
||||||
)
|
)
|
||||||
@@ -187,7 +191,7 @@ fun AddAlbumScreen(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
onFolderViewClick = {
|
onFolderViewClick = {
|
||||||
onShowFolderView(folder.folderUri, folder.folderName, folder.wallpapers)
|
onShowFolderView(folder.folderName, folder.wallpapers)
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(4.dp).animateItem(
|
modifier = Modifier.padding(4.dp).animateItem(
|
||||||
placementSpec = tween(
|
placementSpec = tween(
|
||||||
@@ -223,7 +227,8 @@ fun AddAlbumScreen(
|
|||||||
delayMillis = 0,
|
delayMillis = 0,
|
||||||
easing = FastOutSlowInEasing
|
easing = FastOutSlowInEasing
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
animate = settingsState.value.animate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+47
-54
@@ -3,7 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.webkit.MimeTypeMap
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
@@ -59,8 +58,6 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
folders = _state.value.folders,
|
folders = _state.value.folders,
|
||||||
)
|
)
|
||||||
repository.upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder)
|
repository.upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder)
|
||||||
|
|
||||||
//Clear viewModel state after adding album
|
|
||||||
_state.update { it.copy(
|
_state.update { it.copy(
|
||||||
initialAlbumName = "",
|
initialAlbumName = "",
|
||||||
displayedAlbumName = "",
|
displayedAlbumName = "",
|
||||||
@@ -77,13 +74,14 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
is AddAlbumEvent.DeleteSelected -> {
|
is AddAlbumEvent.DeleteSelected -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val wallpapersRemoved = _state.value.wallpapers.filterNot { it.wallpaperUri in _state.value.selectedWallpapers }
|
_state.update {
|
||||||
val foldersRemoved = _state.value.folders.filterNot { it.folderUri in _state.value.selectedFolders }
|
val wallpapersRemoved = it.wallpapers.filterNot { it.wallpaperUri in _state.value.selectedWallpapers }
|
||||||
_state.update { it.copy(
|
val foldersRemoved = it.folders.filterNot { it.folderUri in _state.value.selectedFolders }
|
||||||
|
it.copy(
|
||||||
wallpapers = wallpapersRemoved,
|
wallpapers = wallpapersRemoved,
|
||||||
folders = foldersRemoved
|
folders = foldersRemoved,
|
||||||
|
isEmpty = wallpapersRemoved.isEmpty() && foldersRemoved.isEmpty()
|
||||||
) }
|
) }
|
||||||
updateIsEmpty()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AddAlbumEvent.SetAlbumName -> {
|
is AddAlbumEvent.SetAlbumName -> {
|
||||||
@@ -98,18 +96,21 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
is AddAlbumEvent.ReflectAlbumName -> {
|
is AddAlbumEvent.ReflectAlbumName -> {
|
||||||
if (event.newAlbumName != _state.value.initialAlbumName) {
|
if (event.newAlbumName != _state.value.initialAlbumName) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
val wallpapers = it.wallpapers.map { wallpaper ->
|
||||||
|
wallpaper.copy(initialAlbumName = event.newAlbumName)
|
||||||
|
}
|
||||||
|
val folders = it.folders.map { folder ->
|
||||||
|
folder.copy(initialAlbumName = event.newAlbumName)
|
||||||
|
}
|
||||||
|
it.copy(
|
||||||
initialAlbumName = event.newAlbumName,
|
initialAlbumName = event.newAlbumName,
|
||||||
displayedAlbumName = event.newAlbumName,
|
displayedAlbumName = event.newAlbumName,
|
||||||
coverUri = it.coverUri,
|
coverUri = it.coverUri,
|
||||||
wallpapers = it.wallpapers.map { wallpaper ->
|
wallpapers = wallpapers,
|
||||||
wallpaper.copy(initialAlbumName = event.newAlbumName)
|
folders = folders,
|
||||||
},
|
isEmpty = wallpapers.isEmpty() && folders.isEmpty()
|
||||||
folders = it.folders.map { folder ->
|
|
||||||
folder.copy(initialAlbumName = event.newAlbumName)
|
|
||||||
},
|
|
||||||
) }
|
) }
|
||||||
updateIsEmpty()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,9 +169,9 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
_state.update { it.copy(
|
_state.update { it.copy(
|
||||||
selectedFolders = _state.value.folders.map { folder -> folder.folderUri },
|
selectedFolders = _state.value.folders.map { folder -> folder.folderUri },
|
||||||
selectedWallpapers = _state.value.wallpapers.map { wallpaper -> wallpaper.wallpaperUri },
|
selectedWallpapers = _state.value.wallpapers.map { wallpaper -> wallpaper.wallpaperUri },
|
||||||
selectedCount = it.folders.size + it.wallpapers.size
|
selectedCount = it.folders.size + it.wallpapers.size,
|
||||||
|
allSelected = true
|
||||||
) }
|
) }
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,48 +188,57 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
is AddAlbumEvent.SelectFolder -> {
|
is AddAlbumEvent.SelectFolder -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
selectedFolders = it.selectedFolders.plus(event.directoryUri),
|
val folders = it.selectedFolders.plus(event.directoryUri)
|
||||||
selectedCount = it.selectedCount + 1
|
it.copy(
|
||||||
|
selectedFolders = folders,
|
||||||
|
selectedCount = it.selectedCount + 1,
|
||||||
|
allSelected = folders.size + it.selectedWallpapers.size >= it.wallpapers.size + it.folders.size
|
||||||
) }
|
) }
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AddAlbumEvent.SelectWallpaper -> {
|
is AddAlbumEvent.SelectWallpaper -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
selectedWallpapers = it.selectedWallpapers.plus(event.wallpaperUri),
|
val wallpapers = it.selectedWallpapers.plus(event.wallpaperUri)
|
||||||
selectedCount = it.selectedCount + 1
|
it.copy(
|
||||||
|
selectedWallpapers = wallpapers,
|
||||||
|
selectedCount = it.selectedCount + 1,
|
||||||
|
allSelected = it.selectedFolders.size + wallpapers.size >= it.wallpapers.size + it.folders.size
|
||||||
) }
|
) }
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AddAlbumEvent.RemoveFolderFromSelection -> {
|
is AddAlbumEvent.RemoveFolderFromSelection -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (_state.value.selectedFolders.find { it == event.directoryUri } != null ) {
|
if (_state.value.selectedFolders.find { it == event.directoryUri } != null ) {
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
selectedFolders = it.selectedFolders.minus(event.directoryUri),
|
val folders = it.selectedFolders.minus(event.directoryUri)
|
||||||
selectedCount = it.selectedCount - 1
|
it.copy(
|
||||||
|
selectedFolders = folders,
|
||||||
|
selectedCount = it.selectedCount - 1,
|
||||||
|
allSelected = folders.size + it.selectedWallpapers.size >= it.wallpapers.size + it.folders.size
|
||||||
|
|
||||||
) }
|
) }
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AddAlbumEvent.RemoveWallpaperFromSelection -> {
|
is AddAlbumEvent.RemoveWallpaperFromSelection -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null ) {
|
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null ) {
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
selectedWallpapers = it.selectedWallpapers.minus(event.wallpaperUri),
|
val wallpapers = it.selectedWallpapers.minus(event.wallpaperUri)
|
||||||
selectedCount = it.selectedCount - 1
|
it.copy(
|
||||||
|
selectedWallpapers = wallpapers,
|
||||||
|
selectedCount = it.selectedCount - 1,
|
||||||
|
allSelected = it.selectedFolders.size + wallpapers.size >= it.wallpapers.size + it.folders.size
|
||||||
) }
|
) }
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AddAlbumEvent.ClearState -> {
|
is AddAlbumEvent.Reset -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_state.update { it.copy(
|
_state.update { it.copy(
|
||||||
initialAlbumName = "",
|
initialAlbumName = "",
|
||||||
@@ -247,22 +257,6 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateIsEmpty() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
_state.update { it.copy(
|
|
||||||
isEmpty = it.wallpapers.isEmpty() && it.folders.isEmpty()
|
|
||||||
) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateAllSelected() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
_state.update { it.copy(
|
|
||||||
allSelected = it.selectedFolders.size + it.selectedWallpapers.size >= it.wallpapers.size + it.folders.size
|
|
||||||
) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
private fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
||||||
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
||||||
return listFilesRecursive(folderDocumentFile, context)
|
return listFilesRecursive(folderDocumentFile, context)
|
||||||
@@ -274,9 +268,8 @@ class AddAlbumViewModel @Inject constructor(
|
|||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
files.addAll(listFilesRecursive(file, context))
|
files.addAll(listFilesRecursive(file, context))
|
||||||
} else {
|
} else {
|
||||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
if (file.extension in allowedExtensions) {
|
||||||
if (extension in allowedExtensions) {
|
|
||||||
files.add(file.uri.toString())
|
files.add(file.uri.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-9
@@ -21,12 +21,16 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
|
import androidx.compose.material.icons.filled.Folder
|
||||||
|
import androidx.compose.material.icons.filled.PhotoLibrary
|
||||||
import androidx.compose.material.icons.filled.Remove
|
import androidx.compose.material.icons.filled.Remove
|
||||||
|
import androidx.compose.material3.CardColors
|
||||||
import androidx.compose.material3.ElevatedCard
|
import androidx.compose.material3.ElevatedCard
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LargeFloatingActionButton
|
import androidx.compose.material3.LargeFloatingActionButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -34,6 +38,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.input.pointer.pointerInput
|
import androidx.compose.ui.input.pointer.pointerInput
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -46,7 +51,6 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.comp
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun AddAlbumAnimatedFab(
|
fun AddAlbumAnimatedFab(
|
||||||
menuOptions: AddAlbumFabMenuOptions,
|
|
||||||
animate: Boolean,
|
animate: Boolean,
|
||||||
onImageClick: () -> Unit,
|
onImageClick: () -> Unit,
|
||||||
onFolderClick: () -> Unit
|
onFolderClick: () -> Unit
|
||||||
@@ -82,6 +86,12 @@ fun AddAlbumAnimatedFab(
|
|||||||
|
|
||||||
if (animate) {
|
if (animate) {
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
|
colors = CardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||||
|
contentColor = Color.Transparent,
|
||||||
|
disabledContentColor = Color.Transparent,
|
||||||
|
disabledContainerColor = Color.Transparent,
|
||||||
|
),
|
||||||
shape = RoundedCornerShape(28.dp),
|
shape = RoundedCornerShape(28.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
@@ -99,8 +109,8 @@ fun AddAlbumAnimatedFab(
|
|||||||
Surface(tonalElevation = 5.dp) {
|
Surface(tonalElevation = 5.dp) {
|
||||||
Column(modifier = Modifier.height(menuHeight)) {
|
Column(modifier = Modifier.height(menuHeight)) {
|
||||||
MenuRow(
|
MenuRow(
|
||||||
text = menuOptions.imageOption.text,
|
text = stringResource(R.string.add_images_btn),
|
||||||
icon = menuOptions.imageOption.icon,
|
icon = Icons.Filled.PhotoLibrary,
|
||||||
horizontalExpansion = expandHorizontally,
|
horizontalExpansion = expandHorizontally,
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
@@ -108,8 +118,8 @@ fun AddAlbumAnimatedFab(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
MenuRow(
|
MenuRow(
|
||||||
text = menuOptions.folderOption.text,
|
text = stringResource(R.string.add_folder_btn),
|
||||||
icon = menuOptions.folderOption.icon,
|
icon = Icons.Filled.Folder,
|
||||||
horizontalExpansion = expandHorizontally,
|
horizontalExpansion = expandHorizontally,
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
@@ -147,6 +157,12 @@ fun AddAlbumAnimatedFab(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
|
colors = CardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||||
|
contentColor = Color.Transparent,
|
||||||
|
disabledContentColor = Color.Transparent,
|
||||||
|
disabledContainerColor = Color.Transparent,
|
||||||
|
),
|
||||||
shape = RoundedCornerShape(28.dp),
|
shape = RoundedCornerShape(28.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
@@ -159,8 +175,8 @@ fun AddAlbumAnimatedFab(
|
|||||||
Surface(tonalElevation = 5.dp) {
|
Surface(tonalElevation = 5.dp) {
|
||||||
Column(modifier = Modifier.height(if (expanded) menuHeightSize.first else menuHeightSize.second)) {
|
Column(modifier = Modifier.height(if (expanded) menuHeightSize.first else menuHeightSize.second)) {
|
||||||
MenuRow(
|
MenuRow(
|
||||||
text = menuOptions.imageOption.text,
|
text = stringResource(R.string.add_images_btn),
|
||||||
icon = menuOptions.imageOption.icon,
|
icon = Icons.Filled.PhotoLibrary,
|
||||||
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
@@ -168,8 +184,8 @@ fun AddAlbumAnimatedFab(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
MenuRow(
|
MenuRow(
|
||||||
text = menuOptions.folderOption.text,
|
text = stringResource(R.string.add_folder_btn),
|
||||||
icon = menuOptions.folderOption.icon,
|
icon = Icons.Filled.Folder,
|
||||||
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ fun AddAlbumDialog(
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "New Album",
|
text = stringResource(R.string.new_album),
|
||||||
modifier = Modifier.padding(20.dp),
|
modifier = Modifier.padding(20.dp),
|
||||||
fontSize = 25.sp
|
fontSize = 25.sp
|
||||||
)
|
)
|
||||||
|
|||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components
|
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.Folder
|
|
||||||
import androidx.compose.material.icons.filled.PhotoLibrary
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.components.SelectionOptions
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options for the FAB menu in the Add Album screen
|
|
||||||
*/
|
|
||||||
data class AddAlbumFabMenuOptions (
|
|
||||||
val imageOption: SelectionOptions = SelectionOptions("add_images", "Add Image", null, Icons.Filled.PhotoLibrary),
|
|
||||||
val folderOption: SelectionOptions = SelectionOptions("add_folder", "Add Folder", null, Icons.Filled.Folder)
|
|
||||||
)
|
|
||||||
+68
-6
@@ -1,8 +1,16 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components
|
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.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
@@ -33,7 +41,9 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
@@ -54,17 +64,45 @@ fun AddAlbumSmallTopBar(
|
|||||||
title: String,
|
title: String,
|
||||||
isEmpty: Boolean,
|
isEmpty: Boolean,
|
||||||
selectionMode: Boolean,
|
selectionMode: Boolean,
|
||||||
|
showSpotlight: Boolean,
|
||||||
onSelectAllClick: () -> Unit,
|
onSelectAllClick: () -> Unit,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onDeleteSelected: () -> Unit,
|
onDeleteSelected: () -> Unit,
|
||||||
onConfirmationClick: (String) -> Unit,
|
onConfirmationClick: (String) -> Unit
|
||||||
modifier: Modifier = Modifier
|
) {
|
||||||
) {
|
|
||||||
val state = albumState.collectAsStateWithLifecycle()
|
val state = albumState.collectAsStateWithLifecycle()
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
var editableTitle by rememberSaveable { mutableStateOf(title) }
|
var editableTitle by rememberSaveable { mutableStateOf(title) }
|
||||||
var showSelectionDeleteDialog by rememberSaveable { mutableStateOf(false) }
|
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(
|
TopAppBar(
|
||||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||||
title = {
|
title = {
|
||||||
@@ -109,9 +147,7 @@ fun AddAlbumSmallTopBar(
|
|||||||
horizontalArrangement = Arrangement.Start,
|
horizontalArrangement = Arrangement.Start,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(onClick = onSelectAllClick) {
|
||||||
onClick = onSelectAllClick
|
|
||||||
) {
|
|
||||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||||
if (state.value.allSelected) {
|
if (state.value.allSelected) {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -139,6 +175,9 @@ fun AddAlbumSmallTopBar(
|
|||||||
actions = {
|
actions = {
|
||||||
if(!selectionMode) {
|
if(!selectionMode) {
|
||||||
if (!isEmpty) {
|
if (!isEmpty) {
|
||||||
|
Box {
|
||||||
|
val primaryColor = MaterialTheme.colorScheme.inversePrimary
|
||||||
|
val secondaryColor = MaterialTheme.colorScheme.secondary
|
||||||
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Add,
|
imageVector = Icons.Outlined.Add,
|
||||||
@@ -146,6 +185,29 @@ fun AddAlbumSmallTopBar(
|
|||||||
modifier = Modifier.padding(6.dp)
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+4
-4
@@ -22,17 +22,17 @@ fun DeleteImagesAlertDialog(
|
|||||||
icon = {
|
icon = {
|
||||||
Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
||||||
},
|
},
|
||||||
title = { Text(text = "Delete these?") },
|
title = { Text(text = stringResource(R.string.delete_these)) },
|
||||||
text = { Text(text = "Are you sure you want to delete these wallpapers?") },
|
text = { Text(text = stringResource(R.string.are_you_sure_you_want_to_delete_these_wallpapers)) },
|
||||||
onDismissRequest = { onDismissRequest() },
|
onDismissRequest = { onDismissRequest() },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = { onConfirmation() }) {
|
TextButton(onClick = { onConfirmation() }) {
|
||||||
Text("Confirm")
|
Text(stringResource(R.string.confirm))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { onDismissRequest() }) {
|
TextButton(onClick = { onDismissRequest() }) {
|
||||||
Text("Cancel")
|
Text(stringResource(R.string.cancel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+1
@@ -3,6 +3,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
|
|||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
sealed class AlbumsEvent {
|
sealed class AlbumsEvent {
|
||||||
data object RefreshAlbums: AlbumsEvent()
|
data object RefreshAlbums: AlbumsEvent()
|
||||||
|
data object Reset: AlbumsEvent()
|
||||||
|
|
||||||
data class DeleteAlbumWithWallpapers(
|
data class DeleteAlbumWithWallpapers(
|
||||||
val albumWithWallpaperAndFolder: AlbumWithWallpaperAndFolder
|
val albumWithWallpaperAndFolder: AlbumWithWallpaperAndFolder
|
||||||
|
|||||||
+21
-24
@@ -2,12 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
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.core.net.toUri
|
||||||
import androidx.documentfile.provider.DocumentFile
|
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
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.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@@ -37,22 +33,20 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
|
||||||
updateAlbums()
|
updateAlbums()
|
||||||
refreshAlbums()
|
refreshAlbums()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun onEvent(event: AlbumsEvent) {
|
fun onEvent(event: AlbumsEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is AlbumsEvent.DeleteAlbumWithWallpapers -> {
|
is AlbumsEvent.DeleteAlbumWithWallpapers -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
repository.cascadeDeleteAlbum(event.albumWithWallpaperAndFolder.album)
|
repository.cascadeDeleteAlbum(event.albumWithWallpaperAndFolder.album)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AlbumsEvent.ChangeAlbumName -> {
|
is AlbumsEvent.ChangeAlbumName -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
if (!(_state.value.albumsWithWallpapers.any { it.album.displayedAlbumName == event.title })) {
|
if (!(_state.value.albumsWithWallpapers.any { it.album.displayedAlbumName == event.title })) {
|
||||||
repository.updateAlbum(
|
repository.updateAlbum(
|
||||||
event.albumWithWallpaperAndFolder.album.copy(displayedAlbumName = event.title)
|
event.albumWithWallpaperAndFolder.album.copy(displayedAlbumName = event.title)
|
||||||
@@ -61,13 +55,11 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AlbumsEvent.RefreshAlbums -> {
|
is AlbumsEvent.RefreshAlbums -> {
|
||||||
viewModelScope.launch {
|
|
||||||
updateAlbums()
|
updateAlbums()
|
||||||
refreshAlbums()
|
refreshAlbums()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
is AlbumsEvent.InitializeAlbum -> {
|
is AlbumsEvent.InitializeAlbum -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
repository.updateAlbum(
|
repository.updateAlbum(
|
||||||
event.albumWithWallpaperAndFolder.album.copy(
|
event.albumWithWallpaperAndFolder.album.copy(
|
||||||
initialized = true
|
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
|
* Verify and remove stale data in Room database
|
||||||
*/
|
*/
|
||||||
private fun updateAlbums() {
|
private fun updateAlbums() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
var albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
var albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||||
// Delete wallpaper if the URI is invalid
|
// Delete wallpaper if the URI is invalid
|
||||||
val invalidWallpapers = albumWithWallpaper.wallpapers.filterNot { wallpaper ->
|
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
|
file?.exists() == true
|
||||||
}
|
}
|
||||||
if (invalidWallpapers.isNotEmpty()) {
|
if (invalidWallpapers.isNotEmpty()) {
|
||||||
@@ -96,12 +94,12 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
|
|
||||||
// Update folder cover uri and children uri
|
// Update folder cover uri and children uri
|
||||||
albumWithWallpaper.folders.forEach { folder ->
|
albumWithWallpaper.folders.forEach { folder ->
|
||||||
DocumentFile.fromTreeUri(context, folder.folderUri.toUri())?.let { folderDirectory ->
|
DocumentFileCompat.fromTreeUri(context, folder.folderUri.toUri())?.let { folderDirectory ->
|
||||||
if (!folderDirectory.isDirectory) {
|
if (!folderDirectory.isDirectory()) {
|
||||||
repository.deleteFolder(folder)
|
repository.deleteFolder(folder)
|
||||||
} else {
|
} else {
|
||||||
val wallpapers = getWallpaperFromFolder(folder.folderUri, context)
|
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()
|
val folderCover = folderCoverFile?.takeIf { it.exists() }?.uri?.toString() ?: wallpapers.randomOrNull()
|
||||||
repository.updateFolder(folder.copy(coverUri = folderCover, wallpapers = wallpapers))
|
repository.updateFolder(folder.copy(coverUri = folderCover, wallpapers = wallpapers))
|
||||||
}
|
}
|
||||||
@@ -111,7 +109,7 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||||
// Update album cover uri if null or invalid
|
// 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()) {
|
if (albumCoverFile == null || !albumCoverFile.exists()) {
|
||||||
val newCoverUri = findFirstValidUri(albumWithWallpaper.wallpapers, albumWithWallpaper.folders)
|
val newCoverUri = findFirstValidUri(albumWithWallpaper.wallpapers, albumWithWallpaper.folders)
|
||||||
repository.updateAlbum(albumWithWallpaper.album.copy(coverUri = newCoverUri))
|
repository.updateAlbum(albumWithWallpaper.album.copy(coverUri = newCoverUri))
|
||||||
@@ -124,7 +122,7 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
* Retrieve albums from database into viewModel
|
* Retrieve albums from database into viewModel
|
||||||
*/
|
*/
|
||||||
private fun refreshAlbums() {
|
private fun refreshAlbums() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
repository.getAlbumsWithWallpaperAndFolder().collect { albumWithWallpapers ->
|
repository.getAlbumsWithWallpaperAndFolder().collect { albumWithWallpapers ->
|
||||||
_state.update { it.copy(
|
_state.update { it.copy(
|
||||||
albumsWithWallpapers = albumWithWallpapers
|
albumsWithWallpapers = albumWithWallpapers
|
||||||
@@ -150,9 +148,8 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
files.addAll(listFilesRecursive(file, context))
|
files.addAll(listFilesRecursive(file, context))
|
||||||
} else {
|
} else {
|
||||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
if (file.extension in allowedExtensions) {
|
||||||
if (extension in allowedExtensions) {
|
|
||||||
files.add(file.uri.toString())
|
files.add(file.uri.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,14 +163,14 @@ class AlbumsViewModel @Inject constructor (
|
|||||||
*/
|
*/
|
||||||
private fun findFirstValidUri(wallpapers: List<Wallpaper>, folders: List<Folder>): String? {
|
private fun findFirstValidUri(wallpapers: List<Wallpaper>, folders: List<Folder>): String? {
|
||||||
wallpapers.forEach { wallpaper ->
|
wallpapers.forEach { wallpaper ->
|
||||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||||
if (file?.exists() == true) {
|
if (file?.exists() == true) {
|
||||||
return wallpaper.wallpaperUri
|
return wallpaper.wallpaperUri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
folders.forEach { folder ->
|
folders.forEach { folder ->
|
||||||
folder.wallpapers.forEach { wallpaper ->
|
folder.wallpapers.forEach { wallpaper ->
|
||||||
val file = DocumentFile.fromSingleUri(context, wallpaper.toUri())
|
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.toUri())
|
||||||
if (file?.exists() == true) {
|
if (file?.exists() == true) {
|
||||||
return wallpaper
|
return wallpaper
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-9
@@ -1,5 +1,6 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@@ -21,9 +22,8 @@ import androidx.compose.ui.layout.ContentScale
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.core.net.toUri
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
|
|
||||||
@@ -34,8 +34,22 @@ import com.skydoves.landscapist.glide.GlideImage
|
|||||||
fun AlbumItem(
|
fun AlbumItem(
|
||||||
album: Album,
|
album: Album,
|
||||||
onAlbumViewClick: () -> Unit,
|
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(
|
Card(
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -49,28 +63,26 @@ fun AlbumItem(
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Box {
|
Box {
|
||||||
|
if (showCoverUri) {
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { album.coverUri },
|
imageModel = { album.coverUri },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
alignment = Alignment.Center
|
alignment = Alignment.Center
|
||||||
),
|
),
|
||||||
requestBuilder = {
|
|
||||||
Glide
|
|
||||||
.with(LocalContext.current)
|
|
||||||
.asBitmap()
|
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
|
||||||
},
|
|
||||||
loading = {
|
loading = {
|
||||||
|
if (animate) {
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
.clip(RoundedCornerShape(16.dp))
|
.clip(RoundedCornerShape(16.dp))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.padding(6.dp))
|
Spacer(modifier = Modifier.padding(6.dp))
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
+26
-14
@@ -1,5 +1,6 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.animation.core.animateDp
|
import androidx.compose.animation.core.animateDp
|
||||||
import androidx.compose.animation.core.updateTransition
|
import androidx.compose.animation.core.updateTransition
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
@@ -42,8 +43,6 @@ import androidx.compose.ui.unit.sp
|
|||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
|
|
||||||
@@ -59,7 +58,8 @@ fun FolderItem(
|
|||||||
onActivateSelectionMode: (Boolean) -> Unit,
|
onActivateSelectionMode: (Boolean) -> Unit,
|
||||||
onItemSelection: () -> Unit,
|
onItemSelection: () -> Unit,
|
||||||
onFolderViewClick: () -> Unit,
|
onFolderViewClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier,
|
||||||
|
animate: Boolean = true
|
||||||
) {
|
) {
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val haptics = LocalHapticFeedback.current
|
val haptics = LocalHapticFeedback.current
|
||||||
@@ -73,6 +73,19 @@ fun FolderItem(
|
|||||||
if (selected) 24.dp else 16.dp
|
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(
|
Card(
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -81,8 +94,11 @@ fun FolderItem(
|
|||||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
if (!selectionMode) { onFolderViewClick() }
|
if (!selectionMode) {
|
||||||
else { onItemSelection() }
|
onFolderViewClick()
|
||||||
|
} else {
|
||||||
|
onItemSelection()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
if (!selectionMode) {
|
if (!selectionMode) {
|
||||||
@@ -99,23 +115,19 @@ fun FolderItem(
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Box {
|
Box {
|
||||||
if (folder.coverUri != null) {
|
if (showCoverUri) {
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { folder.coverUri.toUri() },
|
imageModel = { folder.coverUri?.toUri() },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
alignment = Alignment.Center
|
alignment = Alignment.Center
|
||||||
),
|
),
|
||||||
requestBuilder = {
|
|
||||||
Glide
|
|
||||||
.with(LocalContext.current)
|
|
||||||
.asBitmap()
|
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
|
||||||
},
|
|
||||||
loading = {
|
loading = {
|
||||||
|
if (animate) {
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(configuration.screenHeightDp.dp / 4.0f)
|
.height(configuration.screenHeightDp.dp / 4.0f)
|
||||||
@@ -154,7 +166,7 @@ fun FolderItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = folder.wallpapers.size.toString().plus(" wallpapers"),
|
text = folder.wallpapers.size.toString().plus(" " + stringResource(R.string.wallpapers)),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = 24.dp)
|
.padding(horizontal = 24.dp)
|
||||||
.align(Alignment.Start),
|
.align(Alignment.Start),
|
||||||
|
|||||||
+63
-32
@@ -1,8 +1,6 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.compose.animation.core.animateDp
|
import androidx.compose.animation.core.animateDp
|
||||||
import androidx.compose.animation.core.updateTransition
|
import androidx.compose.animation.core.updateTransition
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
@@ -26,7 +24,9 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.BlendMode
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -34,10 +34,11 @@ import androidx.compose.ui.platform.LocalHapticFeedback
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.exifinterface.media.ExifInterface
|
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
import com.anthonyla.paperize.core.getImageDimensions
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions.withCrossFade
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
|
|
||||||
@@ -54,7 +55,12 @@ fun WallpaperItem(
|
|||||||
onItemSelection: () -> Unit,
|
onItemSelection: () -> Unit,
|
||||||
onWallpaperViewClick: () -> Unit,
|
onWallpaperViewClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
wallpaperDrawable : Bitmap? = null
|
aspectRatio: Float? = null,
|
||||||
|
clickable: Boolean = true,
|
||||||
|
animate: Boolean = true,
|
||||||
|
darken: Boolean = false,
|
||||||
|
darkenPercentage: Int? = null,
|
||||||
|
scaling: ScalingConstants? = null
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val haptics = LocalHapticFeedback.current
|
val haptics = LocalHapticFeedback.current
|
||||||
@@ -67,17 +73,29 @@ fun WallpaperItem(
|
|||||||
if (selected) 24.dp else 16.dp
|
if (selected) 24.dp else 16.dp
|
||||||
}
|
}
|
||||||
|
|
||||||
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
|
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||||
val aspectRatio = (dimension.first.toFloat()/dimension.second.toFloat())
|
val uri = uriString?.toUri()
|
||||||
|
return try {
|
||||||
|
uri?.let {
|
||||||
|
val inputStream = context.contentResolver.openInputStream(it)
|
||||||
|
inputStream?.close()
|
||||||
|
}
|
||||||
|
true
|
||||||
|
} catch (e: Exception) { false }
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
val showUri = isValidUri(LocalContext.current, wallpaperUri)
|
||||||
modifier = modifier
|
val boxModifier = if (clickable) {
|
||||||
|
modifier
|
||||||
.padding(paddingTransition)
|
.padding(paddingTransition)
|
||||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
if (!selectionMode) { onWallpaperViewClick() }
|
if (!selectionMode) {
|
||||||
else { onItemSelection() }
|
onWallpaperViewClick()
|
||||||
|
} else {
|
||||||
|
onItemSelection()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
if (!selectionMode) {
|
if (!selectionMode) {
|
||||||
@@ -87,26 +105,49 @@ fun WallpaperItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) {
|
} else {
|
||||||
|
modifier
|
||||||
|
.padding(paddingTransition)
|
||||||
|
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||||
|
}
|
||||||
|
Box(modifier = boxModifier) {
|
||||||
|
if (showUri) {
|
||||||
|
val dimension = wallpaperUri.toUri().getImageDimensions(context)
|
||||||
|
val imageAspectRatio = aspectRatio ?: (dimension.width.toFloat() / dimension.height.toFloat())
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
|
imageModel = { wallpaperUri },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = if (scaling != null) {
|
||||||
alignment = Alignment.Center
|
when (scaling) {
|
||||||
|
ScalingConstants.FILL -> ContentScale.FillHeight
|
||||||
|
ScalingConstants.FIT -> ContentScale.FillWidth
|
||||||
|
ScalingConstants.STRETCH -> ContentScale.FillBounds
|
||||||
|
}
|
||||||
|
} else { ContentScale.Crop },
|
||||||
|
alignment = Alignment.Center,
|
||||||
|
colorFilter = if (darken && darkenPercentage != null && darkenPercentage < 100) {
|
||||||
|
ColorFilter.tint(
|
||||||
|
Color.Black.copy(alpha = (100 - darkenPercentage).toFloat().div(100f)),
|
||||||
|
BlendMode.Darken
|
||||||
|
)
|
||||||
|
} else { null }
|
||||||
),
|
),
|
||||||
|
loading = {
|
||||||
|
if (animate) {
|
||||||
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
|
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
requestBuilder = {
|
requestBuilder = {
|
||||||
Glide
|
Glide
|
||||||
.with(LocalContext.current)
|
.with(LocalContext.current)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.transition(withCrossFade())
|
.format(DecodeFormat.PREFER_RGB_565)
|
||||||
},
|
},
|
||||||
loading = {
|
modifier = Modifier.aspectRatio(imageAspectRatio).background(if (scaling != null) Color.Black else Color.Transparent),
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
|
||||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modifier = Modifier.aspectRatio(aspectRatio)
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||||
if (itemSelected) {
|
if (itemSelected) {
|
||||||
@@ -130,13 +171,3 @@ fun WallpaperItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
return Pair(width, height)
|
|
||||||
}
|
|
||||||
+55
-6
@@ -31,7 +31,6 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumAnimatedFab
|
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumAnimatedFab
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components.AddAlbumFabMenuOptions
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.FolderItem
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.components.AlbumViewTopBar
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.components.AlbumViewTopBar
|
||||||
@@ -47,7 +46,7 @@ fun AlbumViewScreen(
|
|||||||
onShowFolderView: (String?, List<String>) -> Unit,
|
onShowFolderView: (String?, List<String>) -> Unit,
|
||||||
onDeleteAlbum: () -> Unit,
|
onDeleteAlbum: () -> Unit,
|
||||||
onTitleChange: (String, AlbumWithWallpaperAndFolder) -> Unit,
|
onTitleChange: (String, AlbumWithWallpaperAndFolder) -> Unit,
|
||||||
onSelectionDeleted: () -> Unit
|
onSelectionDeleted: () -> Unit,
|
||||||
) {
|
) {
|
||||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
|
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
|
||||||
val lazyListState = rememberLazyStaggeredGridState()
|
val lazyListState = rememberLazyStaggeredGridState()
|
||||||
@@ -129,7 +128,6 @@ fun AlbumViewScreen(
|
|||||||
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
||||||
) {
|
) {
|
||||||
AddAlbumAnimatedFab(
|
AddAlbumAnimatedFab(
|
||||||
menuOptions = AddAlbumFabMenuOptions(),
|
|
||||||
onImageClick = {
|
onImageClick = {
|
||||||
selectionMode = false
|
selectionMode = false
|
||||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||||
@@ -144,7 +142,6 @@ fun AlbumViewScreen(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AddAlbumAnimatedFab(
|
AddAlbumAnimatedFab(
|
||||||
menuOptions = AddAlbumFabMenuOptions(),
|
|
||||||
onImageClick = {
|
onImageClick = {
|
||||||
selectionMode = false
|
selectionMode = false
|
||||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||||
@@ -153,7 +150,7 @@ fun AlbumViewScreen(
|
|||||||
selectionMode = false
|
selectionMode = false
|
||||||
folderPickerLauncher.launch(null)
|
folderPickerLauncher.launch(null)
|
||||||
},
|
},
|
||||||
animate = true
|
animate = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -169,6 +166,7 @@ fun AlbumViewScreen(
|
|||||||
content = {
|
content = {
|
||||||
items (items = album.folders, key = { folder -> folder.folderUri.hashCode() }
|
items (items = album.folders, key = { folder -> folder.folderUri.hashCode() }
|
||||||
) { folder ->
|
) { folder ->
|
||||||
|
if (settingsState.value.animate) {
|
||||||
FolderItem(
|
FolderItem(
|
||||||
folder = folder,
|
folder = folder,
|
||||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||||
@@ -192,11 +190,36 @@ fun AlbumViewScreen(
|
|||||||
delayMillis = 0,
|
delayMillis = 0,
|
||||||
easing = FastOutSlowInEasing
|
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()}
|
items (items = album.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
|
||||||
) { wallpaper ->
|
) { wallpaper ->
|
||||||
|
if (settingsState.value.animate) {
|
||||||
WallpaperItem(
|
WallpaperItem(
|
||||||
wallpaperUri = wallpaper.wallpaperUri,
|
wallpaperUri = wallpaper.wallpaperUri,
|
||||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||||
@@ -214,14 +237,40 @@ fun AlbumViewScreen(
|
|||||||
onWallpaperViewClick = {
|
onWallpaperViewClick = {
|
||||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(4.dp).animateItem(
|
modifier = Modifier
|
||||||
|
.padding(4.dp)
|
||||||
|
.animateItem(
|
||||||
placementSpec = tween(
|
placementSpec = tween(
|
||||||
durationMillis = 800,
|
durationMillis = 800,
|
||||||
delayMillis = 0,
|
delayMillis = 0,
|
||||||
easing = FastOutSlowInEasing
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+28
-36
@@ -3,7 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.webkit.MimeTypeMap
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
@@ -39,10 +38,10 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
event.albumsWithWallpaper.let { album ->
|
event.albumsWithWallpaper.let { album ->
|
||||||
val folders = album.folders.filter { _state.value.selectedFolders.contains(it.folderUri)}
|
val folders = album.folders.filter { _state.value.selectedFolders.contains(it.folderUri)}
|
||||||
val wallpapers = album.wallpapers.filter { _state.value.selectedWallpapers.contains(it.wallpaperUri)}
|
val wallpapers = album.wallpapers.filter { _state.value.selectedWallpapers.contains(it.wallpaperUri)}
|
||||||
val doesContainCover = wallpapers.any { it.wallpaperUri == album.album.coverUri }
|
val containsCoverUri = wallpapers.any { it.wallpaperUri == album.album.coverUri }
|
||||||
repository.deleteFolderList(folders)
|
repository.deleteFolderList(folders)
|
||||||
repository.deleteWallpaperList(wallpapers)
|
repository.deleteWallpaperList(wallpapers)
|
||||||
if (doesContainCover) {
|
if (containsCoverUri) {
|
||||||
repository.updateAlbum(album.album.copy(coverUri = null))
|
repository.updateAlbum(album.album.copy(coverUri = null))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,15 +51,15 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
event.albumsWithWallpaper.let { album ->
|
event.albumsWithWallpaper.let { album ->
|
||||||
if (!_state.value.allSelected) {
|
if (!_state.value.allSelected) {
|
||||||
_state.update { state ->
|
_state.update { it ->
|
||||||
state.copy(
|
it.copy(
|
||||||
selectedFolders = album.folders.map { it.folderUri },
|
selectedFolders = album.folders.map { it.folderUri },
|
||||||
selectedWallpapers = album.wallpapers.map { it.wallpaperUri },
|
selectedWallpapers = album.wallpapers.map { it.wallpaperUri },
|
||||||
selectedCount = album.folders.size + album.wallpapers.size,
|
selectedCount = album.folders.size + album.wallpapers.size,
|
||||||
maxSize = album.folders.size + album.wallpapers.size
|
maxSize = album.folders.size + album.wallpapers.size,
|
||||||
|
allSelected = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,12 +82,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
||||||
_state.update {
|
_state.update {
|
||||||
|
val folders = it.selectedFolders.plus(event.directoryUri)
|
||||||
it.copy(
|
it.copy(
|
||||||
selectedFolders = it.selectedFolders.plus(event.directoryUri),
|
selectedFolders = folders,
|
||||||
selectedCount = it.selectedCount + 1
|
selectedCount = it.selectedCount + 1,
|
||||||
|
allSelected = folders.size + it.selectedWallpapers.size >= it.maxSize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,12 +97,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
||||||
_state.update {
|
_state.update {
|
||||||
|
val wallpapers = it.selectedWallpapers.plus(event.wallpaperUri)
|
||||||
it.copy(
|
it.copy(
|
||||||
selectedWallpapers = it.selectedWallpapers.plus(event.wallpaperUri),
|
selectedWallpapers = it.selectedWallpapers.plus(event.wallpaperUri),
|
||||||
selectedCount = it.selectedCount + 1
|
selectedCount = it.selectedCount + 1,
|
||||||
|
allSelected = it.selectedFolders.size + wallpapers.size >= it.maxSize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,12 +112,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (_state.value.selectedFolders.find { it == event.directoryUri } != null) {
|
if (_state.value.selectedFolders.find { it == event.directoryUri } != null) {
|
||||||
_state.update {
|
_state.update {
|
||||||
|
val folders = it.selectedFolders.minus(event.directoryUri)
|
||||||
it.copy(
|
it.copy(
|
||||||
selectedFolders = it.selectedFolders.minus(event.directoryUri),
|
selectedFolders = folders,
|
||||||
selectedCount = it.selectedCount - 1
|
selectedCount = it.selectedCount - 1,
|
||||||
|
allSelected = folders.size + it.selectedWallpapers.size >= it.maxSize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,12 +127,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null) {
|
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null) {
|
||||||
_state.update {
|
_state.update {
|
||||||
|
val wallpapers = it.selectedWallpapers.minus(event.wallpaperUri)
|
||||||
it.copy(
|
it.copy(
|
||||||
selectedWallpapers = it.selectedWallpapers.minus(event.wallpaperUri),
|
selectedWallpapers = wallpapers,
|
||||||
selectedCount = it.selectedCount - 1
|
selectedCount = it.selectedCount - 1,
|
||||||
|
allSelected = it.selectedFolders.size + wallpapers.size >= it.maxSize
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateAllSelected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,22 +164,22 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
is AlbumViewEvent.AddWallpapers -> {
|
is AlbumViewEvent.AddWallpapers -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val newWallpaperUris = event.wallpaperUris.filterNot { it in event.album.wallpapers.map { wallpaper -> wallpaper.wallpaperUri } }
|
val wallpaperUris = event.wallpaperUris.filterNot { it in event.album.wallpapers.map { wallpaper -> wallpaper.wallpaperUri } }
|
||||||
val newWallpapers = newWallpaperUris.map { uri ->
|
val wallpapers = wallpaperUris.map { uri ->
|
||||||
Wallpaper(
|
Wallpaper(
|
||||||
initialAlbumName = event.album.album.initialAlbumName,
|
initialAlbumName = event.album.album.initialAlbumName,
|
||||||
wallpaperUri = uri,
|
wallpaperUri = uri,
|
||||||
key = uri.hashCode() + event.album.album.initialAlbumName.hashCode(),
|
key = uri.hashCode() + event.album.album.initialAlbumName.hashCode(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
repository.upsertWallpaperList(newWallpapers)
|
repository.upsertWallpaperList(wallpapers)
|
||||||
_state.update {
|
_state.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
selectedFolders = emptyList(),
|
selectedFolders = emptyList(),
|
||||||
selectedWallpapers = emptyList(),
|
selectedWallpapers = emptyList(),
|
||||||
allSelected = false,
|
allSelected = false,
|
||||||
selectedCount = 0,
|
selectedCount = 0,
|
||||||
maxSize = _state.value.maxSize + newWallpapers.size
|
maxSize = it.maxSize + wallpapers.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,7 +206,7 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
selectedWallpapers = emptyList(),
|
selectedWallpapers = emptyList(),
|
||||||
allSelected = false,
|
allSelected = false,
|
||||||
selectedCount = 0,
|
selectedCount = 0,
|
||||||
maxSize = _state.value.maxSize + 1
|
maxSize = it.maxSize + 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,16 +215,6 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAllSelected() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
_state.update {
|
|
||||||
it.copy(
|
|
||||||
allSelected = it.selectedFolders.size + it.selectedWallpapers.size >= _state.value.maxSize
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
private fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
||||||
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
||||||
return listFilesRecursive(folderDocumentFile, context)
|
return listFilesRecursive(folderDocumentFile, context)
|
||||||
@@ -233,9 +226,8 @@ class AlbumViewScreenViewModel @Inject constructor(
|
|||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
files.addAll(listFilesRecursive(file, context))
|
files.addAll(listFilesRecursive(file, context))
|
||||||
} else {
|
} else {
|
||||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
if (file.extension in allowedExtensions) {
|
||||||
if (extension in allowedExtensions) {
|
|
||||||
files.add(file.uri.toString())
|
files.add(file.uri.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -56,7 +56,6 @@ fun AlbumViewTopBar(
|
|||||||
onDeleteAlbum: () -> Unit,
|
onDeleteAlbum: () -> Unit,
|
||||||
onDeleteSelected: () -> Unit,
|
onDeleteSelected: () -> Unit,
|
||||||
onTitleChange: (String) -> Unit,
|
onTitleChange: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier
|
|
||||||
) {
|
) {
|
||||||
val state = albumState.collectAsStateWithLifecycle()
|
val state = albumState.collectAsStateWithLifecycle()
|
||||||
var showDeleteAlertDialog by rememberSaveable { mutableStateOf(false) }
|
var showDeleteAlertDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
@@ -109,7 +108,7 @@ fun AlbumViewTopBar(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text("${state.value.selectedCount} selected")
|
Text(stringResource(R.string.selected_count, state.value.selectedCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-4
@@ -22,17 +22,17 @@ fun DeleteAlbumAlertDialog(
|
|||||||
icon = {
|
icon = {
|
||||||
Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
||||||
},
|
},
|
||||||
title = { Text(text = "Delete album?") },
|
title = { Text(text = stringResource(R.string.delete_album_question)) },
|
||||||
text = { Text(text = "Are you sure you want to delete this?") },
|
text = { Text(text = stringResource(R.string.are_you_sure_you_want_to_delete_this)) },
|
||||||
onDismissRequest = { onDismissRequest() },
|
onDismissRequest = { onDismissRequest() },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = { onConfirmation() }) {
|
TextButton(onClick = { onConfirmation() }) {
|
||||||
Text("Confirm")
|
Text(stringResource(R.string.confirm))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { onDismissRequest() }) {
|
TextButton(onClick = { onDismissRequest() }) {
|
||||||
Text("Cancel")
|
Text(stringResource(R.string.cancel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+21
-4
@@ -23,7 +23,8 @@ fun FolderViewScreen(
|
|||||||
folderName: String?,
|
folderName: String?,
|
||||||
wallpapers: List<String>,
|
wallpapers: List<String>,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onShowWallpaperView: (String) -> Unit
|
onShowWallpaperView: (String) -> Unit,
|
||||||
|
animate: Boolean
|
||||||
) {
|
) {
|
||||||
val lazyListState = rememberLazyStaggeredGridState()
|
val lazyListState = rememberLazyStaggeredGridState()
|
||||||
BackHandler { onBackClick() }
|
BackHandler { onBackClick() }
|
||||||
@@ -32,9 +33,8 @@ fun FolderViewScreen(
|
|||||||
topBar = {
|
topBar = {
|
||||||
FolderViewTopBar(
|
FolderViewTopBar(
|
||||||
title = folderName ?: "",
|
title = folderName ?: "",
|
||||||
) {
|
onBackClick = onBackClick
|
||||||
onBackClick()
|
)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
LazyVerticalStaggeredGrid(
|
LazyVerticalStaggeredGrid(
|
||||||
@@ -48,6 +48,7 @@ fun FolderViewScreen(
|
|||||||
content = {
|
content = {
|
||||||
items (items = wallpapers, key = { wallpaper -> wallpaper }
|
items (items = wallpapers, key = { wallpaper -> wallpaper }
|
||||||
) { wallpaper ->
|
) { wallpaper ->
|
||||||
|
if (animate) {
|
||||||
WallpaperItem(
|
WallpaperItem(
|
||||||
wallpaperUri = wallpaper,
|
wallpaperUri = wallpaper,
|
||||||
itemSelected = false,
|
itemSelected = false,
|
||||||
@@ -63,10 +64,26 @@ fun FolderViewScreen(
|
|||||||
delayMillis = 0,
|
delayMillis = 0,
|
||||||
easing = FastOutSlowInEasing
|
easing = FastOutSlowInEasing
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
animate = true
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WallpaperItem(
|
||||||
|
wallpaperUri = wallpaper,
|
||||||
|
itemSelected = false,
|
||||||
|
selectionMode = false,
|
||||||
|
onActivateSelectionMode = {},
|
||||||
|
onItemSelection = {},
|
||||||
|
onWallpaperViewClick = {
|
||||||
|
onShowWallpaperView(wallpaper)
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(4.dp),
|
||||||
|
animate = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+51
-9
@@ -1,6 +1,5 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen
|
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.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
@@ -23,24 +22,42 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.runtime.snapshotFlow
|
import androidx.compose.runtime.snapshotFlow
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
|
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.add_album_screen.components.AddAlbumDialog
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.components.HomeTopBar
|
import com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.components.HomeTopBar
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.components.getTabItems
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.LibraryScreen
|
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
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreen
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreen(
|
fun HomeScreen(
|
||||||
onSettingsClick: () -> Unit,
|
onSettingsClick: () -> Unit,
|
||||||
navigateToAddWallpaperScreen: (String) -> Unit,
|
navigateToAddWallpaperScreen: (String) -> Unit,
|
||||||
onAlbumViewClick: (String) -> Unit,
|
onAlbumViewClick: (String) -> Unit,
|
||||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||||
onStop: () -> Unit
|
onSetLockWithHome: (Boolean) -> Unit,
|
||||||
|
onToggleChanger: (Boolean) -> Unit,
|
||||||
|
onSelectAlbum: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||||
|
onStop: () -> Unit,
|
||||||
|
animate : Boolean,
|
||||||
|
interval: Int,
|
||||||
|
setLockWithHome: Boolean,
|
||||||
|
lastSetTime: String?,
|
||||||
|
nextSetTime: String?,
|
||||||
|
selectedAlbum: SelectedAlbum?,
|
||||||
|
enableChanger: Boolean,
|
||||||
|
darkenPercentage: Int,
|
||||||
|
onDarkenPercentage: (Int) -> Unit,
|
||||||
|
darken: Boolean,
|
||||||
|
onDarkCheck: (Boolean) -> Unit,
|
||||||
|
scaling: ScalingConstants,
|
||||||
|
onScalingChange: (ScalingConstants) -> Unit
|
||||||
) {
|
) {
|
||||||
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
|
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
|
||||||
|
val tabItems = getTabItems()
|
||||||
val pagerState = rememberPagerState { tabItems.size }
|
val pagerState = rememberPagerState { tabItems.size }
|
||||||
|
|
||||||
var addAlbumDialog by rememberSaveable { mutableStateOf(false) }
|
var addAlbumDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
if (addAlbumDialog) AddAlbumDialog(
|
if (addAlbumDialog) AddAlbumDialog(
|
||||||
onDismissRequest = { addAlbumDialog = false },
|
onDismissRequest = { addAlbumDialog = false },
|
||||||
@@ -56,9 +73,17 @@ fun HomeScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
) { padding ->
|
) { padding ->
|
||||||
LaunchedEffect(tabIndex) { pagerState.animateScrollToPage(tabIndex) }
|
LaunchedEffect(tabIndex) {
|
||||||
|
if (tabIndex in tabItems.indices) {
|
||||||
|
pagerState.animateScrollToPage(tabIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
LaunchedEffect(pagerState) {
|
LaunchedEffect(pagerState) {
|
||||||
snapshotFlow { pagerState.currentPage }.collect { page -> tabIndex = page }
|
snapshotFlow { pagerState.currentPage }.collect { page ->
|
||||||
|
if (page in tabItems.indices) {
|
||||||
|
tabIndex = page
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Column(modifier = Modifier.padding(padding)) {
|
Column(modifier = Modifier.padding(padding)) {
|
||||||
TabRow(
|
TabRow(
|
||||||
@@ -104,11 +129,28 @@ fun HomeScreen(
|
|||||||
when(index) {
|
when(index) {
|
||||||
0 -> WallpaperScreen(
|
0 -> WallpaperScreen(
|
||||||
onScheduleWallpaperChanger = onScheduleWallpaperChanger,
|
onScheduleWallpaperChanger = onScheduleWallpaperChanger,
|
||||||
onStop = onStop
|
onStop = onStop,
|
||||||
|
animate = animate,
|
||||||
|
interval = interval,
|
||||||
|
setLockWithHome = setLockWithHome,
|
||||||
|
lastSetTime = lastSetTime,
|
||||||
|
nextSetTime = nextSetTime,
|
||||||
|
onSetLockWithHome = onSetLockWithHome,
|
||||||
|
selectedAlbum = selectedAlbum,
|
||||||
|
enableChanger = enableChanger,
|
||||||
|
onToggleChanger = onToggleChanger,
|
||||||
|
onSelectAlbum = onSelectAlbum,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
onDarkenPercentage = onDarkenPercentage,
|
||||||
|
darken = darken,
|
||||||
|
onDarkCheck = onDarkCheck,
|
||||||
|
scaling = scaling,
|
||||||
|
onScalingChange = onScalingChange
|
||||||
)
|
)
|
||||||
1 -> LibraryScreen(
|
1 -> LibraryScreen(
|
||||||
onAddNewAlbumClick = { addAlbumDialog = true },
|
onAddNewAlbumClick = { addAlbumDialog = true },
|
||||||
onViewAlbum = onAlbumViewClick
|
onViewAlbum = onAlbumViewClick,
|
||||||
|
animate = animate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -5,7 +5,6 @@ import androidx.compose.foundation.border
|
|||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.CheckCircle
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
@@ -45,7 +44,7 @@ fun HomeTopBar (
|
|||||||
) {
|
) {
|
||||||
CenterAlignedTopAppBar(
|
CenterAlignedTopAppBar(
|
||||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
||||||
title = { if (!showSelectionModeAppBar) Text(stringResource(R.string.appname)) },
|
title = { if (!showSelectionModeAppBar) Text(stringResource(R.string.app_name)) },
|
||||||
actions = {
|
actions = {
|
||||||
if (showSelectionModeAppBar) {
|
if (showSelectionModeAppBar) {
|
||||||
var showAlertDialog by rememberSaveable { mutableStateOf(false) }
|
var showAlertDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
@@ -87,7 +86,7 @@ fun HomeTopBar (
|
|||||||
.background(bgColor)
|
.background(bgColor)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text("$selectionCount selected")
|
Text(stringResource(R.string.selected_count, selectionCount))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen.components
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.AddToPhotos
|
||||||
|
import androidx.compose.material.icons.filled.Image
|
||||||
|
import androidx.compose.material.icons.outlined.AddToPhotos
|
||||||
|
import androidx.compose.material.icons.outlined.Image
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data class representing a tab item
|
||||||
|
*/
|
||||||
|
data class TabItem(
|
||||||
|
val title: String,
|
||||||
|
val filledIcon: ImageVector,
|
||||||
|
val unfilledIcon: ImageVector,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun getTabItems(): List<TabItem> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
return listOf(
|
||||||
|
TabItem(
|
||||||
|
title = context.getString(R.string.wallpaper_screen),
|
||||||
|
filledIcon = Icons.Filled.Image,
|
||||||
|
unfilledIcon = Icons.Outlined.Image
|
||||||
|
),
|
||||||
|
TabItem(
|
||||||
|
title = context.getString(R.string.library_screen),
|
||||||
|
filledIcon = Icons.Filled.AddToPhotos,
|
||||||
|
unfilledIcon = Icons.Outlined.AddToPhotos
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
+4
-8
@@ -30,7 +30,8 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.Al
|
|||||||
fun LibraryScreen(
|
fun LibraryScreen(
|
||||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||||
onAddNewAlbumClick: () -> Unit,
|
onAddNewAlbumClick: () -> Unit,
|
||||||
onViewAlbum: (String) -> Unit
|
onViewAlbum: (String) -> Unit,
|
||||||
|
animate: Boolean
|
||||||
) {
|
) {
|
||||||
val lazyListState = rememberLazyGridState()
|
val lazyListState = rememberLazyGridState()
|
||||||
val state = albumsViewModel.state.collectAsStateWithLifecycle()
|
val state = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||||
@@ -62,13 +63,8 @@ fun LibraryScreen(
|
|||||||
AlbumItem(
|
AlbumItem(
|
||||||
album = album.album,
|
album = album.album,
|
||||||
onAlbumViewClick = { onViewAlbum(album.album.initialAlbumName) },
|
onAlbumViewClick = { onViewAlbum(album.album.initialAlbumName) },
|
||||||
modifier = Modifier.padding(4.dp).animateItem(
|
modifier = Modifier.padding(4.dp),
|
||||||
placementSpec = tween(
|
animate = animate
|
||||||
durationMillis = 800,
|
|
||||||
delayMillis = 0,
|
|
||||||
easing = FastOutSlowInEasing
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-8
@@ -1,19 +1,11 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components
|
||||||
|
|
||||||
import androidx.compose.foundation.ScrollState
|
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.MutableState
|
|
||||||
import androidx.compose.runtime.SideEffect
|
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|||||||
+15
-3
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowCircleRight
|
import androidx.compose.material.icons.outlined.ArrowCircleRight
|
||||||
import androidx.compose.material.icons.outlined.Info
|
import androidx.compose.material.icons.outlined.Info
|
||||||
@@ -32,9 +33,12 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.airbnb.lottie.compose.LottieAnimation
|
import com.airbnb.lottie.compose.LottieAnimation
|
||||||
@@ -111,19 +115,27 @@ fun NotificationScreen(
|
|||||||
snackbar = { data ->
|
snackbar = { data ->
|
||||||
Snackbar(
|
Snackbar(
|
||||||
snackbarData = data,
|
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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) },
|
) },
|
||||||
content = { it
|
content = { it
|
||||||
Column (modifier = Modifier.padding(32.dp)) {
|
Column (modifier = Modifier.padding(32.dp)) {
|
||||||
Spacer(modifier = Modifier.height(120.dp))
|
Spacer(modifier = Modifier.height(120.dp))
|
||||||
Text(text = "Notifications", style = MaterialTheme.typography.headlineLarge)
|
Text(text = stringResource(id = R.string.notifications), style = MaterialTheme.typography.headlineLarge)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
LottieAnimation(
|
LottieAnimation(
|
||||||
composition = composition,
|
composition = composition,
|
||||||
progress = { progress },
|
progress = { progress },
|
||||||
modifier = Modifier.fillMaxHeight(0.5f)
|
modifier = Modifier
|
||||||
|
.fillMaxHeight(0.5f)
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.semantics {
|
||||||
|
contentDescription = context.getString(R.string.notification_bell_animation)
|
||||||
|
},
|
||||||
|
safeMode = true,
|
||||||
|
enableMergePaths = true
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Info,
|
imageVector = Icons.Outlined.Info,
|
||||||
|
|||||||
+13
-11
@@ -13,11 +13,13 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrollable privacy screen to display privacy policy
|
* Scrollable privacy screen to display privacy note
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun PrivacyScrollableSettings(
|
fun PrivacyScrollableSettings(
|
||||||
@@ -34,20 +36,20 @@ fun PrivacyScrollableSettings(
|
|||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
PrivacyPolicyText()
|
PrivacyNoticeText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PrivacyPolicyText() {
|
fun PrivacyNoticeText() {
|
||||||
SectionText("Introduction", "Welcome to Paperize! This privacy policy 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 policy.")
|
SectionText(stringResource(R.string.privacy_intro_title), stringResource(R.string.privacy_intro_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Data Collection", "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.\n\nLocal 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.")
|
SectionText(stringResource(R.string.privacy_data_collection_title), stringResource(R.string.privacy_data_collection_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Information Usage", "Personal Data: We do not collect or store any personal data such as names, email addresses, or phone numbers.\n\nUsage Analytics: Paperize does not track your usage behavior or collect analytics data.")
|
SectionText(stringResource(R.string.privacy_information_usage_title), stringResource(R.string.privacy_information_usage_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Data Security", "On-Device Storage: All data used by Paperize remains on your device. We do not transmit or store any data externally.\n\nEncryption: We use encryption protocols to secure communication between the app and your device.")
|
SectionText(stringResource(R.string.privacy_data_security_title), stringResource(R.string.privacy_data_security_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Third-Party Services", "Advertisements: Paperize does not display third-party ads.\n\nExternal Links: Our app may contain links to external websites. Please note that we are not responsible for the privacy practices of these sites.")
|
SectionText(stringResource(R.string.privacy_third_party_services_title), stringResource(R.string.privacy_third_party_services_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Children’s Privacy", "Paperize is not intended for children under the age of 13. We do not knowingly collect any information from children.")
|
SectionText(stringResource(R.string.privacy_children_privacy_title), stringResource(R.string.privacy_children_privacy_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Changes to this Policy", "We may update this privacy policy from time to time. Any changes will be reflected in the app and on our website.")
|
SectionText(stringResource(R.string.privacy_changes_notice_title), stringResource(R.string.privacy_changes_notice_content, stringResource(R.string.app_name)))
|
||||||
SectionText("Contact Us", "If you have any questions or concerns about this privacy policy, please contact me at anthonyyla.dev@gmail.com.")
|
SectionText(stringResource(R.string.privacy_contact_us_title), stringResource(R.string.privacy_contact_us_content, "anthonyyla.dev@gmail.com"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
+7
@@ -1,12 +1,19 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||||
|
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
|
||||||
|
|
||||||
sealed class SettingsEvent {
|
sealed class SettingsEvent {
|
||||||
data object Refresh: SettingsEvent()
|
data object Refresh: SettingsEvent()
|
||||||
|
data object Reset: SettingsEvent()
|
||||||
data object SetFirstLaunch: SettingsEvent()
|
data object SetFirstLaunch: SettingsEvent()
|
||||||
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
|
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
|
||||||
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
|
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
|
||||||
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
||||||
|
data class SetDarken(val darken: Boolean): SettingsEvent()
|
||||||
data class SetWallpaperInterval(val interval: Int): SettingsEvent()
|
data class SetWallpaperInterval(val interval: Int): SettingsEvent()
|
||||||
|
data class SetDarkenPercentage(val darkenPercentage: Int): SettingsEvent()
|
||||||
data class SetLockWithHome(val lockWithHome: Boolean): SettingsEvent()
|
data class SetLockWithHome(val lockWithHome: Boolean): SettingsEvent()
|
||||||
|
data class SetChangerToggle(val toggle: Boolean): SettingsEvent()
|
||||||
|
data class SetWallpaperScaling(val scaling: ScalingConstants): SettingsEvent()
|
||||||
}
|
}
|
||||||
+5
-3
@@ -8,8 +8,8 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
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.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.SettingsSmallTopAppBar
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components.SettingsTitle
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -20,7 +20,8 @@ fun SettingsScreen(
|
|||||||
onDynamicThemingClick: (Boolean) -> Unit,
|
onDynamicThemingClick: (Boolean) -> Unit,
|
||||||
onAnimateClick: (Boolean) -> Unit,
|
onAnimateClick: (Boolean) -> Unit,
|
||||||
onPrivacyClick: () -> Unit,
|
onPrivacyClick: () -> Unit,
|
||||||
onLicenseClick: () -> Unit
|
onLicenseClick: () -> Unit,
|
||||||
|
onResetClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
val scroll: ScrollState = rememberScrollState(0)
|
val scroll: ScrollState = rememberScrollState(0)
|
||||||
val largeTopAppBarHeight = 152.dp
|
val largeTopAppBarHeight = 152.dp
|
||||||
@@ -36,7 +37,8 @@ fun SettingsScreen(
|
|||||||
onDynamicThemingClick = onDynamicThemingClick,
|
onDynamicThemingClick = onDynamicThemingClick,
|
||||||
onAnimateClick = onAnimateClick,
|
onAnimateClick = onAnimateClick,
|
||||||
onPrivacyClick = onPrivacyClick,
|
onPrivacyClick = onPrivacyClick,
|
||||||
onLicenseClick = onLicenseClick
|
onLicenseClick = onLicenseClick,
|
||||||
|
onResetClick = onResetClick
|
||||||
)
|
)
|
||||||
SettingsSmallTopAppBar(onBackClick = onBackClick)
|
SettingsSmallTopAppBar(onBackClick = onBackClick)
|
||||||
SettingsTitle(
|
SettingsTitle(
|
||||||
|
|||||||
+7
-2
@@ -1,7 +1,8 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
import com.anthonyla.paperize.core.SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||||
|
|
||||||
data class SettingsState (
|
data class SettingsState(
|
||||||
val firstLaunch: Boolean = true,
|
val firstLaunch: Boolean = true,
|
||||||
val darkMode: Boolean? = null,
|
val darkMode: Boolean? = null,
|
||||||
val dynamicTheming: Boolean = false,
|
val dynamicTheming: Boolean = false,
|
||||||
@@ -9,5 +10,9 @@ data class SettingsState (
|
|||||||
val interval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
val interval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||||
val setLockWithHome: Boolean = false,
|
val setLockWithHome: Boolean = false,
|
||||||
val lastSetTime: String? = null,
|
val lastSetTime: String? = null,
|
||||||
val nextSetTime: String? = null
|
val nextSetTime: String? = null,
|
||||||
|
val enableChanger: Boolean = false,
|
||||||
|
val darkenPercentage: Int = 100,
|
||||||
|
val darken: Boolean = false,
|
||||||
|
val wallpaperScaling: ScalingConstants = ScalingConstants.FILL
|
||||||
)
|
)
|
||||||
+149
-29
@@ -1,8 +1,8 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
import com.anthonyla.paperize.core.SettingsConstants
|
import com.anthonyla.paperize.core.SettingsConstants
|
||||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
@@ -14,9 +14,9 @@ import kotlinx.coroutines.flow.SharingStarted
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.time.format.FormatStyle
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
@@ -33,7 +33,7 @@ class SettingsViewModel @Inject constructor (
|
|||||||
var setKeepOnScreenCondition: Boolean = true
|
var setKeepOnScreenCondition: Boolean = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
currentGetJob = viewModelScope.launch {
|
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||||
val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||||
@@ -42,8 +42,13 @@ class SettingsViewModel @Inject constructor (
|
|||||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||||
|
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false }
|
||||||
|
val darkenPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.DARKEN_PERCENTAGE) ?: 100 }
|
||||||
|
val darken = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARKEN) ?: false }
|
||||||
|
val wallpaperScaling = async { ScalingConstants.valueOf(settingsDataStoreImpl.getString(SettingsConstants.WALLPAPER_SCALING) ?: ScalingConstants.FILL.name) }
|
||||||
|
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
darkMode = darkMode.await(),
|
darkMode = darkMode.await(),
|
||||||
dynamicTheming = dynamicTheming.await(),
|
dynamicTheming = dynamicTheming.await(),
|
||||||
interval = wallpaperInterval.await(),
|
interval = wallpaperInterval.await(),
|
||||||
@@ -51,8 +56,13 @@ class SettingsViewModel @Inject constructor (
|
|||||||
firstLaunch = firstLaunch.await(),
|
firstLaunch = firstLaunch.await(),
|
||||||
lastSetTime = lastSetTime.await(),
|
lastSetTime = lastSetTime.await(),
|
||||||
nextSetTime = nextSetTime.await(),
|
nextSetTime = nextSetTime.await(),
|
||||||
animate = animate.await()
|
animate = animate.await(),
|
||||||
) }
|
enableChanger = enableChanger.await(),
|
||||||
|
darkenPercentage = darkenPercentage.await(),
|
||||||
|
darken = darken.await(),
|
||||||
|
wallpaperScaling = wallpaperScaling.await(),
|
||||||
|
)
|
||||||
|
}
|
||||||
setKeepOnScreenCondition = false
|
setKeepOnScreenCondition = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,15 +70,32 @@ class SettingsViewModel @Inject constructor (
|
|||||||
fun onEvent(event: SettingsEvent) {
|
fun onEvent(event: SettingsEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is SettingsEvent.SetFirstLaunch -> {
|
is SettingsEvent.SetFirstLaunch -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_LAUNCH, false)
|
settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_LAUNCH, false)
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
firstLaunch = false
|
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 -> {
|
is SettingsEvent.Refresh -> {
|
||||||
currentGetJob = viewModelScope.launch {
|
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||||
val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||||
@@ -77,8 +104,12 @@ class SettingsViewModel @Inject constructor (
|
|||||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||||
|
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: false }
|
||||||
|
val darkenPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.DARKEN_PERCENTAGE) ?: 0 }
|
||||||
|
val darken = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARKEN) ?: false }
|
||||||
|
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
darkMode = darkMode.await(),
|
darkMode = darkMode.await(),
|
||||||
dynamicTheming = dynamicTheming.await(),
|
dynamicTheming = dynamicTheming.await(),
|
||||||
interval = wallpaperInterval.await(),
|
interval = wallpaperInterval.await(),
|
||||||
@@ -86,69 +117,158 @@ class SettingsViewModel @Inject constructor (
|
|||||||
firstLaunch = firstLaunch.await(),
|
firstLaunch = firstLaunch.await(),
|
||||||
lastSetTime = lastSetTime.await(),
|
lastSetTime = lastSetTime.await(),
|
||||||
nextSetTime = nextSetTime.await(),
|
nextSetTime = nextSetTime.await(),
|
||||||
animate = animate.await()
|
animate = animate.await(),
|
||||||
) }
|
enableChanger = enableChanger.await(),
|
||||||
|
darkenPercentage = darkenPercentage.await(),
|
||||||
|
darken = darken.await()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is SettingsEvent.SetDarkMode -> {
|
is SettingsEvent.SetDarkMode -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
when (event.darkMode) {
|
when (event.darkMode) {
|
||||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) }
|
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) }
|
||||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) }
|
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) }
|
||||||
null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||||
}
|
}
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
darkMode = event.darkMode
|
darkMode = event.darkMode
|
||||||
) }
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is SettingsEvent.SetDynamicTheming -> {
|
is SettingsEvent.SetDynamicTheming -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
when (event.dynamicTheming) {
|
when (event.dynamicTheming) {
|
||||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) }
|
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) }
|
||||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) }
|
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) }
|
||||||
}
|
}
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
dynamicTheming = event.dynamicTheming
|
dynamicTheming = event.dynamicTheming
|
||||||
) }
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is SettingsEvent.SetAnimate -> {
|
is SettingsEvent.SetAnimate -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
when (event.animate) {
|
when (event.animate) {
|
||||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) }
|
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) }
|
||||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) }
|
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) }
|
||||||
}
|
}
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
animate = event.animate
|
animate = event.animate
|
||||||
) }
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is SettingsEvent.SetWallpaperInterval -> {
|
is SettingsEvent.SetWallpaperInterval -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val formatter = DateTimeFormatter.ofPattern("MM/dd/yy hh:mm\na")
|
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||||
val time = LocalDateTime.now()
|
val time = LocalDateTime.now()
|
||||||
val formattedLastSetTime = time.format(formatter)
|
val formattedLastSetTime = time.format(formatter)
|
||||||
val formattedNextSetTime = time.plusMinutes(event.interval.toLong()).format(formatter)
|
val formattedNextSetTime = time.plusMinutes(event.interval.toLong()).format(formatter)
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, formattedLastSetTime)
|
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, formattedLastSetTime)
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, formattedNextSetTime)
|
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, formattedNextSetTime)
|
||||||
settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval)
|
settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval)
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
interval = event.interval,
|
interval = event.interval,
|
||||||
lastSetTime = formattedLastSetTime,
|
lastSetTime = formattedLastSetTime,
|
||||||
nextSetTime = formattedNextSetTime
|
nextSetTime = formattedNextSetTime
|
||||||
) }
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is SettingsEvent.SetDarkenPercentage -> {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
settingsDataStoreImpl.putInt(SettingsConstants.DARKEN_PERCENTAGE, event.darkenPercentage)
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
darkenPercentage = event.darkenPercentage
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is SettingsEvent.SetDarken -> {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
when (event.darken) {
|
||||||
|
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARKEN, true) }
|
||||||
|
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARKEN, false) }
|
||||||
|
}
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
darken = event.darken
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is SettingsEvent.SetLockWithHome -> {
|
is SettingsEvent.SetLockWithHome -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
when (event.lockWithHome) {
|
when (event.lockWithHome) {
|
||||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, true) }
|
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, true) }
|
||||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, false) }
|
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, false) }
|
||||||
}
|
}
|
||||||
_state.update { it.copy(
|
_state.update {
|
||||||
|
it.copy(
|
||||||
setLockWithHome = event.lockWithHome
|
setLockWithHome = event.lockWithHome
|
||||||
) }
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is SettingsEvent.SetWallpaperScaling -> {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.WALLPAPER_SCALING, event.scaling.name)
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
wallpaperScaling = event.scaling
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
settingsDataStoreImpl.deleteInt(SettingsConstants.DARKEN_PERCENTAGE)
|
||||||
|
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARKEN)
|
||||||
|
settingsDataStoreImpl.deleteString(SettingsConstants.WALLPAPER_SCALING)
|
||||||
|
|
||||||
|
_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,
|
||||||
|
darkenPercentage = 100,
|
||||||
|
darken = false,
|
||||||
|
wallpaperScaling = ScalingConstants.FILL
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Animation
|
import androidx.compose.material.icons.outlined.Animation
|
||||||
import androidx.compose.material.icons.outlined.Palette
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.ListItem
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -14,15 +13,19 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable animation switch
|
* Enable animation switch
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
Row {
|
Row {
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -30,17 +33,17 @@ fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
|||||||
.clickable { onAnimateClick(!animate) },
|
.clickable { onAnimateClick(!animate) },
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Animation",
|
text = stringResource(R.string.animation),
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Increase visual appeal",
|
text = stringResource(R.string.increase_visual_appeal),
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
) },
|
) },
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
Switch(
|
Switch(
|
||||||
modifier = Modifier.semantics { contentDescription = "Animation" },
|
modifier = Modifier.semantics { contentDescription = context.getString(R.string.animation) },
|
||||||
checked = animate,
|
checked = animate,
|
||||||
onCheckedChange = onAnimateClick,
|
onCheckedChange = onAnimateClick,
|
||||||
enabled = true
|
enabled = true
|
||||||
@@ -48,7 +51,7 @@ fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
|||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Outlined.Animation,
|
Icons.Outlined.Animation,
|
||||||
contentDescription = "Animation",
|
contentDescription = stringResource(R.string.animation),
|
||||||
tint = MaterialTheme.colorScheme.primary
|
tint = MaterialTheme.colorScheme.primary
|
||||||
) },
|
) },
|
||||||
tonalElevation = 5.dp
|
tonalElevation = 5.dp
|
||||||
|
|||||||
-3
@@ -4,10 +4,7 @@ import androidx.compose.foundation.clickable
|
|||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowCircleRight
|
|
||||||
import androidx.compose.material.icons.outlined.Email
|
import androidx.compose.material.icons.outlined.Email
|
||||||
import androidx.compose.material.icons.outlined.PrivacyTip
|
|
||||||
import androidx.compose.material.icons.outlined.SubdirectoryArrowRight
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.ListItem
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
|||||||
+12
-8
@@ -30,8 +30,10 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Three-state selector for dark mode in settings
|
* Three-state selector for dark mode in settings
|
||||||
@@ -40,9 +42,9 @@ import androidx.compose.ui.unit.dp
|
|||||||
@Composable
|
@Composable
|
||||||
fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||||
val options = listOf(
|
val options = listOf(
|
||||||
Triple("Dark Mode", Icons.Outlined.DarkMode, Icons.Filled.DarkMode),
|
Triple(stringResource(R.string.dark_mode), Icons.Outlined.DarkMode, Icons.Filled.DarkMode),
|
||||||
Triple("Automatic Device Mode", Icons.Outlined.BrightnessAuto, Icons.Filled.BrightnessAuto),
|
Triple(stringResource(R.string.automatic_device_mode), Icons.Outlined.BrightnessAuto, Icons.Filled.BrightnessAuto),
|
||||||
Triple("Light Mode", Icons.Outlined.LightMode, Icons.Filled.LightMode)
|
Triple(stringResource(R.string.light_mode), Icons.Outlined.LightMode, Icons.Filled.LightMode)
|
||||||
)
|
)
|
||||||
var selectedIndex by remember {
|
var selectedIndex by remember {
|
||||||
mutableIntStateOf(
|
mutableIntStateOf(
|
||||||
@@ -51,7 +53,8 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
|||||||
false -> 2
|
false -> 2
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
) }
|
)
|
||||||
|
}
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
@@ -70,16 +73,17 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
|||||||
2 -> false
|
2 -> false
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
) },
|
)
|
||||||
|
},
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Dark Mode",
|
text = stringResource(R.string.dark_mode),
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
|
||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Easier on the eyes",
|
text = stringResource(R.string.easier_on_the_eyes),
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
) },
|
) },
|
||||||
@@ -116,7 +120,7 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
|||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Outlined.Brightness6,
|
Icons.Outlined.Brightness6,
|
||||||
contentDescription = "Dark Mode",
|
contentDescription = stringResource(R.string.dark_mode),
|
||||||
tint = MaterialTheme.colorScheme.primary
|
tint = MaterialTheme.colorScheme.primary
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
+8
-4
@@ -13,15 +13,19 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic theming switch
|
* Dynamic theming switch
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Boolean) -> Unit) {
|
fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Boolean) -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
Row {
|
Row {
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -29,18 +33,18 @@ fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Bool
|
|||||||
.clickable { onDynamicThemingClick(!dynamicTheming) },
|
.clickable { onDynamicThemingClick(!dynamicTheming) },
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Dynamic Theme",
|
text = stringResource(R.string.dynamic_theme),
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
|
||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Material You",
|
text = stringResource(R.string.material_you),
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
) },
|
) },
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
Switch(
|
Switch(
|
||||||
modifier = Modifier.semantics { contentDescription = "Dynamic Theme" },
|
modifier = Modifier.semantics { contentDescription = context.getString(R.string.dynamic_theme) },
|
||||||
checked = dynamicTheming,
|
checked = dynamicTheming,
|
||||||
onCheckedChange = onDynamicThemingClick,
|
onCheckedChange = onDynamicThemingClick,
|
||||||
enabled = true
|
enabled = true
|
||||||
@@ -48,7 +52,7 @@ fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Bool
|
|||||||
leadingContent = {
|
leadingContent = {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Outlined.Palette,
|
Icons.Outlined.Palette,
|
||||||
contentDescription = "Dynamic Theming",
|
contentDescription = stringResource(R.string.dynamic_theming),
|
||||||
tint = MaterialTheme.colorScheme.primary
|
tint = MaterialTheme.colorScheme.primary
|
||||||
) },
|
) },
|
||||||
tonalElevation = 5.dp
|
tonalElevation = 5.dp
|
||||||
|
|||||||
+1
-3
@@ -4,8 +4,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.LibraryBooks
|
import androidx.compose.material.icons.automirrored.outlined.LibraryBooks
|
||||||
import androidx.compose.material.icons.outlined.Newspaper
|
|
||||||
import androidx.compose.material.icons.outlined.PrivacyTip
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.ListItem
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -34,7 +32,7 @@ fun LicenseListItem(onLicenseClick: () -> Unit) {
|
|||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Click here to view the licenses",
|
text = stringResource(R.string.click_here_to_view_the_licenses),
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
) },
|
) },
|
||||||
trailingContent = {},
|
trailingContent = {},
|
||||||
|
|||||||
+144
@@ -0,0 +1,144 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||||
|
|
||||||
|
import android.content.pm.PackageInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Card
|
||||||
|
import androidx.compose.material3.CardDefaults
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
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.scale
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.res.vectorResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List item for app version and link to GitHub and PlayStore
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun PaperizeListItem(onGitHubClick: () -> Unit, onPlaystoreClick: () -> Unit, onFdroidClick: () -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
var version = ""
|
||||||
|
try {
|
||||||
|
val pInfo: PackageInfo =
|
||||||
|
context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
version = pInfo.versionName
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(16.dp)),
|
||||||
|
elevation = CardDefaults.cardElevation(10.dp),
|
||||||
|
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.primaryContainer)
|
||||||
|
) {
|
||||||
|
Row (
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(2f)
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(id = R.drawable.app_icon_foreground),
|
||||||
|
contentDescription = stringResource(id = R.string.app_name),
|
||||||
|
modifier = Modifier
|
||||||
|
.size(160.dp)
|
||||||
|
.scale(1.5f),
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.app_name),
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
fontSize = MaterialTheme.typography.titleLarge.fontSize
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.version, version),
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
fontSize = MaterialTheme.typography.bodyMedium.fontSize
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Anthony La",
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
IconButton(
|
||||||
|
onClick = onGitHubClick,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(60.dp)
|
||||||
|
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(id = R.drawable.github),
|
||||||
|
contentDescription = "GitHub",
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
IconButton(
|
||||||
|
onClick = onPlaystoreClick,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(60.dp)
|
||||||
|
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(id = R.drawable.google_play),
|
||||||
|
contentDescription = "Playstore",
|
||||||
|
modifier = Modifier.size(12.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
IconButton(
|
||||||
|
onClick = onFdroidClick,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(60.dp)
|
||||||
|
.background(MaterialTheme.colorScheme.primary, CircleShape)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = ImageVector.vectorResource(id = R.drawable.fdroid),
|
||||||
|
contentDescription = "F-Droid",
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.onPrimary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -33,7 +33,7 @@ fun PrivacyPolicyListItem(onPrivacyPolicyClick: () -> Unit) {
|
|||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = "Click here to view our privacy policy",
|
text = stringResource(R.string.click_here_to_view_our_privacy_policy),
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
) },
|
) },
|
||||||
trailingContent = {},
|
trailingContent = {},
|
||||||
|
|||||||
+85
@@ -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,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+80
-7
@@ -1,28 +1,41 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import androidx.compose.foundation.ScrollState
|
import androidx.compose.foundation.ScrollState
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Snackbar
|
||||||
|
import androidx.compose.material3.SnackbarDuration
|
||||||
|
import androidx.compose.material3.SnackbarHost
|
||||||
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
import com.anthonyla.paperize.data.Contact
|
import com.anthonyla.paperize.data.Contact
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrollable settings screen to wrap all settings components
|
* Scrollable settings screen to wrap all settings components
|
||||||
@@ -36,10 +49,13 @@ fun SettingsScrollableSettings(
|
|||||||
onDarkModeClick: (Boolean?) -> Unit,
|
onDarkModeClick: (Boolean?) -> Unit,
|
||||||
onAnimateClick: (Boolean) -> Unit,
|
onAnimateClick: (Boolean) -> Unit,
|
||||||
onPrivacyClick: () -> Unit,
|
onPrivacyClick: () -> Unit,
|
||||||
onLicenseClick: () -> Unit
|
onLicenseClick: () -> Unit,
|
||||||
|
onResetClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val state = settingsState.collectAsStateWithLifecycle()
|
val state = settingsState.collectAsStateWithLifecycle()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
var toContact by rememberSaveable { mutableStateOf(false) }
|
var toContact by rememberSaveable { mutableStateOf(false) }
|
||||||
if (toContact) {
|
if (toContact) {
|
||||||
@@ -47,6 +63,25 @@ fun SettingsScrollableSettings(
|
|||||||
toContact = false
|
toContact = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val githubLink = "https://github.com/Anthonyy232/Paperize"
|
||||||
|
val playstoreLink = ""
|
||||||
|
val fdroidLink = ""
|
||||||
|
val translateLink = "https://crowdin.com/project/paperize/invite?h=d8d7a7513d2beb0c96ba9b2a5f85473e2084922"
|
||||||
|
|
||||||
|
Scaffold(
|
||||||
|
snackbarHost = {
|
||||||
|
SnackbarHost(
|
||||||
|
hostState = snackbarHostState,
|
||||||
|
snackbar = { data ->
|
||||||
|
Snackbar(
|
||||||
|
snackbarData = data,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||||
|
shape = RoundedCornerShape(24.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) },
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
content = { it
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.Start,
|
horizontalAlignment = Alignment.Start,
|
||||||
verticalArrangement = Arrangement.Top,
|
verticalArrangement = Arrangement.Top,
|
||||||
@@ -57,10 +92,8 @@ fun SettingsScrollableSettings(
|
|||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
ListSectionTitle(stringResource(R.string.appearance))
|
||||||
ListSectionTitle("Appearance")
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
DarkModeListItem(
|
DarkModeListItem(
|
||||||
darkMode = state.value.darkMode,
|
darkMode = state.value.darkMode,
|
||||||
@@ -79,13 +112,53 @@ fun SettingsScrollableSettings(
|
|||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
ListSectionTitle("About")
|
ListSectionTitle(stringResource(R.string.about))
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
TranslateListItem(
|
||||||
|
onClick = {
|
||||||
|
val openURL = Intent(Intent.ACTION_VIEW)
|
||||||
|
openURL.data = Uri.parse(translateLink)
|
||||||
|
context.startActivity(openURL)
|
||||||
|
}
|
||||||
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
PrivacyPolicyListItem (onPrivacyPolicyClick = onPrivacyClick)
|
PrivacyPolicyListItem (onPrivacyPolicyClick = onPrivacyClick)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
LicenseListItem(onLicenseClick = onLicenseClick)
|
LicenseListItem(onLicenseClick = onLicenseClick)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
ContactListItem(onContactClick = { toContact = true })
|
ContactListItem(onContactClick = { toContact = true })
|
||||||
//GPL and License and link to github etc, contact, terms of service, privacy policy
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
PaperizeListItem(
|
||||||
|
onGitHubClick = {
|
||||||
|
val openURL = Intent(Intent.ACTION_VIEW)
|
||||||
|
openURL.data = Uri.parse(githubLink)
|
||||||
|
context.startActivity(openURL)
|
||||||
|
},
|
||||||
|
onPlaystoreClick = {
|
||||||
|
coroutineScope.launch {
|
||||||
|
snackbarHostState.currentSnackbarData?.dismiss()
|
||||||
|
snackbarHostState.showSnackbar(
|
||||||
|
message = context.getString(R.string.coming_soon),
|
||||||
|
actionLabel = context.getString(R.string.dismiss),
|
||||||
|
duration = SnackbarDuration.Short
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onFdroidClick = {
|
||||||
|
coroutineScope.launch {
|
||||||
|
snackbarHostState.currentSnackbarData?.dismiss()
|
||||||
|
snackbarHostState.showSnackbar(
|
||||||
|
message = context.getString(R.string.coming_soon),
|
||||||
|
actionLabel = context.getString(R.string.dismiss),
|
||||||
|
duration = SnackbarDuration.Short
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
ResetListItem(onResetClick = onResetClick)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.AddToPhotos
|
|
||||||
import androidx.compose.material.icons.filled.Image
|
|
||||||
import androidx.compose.material.icons.outlined.AddToPhotos
|
|
||||||
import androidx.compose.material.icons.outlined.Image
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data class representing a tab item
|
|
||||||
*/
|
|
||||||
data class TabItem(
|
|
||||||
val title: String,
|
|
||||||
val filledIcon: ImageVector,
|
|
||||||
val unfilledIcon: ImageVector,
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of tab items
|
|
||||||
*/
|
|
||||||
val tabItems = listOf(
|
|
||||||
TabItem(
|
|
||||||
title = "Wallpaper",
|
|
||||||
filledIcon = Icons.Filled.Image,
|
|
||||||
unfilledIcon = Icons.Outlined.Image
|
|
||||||
),
|
|
||||||
TabItem(
|
|
||||||
title = "Library",
|
|
||||||
filledIcon = Icons.Filled.AddToPhotos,
|
|
||||||
unfilledIcon = Icons.Outlined.AddToPhotos
|
|
||||||
)
|
|
||||||
)
|
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Translate
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.ListItem
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list item that links the user to the translation page
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun TranslateListItem(onClick: () -> Unit) {
|
||||||
|
Row {
|
||||||
|
ListItem(
|
||||||
|
modifier = Modifier
|
||||||
|
.clip(RoundedCornerShape(16.dp))
|
||||||
|
.clickable { onClick() },
|
||||||
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.translation),
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
) },
|
||||||
|
supportingContent = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.help_translate_the_app_on_crowdin),
|
||||||
|
style = MaterialTheme.typography.bodySmall
|
||||||
|
) },
|
||||||
|
trailingContent = {},
|
||||||
|
leadingContent = {
|
||||||
|
Icon(
|
||||||
|
Icons.Outlined.Translate,
|
||||||
|
contentDescription = stringResource(R.string.translation),
|
||||||
|
tint = MaterialTheme.colorScheme.primary
|
||||||
|
) },
|
||||||
|
tonalElevation = 5.dp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
-35
@@ -1,5 +1,7 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.startup_screen
|
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.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
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.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Info
|
import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.material.icons.sharp.CheckCircleOutline
|
import androidx.compose.material.icons.sharp.CheckCircleOutline
|
||||||
@@ -34,6 +37,8 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.airbnb.lottie.compose.LottieAnimation
|
import com.airbnb.lottie.compose.LottieAnimation
|
||||||
@@ -44,11 +49,11 @@ import com.airbnb.lottie.compose.rememberLottieComposition
|
|||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
// Inspired by https://github.com/Ashinch/ReadYou
|
||||||
@Composable
|
@Composable
|
||||||
fun StartupScreen(
|
fun StartupScreen(
|
||||||
onAgree: () -> Unit
|
onAgree: () -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
|
||||||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.onboarding_animation))
|
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.onboarding_animation))
|
||||||
val progress by animateLottieCompositionAsState(
|
val progress by animateLottieCompositionAsState(
|
||||||
composition = composition,
|
composition = composition,
|
||||||
@@ -59,6 +64,12 @@ fun StartupScreen(
|
|||||||
var showToS by remember { mutableStateOf(false) }
|
var showToS by remember { mutableStateOf(false) }
|
||||||
var seenToS by remember { mutableStateOf(false) }
|
var seenToS by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
val context = LocalContext.current
|
||||||
|
val activity = context as? Activity
|
||||||
|
BackHandler {
|
||||||
|
activity?.moveTaskToBack(true)
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
snackbarHost = {
|
snackbarHost = {
|
||||||
SnackbarHost(
|
SnackbarHost(
|
||||||
@@ -66,7 +77,8 @@ fun StartupScreen(
|
|||||||
snackbar = { data ->
|
snackbar = { data ->
|
||||||
Snackbar(
|
Snackbar(
|
||||||
snackbarData = data,
|
snackbarData = data,
|
||||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp))
|
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp)),
|
||||||
|
shape = RoundedCornerShape(24.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) },
|
) },
|
||||||
@@ -78,7 +90,14 @@ fun StartupScreen(
|
|||||||
LottieAnimation(
|
LottieAnimation(
|
||||||
composition = composition,
|
composition = composition,
|
||||||
progress = { progress },
|
progress = { progress },
|
||||||
modifier = Modifier.fillMaxHeight(0.5f)
|
modifier = Modifier
|
||||||
|
.fillMaxHeight(0.5f)
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.semantics {
|
||||||
|
contentDescription = context.getString(R.string.welcome_animation)
|
||||||
|
},
|
||||||
|
safeMode = true,
|
||||||
|
enableMergePaths = true
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Info,
|
imageVector = Icons.Outlined.Info,
|
||||||
@@ -86,7 +105,7 @@ fun StartupScreen(
|
|||||||
modifier = Modifier.padding(PaddingValues(vertical = 16.dp))
|
modifier = Modifier.padding(PaddingValues(vertical = 16.dp))
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "Please read and agree to the following privacy policy to use the app.",
|
text = stringResource(R.string.please_read_and_agree_to_the_following_privacy_notice_to_use_the_app),
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
@@ -101,7 +120,7 @@ fun StartupScreen(
|
|||||||
} },
|
} },
|
||||||
modifier = Modifier.padding(PaddingValues(vertical = 16.dp)),
|
modifier = Modifier.padding(PaddingValues(vertical = 16.dp)),
|
||||||
) {
|
) {
|
||||||
Text(text = "Privacy Policy", textAlign = TextAlign.Start)
|
Text(text = stringResource(R.string.privacy_notice), textAlign = TextAlign.Start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,8 +134,8 @@ fun StartupScreen(
|
|||||||
} else {
|
} else {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
val result = snackbarHostState.showSnackbar(
|
val result = snackbarHostState.showSnackbar(
|
||||||
message = "Please read and agree to the privacy policy.",
|
message = context.getString(R.string.please_read_and_agree_to_the_privacy_notice),
|
||||||
actionLabel = "View",
|
actionLabel = context.getString(R.string.view),
|
||||||
duration = SnackbarDuration.Short,
|
duration = SnackbarDuration.Short,
|
||||||
)
|
)
|
||||||
when (result) {
|
when (result) {
|
||||||
@@ -147,18 +166,18 @@ fun StartupScreen(
|
|||||||
title = {
|
title = {
|
||||||
Box(modifier = Modifier.fillMaxWidth()) {
|
Box(modifier = Modifier.fillMaxWidth()) {
|
||||||
Text(
|
Text(
|
||||||
text = "Privacy Policy",
|
text = stringResource(R.string.privacy_notice),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
modifier = Modifier.align(Alignment.Center)
|
modifier = Modifier.align(Alignment.Center)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
text = { PrivacyPolicyText() },
|
text = { PrivacyNoticeText() },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
Button(
|
Button(
|
||||||
onClick = { showToS = false },
|
onClick = { showToS = false },
|
||||||
) {
|
) {
|
||||||
Text("Dismiss")
|
Text(stringResource(R.string.dismiss))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -166,32 +185,16 @@ fun StartupScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PrivacyPolicyText() {
|
fun PrivacyNoticeText() {
|
||||||
LazyColumn {
|
LazyColumn {
|
||||||
item {
|
item { SectionText(stringResource(R.string.privacy_intro_title), stringResource(R.string.privacy_intro_content, stringResource(R.string.app_name))) }
|
||||||
SectionText("Introduction", "Welcome to Paperize! This privacy policy 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 policy.")
|
item { SectionText(stringResource(R.string.privacy_data_collection_title), stringResource(R.string.privacy_data_collection_content, stringResource(R.string.app_name))) }
|
||||||
}
|
item { SectionText(stringResource(R.string.privacy_information_usage_title), stringResource(R.string.privacy_information_usage_content, stringResource(R.string.app_name))) }
|
||||||
item {
|
item { SectionText(stringResource(R.string.privacy_data_security_title), stringResource(R.string.privacy_data_security_content, stringResource(R.string.app_name))) }
|
||||||
SectionText("Data Collection", "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.\n\nLocal 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.")
|
item { SectionText(stringResource(R.string.privacy_third_party_services_title), stringResource(R.string.privacy_third_party_services_content, stringResource(R.string.app_name))) }
|
||||||
}
|
item { SectionText(stringResource(R.string.privacy_children_privacy_title), stringResource(R.string.privacy_children_privacy_content, stringResource(R.string.app_name))) }
|
||||||
item {
|
item { SectionText(stringResource(R.string.privacy_changes_notice_title), stringResource(R.string.privacy_changes_notice_content, stringResource(R.string.app_name))) }
|
||||||
SectionText("Information Usage", "Personal Data: We do not collect or store any personal data such as names, email addresses, or phone numbers.\n\nUsage Analytics: Paperize does not track your usage behavior or collect analytics data.")
|
item { SectionText(stringResource(R.string.privacy_contact_us_title), stringResource(R.string.privacy_contact_us_content, "anthonyyla.dev@gmail.com")) }
|
||||||
}
|
|
||||||
item {
|
|
||||||
SectionText("Data Security", "On-Device Storage: All data used by Paperize remains on your device. We do not transmit or store any data externally.\n\nEncryption: We use encryption protocols to secure communication between the app and your device.")
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
SectionText("Third-Party Services", "Advertisements: Paperize does not display third-party ads.\n\nExternal Links: Our app may contain links to external websites. Please note that we are not responsible for the privacy practices of these sites.")
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
SectionText("Children’s Privacy", "Paperize is not intended for children under the age of 13. We do not knowingly collect any information from children.")
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
SectionText("Changes to this Policy", "We may update this privacy policy from time to time. Any changes will be reflected in the app and on our website.")
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
SectionText("Contact Us", "If you have any questions or concerns about this privacy policy, please contact me at anthonyyla.dev@gmail.com.")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.example.compose
|
package com.anthonyla.paperize.feature.wallpaper.presentation.themes
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
val md_theme_light_primary = Color(0xFF984061)
|
val md_theme_light_primary = Color(0xFF984061)
|
||||||
|
|||||||
+5
-65
@@ -6,76 +6,17 @@ import android.os.Build
|
|||||||
import androidx.activity.SystemBarStyle
|
import androidx.activity.SystemBarStyle
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.lightColorScheme
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.material3.dynamicDarkColorScheme
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
import androidx.compose.material3.dynamicLightColorScheme
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||||
import com.example.compose.md_theme_dark_background
|
|
||||||
import com.example.compose.md_theme_dark_error
|
|
||||||
import com.example.compose.md_theme_dark_errorContainer
|
|
||||||
import com.example.compose.md_theme_dark_inverseOnSurface
|
|
||||||
import com.example.compose.md_theme_dark_inversePrimary
|
|
||||||
import com.example.compose.md_theme_dark_inverseSurface
|
|
||||||
import com.example.compose.md_theme_dark_onBackground
|
|
||||||
import com.example.compose.md_theme_dark_onError
|
|
||||||
import com.example.compose.md_theme_dark_onErrorContainer
|
|
||||||
import com.example.compose.md_theme_dark_onPrimary
|
|
||||||
import com.example.compose.md_theme_dark_onPrimaryContainer
|
|
||||||
import com.example.compose.md_theme_dark_onSecondary
|
|
||||||
import com.example.compose.md_theme_dark_onSecondaryContainer
|
|
||||||
import com.example.compose.md_theme_dark_onSurface
|
|
||||||
import com.example.compose.md_theme_dark_onSurfaceVariant
|
|
||||||
import com.example.compose.md_theme_dark_onTertiary
|
|
||||||
import com.example.compose.md_theme_dark_onTertiaryContainer
|
|
||||||
import com.example.compose.md_theme_dark_outline
|
|
||||||
import com.example.compose.md_theme_dark_outlineVariant
|
|
||||||
import com.example.compose.md_theme_dark_primary
|
|
||||||
import com.example.compose.md_theme_dark_primaryContainer
|
|
||||||
import com.example.compose.md_theme_dark_scrim
|
|
||||||
import com.example.compose.md_theme_dark_secondary
|
|
||||||
import com.example.compose.md_theme_dark_secondaryContainer
|
|
||||||
import com.example.compose.md_theme_dark_surface
|
|
||||||
import com.example.compose.md_theme_dark_surfaceTint
|
|
||||||
import com.example.compose.md_theme_dark_surfaceVariant
|
|
||||||
import com.example.compose.md_theme_dark_tertiary
|
|
||||||
import com.example.compose.md_theme_dark_tertiaryContainer
|
|
||||||
import com.example.compose.md_theme_light_background
|
|
||||||
import com.example.compose.md_theme_light_error
|
|
||||||
import com.example.compose.md_theme_light_errorContainer
|
|
||||||
import com.example.compose.md_theme_light_inverseOnSurface
|
|
||||||
import com.example.compose.md_theme_light_inversePrimary
|
|
||||||
import com.example.compose.md_theme_light_inverseSurface
|
|
||||||
import com.example.compose.md_theme_light_onBackground
|
|
||||||
import com.example.compose.md_theme_light_onError
|
|
||||||
import com.example.compose.md_theme_light_onErrorContainer
|
|
||||||
import com.example.compose.md_theme_light_onPrimary
|
|
||||||
import com.example.compose.md_theme_light_onPrimaryContainer
|
|
||||||
import com.example.compose.md_theme_light_onSecondary
|
|
||||||
import com.example.compose.md_theme_light_onSecondaryContainer
|
|
||||||
import com.example.compose.md_theme_light_onSurface
|
|
||||||
import com.example.compose.md_theme_light_onSurfaceVariant
|
|
||||||
import com.example.compose.md_theme_light_onTertiary
|
|
||||||
import com.example.compose.md_theme_light_onTertiaryContainer
|
|
||||||
import com.example.compose.md_theme_light_outline
|
|
||||||
import com.example.compose.md_theme_light_outlineVariant
|
|
||||||
import com.example.compose.md_theme_light_primary
|
|
||||||
import com.example.compose.md_theme_light_primaryContainer
|
|
||||||
import com.example.compose.md_theme_light_scrim
|
|
||||||
import com.example.compose.md_theme_light_secondary
|
|
||||||
import com.example.compose.md_theme_light_secondaryContainer
|
|
||||||
import com.example.compose.md_theme_light_surface
|
|
||||||
import com.example.compose.md_theme_light_surfaceTint
|
|
||||||
import com.example.compose.md_theme_light_surfaceVariant
|
|
||||||
import com.example.compose.md_theme_light_tertiary
|
|
||||||
import com.example.compose.md_theme_light_tertiaryContainer
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
|
|
||||||
|
|
||||||
private val LightColors = lightColorScheme(
|
private val LightColors = lightColorScheme(
|
||||||
@@ -149,14 +90,13 @@ private val DarkColors = darkColorScheme(
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun PaperizeTheme(
|
fun PaperizeTheme(
|
||||||
settingsState: StateFlow<SettingsState>,
|
settingsState: State<SettingsState>,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
val state = settingsState.collectAsStateWithLifecycle()
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val isDarkMode = isDarkMode(darkMode = state.value.darkMode)
|
val isDarkMode = isDarkMode(darkMode = settingsState.value.darkMode)
|
||||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = state.value.dynamicTheming)
|
val isDynamicTheming = isDynamicTheming(dynamicTheming = settingsState.value.dynamicTheming)
|
||||||
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
val colors = when {
|
val colors = when {
|
||||||
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
||||||
|
|||||||
+1
-2
@@ -2,10 +2,9 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
|||||||
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
|
||||||
|
|
||||||
sealed class WallpaperEvent {
|
sealed class WallpaperEvent {
|
||||||
data class UpdateSelectedAlbum(val selectedAlbum: SelectedAlbum): WallpaperEvent()
|
data class UpdateSelectedAlbum(val selectedAlbum: SelectedAlbum?, val album: AlbumWithWallpaperAndFolder?): WallpaperEvent()
|
||||||
object Reset : WallpaperEvent()
|
object Reset : WallpaperEvent()
|
||||||
object Refresh : WallpaperEvent()
|
object Refresh : WallpaperEvent()
|
||||||
}
|
}
|
||||||
+189
-94
@@ -1,7 +1,7 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||||
|
|
||||||
import android.os.Build
|
import android.app.WallpaperManager
|
||||||
import android.view.HapticFeedbackConstants
|
import android.content.Context
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.slideInVertically
|
||||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.PaddingValues
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Snackbar
|
import androidx.compose.material3.Snackbar
|
||||||
import androidx.compose.material3.SnackbarDuration
|
import androidx.compose.material3.SnackbarDuration
|
||||||
@@ -23,36 +24,60 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
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.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.AlbumBottomSheet
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.AlbumBottomSheet
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentAndNextChange
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentAndNextChange
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentSelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.CurrentSelectedAlbum
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.DarkenSwitchAndSlider
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.SetLockScreenSwitch
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.SetLockScreenSwitch
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ShowLiveWallpaperEnabledDialog
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.WallpaperScalingRow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WallpaperScreen(
|
fun WallpaperScreen(
|
||||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||||
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
|
||||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
|
||||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||||
onStop: () -> Unit
|
onSetLockWithHome: (Boolean) -> Unit,
|
||||||
|
onToggleChanger: (Boolean) -> Unit,
|
||||||
|
onSelectAlbum: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||||
|
onStop: () -> Unit,
|
||||||
|
animate: Boolean,
|
||||||
|
interval: Int,
|
||||||
|
setLockWithHome: Boolean,
|
||||||
|
lastSetTime: String?,
|
||||||
|
nextSetTime: String?,
|
||||||
|
selectedAlbum: SelectedAlbum?,
|
||||||
|
enableChanger: Boolean,
|
||||||
|
darkenPercentage: Int,
|
||||||
|
onDarkenPercentage: (Int) -> Unit,
|
||||||
|
darken: Boolean,
|
||||||
|
onDarkCheck: (Boolean) -> Unit,
|
||||||
|
scaling: ScalingConstants,
|
||||||
|
onScalingChange: (ScalingConstants) -> Unit
|
||||||
) {
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||||
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
|
||||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
|
||||||
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
|
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
val openDialog = rememberSaveable { mutableStateOf(false) }
|
||||||
|
val showInterval = rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
|
if (openDialog.value) {
|
||||||
|
ShowLiveWallpaperEnabledDialog(
|
||||||
|
onDismissRequest = { openDialog.value = false }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
snackbarHost = {
|
snackbarHost = {
|
||||||
@@ -61,12 +86,13 @@ fun WallpaperScreen(
|
|||||||
snackbar = { data ->
|
snackbar = { data ->
|
||||||
Snackbar(
|
Snackbar(
|
||||||
snackbarData = data,
|
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(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
content = { it
|
content = { padding ->
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@@ -75,141 +101,210 @@ fun WallpaperScreen(
|
|||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
CurrentSelectedAlbum(
|
CurrentSelectedAlbum(
|
||||||
selectedAlbum = selectedState.value.selectedAlbum,
|
selectedAlbum = selectedAlbum,
|
||||||
onOpenBottomSheet = {
|
onOpenBottomSheet = {
|
||||||
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) openBottomSheet = true
|
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) {
|
||||||
},
|
if (isLiveWallpaperSet(context)) {
|
||||||
onStop = {
|
openDialog.value = true
|
||||||
if (selectedState.value.selectedAlbum != null) {
|
}
|
||||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
else { openBottomSheet = true }
|
||||||
|
}
|
||||||
|
else {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
snackbarHostState.currentSnackbarData?.dismiss()
|
snackbarHostState.currentSnackbarData?.dismiss()
|
||||||
snackbarHostState.showSnackbar(
|
snackbarHostState.showSnackbar(
|
||||||
message = "${selectedState.value.selectedAlbum?.album?.displayedAlbumName} has been unselected.",
|
message = context.getString(R.string.no_albums_found),
|
||||||
actionLabel = "Dismiss",
|
actionLabel = context.getString(R.string.dismiss),
|
||||||
|
duration = SnackbarDuration.Short
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onStop = {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
scope.launch {
|
||||||
|
snackbarHostState.currentSnackbarData?.dismiss()
|
||||||
|
snackbarHostState.showSnackbar(
|
||||||
|
message = context.getString(R.string.has_been_unselected, selectedAlbum.album.displayedAlbumName),
|
||||||
|
actionLabel = context.getString(R.string.dismiss),
|
||||||
duration = SnackbarDuration.Short
|
duration = SnackbarDuration.Short
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
onStop()
|
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(
|
AnimatedVisibility(
|
||||||
visible = selectedState.value.selectedAlbum != null,
|
visible = selectedAlbum != null,
|
||||||
enter = slideInVertically(initialOffsetY = { -it }),
|
enter = slideInVertically(initialOffsetY = { -it }),
|
||||||
exit = fadeOut()
|
exit = fadeOut()
|
||||||
) {
|
) {
|
||||||
if (selectedState.value.selectedAlbum != null) {
|
if (selectedAlbum != null) {
|
||||||
CurrentAndNextChange(
|
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||||
settingsState.value.lastSetTime,
|
|
||||||
settingsState.value.nextSetTime
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
if (animate) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = selectedState.value.selectedAlbum != null,
|
visible = selectedAlbum != null,
|
||||||
enter = slideInVertically(initialOffsetY = { -it }),
|
enter = slideInVertically(initialOffsetY = { -it }),
|
||||||
exit = fadeOut()
|
exit = fadeOut()
|
||||||
) {
|
) {
|
||||||
if (selectedState.value.selectedAlbum != null) {
|
if (selectedAlbum != null) {
|
||||||
SetLockScreenSwitch(
|
SetLockScreenSwitch(
|
||||||
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
|
albumUri = selectedAlbum.album.currentWallpaper,
|
||||||
checked = settingsState.value.setLockWithHome,
|
checked = setLockWithHome,
|
||||||
onCheckedChange = { isChecked ->
|
onCheckedChange = { onSetLockWithHome(it) },
|
||||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
|
animate = true,
|
||||||
}
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
SetLockScreenSwitch(
|
||||||
|
albumUri = selectedAlbum.album.currentWallpaper,
|
||||||
|
checked = setLockWithHome,
|
||||||
|
onCheckedChange = { onSetLockWithHome(it) },
|
||||||
|
animate = false,
|
||||||
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
if (animate) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = selectedState.value.selectedAlbum != null,
|
visible = selectedAlbum != null,
|
||||||
|
enter = slideInVertically(initialOffsetY = { -it }),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
WallpaperScalingRow(
|
||||||
|
scaling = scaling,
|
||||||
|
onScalingChange = onScalingChange
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
WallpaperScalingRow(
|
||||||
|
scaling = scaling,
|
||||||
|
onScalingChange = onScalingChange
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
if (animate) {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = selectedAlbum != null,
|
||||||
enter = slideInVertically(initialOffsetY = { -it }),
|
enter = slideInVertically(initialOffsetY = { -it }),
|
||||||
exit = fadeOut()
|
exit = fadeOut()
|
||||||
) {
|
) {
|
||||||
TimeSliders(
|
TimeSliders(
|
||||||
timeInMinutes = settingsState.value.interval,
|
timeInMinutes = interval,
|
||||||
onTimeChange = { days, hours, minutes ->
|
onTimeChange = { days, hours, minutes ->
|
||||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||||
settingsViewModel.onEvent(
|
|
||||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
|
||||||
)
|
|
||||||
onScheduleWallpaperChanger(totalMinutes)
|
onScheduleWallpaperChanger(totalMinutes)
|
||||||
}
|
},
|
||||||
|
showInterval = showInterval.value,
|
||||||
|
animate = true,
|
||||||
|
onShowIntervalChange = { showInterval.value = it }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
item {
|
if (selectedAlbum != null) {
|
||||||
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))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
TimeSliders(
|
TimeSliders(
|
||||||
timeInMinutes = settingsState.value.interval,
|
timeInMinutes = interval,
|
||||||
onTimeChange = { days, hours, minutes ->
|
onTimeChange = { days, hours, minutes ->
|
||||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||||
settingsViewModel.onEvent(
|
|
||||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
|
||||||
)
|
|
||||||
onScheduleWallpaperChanger(totalMinutes)
|
onScheduleWallpaperChanger(totalMinutes)
|
||||||
}
|
},
|
||||||
|
showInterval = showInterval.value,
|
||||||
|
animate = false,
|
||||||
|
onShowIntervalChange = { showInterval.value = it }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
item {
|
||||||
|
if (animate) {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = selectedAlbum != null,
|
||||||
|
enter = slideInVertically(initialOffsetY = { -it }),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
DarkenSwitchAndSlider(
|
||||||
|
onDarkCheck = onDarkCheck,
|
||||||
|
darken = darken,
|
||||||
|
onDarkenChange = onDarkenPercentage,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
animate = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
DarkenSwitchAndSlider(
|
||||||
|
onDarkCheck = onDarkCheck,
|
||||||
|
darken = darken,
|
||||||
|
onDarkenChange = onDarkenPercentage,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
animate = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (openBottomSheet) {
|
if (openBottomSheet) {
|
||||||
AlbumBottomSheet(
|
AlbumBottomSheet(
|
||||||
albums = albumState.value.albumsWithWallpapers,
|
albums = albumState.value.albumsWithWallpapers,
|
||||||
currentSelectedAlbum = selectedState.value.selectedAlbum,
|
currentSelectedAlbum = selectedAlbum,
|
||||||
onDismiss = { openBottomSheet = false },
|
onDismiss = { openBottomSheet = false },
|
||||||
onSelect = { album ->
|
onSelect = { album ->
|
||||||
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.flatMap { folder ->
|
|
||||||
folder.wallpapers.map { wallpaper ->
|
|
||||||
Wallpaper(
|
|
||||||
initialAlbumName = album.album.initialAlbumName,
|
|
||||||
wallpaperUri = wallpaper,
|
|
||||||
key = wallpaper.hashCode() + album.album.initialAlbumName.hashCode(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val newSelectedAlbum = SelectedAlbum(
|
|
||||||
album = album.album.copy(
|
|
||||||
wallpapersInQueue = wallpapers.map { it.wallpaperUri }.shuffled()
|
|
||||||
),
|
|
||||||
wallpapers = wallpapers
|
|
||||||
)
|
|
||||||
openBottomSheet = false
|
openBottomSheet = false
|
||||||
scope.launch {
|
onSelectAlbum(album)
|
||||||
snackbarHostState.currentSnackbarData?.dismiss()
|
onScheduleWallpaperChanger(interval)
|
||||||
snackbarHostState.showSnackbar(
|
},
|
||||||
message = "${album.album.displayedAlbumName} has been selected.",
|
animate = animate
|
||||||
actionLabel = "Dismiss",
|
|
||||||
duration = SnackbarDuration.Short
|
|
||||||
)
|
|
||||||
}
|
|
||||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
|
||||||
onScheduleWallpaperChanger(settingsState.value.interval)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isLiveWallpaperSet(context: Context): Boolean {
|
||||||
|
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||||
|
return wallpaperManager.wallpaperInfo != null
|
||||||
|
}
|
||||||
+48
-18
@@ -1,10 +1,6 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||||
|
|
||||||
import android.app.Application
|
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.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
@@ -14,11 +10,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
@@ -33,32 +27,68 @@ class WallpaperScreenViewModel @Inject constructor (
|
|||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
refreshAlbums()
|
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||||
|
isDataLoaded = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEvent(event: WallpaperEvent) {
|
fun onEvent(event: WallpaperEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is WallpaperEvent.UpdateSelectedAlbum -> {
|
is WallpaperEvent.UpdateSelectedAlbum -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
withContext(Dispatchers.IO) {
|
if (event.selectedAlbum != null) {
|
||||||
repository.deleteAll()
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
selectedAlbum = event.selectedAlbum
|
||||||
|
)
|
||||||
|
}
|
||||||
repository.upsertSelectedAlbum(event.selectedAlbum)
|
repository.upsertSelectedAlbum(event.selectedAlbum)
|
||||||
}
|
}
|
||||||
|
else if (event.album != null) {
|
||||||
|
val wallpapers: List<Wallpaper> = event.album.wallpapers + event.album.folders.asSequence().flatMap { folder ->
|
||||||
|
folder.wallpapers.asSequence().map { wallpaper ->
|
||||||
|
Wallpaper(
|
||||||
|
initialAlbumName = event.album.album.initialAlbumName,
|
||||||
|
wallpaperUri = wallpaper,
|
||||||
|
key = wallpaper.hashCode() + event.album.album.initialAlbumName.hashCode(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}.toList()
|
||||||
|
val shuffledWallpapers = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||||
|
val newSelectedAlbum = SelectedAlbum(
|
||||||
|
album = event.album.album.copy(
|
||||||
|
wallpapersInQueue = shuffledWallpapers,
|
||||||
|
currentWallpaper = shuffledWallpapers.firstOrNull()
|
||||||
|
),
|
||||||
|
wallpapers = wallpapers
|
||||||
|
)
|
||||||
|
_state.update {
|
||||||
|
it.copy(
|
||||||
|
selectedAlbum = newSelectedAlbum
|
||||||
|
)
|
||||||
|
}
|
||||||
|
repository.upsertSelectedAlbum(newSelectedAlbum)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is WallpaperEvent.Refresh -> {
|
is WallpaperEvent.Refresh -> {
|
||||||
refreshAlbums()
|
refreshAlbums()
|
||||||
}
|
}
|
||||||
is WallpaperEvent.Reset -> {
|
is WallpaperEvent.Reset -> {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
withContext(Dispatchers.IO) {
|
|
||||||
repository.deleteAll()
|
|
||||||
_state.update {
|
_state.update {
|
||||||
it.copy(selectedAlbum = null)
|
it.copy(
|
||||||
}
|
selectedAlbum = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
repository.deleteAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,10 +96,10 @@ class WallpaperScreenViewModel @Inject constructor (
|
|||||||
|
|
||||||
// Retrieve album from database into viewModel
|
// Retrieve album from database into viewModel
|
||||||
private fun refreshAlbums() {
|
private fun refreshAlbums() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
repository.getSelectedAlbum().collect { selectedAlbum ->
|
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||||
_state.update { it.copy(
|
_state.update { it.copy(
|
||||||
selectedAlbum = selectedAlbum.firstOrNull()
|
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||||
) }
|
) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -3,5 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
|||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
|
|
||||||
data class WallpaperState (
|
data class WallpaperState (
|
||||||
|
val isDataLoaded: Boolean = false,
|
||||||
val selectedAlbum: SelectedAlbum? = null
|
val selectedAlbum: SelectedAlbum? = null
|
||||||
)
|
)
|
||||||
+31
-15
@@ -1,8 +1,8 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
@@ -29,11 +29,10 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.net.toUri
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -47,17 +46,31 @@ fun AlbumBottomSheet(
|
|||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
currentSelectedAlbum: SelectedAlbum?,
|
currentSelectedAlbum: SelectedAlbum?,
|
||||||
albums: List<AlbumWithWallpaperAndFolder>,
|
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 modalBottomSheetState = rememberModalBottomSheetState()
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = { onDismiss() },
|
onDismissRequest = { onDismiss() },
|
||||||
sheetState = modalBottomSheetState,
|
sheetState = modalBottomSheetState,
|
||||||
dragHandle = { BottomSheetDefaults.DragHandle() },
|
dragHandle = { BottomSheetDefaults.DragHandle() },
|
||||||
windowInsets = WindowInsets(0.dp)
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
|
tonalElevation = 5.dp
|
||||||
) {
|
) {
|
||||||
albums.forEach {
|
albums.forEach {
|
||||||
|
if (it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size == 0) return@forEach
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
@@ -74,8 +87,9 @@ fun AlbumBottomSheet(
|
|||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
) },
|
) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
|
val totalWallpapers = it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size
|
||||||
Text(
|
Text(
|
||||||
text = (it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size).toString() + stringResource(R.string.wallpaper),
|
text = LocalContext.current.resources.getQuantityString(R.plurals.wallpaper_count, totalWallpapers, totalWallpapers),
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -84,22 +98,23 @@ fun AlbumBottomSheet(
|
|||||||
Box (
|
Box (
|
||||||
modifier = Modifier.size(60.dp)
|
modifier = Modifier.size(60.dp)
|
||||||
) {
|
) {
|
||||||
|
val showCoverUri = isValidUri(LocalContext.current, it.album.coverUri)
|
||||||
|
if (showCoverUri) {
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { it.album.coverUri },
|
imageModel = { it.album.coverUri },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.FillBounds,
|
contentScale = ContentScale.Crop,
|
||||||
alignment = Alignment.Center,
|
alignment = Alignment.Center,
|
||||||
),
|
),
|
||||||
requestBuilder = {
|
|
||||||
Glide
|
|
||||||
.with(LocalContext.current)
|
|
||||||
.asBitmap()
|
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
|
||||||
},
|
|
||||||
loading = {
|
loading = {
|
||||||
|
if (animate) {
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
CircularProgressIndicator(modifier = Modifier.align(
|
CircularProgressIndicator(
|
||||||
Alignment.Center))
|
modifier = Modifier.align(
|
||||||
|
Alignment.Center
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -107,6 +122,7 @@ fun AlbumBottomSheet(
|
|||||||
.clip(RoundedCornerShape(16.dp))
|
.clip(RoundedCornerShape(16.dp))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
if (currentSelectedAlbum != null) {
|
if (currentSelectedAlbum != null) {
|
||||||
|
|||||||
+12
-8
@@ -10,7 +10,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.QueuePlayNext
|
import androidx.compose.material.icons.outlined.QueuePlayNext
|
||||||
import androidx.compose.material.icons.outlined.RemoveFromQueue
|
import androidx.compose.material.icons.outlined.RemoveFromQueue
|
||||||
import androidx.compose.material3.Card
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -25,6 +24,9 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the current and next change components that shows the last and next set time
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun CurrentAndNextChange(
|
fun CurrentAndNextChange(
|
||||||
lastSetTime: String?,
|
lastSetTime: String?,
|
||||||
@@ -38,10 +40,10 @@ fun CurrentAndNextChange(
|
|||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
tonalElevation = 10.dp,
|
tonalElevation = 10.dp,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.padding(PaddingValues(16.dp, 8.dp, 8.dp, 8.dp))
|
.padding(PaddingValues(16.dp, 8.dp, 8.dp, 8.dp))
|
||||||
.clip(RoundedCornerShape(16.dp))
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
@@ -56,10 +58,11 @@ fun CurrentAndNextChange(
|
|||||||
)
|
)
|
||||||
Column {
|
Column {
|
||||||
lastSetTime?.split(" ", "\n")?.let { parts ->
|
lastSetTime?.split(" ", "\n")?.let { parts ->
|
||||||
if (parts.size == 3) {
|
if (parts.size == 2) {
|
||||||
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
Text(stringResource(R.string.last_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
Text(parts[0], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
Text("${parts[1]} ${parts[2]}", style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally)) }
|
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,10 +88,11 @@ fun CurrentAndNextChange(
|
|||||||
)
|
)
|
||||||
Column {
|
Column {
|
||||||
nextSetTime?.split(" ", "\n")?.let { parts ->
|
nextSetTime?.split(" ", "\n")?.let { parts ->
|
||||||
if (parts.size == 3) {
|
if (parts.size == 2) {
|
||||||
Text(stringResource(R.string.next_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
Text(stringResource(R.string.next_change), style = textFirst, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
Text(parts[0], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
Text("${parts[1]} ${parts[2]}", style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally)) }
|
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-18
@@ -1,8 +1,11 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -18,20 +21,22 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.ListItem
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
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.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.net.toUri
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
|
|
||||||
@@ -41,14 +46,36 @@ import com.skydoves.landscapist.glide.GlideImage
|
|||||||
@Composable
|
@Composable
|
||||||
fun CurrentSelectedAlbum(
|
fun CurrentSelectedAlbum(
|
||||||
selectedAlbum: SelectedAlbum?,
|
selectedAlbum: SelectedAlbum?,
|
||||||
|
enableChanger: Boolean,
|
||||||
onOpenBottomSheet: () -> Unit,
|
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(
|
ListItem(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(16.dp)
|
.padding(PaddingValues(vertical = 8.dp, horizontal = 16.dp))
|
||||||
.clip(RoundedCornerShape(16.dp))
|
.clip(RoundedCornerShape(16.dp))
|
||||||
.clickable { onOpenBottomSheet() },
|
.clickable {
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
onToggleChanger(!enableChanger)
|
||||||
|
} else {
|
||||||
|
onOpenBottomSheet()
|
||||||
|
}
|
||||||
|
},
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
|
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
|
||||||
@@ -59,37 +86,34 @@ fun CurrentSelectedAlbum(
|
|||||||
supportingContent = {
|
supportingContent = {
|
||||||
if (selectedAlbum != null) {
|
if (selectedAlbum != null) {
|
||||||
Text(
|
Text(
|
||||||
text = "${selectedAlbum.wallpapers.size} ${stringResource(R.string.wallpaper)}",
|
text = LocalContext.current.resources.getQuantityString(R.plurals.wallpaper_count, selectedAlbum.wallpapers.size, selectedAlbum.wallpapers.size),
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
} },
|
} },
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Box (
|
Box (modifier = Modifier.size(60.dp)) {
|
||||||
modifier = Modifier.size(60.dp)
|
|
||||||
) {
|
|
||||||
if (selectedAlbum != null) {
|
if (selectedAlbum != null) {
|
||||||
|
if (showCoverUri) {
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { selectedAlbum.album.coverUri },
|
imageModel = { selectedAlbum.album.coverUri },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.FillBounds,
|
contentScale = ContentScale.Crop,
|
||||||
alignment = Alignment.Center,
|
alignment = Alignment.Center,
|
||||||
),
|
),
|
||||||
requestBuilder = {
|
|
||||||
Glide
|
|
||||||
.with(LocalContext.current)
|
|
||||||
.asBitmap()
|
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
|
||||||
},
|
|
||||||
loading = {
|
loading = {
|
||||||
|
if (animate) {
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
CircularProgressIndicator(modifier = Modifier.align(
|
||||||
|
Alignment.Center))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
.clip(RoundedCornerShape(16.dp))
|
.clip(RoundedCornerShape(16.dp))
|
||||||
)
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Image(
|
Image(
|
||||||
imageVector = Icons.Default.RadioButtonUnchecked,
|
imageVector = Icons.Default.RadioButtonUnchecked,
|
||||||
@@ -100,7 +124,10 @@ fun CurrentSelectedAlbum(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
Row {
|
Row (
|
||||||
|
horizontalArrangement = Arrangement.spacedBy((-8).dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
if (selectedAlbum != null) {
|
if (selectedAlbum != null) {
|
||||||
IconButton(onClick = { onStop() }) {
|
IconButton(onClick = { onStop() }) {
|
||||||
Icon(imageVector = Icons.Default.Stop, contentDescription = stringResource(R.string.stop_the_album))
|
Icon(imageVector = Icons.Default.Stop, contentDescription = stringResource(R.string.stop_the_album))
|
||||||
@@ -112,6 +139,15 @@ fun CurrentSelectedAlbum(
|
|||||||
imageVector = Icons.Filled.ArrowDropDown,
|
imageVector = Icons.Filled.ArrowDropDown,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (selectedAlbum != null) {
|
||||||
|
Switch(
|
||||||
|
checked = enableChanger,
|
||||||
|
onCheckedChange = onToggleChanger,
|
||||||
|
modifier = Modifier
|
||||||
|
.rotate(270f)
|
||||||
|
.scale(0.75f)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tonalElevation = 10.dp
|
tonalElevation = 10.dp
|
||||||
|
|||||||
+154
@@ -0,0 +1,154 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
import android.view.HapticFeedbackConstants
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.animateContentSize
|
||||||
|
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.fadeOut
|
||||||
|
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.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Slider
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
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 com.anthonyla.paperize.R
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composable that displays a switch and slider to adjust the brightness of the wallpaper
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun DarkenSwitchAndSlider(
|
||||||
|
onDarkCheck: (Boolean) -> Unit,
|
||||||
|
onDarkenChange: (Int) -> Unit,
|
||||||
|
darken: Boolean,
|
||||||
|
darkenPercentage: Int,
|
||||||
|
animate: Boolean
|
||||||
|
) {
|
||||||
|
val view = LocalView.current
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
var job by remember { mutableStateOf<Job?>(null) }
|
||||||
|
var percentage by rememberSaveable { mutableFloatStateOf(darkenPercentage.toFloat()) }
|
||||||
|
|
||||||
|
Surface(
|
||||||
|
tonalElevation = 10.dp,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||||
|
) {
|
||||||
|
val columnModifier = if (animate) {
|
||||||
|
Modifier.animateContentSize(
|
||||||
|
animationSpec = tween(durationMillis = 300, easing = LinearOutSlowInEasing)
|
||||||
|
)
|
||||||
|
} else { Modifier }
|
||||||
|
Column (
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
modifier = columnModifier
|
||||||
|
) {
|
||||||
|
Row (horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.adjust_brightness),
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
fontWeight = FontWeight.W500
|
||||||
|
)
|
||||||
|
Switch(
|
||||||
|
checked = darken,
|
||||||
|
onCheckedChange = onDarkCheck
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (animate) {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = darken,
|
||||||
|
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||||
|
exit = fadeOut(
|
||||||
|
animationSpec = tween(
|
||||||
|
durationMillis = 300,
|
||||||
|
easing = LinearOutSlowInEasing
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.brightness_percentage, percentage.roundToInt()),
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||||
|
fontWeight = FontWeight.W400
|
||||||
|
)
|
||||||
|
Slider(
|
||||||
|
value = percentage,
|
||||||
|
onValueChange = {
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
|
percentage = it
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(500)
|
||||||
|
onDarkenChange(it.roundToInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..100f,
|
||||||
|
steps = 100,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (darken) {
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.brightness_percentage, percentage.roundToInt()),
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp)),
|
||||||
|
fontWeight = FontWeight.W500
|
||||||
|
)
|
||||||
|
Slider(
|
||||||
|
value = percentage,
|
||||||
|
onValueChange = {
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
|
percentage = it
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(500)
|
||||||
|
onDarkenChange(it.roundToInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..100f,
|
||||||
|
steps = 100,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ErrorOutline
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog to show when a live wallpaper is detected and ask the user to disable it
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun ShowLiveWallpaperEnabledDialog(
|
||||||
|
onDismissRequest: () -> Unit
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { onDismissRequest() },
|
||||||
|
icon = { Icon(Icons.Filled.ErrorOutline, stringResource(R.string.disable_live_wallpaper)) },
|
||||||
|
title = {
|
||||||
|
Text(stringResource(R.string.live_wallpaper_detected))
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.please_disable_your_live_wallpaper_to_use_the_wallpaper_changer))
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = { onDismissRequest() }
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.ok))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
-105
@@ -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))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+231
@@ -0,0 +1,231 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.animateContentSize
|
||||||
|
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.fadeOut
|
||||||
|
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.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
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.runtime.remember
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SetLockScreenSwitch is a composable that displays a switch to set the wallpaper as the lock screen wallpaper
|
||||||
|
* Also shows a preview of lock and home screen when enabled along with brightness added
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun SetLockScreenSwitch(
|
||||||
|
albumUri : String?,
|
||||||
|
checked: Boolean,
|
||||||
|
onCheckedChange: (Boolean) -> Unit,
|
||||||
|
animate: Boolean,
|
||||||
|
darken: Boolean,
|
||||||
|
darkenPercentage: Int,
|
||||||
|
scaling: ScalingConstants?
|
||||||
|
) {
|
||||||
|
Surface(
|
||||||
|
tonalElevation = 10.dp,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||||
|
) {
|
||||||
|
val columnModifier = remember {
|
||||||
|
if (animate) {
|
||||||
|
Modifier.animateContentSize(
|
||||||
|
animationSpec = tween(durationMillis = 300, easing = LinearOutSlowInEasing)
|
||||||
|
)
|
||||||
|
} else { Modifier }
|
||||||
|
}
|
||||||
|
Column (
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
modifier = columnModifier
|
||||||
|
) {
|
||||||
|
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 = fadeOut(
|
||||||
|
animationSpec = tween(
|
||||||
|
durationMillis = 300,
|
||||||
|
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,
|
||||||
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.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)
|
||||||
|
),
|
||||||
|
aspectRatio = 9f / 19.5f,
|
||||||
|
clickable = false,
|
||||||
|
animate = true,
|
||||||
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.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)
|
||||||
|
),
|
||||||
|
aspectRatio = 9f / 19.5f,
|
||||||
|
clickable = false,
|
||||||
|
animate = false,
|
||||||
|
darken = darken,
|
||||||
|
darkenPercentage = darkenPercentage,
|
||||||
|
scaling = scaling
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+157
-31
@@ -1,10 +1,28 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.animateContentSize
|
||||||
|
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.fadeOut
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ArrowDropDown
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.Slider
|
import androidx.compose.material3.Slider
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -16,70 +34,111 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import com.anthonyla.paperize.R
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TimeSliders is a composable that displays sliders for the user to select the time interval for changing wallpaper
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun TimeSliders(
|
fun TimeSliders(
|
||||||
onTimeChange: (Int, Int, Int) -> Unit,
|
onTimeChange: (Int, Int, Int) -> Unit,
|
||||||
timeInMinutes: Int
|
timeInMinutes: Int,
|
||||||
|
showInterval: Boolean,
|
||||||
|
animate: Boolean,
|
||||||
|
onShowIntervalChange: (Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
var days by rememberSaveable { mutableFloatStateOf((timeInMinutes / (24 * 60)).toFloat()) }
|
var days by rememberSaveable { mutableFloatStateOf((timeInMinutes / (24 * 60)).toFloat()) }
|
||||||
var hours by rememberSaveable { mutableFloatStateOf(((timeInMinutes % (24 * 60)) / 60).toFloat()) }
|
var hours by rememberSaveable { mutableFloatStateOf(((timeInMinutes % (24 * 60)) / 60).toFloat()) }
|
||||||
var minutes by rememberSaveable { mutableFloatStateOf((timeInMinutes % 60).toFloat()) }
|
var minutes by rememberSaveable { mutableFloatStateOf((timeInMinutes % 60).toFloat()) }
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
val context = LocalView.current
|
||||||
var job by remember { mutableStateOf<Job?>(null) }
|
var job by remember { mutableStateOf<Job?>(null) }
|
||||||
|
|
||||||
|
val columnModifier = remember {
|
||||||
|
if (animate) {
|
||||||
|
Modifier.animateContentSize(
|
||||||
|
animationSpec = tween(durationMillis = 300, easing = LinearOutSlowInEasing)
|
||||||
|
)
|
||||||
|
} else { Modifier }
|
||||||
|
}
|
||||||
|
|
||||||
Surface(
|
Surface(
|
||||||
tonalElevation = 10.dp,
|
tonalElevation = 10.dp,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(16.dp)
|
.fillMaxWidth()
|
||||||
.clip(RoundedCornerShape(16.dp))
|
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||||
|
) {
|
||||||
|
Column (
|
||||||
|
modifier = columnModifier
|
||||||
) {
|
) {
|
||||||
Column {
|
|
||||||
val totalMinutes = (days.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
val totalMinutes = (days.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
||||||
val displayDays = totalMinutes / (24 * 60)
|
val displayDays = totalMinutes / (24 * 60)
|
||||||
val displayHours = (totalMinutes % (24 * 60)) / 60
|
val displayHours = (totalMinutes % (24 * 60)) / 60
|
||||||
val displayMinutes = totalMinutes % 60
|
val displayMinutes = totalMinutes % 60
|
||||||
val formattedDays = when {
|
val formattedDays = if (displayDays > 0) {
|
||||||
displayDays > 1 -> "$displayDays days"
|
context.resources.getQuantityString(R.plurals.days, displayDays, displayDays)
|
||||||
displayDays == 1 -> "$displayDays day"
|
} else {""}
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
val formattedHours = when {
|
|
||||||
displayHours > 1 -> "$displayHours hours"
|
|
||||||
displayHours == 1 -> "$displayHours hour"
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
val formattedMinutes = when {
|
|
||||||
displayMinutes > 1 -> "$displayMinutes minutes"
|
|
||||||
displayMinutes == 1 -> "$displayMinutes minute"
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
val formattedTime = "Interval | ${listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")}"
|
|
||||||
|
|
||||||
Text(
|
val formattedHours = if (displayHours > 0) {
|
||||||
text = formattedTime,
|
context.resources.getQuantityString(R.plurals.hours, displayHours, displayHours)
|
||||||
modifier = Modifier.padding(PaddingValues(horizontal = 24.dp, vertical = 12.dp)),
|
} else {""}
|
||||||
fontWeight = FontWeight.W500
|
|
||||||
|
val formattedMinutes = if (displayMinutes > 0) {
|
||||||
|
context.resources.getQuantityString(R.plurals.minutes, displayMinutes, displayMinutes)
|
||||||
|
} else {""}
|
||||||
|
|
||||||
|
val formattedTime = stringResource(
|
||||||
|
R.string.interval,
|
||||||
|
listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Row (
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Spacer(modifier = Modifier.width(32.dp))
|
||||||
|
Text(
|
||||||
|
text = formattedTime,
|
||||||
|
fontWeight = FontWeight.W500,
|
||||||
|
)
|
||||||
|
IconButton(
|
||||||
|
onClick = { onShowIntervalChange(!showInterval) },
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Filled.ArrowDropDown, contentDescription = "Show interval sliders")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animate) {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = showInterval,
|
||||||
|
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||||
|
exit = fadeOut(
|
||||||
|
animationSpec = tween(
|
||||||
|
durationMillis = 300,
|
||||||
|
easing = LinearOutSlowInEasing
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
Slider(
|
Slider(
|
||||||
value = days,
|
value = days,
|
||||||
onValueChange = { newDays ->
|
onValueChange = { newDays ->
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
days = newDays
|
days = newDays
|
||||||
val totalMinutes = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
val totalMinute = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
||||||
if (totalMinutes < 15) {
|
if (totalMinute < 15) {
|
||||||
minutes = 15f - (hours.toInt() * 60)
|
minutes = 15f - (hours.toInt() * 60)
|
||||||
}
|
}
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
@@ -98,8 +157,73 @@ fun TimeSliders(
|
|||||||
onValueChange = { newHours ->
|
onValueChange = { newHours ->
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
hours = newHours
|
hours = newHours
|
||||||
val totalMinutes = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
|
val totalMinute = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
|
||||||
if (totalMinutes < 15) {
|
if (totalMinute < 15) {
|
||||||
|
minutes = 15f - (newHours.toInt() * 60)
|
||||||
|
}
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(500)
|
||||||
|
onTimeChange(days.toInt(), newHours.toInt(), minutes.toInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..24f,
|
||||||
|
steps = 24,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||||
|
)
|
||||||
|
|
||||||
|
Slider(
|
||||||
|
value = minutes,
|
||||||
|
onValueChange = { newMinutes ->
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
|
minutes = if (days.toInt() == 0 && hours.toInt() == 0 && newMinutes < 15) {
|
||||||
|
15f
|
||||||
|
} else {
|
||||||
|
newMinutes
|
||||||
|
}
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(500)
|
||||||
|
onTimeChange(days.toInt(), hours.toInt(), minutes.toInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..60f,
|
||||||
|
steps = 60,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (showInterval) {
|
||||||
|
Slider(
|
||||||
|
value = days,
|
||||||
|
onValueChange = { newDays ->
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
|
days = newDays
|
||||||
|
val totalMinute = (newDays.toInt() * 24 * 60) + (hours.toInt() * 60) + minutes.toInt()
|
||||||
|
if (totalMinute < 15) {
|
||||||
|
minutes = 15f - (hours.toInt() * 60)
|
||||||
|
}
|
||||||
|
job?.cancel()
|
||||||
|
job = scope.launch {
|
||||||
|
delay(500)
|
||||||
|
onTimeChange(newDays.toInt(), hours.toInt(), minutes.toInt())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..30f,
|
||||||
|
steps = 30,
|
||||||
|
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||||
|
)
|
||||||
|
|
||||||
|
Slider(
|
||||||
|
value = hours,
|
||||||
|
onValueChange = { newHours ->
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||||
|
hours = newHours
|
||||||
|
val totalMinute = (days.toInt() * 24 * 60) + (newHours.toInt() * 60) + minutes.toInt()
|
||||||
|
if (totalMinute < 15) {
|
||||||
minutes = 15f - (newHours.toInt() * 60)
|
minutes = 15f - (newHours.toInt() * 60)
|
||||||
}
|
}
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
@@ -134,5 +258,7 @@ fun TimeSliders(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||||
|
|
||||||
|
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.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.SegmentedButton
|
||||||
|
import androidx.compose.material3.SegmentedButtonDefaults
|
||||||
|
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
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.core.ScalingConstants
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Row for selecting the scaling of the wallpaper
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun WallpaperScalingRow(
|
||||||
|
scaling: ScalingConstants,
|
||||||
|
onScalingChange: (ScalingConstants) -> Unit
|
||||||
|
) {
|
||||||
|
var selectedIndex by rememberSaveable {
|
||||||
|
mutableIntStateOf(
|
||||||
|
when (scaling) {
|
||||||
|
ScalingConstants.FILL -> 0
|
||||||
|
ScalingConstants.FIT -> 1
|
||||||
|
ScalingConstants.STRETCH -> 2
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val options = listOf(
|
||||||
|
stringResource(R.string.fill),
|
||||||
|
stringResource(R.string.fit),
|
||||||
|
stringResource(R.string.stretch)
|
||||||
|
)
|
||||||
|
|
||||||
|
Surface(
|
||||||
|
tonalElevation = 10.dp,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(PaddingValues(horizontal = 16.dp, vertical = 8.dp))
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
Row (
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(PaddingValues(top = 16.dp, bottom = 4.dp)),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.wallpaper_scaling),
|
||||||
|
fontWeight = FontWeight.W500
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SingleChoiceSegmentedButtonRow (
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(PaddingValues(start = 16.dp, end = 16.dp, top = 4.dp, bottom = 16.dp))
|
||||||
|
) {
|
||||||
|
options.forEachIndexed { index, label ->
|
||||||
|
SegmentedButton(
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(index = index, count = options.size),
|
||||||
|
onClick = {
|
||||||
|
selectedIndex = index
|
||||||
|
onScalingChange(
|
||||||
|
when (index) {
|
||||||
|
0 -> ScalingConstants.FILL
|
||||||
|
1 -> ScalingConstants.FIT
|
||||||
|
2 -> ScalingConstants.STRETCH
|
||||||
|
else -> ScalingConstants.FILL
|
||||||
|
}
|
||||||
|
) },
|
||||||
|
selected = index == selectedIndex
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = when (index) {
|
||||||
|
0 -> painterResource(id = R.drawable.fill)
|
||||||
|
1 -> painterResource(id = R.drawable.fit)
|
||||||
|
2 -> painterResource(id = R.drawable.stretch)
|
||||||
|
else -> painterResource(id = R.drawable.fill)
|
||||||
|
},
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color.Unspecified,
|
||||||
|
modifier = Modifier.size(36.dp)
|
||||||
|
)
|
||||||
|
Text(text = label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
-9
@@ -1,5 +1,6 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen
|
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_view_screen
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -28,8 +29,6 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.anthonyla.paperize.R
|
import com.anthonyla.paperize.R
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
|
||||||
import com.skydoves.landscapist.ImageOptions
|
import com.skydoves.landscapist.ImageOptions
|
||||||
import com.skydoves.landscapist.glide.GlideImage
|
import com.skydoves.landscapist.glide.GlideImage
|
||||||
import net.engawapg.lib.zoomable.rememberZoomState
|
import net.engawapg.lib.zoomable.rememberZoomState
|
||||||
@@ -43,7 +42,20 @@ import net.engawapg.lib.zoomable.zoomable
|
|||||||
fun WallpaperViewScreen(
|
fun WallpaperViewScreen(
|
||||||
wallpaperUri: String,
|
wallpaperUri: String,
|
||||||
onBackClick: () -> Unit,
|
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()
|
val zoomState = rememberZoomState()
|
||||||
BackHandler { onBackClick() }
|
BackHandler { onBackClick() }
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@@ -62,6 +74,7 @@ fun WallpaperViewScreen(
|
|||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
contentDescription = stringResource(id = R.string.home_screen),
|
contentDescription = stringResource(id = R.string.home_screen),
|
||||||
|
tint = Color.White
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -85,26 +98,24 @@ fun WallpaperViewScreen(
|
|||||||
.padding(padding)
|
.padding(padding)
|
||||||
.zoomable(zoomState)
|
.zoomable(zoomState)
|
||||||
) {
|
) {
|
||||||
|
if (showUri) {
|
||||||
GlideImage(
|
GlideImage(
|
||||||
imageModel = { wallpaperUri.toUri() },
|
imageModel = { wallpaperUri.toUri() },
|
||||||
imageOptions = ImageOptions(
|
imageOptions = ImageOptions(
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Fit,
|
||||||
alignment = Alignment.Center
|
alignment = Alignment.Center
|
||||||
),
|
),
|
||||||
requestBuilder = {
|
|
||||||
Glide
|
|
||||||
.with(LocalContext.current)
|
|
||||||
.asBitmap()
|
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
|
||||||
},
|
|
||||||
loading = {
|
loading = {
|
||||||
|
if (animate) {
|
||||||
Box(modifier = Modifier.matchParentSize()) {
|
Box(modifier = Modifier.matchParentSize()) {
|
||||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+44
-53
@@ -1,77 +1,68 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.util.navigation
|
package com.anthonyla.paperize.feature.wallpaper.util.navigation
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import kotlinx.serialization.Serializable
|
||||||
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
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
@Serializable
|
||||||
/**
|
object Startup
|
||||||
* Home screen that the user lands on initially
|
|
||||||
*/
|
|
||||||
object Startup : NavScreens("startup_screen", R.string.startup, Icons.Outlined.Start, Icons.Filled.Start)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification screen for the application to ask for permission
|
* Object for Notification screen
|
||||||
*/
|
*/
|
||||||
object Notification : NavScreens("notification_screen", R.string.notifications, Icons.Outlined.Notifications, Icons.Filled.Notifications)
|
@Serializable
|
||||||
|
object Notification
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Home screen that the user lands on initially containing the wallpapers and albums
|
* Object for Home screen
|
||||||
*/
|
*/
|
||||||
object Home : NavScreens("home_screen", R.string.home_screen, Icons.Outlined.Image, Icons.Filled.Image)
|
@Serializable
|
||||||
|
object Home
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings screen for the application
|
* Object for Settings screen
|
||||||
*/
|
*/
|
||||||
object Settings : NavScreens("settings_screen", R.string.settings_screen, Icons.Outlined.Settings, Icons.Filled.Settings)
|
@Serializable
|
||||||
|
object Settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* License screen for the application
|
* Object for Licenses screen
|
||||||
*/
|
*/
|
||||||
object Licenses : NavScreens("licenses_screen", R.string.licenses_screen, Icons.Outlined.Newspaper, Icons.Filled.Newspaper)
|
@Serializable
|
||||||
|
object Licenses
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings screen for the application
|
* Object for Privacy screen
|
||||||
*/
|
*/
|
||||||
object Privacy : NavScreens("privacy_screen", R.string.privacy_screen, Icons.Outlined.PrivacyTip, Icons.Filled.PrivacyTip)
|
@Serializable
|
||||||
|
object Privacy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/Edit screen for album when adding or editing
|
* Data class for AlbumView screen
|
||||||
*/
|
*/
|
||||||
object AddEdit : NavScreens("add_edit_screen", R.string.add_wallpaper_screen, Icons.Outlined.Add, Icons.Filled.Add)
|
@Serializable
|
||||||
|
data class AlbumView(val initialAlbumName: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wallpaper view screen for viewing wallpapers when clicking on a wallpaper
|
* Data class for AddEdit screen
|
||||||
*/
|
*/
|
||||||
object WallpaperView : NavScreens("wallpaper_view_screen", R.string.wallpaper_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
@Serializable
|
||||||
|
data class AddEdit(val wallpaper: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Folder view screen for viewing wallpapers in a folder when clicking on a folder
|
* Data class for WallpaperView screen
|
||||||
*/
|
*/
|
||||||
object FolderView : NavScreens("folder_view_screen", R.string.folder_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
@Serializable
|
||||||
|
data class WallpaperView(val wallpaper: String)
|
||||||
|
|
||||||
/**
|
/** Reverted back to passing JSON due to bug in navigation compose causing crash
|
||||||
* Album view screen for viewing albums when clicking on an album. Shows wallpapers and folders of the album
|
* Data class for FolderView screen
|
||||||
|
@Serializable
|
||||||
|
data class FolderView(val folderName: String?, val wallpapers: List<String>)
|
||||||
*/
|
*/
|
||||||
object AlbumView : NavScreens("album_view_screen", R.string.album_view, Icons.Outlined.BrowseGallery, Icons.Filled.BrowseGallery)
|
|
||||||
|
sealed class NavScreens(val route: String) {
|
||||||
|
data object FolderView : NavScreens("folder_view_screen")
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,11 +1,10 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.wallpaperservice
|
package com.anthonyla.paperize.feature.wallpaper.wallpaper_service
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.anthonyla.paperize.core.SettingsConstants
|
import com.anthonyla.paperize.core.SettingsConstants
|
||||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
+414
@@ -0,0 +1,414 @@
|
|||||||
|
package com.anthonyla.paperize.feature.wallpaper.wallpaper_service
|
||||||
|
|
||||||
|
import android.app.Notification
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.app.Service
|
||||||
|
import android.app.WallpaperManager
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.ImageDecoder
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.os.Looper
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import com.anthonyla.paperize.R
|
||||||
|
import com.anthonyla.paperize.core.ScalingConstants
|
||||||
|
import com.anthonyla.paperize.core.SettingsConstants
|
||||||
|
import com.anthonyla.paperize.core.calculateInSampleSize
|
||||||
|
import com.anthonyla.paperize.core.darkenBitmap
|
||||||
|
import com.anthonyla.paperize.core.fillBitmap
|
||||||
|
import com.anthonyla.paperize.core.fitBitmap
|
||||||
|
import com.anthonyla.paperize.core.getImageDimensions
|
||||||
|
import com.anthonyla.paperize.core.stretchBitmap
|
||||||
|
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
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import java.io.IOException
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.time.format.FormatStyle
|
||||||
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class WallpaperService: Service() {
|
||||||
|
@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
|
||||||
|
private var timeInMinutes: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
||||||
|
|
||||||
|
enum class Actions {
|
||||||
|
START,
|
||||||
|
STOP,
|
||||||
|
UPDATE,
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(p0: Intent?): IBinder? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the runnable code to change the wallpaper to prevent runnableCode from being null
|
||||||
|
*/
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
startForeground(1, createNotification(0, 0))
|
||||||
|
runnableCode = object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
val self = this
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
try {
|
||||||
|
changeWallpaper(this@WallpaperService)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error in runnableCode", e)
|
||||||
|
} finally {
|
||||||
|
handler.postDelayed(self, timeInMinutes * 60 * 1000L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the service and schedule the wallpaper change
|
||||||
|
*/
|
||||||
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
|
handler.removeCallbacks(runnableCode)
|
||||||
|
when(intent?.action) {
|
||||||
|
Actions.START.toString() -> {
|
||||||
|
timeInMinutes = intent.getIntExtra("timeInMinutes", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
|
||||||
|
// Schedule the next wallpaper change
|
||||||
|
runnableCode = object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
val self = this
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
try {
|
||||||
|
changeWallpaper(this@WallpaperService)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error in runnableCode", e)
|
||||||
|
} finally {
|
||||||
|
handler.postDelayed(self, timeInMinutes * 60 * 1000L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handler.postDelayed(runnableCode, 3000)
|
||||||
|
}
|
||||||
|
Actions.UPDATE.toString() -> {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
try {
|
||||||
|
updateCurrentWallpaper(this@WallpaperService)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error in changing brightness", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Actions.STOP.toString() -> {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, "")
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, "")
|
||||||
|
}
|
||||||
|
stopSelf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return START_STICKY
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up the service when it is destroyed
|
||||||
|
*/
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
handler.removeCallbacks(runnableCode)
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, "")
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(getString(R.string.app_name))
|
||||||
|
.setContentText(resources.getQuantityString(R.plurals.notification_content_text, total, current, total, formatTime(timeInMinutes)))
|
||||||
|
.setSmallIcon(R.drawable.notification_icon)
|
||||||
|
.setContentIntent(pendingIntent)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the wallpaper to the next wallpaper in the queue of the selected album
|
||||||
|
* If none left, reshuffle the wallpapers and pick the first one
|
||||||
|
*/
|
||||||
|
private suspend fun changeWallpaper(context: Context) {
|
||||||
|
try {
|
||||||
|
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||||
|
val time = LocalDateTime.now()
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, time.format(formatter))
|
||||||
|
settingsDataStoreImpl.putString(
|
||||||
|
SettingsConstants.NEXT_SET_TIME,
|
||||||
|
time.plusMinutes(timeInMinutes.toLong()).format(formatter)
|
||||||
|
)
|
||||||
|
val scaling = settingsDataStoreImpl.getString(SettingsConstants.WALLPAPER_SCALING)
|
||||||
|
?.let { ScalingConstants.valueOf(it) } ?: ScalingConstants.FILL
|
||||||
|
val setLockWithHome =
|
||||||
|
settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false
|
||||||
|
val darken = settingsDataStoreImpl.getBoolean(SettingsConstants.DARKEN) ?: false
|
||||||
|
val darkenPercentage =
|
||||||
|
settingsDataStoreImpl.getInt(SettingsConstants.DARKEN_PERCENTAGE) ?: 100
|
||||||
|
val selectedAlbum = selectedRepository.getSelectedAlbum().first().firstOrNull()
|
||||||
|
if (selectedAlbum == null) {
|
||||||
|
onDestroy()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selectedAlbum.let { it ->
|
||||||
|
var wallpaper = it.album.wallpapersInQueue.firstOrNull()
|
||||||
|
if (wallpaper != null) {
|
||||||
|
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,
|
||||||
|
darken,
|
||||||
|
darkenPercentage,
|
||||||
|
scaling
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
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 = 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,
|
||||||
|
darken,
|
||||||
|
darkenPercentage,
|
||||||
|
scaling
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error in changing wallpaper", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun updateCurrentWallpaper(context: Context) {
|
||||||
|
try {
|
||||||
|
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||||
|
val time = LocalDateTime.now()
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, time.format(formatter))
|
||||||
|
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, time.plusMinutes(timeInMinutes.toLong()).format(formatter))
|
||||||
|
val scaling = settingsDataStoreImpl.getString(SettingsConstants.WALLPAPER_SCALING)?.let { ScalingConstants.valueOf(it) } ?: ScalingConstants.FILL
|
||||||
|
val setLockWithHome = settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false
|
||||||
|
val darken = settingsDataStoreImpl.getBoolean(SettingsConstants.DARKEN) ?: false
|
||||||
|
val darkenPercentage = settingsDataStoreImpl.getInt(SettingsConstants.DARKEN_PERCENTAGE) ?: 100
|
||||||
|
val selectedAlbum = selectedRepository.getSelectedAlbum().first().firstOrNull()
|
||||||
|
if (selectedAlbum == null) {
|
||||||
|
onDestroy()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selectedAlbum.let { it ->
|
||||||
|
val wallpaper = it.album.currentWallpaper
|
||||||
|
if (wallpaper != null) {
|
||||||
|
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, darken, darkenPercentage, scaling)) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error in updating", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the wallpaper to the given uri
|
||||||
|
*/
|
||||||
|
private fun setWallpaper(context: Context, wallpaper: Uri, setLockWithHome: Boolean, darken: Boolean, percent: Int, scaling: ScalingConstants): Boolean {
|
||||||
|
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||||
|
try {
|
||||||
|
val imageSize = wallpaper.getImageDimensions(context)
|
||||||
|
val aspectRatio = imageSize.height.toFloat() / imageSize.width.toFloat()
|
||||||
|
val device = context.resources.displayMetrics
|
||||||
|
val targetWidth = min(4 * device.widthPixels, imageSize.width)
|
||||||
|
val targetHeight = (targetWidth * aspectRatio).toInt()
|
||||||
|
|
||||||
|
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
val source = ImageDecoder.createSource(context.contentResolver, wallpaper)
|
||||||
|
ImageDecoder.decodeBitmap(source) { decoder, _, _ ->
|
||||||
|
decoder.setTargetSize(targetWidth, targetHeight)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.contentResolver.openInputStream(wallpaper)?.use { inputStream ->
|
||||||
|
val options = BitmapFactory.Options().apply {
|
||||||
|
inSampleSize = calculateInSampleSize(imageSize, targetWidth, targetHeight)
|
||||||
|
}
|
||||||
|
BitmapFactory.decodeStream(inputStream, null, options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) return false
|
||||||
|
else {
|
||||||
|
processBitmap(device, bitmap, darken, percent, scaling)?.let {
|
||||||
|
image -> wallpaperManager.setBitmap(image, null, true, when (setLockWithHome) {
|
||||||
|
true -> WallpaperManager.FLAG_LOCK or WallpaperManager.FLAG_SYSTEM
|
||||||
|
false -> WallpaperManager.FLAG_SYSTEM
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error setting wallpaper", e)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the time in minutes to a human readable format
|
||||||
|
*/
|
||||||
|
private fun formatTime(timeInMinutes: Int): String {
|
||||||
|
val days = timeInMinutes / (24 * 60)
|
||||||
|
val hours = (timeInMinutes % (24 * 60)) / 60
|
||||||
|
val minutes = timeInMinutes % 60
|
||||||
|
|
||||||
|
val formattedDays = if (days > 0) resources.getQuantityString(R.plurals.days, days, days) else ""
|
||||||
|
val formattedHours = if (hours > 0) resources.getQuantityString(R.plurals.hours, hours, hours) else ""
|
||||||
|
val formattedMinutes = if (minutes > 0) resources.getQuantityString(R.plurals.minutes, minutes, minutes) else ""
|
||||||
|
|
||||||
|
return listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Darkens the bitmap by the given percentage and returns it
|
||||||
|
* 0 - lightest, 100 - darkest
|
||||||
|
*/
|
||||||
|
private fun processBitmap(device: DisplayMetrics, source: Bitmap, darken: Boolean, percent: Int, scaling: ScalingConstants): Bitmap? {
|
||||||
|
try {
|
||||||
|
var processedBitmap = source.copy(Bitmap.Config.ARGB_8888, true)
|
||||||
|
|
||||||
|
// Apply wallpaper scaling effects
|
||||||
|
processedBitmap = when (scaling) {
|
||||||
|
ScalingConstants.FILL -> fillBitmap(processedBitmap, device.widthPixels, device.heightPixels)
|
||||||
|
ScalingConstants.FIT -> fitBitmap(processedBitmap, device.widthPixels, device.heightPixels)
|
||||||
|
ScalingConstants.STRETCH -> stretchBitmap(processedBitmap, device.widthPixels, device.heightPixels)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply brightness effect
|
||||||
|
if (darken && percent < 100) {
|
||||||
|
processedBitmap = darkenBitmap(processedBitmap, percent, device.widthPixels, device.heightPixels)
|
||||||
|
}
|
||||||
|
return processedBitmap
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("PaperizeWallpaperChanger", "Error darkening bitmap", e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-232
@@ -1,232 +0,0 @@
|
|||||||
package com.anthonyla.paperize.feature.wallpaper.wallpaperservice
|
|
||||||
|
|
||||||
import android.app.Notification
|
|
||||||
import android.app.NotificationManager
|
|
||||||
import android.app.Service
|
|
||||||
import android.app.WallpaperManager
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.graphics.ImageDecoder
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.os.Looper
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
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.SelectedAlbumRepository
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.io.IOException
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class WallpaperService: Service() {
|
|
||||||
@Inject lateinit var repository: SelectedAlbumRepository
|
|
||||||
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
|
||||||
private lateinit var runnableCode: Runnable
|
|
||||||
private var timeInMinutes: Int = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT
|
|
||||||
|
|
||||||
enum class Actions {
|
|
||||||
START,
|
|
||||||
STOP
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBind(p0: Intent?): IBinder? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the runnable code to change the wallpaper to prevent runnableCode from being null
|
|
||||||
*/
|
|
||||||
override fun onCreate() {
|
|
||||||
super.onCreate()
|
|
||||||
startForeground(1, createNotification(0, 0))
|
|
||||||
runnableCode = object : Runnable {
|
|
||||||
override fun run() {
|
|
||||||
val self = this
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
try {
|
|
||||||
changeWallpaper(this@WallpaperService)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("PaperizeWallpaperChanger", "Error in runnableCode", e)
|
|
||||||
} finally {
|
|
||||||
handler.postDelayed(self, timeInMinutes * 60 * 1000L)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start the service and schedule the wallpaper change
|
|
||||||
*/
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
handler.removeCallbacks(runnableCode)
|
|
||||||
when(intent?.action) {
|
|
||||||
Actions.START.toString() -> {
|
|
||||||
timeInMinutes = intent.getIntExtra("timeInMinutes", SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT)
|
|
||||||
// Schedule the next wallpaper change
|
|
||||||
runnableCode = object : Runnable {
|
|
||||||
override fun run() {
|
|
||||||
val self = this
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
try {
|
|
||||||
changeWallpaper(this@WallpaperService)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("PaperizeWallpaperChanger", "Error in runnableCode", e)
|
|
||||||
} finally {
|
|
||||||
handler.postDelayed(self, timeInMinutes * 60 * 1000L)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handler.post(runnableCode)
|
|
||||||
}
|
|
||||||
Actions.STOP.toString() -> {
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, "")
|
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, "")
|
|
||||||
}
|
|
||||||
stopSelf()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return START_STICKY
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 {
|
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, "")
|
|
||||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a notification for the wallpaper service
|
|
||||||
*/
|
|
||||||
private fun createNotification(current: Int = 0, total: Int = 0): Notification {
|
|
||||||
return NotificationCompat.Builder(this, "wallpaper_service_channel")
|
|
||||||
.setContentTitle("Paperize")
|
|
||||||
.setContentText("Rotation: $current/$total wallpapers\nInterval: ${formatTime(timeInMinutes)}")
|
|
||||||
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the wallpaper to the next wallpaper in the queue of the selected album
|
|
||||||
* If none left, reshuffle the wallpapers and pick the first one
|
|
||||||
*/
|
|
||||||
private suspend fun changeWallpaper(context: Context) {
|
|
||||||
val formatter = DateTimeFormatter.ofPattern("MM/dd/yy hh:mm\na")
|
|
||||||
val time = LocalDateTime.now()
|
|
||||||
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)
|
|
||||||
var wallpaper = it.album.wallpapersInQueue.firstOrNull()
|
|
||||||
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(
|
|
||||||
it.copy(
|
|
||||||
album = it.album.copy(
|
|
||||||
wallpapersInQueue = newWallpaperInQueue.drop(1)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the wallpaper to the given uri
|
|
||||||
*/
|
|
||||||
private fun setWallpaper(context: Context, wallpaper: Uri, setLockWithHome: Boolean) {
|
|
||||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
|
||||||
try {
|
|
||||||
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
val source = ImageDecoder.createSource(context.contentResolver, wallpaper)
|
|
||||||
ImageDecoder.decodeBitmap(source) { decoder, _, _ ->
|
|
||||||
val displayMetrics = context.resources.displayMetrics
|
|
||||||
val targetWidth = displayMetrics.widthPixels
|
|
||||||
val targetHeight = displayMetrics.heightPixels
|
|
||||||
decoder.setTargetSize(targetWidth, targetHeight)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
context.contentResolver.openInputStream(wallpaper)?.use { inputStream ->
|
|
||||||
BitmapFactory.decodeStream(inputStream)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bitmap?.let {
|
|
||||||
image -> wallpaperManager.setBitmap(image, null, true, when (setLockWithHome) {
|
|
||||||
true -> WallpaperManager.FLAG_LOCK or WallpaperManager.FLAG_SYSTEM
|
|
||||||
false -> WallpaperManager.FLAG_SYSTEM
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.e("PaperizeWallpaperChanger", "Error changing wallpaper", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formats the time in minutes to a human readable format
|
|
||||||
*/
|
|
||||||
private fun formatTime(timeInMinutes: Int): String {
|
|
||||||
val days = timeInMinutes / (24 * 60)
|
|
||||||
val hours = (timeInMinutes % (24 * 60)) / 60
|
|
||||||
val minutes = timeInMinutes % 60
|
|
||||||
|
|
||||||
val formattedDays = when {
|
|
||||||
days > 1 -> "$days days"
|
|
||||||
days == 1 -> "$days day"
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
val formattedHours = when {
|
|
||||||
hours > 1 -> "$hours hours"
|
|
||||||
hours == 1 -> "$hours hour"
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
val formattedMinutes = when {
|
|
||||||
minutes > 1 -> "$minutes minutes"
|
|
||||||
minutes == 1 -> "$minutes minute"
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return listOf(formattedDays, formattedHours, formattedMinutes).filter { it.isNotEmpty() }.joinToString(", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 683 B |
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
|
||||||
<solid android:color="@color/default_splash_dark"/>
|
|
||||||
</shape>
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,20 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="1024"
|
||||||
|
android:viewportHeight="1024">
|
||||||
|
<group android:scaleX="0.9"
|
||||||
|
android:scaleY="0.9"
|
||||||
|
android:translateX="51.2"
|
||||||
|
android:translateY="51.2">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M351,344c0.2,2.9 -0.8,4.8 -4,5.1 -2.3,0.2 -3.7,1.6 -3.5,4 0.1,2.5 2.1,3.2 4.1,3.5 5.9,0.9 11.7,-0 17.3,-1.8 10.5,-3.3 21.5,-4.7 32,-7.6 3,-0.8 6.9,-0.9 7.6,-4.6 0.7,-3.4 -1.8,-5.8 -4.7,-7.6 -0.5,-0.3 -0.7,-1 -1.4,-2.1 6.8,-2.8 13.7,-3.3 20.5,-4.1 28.2,-3.3 56.6,-5.4 84.6,-10 3.7,-0.6 7.3,-2.2 11.4,-1.3 -10.2,6.7 -20.5,13.2 -32,18.3 3.8,-0.5 7.6,-0.9 11.3,-1.4 3.8,-0.6 7.5,-1.5 11.3,-2.1 48.3,-8 92,-28.4 135,-50.5 12.5,-6.4 25.3,-11.9 38.8,-15.9 7.5,-2.3 14.5,-1.8 21.6,1.9 16,8.2 26.6,21.3 34.6,36.9 0.5,0.9 0.7,1.9 0.2,3.2 -2.6,0.5 -5.6,1.9 -5.3,-3.2 0.1,-1.2 -0.4,-2.5 -1.4,-3 -8,-4.1 -15,-11.3 -25.6,-6.6 -7.4,3.3 -15.6,4.5 -23,8.5 1.6,3.2 4,3.8 7.1,3.1 1.3,-0.3 2.6,-0.3 4,-0.4 2.9,-0 4.7,1.5 5.1,4.4 0.5,3.2 -1.8,4 -4.1,4.6 -8.6,2.1 -17.1,4.2 -25.7,6.3 -20.4,5.1 -40,12.5 -60.3,17.8 -29.1,7.6 -58.3,15 -88.7,16.3 -4.4,0.2 -8.8,0.8 -13.3,1.7 6.6,1.5 12.8,4.6 20.1,3.1 6,-1.2 12.2,-1.1 18.4,-1.5 19.5,-1.1 38.6,-4.4 57.3,-10.2 2.4,-0.7 4.7,-1.6 7.1,-2.3 0.1,-0 0.3,0.1 1.2,0.5 -4.6,5.5 -11.1,8 -18,11.8 4.9,1.5 8.3,0.2 11.5,-0.4 25.4,-4.8 50,-12.7 75,-18.7 21.4,-5.2 43,-8.7 65.2,-7.8 5.7,0.2 11.3,1.1 16.8,2.4 3.1,0.7 5.7,2.4 7.9,4.9 11.4,13 16.8,28.5 19.2,45.3 0.5,3.8 1,7.5 1.8,12.8l-22.7,-9.9c1.6,-1.8 3.1,-1.1 4.5,-1.3 2,-0.3 5,0.6 5.3,-2.3 0.3,-2.5 -1,-5.1 -3.6,-6.1 -4,-1.6 -8.1,-3.1 -12.3,-4.1 -24.1,-5.8 -48.2,-4.4 -72.3,0.3 -15.3,3 -30.6,6.5 -45.5,11.4 -0.9,0.3 -1.9,0.6 -2.8,1 -2,1 -4,2.3 -3.3,4.9 0.7,2.8 3.2,2 5,1.7 8.8,-1.6 17.6,-3.5 26.2,-6.4 1.3,-0.5 2.7,-1.4 4.8,-0.5 -6.4,6.6 -15.2,9.5 -22.5,16.7 11.1,-1.9 20.9,-3.5 30.6,-5.2 25.7,-4.4 51.5,-5.3 76.7,1.7 31.8,8.9 46,27.6 47.1,58.9 0.5,15 -2,29.5 -7.4,43.5 -0.5,1.3 -0.4,3.1 -2.2,3.6 -1.1,-0.4 -1,-1.4 -0.8,-2.1 4,-21 -10.6,-43.7 -30.1,-53.4 -16.8,-8.3 -34.7,-9.9 -53.1,-9 -3.7,0.2 -7.2,1.6 -9.9,4.4 -1.1,1.1 -2.9,2.1 -2.2,4.1 0.8,2.2 2.7,2.7 4.9,2.7 7,0 14,0.3 21,0.9 7.5,0.6 14.8,2 22.2,3.1 3.8,0.6 5.5,2.6 6.3,6.3 4.3,20 5.2,40.2 3.4,60.5 -2.8,30.8 -11.3,59.8 -26.1,86.8 -19.9,36.5 -47,66.4 -81.9,89.3 -34.2,22.5 -71.8,34.9 -112.3,38.2 -24.4,2 -48.9,0.8 -72.9,-5.5 -4,-1 -5.8,-2.5 -5.7,-7 0.1,-46.7 0.1,-93.3 -0,-140 -0,-4.8 1.9,-5.9 6.3,-5.9 24,0.1 48,0.2 72,0 24.7,-0.2 48.8,-4.2 71.1,-15.3 23.7,-11.9 39.9,-30.5 45.8,-56.7 6.1,-27.1 -0.7,-51.1 -19.7,-71.5 -19,-20.4 -43.2,-31.8 -69.4,-39.8 -22,-6.7 -44.7,-10.1 -67.5,-13 -33.7,-4.3 -67.5,-3.1 -101.3,-3.1 -4.7,0 -6,1.8 -6,6.2 0.1,51.2 0,102.3 -0,153.5 -0,74.8 -0.1,149.7 -0.1,224.5 -0,5.4 0,10.9 0,16.1 -2.1,0.5 -2.8,-0.3 -3.4,-1 -7.2,-8.1 -14.4,-16.2 -21.6,-24.2 -2.2,-2.5 -3.2,-5.3 -3.1,-8.6 0.1,-25.5 -0,-50.9 -0,-76.4 0,-91.3 0,-182.6 0.1,-273.9 0,-5.3 -2.7,-7.7 -10.5,-9.4 -1.6,1.8 -0.9,4.1 -0.9,6.2 -0.1,103.7 -0.1,207.3 -0.1,311 0,2.2 0,4.4 -0.3,6.5 -0.3,1.8 0,4.5 -2.8,4.6 -2.6,0.1 -5,-1 -6.1,-3.5 -1.3,-2.8 -1.2,-5.8 -1.2,-8.8 -0,-70.5 -0,-141 -0,-211.5 -0,-33.2 -0.2,-66.3 0.2,-99.5 0.1,-6.7 -1.7,-11.1 -7.8,-13.7 -1.3,-0.6 -2.3,-2 -4.1,-2.1 -2.7,1.6 -1.8,4.3 -1.8,6.6 -0,59.8 -0,119.7 -0,179.5 0,33.3 0.1,66.7 0.1,100 0,1.3 -0.2,2.6 -0.2,4 -0.7,0 -1.3,0.2 -1.6,-0 -7.8,-7.3 -14.8,-15.4 -21.5,-23.6 -2.2,-2.7 -2.1,-6.4 -1.9,-9.6 1.2,-15.2 -2.5,-28.8 -9,-42.7 -10,-21.2 -14,-44.2 -15.6,-67.7 -2.1,-29.9 0.8,-59.1 10.1,-87.7 2,-6 4.7,-11.7 7.3,-17.5 1,-2.3 1.9,-4.9 5.4,-5.2 2.5,-0.2 1.6,-2.9 1.6,-4.6 0.1,-13.7 1,-27.4 -0.1,-41 -1.3,-17.4 5.2,-29.9 18.9,-40.3 17.2,-12.9 35.7,-23.2 55.1,-32.2 33.5,-15.6 69.2,-24.7 104.7,-34.4 33,-9.1 65.3,-20 94.2,-38.9 1.1,-0.7 2.4,-1.3 3.3,-2.3 5.7,-6 12.3,-5.5 19.3,-3.2 5.6,1.8 11.4,3.3 16.9,6.4 -0.7,0.9 -1,1.6 -1.5,1.9 -25.5,14.4 -50.4,30 -77.8,40.7 -24,9.3 -48.7,15.7 -73.8,21.1 -33.6,7.2 -66.8,15.7 -96.9,33.1 -8.8,5.1 -17.6,10.3 -24.1,18.4 -3.1,3.8 -5.3,8 -2.8,13.3 5.6,-1.6 10.4,-4.6 16.3,-5.2 0.4,-0 0.4,-0.1 0.4,-0.1z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M509.5,440.1c10.1,1.1 19.5,2.9 28.4,6.8 22.1,9.6 31.3,34.1 19.8,53.7 -6.8,11.7 -18.4,16.1 -31,17.6 -21.7,2.5 -43.6,0.6 -65.3,1.2 -4.5,0.1 -4.7,-2.7 -4.7,-5.9 -0,-12.8 0,-25.6 0,-38.4 -0,-10.2 0.1,-20.3 -0.1,-30.5 -0.1,-4.2 1.5,-5.6 5.5,-5.6 15.6,-0 31.3,0.1 47.3,1.1zM585,279.1c-22.2,10.8 -44,21.6 -67.6,27.8 -17.7,4.7 -35.7,7.7 -54,9.6 -35.4,3.6 -70.8,7.1 -105,17.8 -5,1.6 -9.9,3.6 -15.4,5.6 0.7,-2.6 2.6,-3 3.9,-3.9 23.4,-16.4 50,-25.3 77.1,-33.3 25.2,-7.4 51.1,-12.1 76.5,-19 29.3,-7.9 56.9,-19.5 83.4,-34.1 14,-7.7 27.9,-15.7 43.6,-19.5 4,-1 7.8,-1 11.8,0.2 11.3,3.4 21.7,8.4 30.5,16.4 3,2.7 2.9,4.5 -0.9,6.1 -3.1,1.3 -6.1,2.7 -9.1,4.2 -3.3,1.7 -6.1,3.6 -9.1,-1 -1.6,-2.3 -5,-1.8 -7.9,-1 -20.1,5.8 -39.2,13.9 -57.9,24z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M615.3,281.3c-17.6,9.8 -35.2,18.9 -54.7,23.9 16.7,-11.1 33.3,-22.2 49.5,-34.4 2.4,4.2 -2.7,5.2 -1.9,8.4 14.4,-4.2 25.3,-16 40.7,-17.7 -10.3,7.9 -22.4,12.7 -33.6,19.7zM715,306.4c4.1,-0.1 7.8,-1.1 12.6,-0.1 -4.4,2.7 -8.1,4.1 -12.3,3.7 -3.4,-0.3 -3.3,-1.7 -0.4,-3.6zM706.1,378c3.5,0.1 6.3,-3.1 9.7,-0.6 -6,0.8 -10.9,5.6 -18.4,4.3 2.8,-2.7 5.7,-2.8 8.6,-3.7zM351,344c4.1,-2.3 7.6,-3.3 11.8,-3 -3.1,4.5 -7.4,2.4 -11.4,3 -0.4,0 -0.4,0 -0.4,0z"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="800dp"
|
||||||
|
android:height="800dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M20.472,10.081L3.528,10.081a1.59,1.59 0,0 0,-1.589 1.589v10.59a1.59,1.59 0,0 0,1.589 1.589h16.944a1.59,1.59 0,0 0,1.589 -1.589L22.061,11.67a1.59,1.59 0,0 0,-1.589 -1.589zM12,22.525c-3.066,0 -5.56,-2.494 -5.56,-5.56s2.494,-5.56 5.56,-5.56c3.066,0 5.56,2.494 5.56,5.56s-2.494,5.56 -5.56,5.56zM12,12.411c-2.511,0 -4.554,2.043 -4.554,4.554S9.489,21.519 12,21.519s4.554,-2.043 4.554,-4.554 -2.043,-4.554 -4.554,-4.554zM12,20.274a3.322,3.322 0,0 1,-3.221 -2.568h1.67c0.275,0.581 0.859,0.979 1.551,0.979 0.96,0 1.721,-0.761 1.721,-1.721 0,-0.96 -0.761,-1.721 -1.721,-1.721a1.7,1.7 0,0 0,-1.493 0.874L8.805,16.117A3.322,3.322 0,0 1,12 13.655a3.321,3.321 0,0 1,3.309 3.309A3.321,3.321 0,0 1,12 20.274zM23.849,0.396l-0.002,0.003 -0.006,-0.005 0.004,-0.004a0.668,0.668 0,0 0,-0.519 -0.238,0.654 0.654,0 0,0 -0.512,0.259l-1.818,2.353a1.564,1.564 0,0 0,-0.523 -0.095L3.528,2.669c-0.184,0 -0.358,0.038 -0.523,0.095L1.187,0.41A0.657,0.657 0,0 0,0.156 0.389L0.16,0.393 0.153,0.399 0.151,0.396a0.662,0.662 0,0 0,-0.012 0.824l1.909,2.471a1.587,1.587 0,0 0,-0.108 0.566v3.707a1.59,1.59 0,0 0,1.589 1.589h16.944a1.59,1.59 0,0 0,1.589 -1.589L22.062,4.257c0,-0.2 -0.041,-0.39 -0.109,-0.566l1.909,-2.471a0.663,0.663 0,0 0,-0.013 -0.824zM6.904,8.228a1.787,1.787 0,1 1,0 -3.574,1.787 1.787,0 0,1 0,3.574zM17.229,8.228a1.787,1.787 0,1 1,0 -3.574,1.787 1.787,0 0,1 0,3.574z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="128dp" android:viewportHeight="128" android:viewportWidth="128" android:width="128dp">
|
||||||
|
|
||||||
|
<path android:fillColor="#e1e0a6" android:pathData="M29.66,113.89l0,0l68.68,0l0,0l0,-98.85l0,0l-68.68,0l0,0l0,98.85z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M79.94,109.3c0,1.76 -1.44,3.2 -3.2,3.2h-38.35c-1.76,0 -3.2,-1.44 -3.2,-3.2 0,0 20.61,-27.17 22.37,-27.17 1.76,0 22.37,27.17 22.37,27.17Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M76.14,113.89h-38.23c-2.65,0 -4.79,-2.15 -4.79,-4.79v-0.48s0.32,-0.48 0.32,-0.48c21.03,-27.81 22.63,-27.81 23.58,-27.81 0.96,0 2.55,0 23.58,27.81l0.32,0.48v0.48c0,2.72 -2.07,4.79 -4.78,4.79h0ZM36.18,109.53c0.16,0.64 0.8,1.12 1.6,1.12h38.35c0.8,0 1.28,-0.48 1.6,-1.12 -7.35,-9.59 -17.74,-22.85 -20.77,-25.73 -3.04,2.88 -13.42,16.14 -20.77,25.73Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M93.63,108.73c0,1.65 -1.36,3.1 -3.13,3.1h-37.04c-1.67,0 -3.13,-1.34 -3.13,-3.1 0,0 19.93,-25.92 21.6,-25.92 1.77,0 21.7,25.92 21.7,25.92Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M90.84,113.89h-37.97c-2.35,0 -4.27,-1.92 -4.27,-4.27v-0.32s0.21,-0.32 0.21,-0.32c20.75,-27.23 22.35,-27.23 22.99,-27.23s2.25,0 22.99,27.23l0.21,0.32v0.32c0.11,2.35 -1.82,4.27 -4.17,4.27ZM50.91,109.76c0.11,0.96 1.07,1.82 2.03,1.82h37.91c1.07,0 1.92,-0.75 2.03,-1.82 -8.65,-11.43 -18.58,-23.92 -20.93,-25.95 -2.35,2.03 -12.28,14.52 -21.04,25.95Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#f29b54" android:pathData="M53.55,45.67c4.7,0 8.24,-4.99 5.59,-9.97 -1.01,-1.89 -3.02,-3.03 -5.16,-3.03h-0.61c-2.55,0 -4.89,1.52 -5.82,3.9 -1.83,4.67 1.56,9.1 5.99,9.1h0Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M60.87,39.62c0,4.47 -3.52,7.99 -7.99,7.99s-7.99,-3.52 -7.99,-7.99 3.52,-7.99 7.99,-7.99 7.99,3.52 7.99,7.99ZM48.09,39.62c0,2.72 2.08,4.79 4.79,4.79s4.79,-2.08 4.79,-4.79 -2.08,-4.79 -4.79,-4.79 -4.79,2.08 -4.79,4.79Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M39.29,23.3c0,-5.14 3.53,-9.31 7.9,-9.31" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M47.2,13.99h34.25" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M88.45,21.29c0,-4.03 -3.35,-7.3 -7.48,-7.3" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M88.45,21.29v85.52" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M88.45,106.81c0,3.98 -3.76,7.21 -8.4,7.21" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M80.05,114.01h-33.38" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M39.56,105.81c0,4.53 3.41,8.2 7.63,8.2" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M40.56,105.81h-1c-0.15,0 -0.27,-36.9 -0.27,-82.51" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="128dp" android:viewportHeight="128" android:viewportWidth="128" android:width="128dp">
|
||||||
|
|
||||||
|
<path android:fillColor="#fff" android:pathData="M47.5,14L80.5,14A8,8 0,0 1,88.5 22L88.5,106A8,8 0,0 1,80.5 114L47.5,114A8,8 0,0 1,39.5 106L39.5,22A8,8 0,0 1,47.5 14z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M47.5,14L80.5,14A8,8 0,0 1,88.5 22L88.5,106A8,8 0,0 1,80.5 114L47.5,114A8,8 0,0 1,39.5 106L39.5,22A8,8 0,0 1,47.5 14z" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#e1e0a6" android:pathData="M40.54,97.28l0,0l46.88,0l0,0l0,-67.64l0,0l-46.88,0l0,0l0,67.64z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M74.87,94.47c0,1.21 -0.99,2.2 -2.2,2.2h-26.37c-1.21,0 -2.2,-0.99 -2.2,-2.2 0,0 14.18,-18.68 15.38,-18.68s15.38,18.68 15.38,18.68Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M72.26,97.62h-26.29c-1.82,0 -3.3,-1.48 -3.3,-3.3v-0.33s0.22,-0.33 0.22,-0.33c14.46,-19.12 15.56,-19.12 16.22,-19.12s1.75,0 16.22,19.12l0.22,0.33v0.33c0,1.87 -1.42,3.3 -3.29,3.3h0ZM44.78,94.62c0.11,0.44 0.55,0.77 1.1,0.77h26.37c0.55,0 0.88,-0.33 1.1,-0.77 -5.06,-6.59 -12.2,-15.71 -14.29,-17.69 -2.09,1.98 -9.23,11.1 -14.29,17.69Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M84.29,94.07c0,1.14 -0.93,2.13 -2.15,2.13h-25.47c-1.15,0 -2.15,-0.92 -2.15,-2.13 0,0 13.71,-17.82 14.85,-17.82 1.22,0 14.93,17.82 14.93,17.82Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M82.36,97.62h-26.11c-1.62,0 -2.94,-1.32 -2.94,-2.94v-0.22s0.15,-0.22 0.15,-0.22c14.27,-18.73 15.37,-18.73 15.81,-18.73s1.54,0 15.81,18.73l0.15,0.22v0.22c0.07,1.62 -1.25,2.94 -2.87,2.94ZM54.91,94.78c0.07,0.66 0.73,1.25 1.4,1.25h26.07c0.73,0 1.32,-0.51 1.4,-1.25 -5.95,-7.86 -12.78,-16.45 -14.39,-17.84 -1.62,1.4 -8.44,9.99 -14.47,17.84Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#f29b54" android:pathData="M56.72,50.71c3.23,0 5.67,-3.43 3.85,-6.85 -0.69,-1.3 -2.08,-2.08 -3.55,-2.08h-0.42c-1.75,0 -3.36,1.05 -4,2.68 -1.26,3.21 1.07,6.25 4.12,6.26h0Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M61.76,46.55c0,3.08 -2.42,5.49 -5.49,5.49s-5.49,-2.42 -5.49,-5.49 2.42,-5.49 5.49,-5.49 5.49,2.42 5.49,5.49ZM52.97,46.55c0,1.87 1.43,3.3 3.3,3.3s3.3,-1.43 3.3,-3.3 -1.43,-3.3 -3.3,-3.3 -3.3,1.43 -3.3,3.3Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M40.3,17.04h47.74v12.6h-47.74z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M42.65,15.47h42.9v2.64h-42.9z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M44.71,14.25h39.23v4.89h-39.23z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M40.3,97.28h47.74v12.35h-47.74z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M41.34,108.99h45.04v3.25h-45.04z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#000" android:pathData="M44.1,110.99h39.67v2.25h-39.67z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="98dp"
|
||||||
|
android:height="96dp"
|
||||||
|
android:viewportWidth="98"
|
||||||
|
android:viewportHeight="96">
|
||||||
|
<path
|
||||||
|
android:pathData="M48.854,0C21.839,0 0,22 0,49.217c0,21.756 13.993,40.172 33.405,46.69 2.427,0.49 3.316,-1.059 3.316,-2.362 0,-1.141 -0.08,-5.052 -0.08,-9.127 -13.59,2.934 -16.42,-5.867 -16.42,-5.867 -2.184,-5.704 -5.42,-7.17 -5.42,-7.17 -4.448,-3.015 0.324,-3.015 0.324,-3.015 4.934,0.326 7.523,5.052 7.523,5.052 4.367,7.496 11.404,5.378 14.235,4.074 0.404,-3.178 1.699,-5.378 3.074,-6.6 -10.839,-1.141 -22.243,-5.378 -22.243,-24.283 0,-5.378 1.94,-9.778 5.014,-13.2 -0.485,-1.222 -2.184,-6.275 0.486,-13.038 0,0 4.125,-1.304 13.426,5.052a46.97,46.97 0,0 1,12.214 -1.63c4.125,0 8.33,0.571 12.213,1.63 9.302,-6.356 13.427,-5.052 13.427,-5.052 2.67,6.763 0.97,11.816 0.485,13.038 3.155,3.422 5.015,7.822 5.015,13.2 0,18.905 -11.404,23.06 -22.324,24.283 1.78,1.548 3.316,4.481 3.316,9.126 0,6.6 -0.08,11.897 -0.08,13.526 0,1.304 0.89,2.853 3.316,2.364 19.412,-6.52 33.405,-24.935 33.405,-46.691C97.707,22 75.788,0 48.854,0z"
|
||||||
|
android:fillColor="#24292f"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="800dp"
|
||||||
|
android:height="800dp"
|
||||||
|
android:viewportWidth="512"
|
||||||
|
android:viewportHeight="512">
|
||||||
|
<path
|
||||||
|
android:pathData="M382.37,175.62C322.89,142.36 227.43,88.94 79.36,6.03C69.37,-0.56 57.89,-1.43 47.96,1.93l254.05,254.05L382.37,175.62z"
|
||||||
|
android:fillColor="#32BBFF"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M47.96,1.93c-1.86,0.63 -3.67,1.39 -5.4,2.31C31.6,10.17 23.55,21.57 23.55,36v439.96c0,14.43 8.05,25.83 19.01,31.76c1.73,0.92 3.54,1.68 5.39,2.31L302.01,255.98L47.96,1.93z"
|
||||||
|
android:fillColor="#32BBFF"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M302.01,255.98L47.96,510.04c9.93,3.38 21.41,2.59 31.4,-4.1c143.6,-80.41 237.99,-133.2 298.15,-166.75c1.67,-0.94 3.32,-1.86 4.94,-2.77L302.01,255.98z"
|
||||||
|
android:fillColor="#32BBFF"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M23.55,255.98v219.98c0,14.43 8.05,25.83 19.01,31.76c1.73,0.92 3.54,1.68 5.39,2.31L302.01,255.98H23.55z"
|
||||||
|
android:fillColor="#2C9FD9"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M79.36,6.03C67.5,-1.8 53.52,-1.58 42.56,4.24l255.6,255.6l84.21,-84.21C322.89,142.36 227.43,88.94 79.36,6.03z"
|
||||||
|
android:fillColor="#29CC5E"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M298.16,252.13L42.56,507.72c10.96,5.82 24.94,6.15 36.79,-1.79c143.6,-80.41 237.99,-133.2 298.15,-166.75c1.67,-0.94 3.32,-1.86 4.94,-2.77L298.16,252.13z"
|
||||||
|
android:fillColor="#D93F21"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M488.45,255.98c0,-12.19 -6.15,-24.49 -18.34,-31.31c0,0 -22.8,-12.72 -92.68,-51.81l-83.12,83.12l83.2,83.21c69.12,-38.81 92.6,-51.89 92.6,-51.89C482.3,280.47 488.45,268.17 488.45,255.98z"
|
||||||
|
android:fillColor="#FFD500"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M470.11,287.29c12.19,-6.82 18.34,-19.12 18.34,-31.31H294.3l83.2,83.21C446.62,300.38 470.11,287.29 470.11,287.29z"
|
||||||
|
android:fillColor="#FFAA00"/>
|
||||||
|
</vector>
|
||||||
@@ -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>
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="128dp" android:viewportHeight="128" android:viewportWidth="128" android:width="128dp">
|
||||||
|
|
||||||
|
<path android:fillColor="#fff" android:pathData="M47.5,14L80.5,14A8,8 0,0 1,88.5 22L88.5,106A8,8 0,0 1,80.5 114L47.5,114A8,8 0,0 1,39.5 106L39.5,22A8,8 0,0 1,47.5 14z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#00000000" android:pathData="M47.5,14L80.5,14A8,8 0,0 1,88.5 22L88.5,106A8,8 0,0 1,80.5 114L47.5,114A8,8 0,0 1,39.5 106L39.5,22A8,8 0,0 1,47.5 14z" android:strokeColor="#000" android:strokeWidth="2"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#e1e0a6" android:pathData="M48.05,14.8L79.67,14.8A8,8 0,0 1,87.67 22.8L87.67,105.29A8,8 0,0 1,79.67 113.29L48.05,113.29A8,8 0,0 1,40.05 105.29L40.05,22.8A8,8 0,0 1,48.05 14.8z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M73.43,109.33c0,1.65 -0.93,3.01 -2.07,3.01h-24.79c-1.14,0 -2.07,-1.35 -2.07,-3.01 0,0 13.32,-25.58 14.46,-25.58s14.46,25.58 14.46,25.58Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M71.51,113.36h-24.06c-1.66,0 -3,-1.92 -3,-4.3v-0.43s0.2,-0.43 0.2,-0.43c13.23,-24.91 14.23,-24.91 14.84,-24.91s1.6,0 14.84,24.91l0.2,0.43v0.43c0,2.43 -1.3,4.3 -3.01,4.3h0ZM45.87,109.34c0.1,0.57 0.5,1 1.01,1h24.19c0.5,0 0.81,-0.43 1.01,-1 -4.64,-8.59 -11.19,-20.47 -13.1,-23.05 -1.91,2.58 -8.47,14.46 -13.1,23.05Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#b8ca43" android:pathData="M82.73,107.65c0,1.83 -1.02,3.43 -2.35,3.43h-27.85c-1.26,0 -2.35,-1.49 -2.35,-3.43 0,0 14.98,-28.68 16.24,-28.68 1.33,0 16.32,28.68 16.32,28.68Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M80.91,113.36h-28.85c-1.78,0 -3.24,-2.12 -3.24,-4.72v-0.35s0.16,-0.35 0.16,-0.35c15.76,-30.09 16.98,-30.09 17.47,-30.09s1.71,0 17.47,30.09l0.16,0.35v0.35c0.08,2.6 -1.38,4.72 -3.17,4.72ZM50.18,108.34c0.08,1.06 0.82,2.01 1.56,2.01h29.13c0.82,0 1.48,-0.83 1.56,-2.01 -6.65,-12.63 -14.28,-26.43 -16.08,-28.68 -1.81,2.24 -9.44,16.05 -16.17,28.68Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#f29b54" android:pathData="M52.47,44.36c3.08,0 5.38,-4.89 3.43,-9.64 -0.63,-1.53 -1.78,-2.45 -3,-2.45h-0.63c-1.37,0 -2.69,0.99 -3.34,2.73 -1.75,4.65 0.52,9.35 3.54,9.35h0Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
<path android:fillColor="#231c1c" android:pathData="M58.4,39.37c0,4.21 -2.27,7.52 -5.16,7.52s-5.16,-3.31 -5.16,-7.52 2.27,-7.52 5.16,-7.52 5.16,3.31 5.16,7.52ZM50.14,39.37c0,2.56 1.34,4.51 3.1,4.51s3.1,-1.96 3.1,-4.51 -1.34,-4.51 -3.1,-4.51 -3.1,1.96 -3.1,4.51Z" android:strokeWidth="0"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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>
|
||||||
Loaded 100 of 189 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user