Compare commits
196
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edfc942a6d | ||
|
|
71f8ee26de | ||
|
|
02ac267c27 | ||
|
|
8ae92ef552 | ||
|
|
4006671f99 | ||
|
|
a19ac36801 | ||
|
|
86d718b5f5 | ||
|
|
e95c923a6a | ||
|
|
ee0a04bf09 | ||
|
|
4f7129f5f4 | ||
|
|
4e5f0d63cc | ||
|
|
c40e70d18e | ||
|
|
b3ca913921 | ||
|
|
99bdcf6637 | ||
|
|
8f8650ef7c | ||
|
|
da2747306b | ||
|
|
bb7dc87027 | ||
|
|
4464cbf7f0 | ||
|
|
c33d567a6a | ||
|
|
2c626db54f | ||
|
|
fec52ca412 | ||
|
|
2cece3dc05 | ||
|
|
37e85c4a6b | ||
|
|
b9f3f158b0 | ||
|
|
e9c4c41d3e | ||
|
|
f2b87a5e0e | ||
|
|
6175338b99 | ||
|
|
729b5bd45a | ||
|
|
5139692f2c | ||
|
|
d6bd048012 | ||
|
|
ca839b2e1f | ||
|
|
02ba6f986b | ||
|
|
417cabcaeb | ||
|
|
5218dd4174 | ||
|
|
35836d7778 | ||
|
|
be9cb13971 | ||
|
|
2a7191b7be | ||
|
|
4b930308f8 | ||
|
|
2567781e63 | ||
|
|
13485cb19c | ||
|
|
eae4e344b6 | ||
|
|
e5fab5cb5e | ||
|
|
5fd233e790 | ||
|
|
48a730e4a9 | ||
|
|
4c3d5af7f7 | ||
|
|
829d982d23 | ||
|
|
b01b9a87d6 | ||
|
|
c4395b364c | ||
|
|
dc1f8b9802 | ||
|
|
4279dd3be7 | ||
|
|
373f784fb6 | ||
|
|
fe12b2116c | ||
|
|
9f906aa11c | ||
|
|
e20b3c7c49 | ||
|
|
9bab8ad4b6 | ||
|
|
31b976c258 | ||
|
|
660116fb60 | ||
|
|
984e34f425 | ||
|
|
cd06c87263 | ||
|
|
633ae66a80 | ||
|
|
005843ec00 | ||
|
|
4327a94c14 | ||
|
|
fb4ffea292 | ||
|
|
7570ab5405 | ||
|
|
8899c5c743 | ||
|
|
cc69b4b63b | ||
|
|
0f77761380 | ||
|
|
cdf124319f | ||
|
|
63fe703a6d | ||
|
|
84043b06e7 | ||
|
|
bf35b34ce2 | ||
|
|
1cde08bef6 | ||
|
|
e37f7e36db | ||
|
|
e6c6184c9d | ||
|
|
512637b23c | ||
|
|
398e43469f | ||
|
|
1f5cab1d5b | ||
|
|
a185c727a2 | ||
|
|
28b9a74c3d | ||
|
|
2e8d8b8603 | ||
|
|
a0a4bc9e4e | ||
|
|
97c23f9d44 | ||
|
|
bde2f7dd1f | ||
|
|
d005102716 | ||
|
|
953dc65428 | ||
|
|
69f8a09ceb | ||
|
|
bf56df28fa | ||
|
|
3e49bc1836 | ||
|
|
ad069e5e9f | ||
|
|
5adfac4db2 | ||
|
|
1ecfa1566f | ||
|
|
724cb5e9f5 | ||
|
|
69a9f36100 | ||
|
|
450dfed0a3 | ||
|
|
c1404ec522 | ||
|
|
bcff2f338f | ||
|
|
5582a5851f | ||
|
|
1d0794d135 | ||
|
|
0e20f211f2 | ||
|
|
6f4a2bec97 | ||
|
|
85e5e3007b | ||
|
|
4760ab01d5 | ||
|
|
d8fc106a89 | ||
|
|
f4bf2786de | ||
|
|
c2e7e38f97 | ||
|
|
343d358d22 | ||
|
|
c219aa2b30 | ||
|
|
5ba325b93f | ||
|
|
dc1a65f234 | ||
|
|
48a198091e | ||
|
|
81020c9ba0 | ||
|
|
c47f3957bf | ||
|
|
68e94fe284 | ||
|
|
265edf8f63 | ||
|
|
322a10bf0c | ||
|
|
f6688c84ab | ||
|
|
62a5934220 | ||
|
|
64dedae516 | ||
|
|
1ff2539574 | ||
|
|
219a4cdb52 | ||
|
|
322e6907ab | ||
|
|
c39527b3b5 | ||
|
|
068f78f86c | ||
|
|
87ef7ebaf0 | ||
|
|
996208b03d | ||
|
|
ec54bbb8c5 | ||
|
|
b52a47770d | ||
|
|
61e3144de4 | ||
|
|
895af4f865 | ||
|
|
c956f6a3e3 | ||
|
|
d52effa343 | ||
|
|
4313e4a442 | ||
|
|
9ecc96e92b | ||
|
|
3df28a3a9a | ||
|
|
fff8b241c0 | ||
|
|
46d1284550 | ||
|
|
25717d83fd | ||
|
|
bca711a50d | ||
|
|
0449a93b31 | ||
|
|
58b24e50ff | ||
|
|
0cc477b7e8 | ||
|
|
4117ffb90a | ||
|
|
a8302ff3e2 | ||
|
|
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 | ||
|
|
902be61924 | ||
|
|
e9f6861d60 | ||
|
|
8f0c5aa309 | ||
|
|
a32ca75126 |
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: Anthonyy232
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1,43 @@
|
||||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static content to Pages
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: '.'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -1,5 +1,6 @@
|
||||
*.iml
|
||||
.gradle
|
||||
.idea
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
@@ -13,3 +14,8 @@
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
/app/build
|
||||
/app/release
|
||||
/app/schemas
|
||||
.kotlin
|
||||
/.kotlin/sessions
|
||||
Generated
-3
@@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
-1
@@ -1 +0,0 @@
|
||||
Paperize
|
||||
Generated
-26
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AppInsightsSettings">
|
||||
<option name="tabSettings">
|
||||
<map>
|
||||
<entry key="Firebase Crashlytics">
|
||||
<value>
|
||||
<InsightsFilterSettings>
|
||||
<option name="connection">
|
||||
<ConnectionSetting>
|
||||
<option name="appId" value="PLACEHOLDER" />
|
||||
<option name="mobileSdkAppId" value="" />
|
||||
<option name="projectId" value="" />
|
||||
<option name="projectNumber" value="" />
|
||||
</ConnectionSetting>
|
||||
</option>
|
||||
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||
<option name="timeIntervalDays" value="THIRTY_DAYS" />
|
||||
<option name="visibilityType" value="ALL" />
|
||||
</InsightsFilterSettings>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-123
@@ -1,123 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
Generated
-5
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-23
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="Paperize">
|
||||
<State>
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="RFCTA1MRS4H" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-04-24T06:32:43.708081Z" />
|
||||
</State>
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-19
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.0" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-54
@@ -1,54 +0,0 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="15">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jspecify.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="4" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="9" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
|
||||
<item index="10" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="12" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="13" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
<item index="14" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="14">
|
||||
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="org.jspecify.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
<item index="6" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||
<item index="8" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="10" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||
<item index="13" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
<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>
|
||||
<p align="center">
|
||||
</p>
|
||||
</p>
|
||||
<p>Paperize is a dynamic wallpaper changer application designed to keep your device's aesthetic fresh and exciting</p>
|
||||
</div>
|
||||
@@ -10,30 +11,40 @@
|
||||
|
||||
## Features
|
||||
- **Dynamic Wallpaper Changer**: Set your wallpaper to change at specific time intervals
|
||||
- **Supports Various Image Types**: Paperize can handle a wide range of image types, offering you flexibility in your wallpaper choices
|
||||
- **Supports Various Image Types**: Paperize can handle a wide range of image types
|
||||
- Including: JPEG, PNG, AVIF, WEBP
|
||||
- **Folder Support**: Organize your wallpapers into folders for auto-updating
|
||||
- **Home and Lock Screen Wallpaper**: Choose to change either your home screen, lock screen, or both
|
||||
- **On-Device Storage**: All your wallpapers and settings are stored on your device
|
||||
<div align="center">
|
||||
<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/60a4d68d-5e19-49f2-8822-e702d02651c6" 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/7093a1ea-91ab-4da8-a82b-43e24d88d376" 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/57122f72-78f8-45ed-a9ac-de943061d6a2" width="30%" alt="onboarding" />
|
||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/9f41d715-7b14-4ff2-9c30-87ad3d86d94c" width="30%" alt="wallpaper" />
|
||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/47aa95c3-ef80-4c3c-a8cd-a51ac6824507" width="30%" alt="interval" />
|
||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/4ce1b28d-f4b2-4048-a261-203156222263" width="30%" alt="album" />
|
||||
<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/66b092e5-4af4-4396-b145-63ee506d9257" width="30%" alt="settings" />
|
||||
<br/>
|
||||
<br/>
|
||||
<div><video controls src="https://github.com/Anthonyy232/Paperize/assets/60626873/015afb04-e3f3-4641-b8f9-707cfa26d16f" muted="true"></video></div>
|
||||
</div>
|
||||
|
||||
|
||||
## Download
|
||||
|
||||
[<img src="https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png" alt="Download app from Google Play" height="80">](https://play.google.com/store/apps/details?id=com.anthonyla.paperize)
|
||||
[<img src="https://github.com/Anthonyy232/Paperize/assets/60626873/1c034414-21cd-4a0a-838d-89fe7bd56910" alt="Download app from GitHub" height="80">](https://github.com/Anthonyy232/Paperize/releases)
|
||||
[<img src="https://gitlab.com/IzzyOnDroid/repo/-/raw/master/assets/IzzyOnDroid.png" alt="Download app from IzzyOnDroid" height="80">](https://apt.izzysoft.de/fdroid/index/apk/com.anthonyla.paperize)
|
||||
|
||||
Playstore and F-Droid will be added soon
|
||||
F-Droid will be added soon
|
||||
|
||||
## Localization
|
||||
I want to allow more people to use the app. Currently, most of the 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
|
||||
|
||||
- [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
|
||||
- [Jetpack Compose](https://developer.android.com/develop/ui/compose) - A declarative UI toolkit for building native Android UI
|
||||
- [Material 3](https://m3.material.io/) - A UI design system git for modern UI guidelines
|
||||
- [Dagger Hilt](https://dagger.dev/hilt/) - A dependency injection library
|
||||
@@ -42,18 +53,20 @@ Playstore and F-Droid will be added soon
|
||||
- [Lottie Compose](https://github.com/airbnb/lottie) - A library that provides Lottie animation support for Jetpack Compose
|
||||
- [Landscapist](https://github.com/skydoves/landscapist) - A Compose and KPP image loading library that streamlines Glide, Coil, and Fresco
|
||||
- [Zoomable](https://github.com/usuiat/Zoomable) - A library that provides a zoomable and pannable view, which can be used with any view you want
|
||||
- [AnimatedFABMenu](https://github.com/rajaumair7890/AnimatedFABMenu) - A animated floating action button with Material 3 design
|
||||
- [DocumentFileCompat](https://github.com/ItzNotABug/DocumentFileCompat) - A DocumentFile wrapper that caches the result to improve efficiency
|
||||
|
||||
Thanks to the creators and maintainers of the open-source libraries used in this project.
|
||||
|
||||
|
||||
## Build
|
||||
|
||||
This project is built using Kotlin, Java, and Gradle. Here are the steps to build the project:
|
||||
|
||||
### Prerequisites
|
||||
- Java 8 (1.8)
|
||||
- Android Studio Iguana | 2023.2.1 or later
|
||||
- Gradle 8.3.2 or later
|
||||
- Android Studio Jellyfish | 2024.1.1 or later
|
||||
- Android Gradle Plugin 8.5.0 or later
|
||||
- Gradle 8.9
|
||||
- Minimum SDK 26
|
||||
|
||||
### Steps
|
||||
@@ -67,8 +80,14 @@ This project is built using Kotlin, Java, and Gradle. Here are the steps to buil
|
||||
|
||||
All contributions to the app is welcome. Feel free to report any issues and create pull requests for any issues or pull requests.
|
||||
|
||||
Inspiration from j4velin for their wallpaper changer app
|
||||
|
||||
## Donations
|
||||
|
||||
If you want to donate, you can do so using GitHub sponsorship (one-time or monthly). I appreciate the thought, thanks!
|
||||
|
||||
|
||||
## License
|
||||
Contact on my GitHub profile
|
||||
|
||||
Paperize © GNU GPL v3.0
|
||||
Anthony La © GNU GPL v3.0
|
||||
+66
-33
@@ -3,11 +3,14 @@ plugins {
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("com.google.devtools.ksp")
|
||||
id("com.google.dagger.hilt.android")
|
||||
id ("com.mikepenz.aboutlibraries.plugin")
|
||||
id("com.mikepenz.aboutlibraries.plugin")
|
||||
id("org.jetbrains.kotlin.plugin.serialization")
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
ksp {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.anthonyla.paperize"
|
||||
compileSdk = 34
|
||||
@@ -16,9 +19,8 @@ android {
|
||||
applicationId = "com.anthonyla.paperize"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
versionCode = 29
|
||||
versionName = "1.6.4"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
@@ -32,21 +34,45 @@ android {
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
ndk {
|
||||
debugSymbolLevel = "FULL"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs += strongSkippingConfiguration()
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
viewBinding = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.1"
|
||||
kotlinCompilerExtensionVersion = "1.5.14"
|
||||
}
|
||||
|
||||
androidResources {
|
||||
generateLocaleConfig = true
|
||||
}
|
||||
|
||||
ndkVersion = "26.3.11579264"
|
||||
buildToolsVersion = "34.0.0"
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
includeInBundle = false
|
||||
}
|
||||
|
||||
aboutLibraries {
|
||||
excludeFields = arrayOf("generated")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,44 +83,51 @@ androidComponents {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.core:core-ktx:1.13.0")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
||||
implementation("androidx.activity:activity-compose:1.9.0")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.04.01"))
|
||||
implementation("androidx.compose.ui:ui:1.6.6")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.6.6")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.6.6")
|
||||
implementation("androidx.compose.material3:material3:1.2.1")
|
||||
implementation("androidx.navigation:navigation-compose:2.8.0-alpha07")
|
||||
implementation("androidx.compose.material:material:1.6.6")
|
||||
implementation("androidx.datastore:datastore:1.1.0")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.0")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.6.6")
|
||||
implementation("com.google.accompanist:accompanist-adaptive:0.34.0")
|
||||
implementation("androidx.core:core-ktx:1.13.1")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
|
||||
implementation("androidx.activity:activity-compose:1.9.1")
|
||||
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
|
||||
implementation("androidx.compose.ui:ui:1.7.0-beta06")
|
||||
implementation("androidx.compose.ui:ui-graphics:1.7.0-beta06")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview:1.7.0-beta06")
|
||||
implementation("androidx.compose.material3:material3:1.3.0-beta05")
|
||||
implementation("androidx.navigation:navigation-compose:2.8.0-beta06")
|
||||
implementation("androidx.compose.material:material:1.7.0-beta06")
|
||||
implementation("androidx.datastore:datastore:1.1.1")
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.1")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.7.0-beta06")
|
||||
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
|
||||
implementation("androidx.compose.animation:animation:1.7.0-alpha07")
|
||||
implementation("androidx.core:core-splashscreen:1.1.0-rc01")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("androidx.compose.animation:animation:1.7.0-beta06")
|
||||
implementation("androidx.core:core-splashscreen:1.2.0-alpha01")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.4")
|
||||
implementation("com.google.code.gson:gson:2.11.0")
|
||||
implementation("androidx.documentfile:documentfile:1.1.0-alpha01")
|
||||
implementation("net.engawapg.lib:zoomable:1.7.0-beta02")
|
||||
implementation("com.github.skydoves:landscapist-glide:2.3.3")
|
||||
implementation("com.github.skydoves:landscapist-glide:2.3.6")
|
||||
implementation("androidx.work:work-runtime-ktx:2.10.0-alpha02")
|
||||
implementation("androidx.hilt:hilt-work:1.2.0")
|
||||
implementation("com.airbnb.android:lottie-compose:6.4.0")
|
||||
implementation("com.airbnb.android:lottie-compose:6.4.1")
|
||||
implementation("com.google.accompanist:accompanist-permissions:0.35.0-alpha")
|
||||
implementation("com.mikepenz:aboutlibraries-core:11.1.3")
|
||||
implementation("com.mikepenz:aboutlibraries-compose-m3:11.1.3")
|
||||
implementation("com.mikepenz:aboutlibraries-core:11.2.2")
|
||||
implementation("com.mikepenz:aboutlibraries-compose-m3:11.2.2")
|
||||
implementation("androidx.compose.foundation:foundation:1.7.0-beta06")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0-alpha03")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.6")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.6.6")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.6")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.0-beta06")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling:1.7.0-beta06")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta06")
|
||||
implementation("com.google.dagger:hilt-android:2.51.1")
|
||||
ksp("com.google.dagger:hilt-android-compiler:2.51.1")
|
||||
implementation("androidx.room:room-runtime:2.6.1")
|
||||
ksp("androidx.room:room-compiler:2.6.1")
|
||||
implementation("androidx.room:room-ktx:2.6.1")
|
||||
implementation("com.lazygeniouz:dfc:1.0.8")
|
||||
}
|
||||
implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
|
||||
implementation("com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3")
|
||||
}
|
||||
|
||||
private fun strongSkippingConfiguration() = listOf(
|
||||
"-P",
|
||||
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true",
|
||||
)
|
||||
Vendored
+2
-2
@@ -14,7 +14,7 @@
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
@@ -26,7 +26,7 @@
|
||||
-keepclassmembers class com.anthonyla.paperize.feature.wallpaper.domain.model.Album {
|
||||
!transient <fields>;
|
||||
}
|
||||
-keepclassmembers class com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaper {
|
||||
-keepclassmembers class com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder {
|
||||
!transient <fields>;
|
||||
}
|
||||
-keepclassmembers class com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper {
|
||||
|
||||
@@ -2,43 +2,62 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.paperize"
|
||||
android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:allowBackup="false"
|
||||
android:name=".App"
|
||||
android:persistent="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@mipmap/app_icon"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Paperize"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
tools:targetApi="tiramisu">
|
||||
android:theme="@style/Theme.Paperize" tools:targetApi="tiramisu">
|
||||
<activity
|
||||
android:name=".feature.wallpaper.presentation.MainActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.Paperize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<meta-data android:resource="@xml/shortcuts" android:name="android.app.shortcuts" />
|
||||
</activity>
|
||||
<service android:name=".feature.wallpaper.wallpaperservice.WallpaperService" android:foregroundServiceType="mediaPlayback"/>
|
||||
<receiver android:name=".feature.wallpaper.wallpaperservice.WallpaperBootReceiver"
|
||||
android:exported="true">
|
||||
<activity android:name=".feature.wallpaper.app_shortcut.BroadcastActivity"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
</activity>
|
||||
<receiver android:name=".feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver" />
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.WallpaperService1"/>
|
||||
<service android:name=".feature.wallpaper.wallpaper_service.WallpaperService2"/>
|
||||
<service
|
||||
android:name=".feature.wallpaper.wallpaper_tile.ChangeWallpaperTileService"
|
||||
android:exported="true"
|
||||
android:label="@string/change_wallpaper"
|
||||
android:icon="@drawable/notification_icon"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter>
|
||||
</service>
|
||||
<receiver android:name=".feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
android:exported="false"
|
||||
tools:node="merge">
|
||||
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
|
||||
tools:node="remove" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -4,7 +4,6 @@ import android.app.Application
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.anthonyla.paperize.core
|
||||
|
||||
enum class ScalingConstants {
|
||||
FIT,
|
||||
FILL,
|
||||
STRETCH
|
||||
}
|
||||
@@ -6,12 +6,25 @@ package com.anthonyla.paperize.core
|
||||
object SettingsConstants {
|
||||
const val SETTINGS_DATASTORE = "settings_datastore"
|
||||
const val DARK_MODE_TYPE = "dark_mode_type"
|
||||
const val AMOLED_THEME_TYPE = "amoled_theme_type"
|
||||
const val DYNAMIC_THEME_TYPE = "dynamic_theme_type"
|
||||
const val ANIMATE_TYPE = "animate_type"
|
||||
const val WALLPAPER_CHANGE_INTERVAL = "wallpaper_change_interval"
|
||||
const val ENABLE_CHANGER = "enable_changer"
|
||||
const val HOME_WALLPAPER = "home_wallpaper"
|
||||
const val LOCK_WALLPAPER = "lock_wallpaper"
|
||||
const val HOME_WALLPAPER_CHANGE_INTERVAL = "home_wallpaper_change_interval"
|
||||
const val LOCK_WALLPAPER_CHANGE_INTERVAL = "lock_wallpaper_change_interval"
|
||||
const val WALLPAPER_CHANGE_INTERVAL_DEFAULT = 15
|
||||
const val SET_LOCK_WITH_HOME = "set_lock_with_home"
|
||||
const val FIRST_LAUNCH = "first_launch"
|
||||
const val FIRST_SET = "first_set"
|
||||
const val LAST_SET_TIME = "last_set_time"
|
||||
const val NEXT_SET_TIME = "next_set_time"
|
||||
const val DARKEN_PERCENTAGE = "darken_percentage"
|
||||
const val DARKEN = "darken"
|
||||
const val WALLPAPER_SCALING = "wallpaper_scaling"
|
||||
const val SCHEDULE_SEPARATELY = "schedule_separately"
|
||||
const val BLUR = "blur"
|
||||
const val BLUR_PERCENTAGE = "blur_percentage"
|
||||
const val NEXT_SET_TIME_1 = "next_set_time_1"
|
||||
const val NEXT_SET_TIME_2 = "next_set_time_2"
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.anthonyla.paperize.core
|
||||
import android.app.WallpaperManager
|
||||
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.core.net.toUri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.google.android.renderscript.Toolkit
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
|
||||
enum class Type { HOME, LOCK, BOTH, REFRESH }
|
||||
|
||||
/**
|
||||
* Get the dimensions of the image from the uri
|
||||
*/
|
||||
fun Uri.getImageDimensions(context: Context): Size? {
|
||||
try {
|
||||
context.contentResolver.openInputStream(this)?.use { inputStream ->
|
||||
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)
|
||||
}
|
||||
return null
|
||||
} catch (e: Exception) { return null }
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 scaledBitmap = Bitmap.createScaledBitmap(source, width, newHeight, true)
|
||||
val top = (height - newHeight) / 2f
|
||||
canvas.drawBitmap(scaledBitmap, 0f, top, null)
|
||||
scaledBitmap.recycle()
|
||||
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)
|
||||
scaledBitmap.recycle()
|
||||
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)
|
||||
bitmap.recycle()
|
||||
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): Bitmap {
|
||||
try {
|
||||
val safePercentage = (100 - percent).coerceIn(0, 100)
|
||||
val factor = 1 - safePercentage / 100f
|
||||
val canvas = Canvas(source)
|
||||
val paint = Paint().apply {
|
||||
colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
||||
setScale(factor, factor, factor, 1f)
|
||||
})
|
||||
}
|
||||
canvas.drawBitmap(source, 0f, 0f, paint)
|
||||
return source
|
||||
} catch (e: Exception) {
|
||||
Log.e("WallpaperUtil", "Error darkening bitmap: $e")
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
||||
fun blurBitmap(source: Bitmap, percent: Int): Bitmap {
|
||||
try {
|
||||
val factor = percent.toFloat().div(100f) * 10
|
||||
return Toolkit.blur(source, factor.toInt())
|
||||
} catch (e: Exception) {
|
||||
Log.e("WallpaperUtil", "Error darkening bitmap: $e")
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve wallpaper URIs from a folder directory URI
|
||||
*/
|
||||
fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
||||
try {
|
||||
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
||||
return listFilesRecursive(folderDocumentFile, context)
|
||||
} catch (e: Exception) {
|
||||
val folderDocumentFile = DocumentFile.fromTreeUri(context, folderUri.toUri())
|
||||
return listFilesRecursive(folderDocumentFile, context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to recursively list files in a directory for DocumentFileCompat
|
||||
*/
|
||||
fun listFilesRecursive(parent: DocumentFileCompat?, context: Context): List<String> {
|
||||
val files = mutableListOf<String>()
|
||||
parent?.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||
if (file.extension in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
/** Overloaded version of the function for DocumentFile */
|
||||
fun listFilesRecursive(parent: DocumentFile?, context: Context): List<String> {
|
||||
val files = mutableListOf<String>()
|
||||
parent?.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val allowedExtensions = listOf("jpg", "jpeg", "png", "heif", "webp", "JPG", "JPEG", "PNG", "HEIF", "WEBP")
|
||||
if ((file.name?.substringAfterLast(".") ?: "") in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to find the first valid URI from a list of wallpapers
|
||||
* It will search through all wallpapers of an album first, and then all wallpapers of every folder of an album
|
||||
*/
|
||||
fun findFirstValidUri(context: Context, wallpapers: List<Wallpaper>, folders: List<Folder>): String? {
|
||||
wallpapers.forEach { wallpaper ->
|
||||
try {
|
||||
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper.wallpaperUri
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper.wallpaperUri
|
||||
}
|
||||
}
|
||||
}
|
||||
folders.forEach { folder ->
|
||||
folder.wallpapers.forEach { wallpaper ->
|
||||
try {
|
||||
val file = DocumentFileCompat.fromSingleUri(context, wallpaper.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the folder name from the folder URI
|
||||
*/
|
||||
fun getFolderNameFromUri(folderUri: String, context: Context): String? {
|
||||
return try {
|
||||
DocumentFileCompat.fromTreeUri(context, folderUri.toUri())?.name
|
||||
} catch (e: Exception) {
|
||||
DocumentFile.fromTreeUri(context, folderUri.toUri())?.name
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a URI is valid
|
||||
*/
|
||||
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 }
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device uses a live wallpaper
|
||||
*/
|
||||
fun isLiveWallpaperSet(context: Context): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
return wallpaperManager.wallpaperInfo != null
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ object AppModule {
|
||||
app,
|
||||
AlbumDatabase::class.java,
|
||||
AlbumDatabase.DATABASE_NAME
|
||||
).build()
|
||||
).fallbackToDestructiveMigration().addMigrations().build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -41,7 +41,7 @@ object AppModule {
|
||||
app,
|
||||
SelectedAlbumDatabase::class.java,
|
||||
SelectedAlbumDatabase.DATABASE_NAME
|
||||
).build()
|
||||
).fallbackToDestructiveMigration().addMigrations().build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.app_shortcut
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperBootAndChangeReceiver
|
||||
|
||||
class BroadcastActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val intent = Intent("WallpaperBootAndChangeReceiver.intent.action.BROADCAST").setClass(this, WallpaperBootAndChangeReceiver::class.java)
|
||||
sendBroadcast(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
+16
@@ -66,4 +66,20 @@ interface AlbumDao {
|
||||
|
||||
@Update
|
||||
suspend fun updateFolder(folder: Folder)
|
||||
|
||||
@Query("DELETE FROM album")
|
||||
suspend fun deleteAllAlbums()
|
||||
|
||||
@Query("DELETE FROM wallpaper")
|
||||
suspend fun deleteAllWallpapers()
|
||||
|
||||
@Query("DELETE FROM folder")
|
||||
suspend fun deleteAllFolders()
|
||||
|
||||
@Transaction
|
||||
suspend fun deleteAllData() {
|
||||
deleteAllWallpapers()
|
||||
deleteAllFolders()
|
||||
deleteAllAlbums()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class, Folder::class],
|
||||
version = 1
|
||||
version = 4
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AlbumDatabase: RoomDatabase() {
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ package com.anthonyla.paperize.feature.wallpaper.data.data_source
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
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
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
*/
|
||||
@Database(
|
||||
entities = [Album::class, Wallpaper::class],
|
||||
version = 1
|
||||
version = 4
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class SelectedAlbumDatabase: RoomDatabase() {
|
||||
|
||||
+4
@@ -86,4 +86,8 @@ class AlbumRepositoryImpl(
|
||||
override suspend fun deleteWallpaperList(wallpapers: List<Wallpaper>) {
|
||||
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.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.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.SelectedAlbumRepository
|
||||
@@ -17,6 +15,7 @@ class SelectedAlbumRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun upsertSelectedAlbum(selectedAlbum: SelectedAlbum) {
|
||||
dao.deleteAll()
|
||||
dao.upsertAlbum(selectedAlbum.album)
|
||||
dao.upsertWallpaperList(selectedAlbum.wallpapers)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ import androidx.room.PrimaryKey
|
||||
* @param displayedAlbumName The displayed album name
|
||||
* @param coverUri The cover uri of the album
|
||||
* @param initialized Whether the album has been initialized
|
||||
* @param wallpapersInQueue The wallpapers in the queue to be displayed
|
||||
* @param homeWallpapersInQueue The wallpapers in the queue to be displayed for the home screen or when the user schedules both lock and home together
|
||||
* @param lockWallpapersInQueue The wallpapers in the queue to be displayed for the lock screen when scheduled separately
|
||||
* @param currentHomeWallpaper The current wallpaper for the home screen
|
||||
* @param currentLockWallpaper The current wallpaper for the lock screen
|
||||
*/
|
||||
@Entity
|
||||
data class Album(
|
||||
@@ -18,5 +21,8 @@ data class Album(
|
||||
val displayedAlbumName: String,
|
||||
val coverUri: String?,
|
||||
val initialized: Boolean = false,
|
||||
val wallpapersInQueue: List<String> = emptyList(),
|
||||
val homeWallpapersInQueue: List<String> = emptyList(),
|
||||
val lockWallpapersInQueue: List<String> = emptyList(),
|
||||
val currentHomeWallpaper: String? = null,
|
||||
val currentLockWallpaper: String? = null
|
||||
)
|
||||
+5
@@ -96,4 +96,9 @@ interface AlbumRepository {
|
||||
* Delete folder list in one transaction
|
||||
*/
|
||||
suspend fun deleteFolderList(folders: List<Folder>)
|
||||
|
||||
/**
|
||||
* Delete all data in database
|
||||
*/
|
||||
suspend fun deleteAllData()
|
||||
}
|
||||
+110
-4
@@ -1,25 +1,50 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation
|
||||
|
||||
import android.Manifest
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.Activity
|
||||
import android.app.AlarmManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.compose.LifecycleEventEffect
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.core.Type
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.themes.PaperizeTheme
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreenViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperReceiver
|
||||
import com.anthonyla.paperize.feature.wallpaper.wallpaper_alarmmanager.WallpaperAlarmSchedulerImpl
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -30,22 +55,103 @@ class MainActivity : ComponentActivity() {
|
||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||
private val wallpaperScreenViewModel: WallpaperScreenViewModel by viewModels()
|
||||
private val context = this
|
||||
private var topInset = 0.dp
|
||||
@Inject lateinit var settingsDataStoreImpl: SettingsDataStore
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.SET_WALLPAPER) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(context as Activity, arrayOf(Manifest.permission.SET_WALLPAPER), 0)
|
||||
}
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT),
|
||||
navigationBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT)
|
||||
)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
val splashScreen = installSplashScreen()
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||
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 }
|
||||
|
||||
setContent {
|
||||
val scheduler = WallpaperAlarmSchedulerImpl(context)
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val isFirstLaunch = runBlocking { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) } ?: true
|
||||
PaperizeTheme(settingsViewModel.state) {
|
||||
if (isFirstLaunch) {
|
||||
scheduler.cancelWallpaperAlarm()
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
settingsViewModel.onEvent(SettingsEvent.Reset)
|
||||
albumsViewModel.onEvent(AlbumsEvent.Reset)
|
||||
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_CREATE) {
|
||||
lifecycleScope.launch {
|
||||
if (settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) == true) {
|
||||
val shouldScheduleSeparately = settingsDataStoreImpl.getBoolean(SettingsConstants.SCHEDULE_SEPARATELY) ?: false
|
||||
val shouldScheduleAlarm = if (shouldScheduleSeparately) {
|
||||
!(isPendingIntentSet(Type.HOME.ordinal) && isPendingIntentSet(Type.LOCK.ordinal))
|
||||
} else {
|
||||
!isPendingIntentSet(Type.BOTH.ordinal)
|
||||
}
|
||||
if (shouldScheduleAlarm) {
|
||||
scheduler.scheduleWallpaperAlarm(
|
||||
WallpaperAlarmItem(
|
||||
timeInMinutes1 = settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
timeInMinutes2 = settingsDataStoreImpl.getInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
scheduleSeparately = shouldScheduleSeparately
|
||||
), null, true, true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PaperizeTheme(settingsState.value.darkMode, settingsState.value.amoledTheme, settingsState.value.dynamicTheming) {
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
PaperizeApp(isFirstLaunch)
|
||||
PaperizeApp(isFirstLaunch, scheduler, topInset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val alarmManager = ContextCompat.getSystemService(context, AlarmManager::class.java)
|
||||
if (alarmManager?.canScheduleExactAlarms() == false) {
|
||||
Intent().also { intent ->
|
||||
intent.action = Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
topInset = window.decorView.rootWindowInsets.stableInsetTop.dp
|
||||
}
|
||||
|
||||
private fun isPendingIntentSet(requestCode: Int): Boolean {
|
||||
val intent = Intent(context.applicationContext, WallpaperReceiver::class.java)
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
context.applicationContext,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_NO_CREATE
|
||||
)
|
||||
return pendingIntent != null
|
||||
}
|
||||
}
|
||||
+573
-223
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -2,7 +2,7 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
||||
|
||||
sealed class AddAlbumEvent {
|
||||
data object SaveAlbum: AddAlbumEvent()
|
||||
data object ClearState: AddAlbumEvent()
|
||||
data object Reset: AddAlbumEvent()
|
||||
data object DeleteSelected: AddAlbumEvent()
|
||||
data object SelectAll: AddAlbumEvent()
|
||||
data object DeselectAll: AddAlbumEvent()
|
||||
@@ -12,8 +12,8 @@ sealed class AddAlbumEvent {
|
||||
data class ReflectAlbumName(
|
||||
val newAlbumName: String
|
||||
): AddAlbumEvent()
|
||||
data class AddWallpaper(
|
||||
val wallpaperUri: String
|
||||
data class AddWallpapers(
|
||||
val wallpaperUris: List<String>
|
||||
): AddAlbumEvent()
|
||||
data class AddFolder(
|
||||
val directoryUri: String
|
||||
|
||||
+49
-58
@@ -2,15 +2,11 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.scaleIn
|
||||
import androidx.compose.animation.scaleOut
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -31,54 +27,46 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
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.AddAlbumFabMenuOptions
|
||||
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.WallpaperItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
|
||||
@Composable
|
||||
fun AddAlbumScreen(
|
||||
addAlbumViewModel: AddAlbumViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
initialAlbumName: String,
|
||||
onBackClick: () -> Unit,
|
||||
onConfirmation: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
onShowFolderView: (String, String?, List<String>) -> Unit
|
||||
onShowFolderView: (String?, List<String>) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val lazyGridState = rememberLazyStaggeredGridState()
|
||||
val addAlbumState = addAlbumViewModel.state.collectAsStateWithLifecycle()
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
var selectionMode by rememberSaveable { mutableStateOf(false) }
|
||||
if (addAlbumState.value.initialAlbumName.isEmpty()) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SetAlbumName(initialAlbumName))
|
||||
}
|
||||
var showSpotlight by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
BackHandler {
|
||||
if (selectionMode) {
|
||||
selectionMode = false
|
||||
BackHandler(
|
||||
enabled = selectionMode,
|
||||
onBack = {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.DeselectAll)
|
||||
} else {
|
||||
onBackClick()
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
selectionMode = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** Image picker **/
|
||||
val imagePickerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.OpenMultipleDocuments(),
|
||||
onResult = { uris: List<Uri> ->
|
||||
for (uri in uris) {
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
val uriList = uris.mapNotNull { uri ->
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.AddWallpaper(wallpaperUri = uri.toString()))
|
||||
} else {
|
||||
Log.e("AddAlbumScreen", "Failed to persist permission for $uri")
|
||||
}
|
||||
if (persistedUriPermissions.any { it.uri == uri }) uri.toString() else null
|
||||
}
|
||||
if (uriList.isNotEmpty()) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.AddWallpapers(uriList))
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -92,9 +80,7 @@ fun AddAlbumScreen(
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.AddFolder(directoryUri = uri.toString()))
|
||||
} else {
|
||||
Log.e("AddAlbumScreen", "Failed to persist permission for $uri")
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.AddFolder(uri.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,14 +93,17 @@ fun AddAlbumScreen(
|
||||
isEmpty = addAlbumState.value.isEmpty,
|
||||
selectionMode = selectionMode,
|
||||
albumState = addAlbumViewModel.state,
|
||||
showSpotlight = showSpotlight,
|
||||
onBackClick = {
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
showSpotlight = false
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
onBackClick()
|
||||
},
|
||||
onConfirmationClick = {
|
||||
showSpotlight = false
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ReflectAlbumName(it))
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.SaveAlbum)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.ClearState)
|
||||
addAlbumViewModel.onEvent(AddAlbumEvent.Reset)
|
||||
onConfirmation()
|
||||
},
|
||||
onSelectAllClick = {
|
||||
@@ -129,28 +118,17 @@ fun AddAlbumScreen(
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (settingsState.value.animate) {
|
||||
AnimatedVisibility(
|
||||
visible = !lazyGridState.isScrollInProgress || lazyGridState.firstVisibleItemScrollOffset < 0,
|
||||
enter = scaleIn(tween(400, 50, FastOutSlowInEasing)),
|
||||
exit = scaleOut(tween(400, 50, FastOutSlowInEasing)),
|
||||
) {
|
||||
AddAlbumAnimatedFab(
|
||||
menuOptions = AddAlbumFabMenuOptions(),
|
||||
onImageClick = { imagePickerLauncher.launch(arrayOf("image/*")) },
|
||||
onFolderClick = { folderPickerLauncher.launch(null) },
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
AddAlbumAnimatedFab(
|
||||
menuOptions = AddAlbumFabMenuOptions(),
|
||||
onImageClick = { imagePickerLauncher.launch(arrayOf("image/*")) },
|
||||
onFolderClick = { folderPickerLauncher.launch(null) },
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
},
|
||||
content = {
|
||||
LazyVerticalStaggeredGrid(
|
||||
@@ -162,7 +140,7 @@ fun AddAlbumScreen(
|
||||
contentPadding = PaddingValues(4.dp, 4.dp),
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
content = {
|
||||
items (items = addAlbumState.value.folders, key = { folder -> folder.folderUri.hashCode()}
|
||||
items (items = addAlbumState.value.folders, key = { folder -> folder.folderUri }
|
||||
) { folder ->
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
@@ -179,12 +157,18 @@ fun AddAlbumScreen(
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderUri, folder.folderName, folder.wallpapers)
|
||||
if (folder.wallpapers.isNotEmpty()) onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp)
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
items (items = addAlbumState.value.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri.hashCode()}
|
||||
items (items = addAlbumState.value.wallpapers, key = { wallpaper -> wallpaper.wallpaperUri }
|
||||
) { wallpaper ->
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
@@ -203,7 +187,14 @@ fun AddAlbumScreen(
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp)
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+93
-111
@@ -3,16 +3,15 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.core.getFolderNameFromUri
|
||||
import com.anthonyla.paperize.core.getWallpaperFromFolder
|
||||
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.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
@@ -59,8 +58,6 @@ class AddAlbumViewModel @Inject constructor(
|
||||
folders = _state.value.folders,
|
||||
)
|
||||
repository.upsertAlbumWithWallpaperAndFolder(albumWithWallpaperAndFolder)
|
||||
|
||||
//Clear viewModel state after adding album
|
||||
_state.update { it.copy(
|
||||
initialAlbumName = "",
|
||||
displayedAlbumName = "",
|
||||
@@ -77,13 +74,14 @@ class AddAlbumViewModel @Inject constructor(
|
||||
}
|
||||
is AddAlbumEvent.DeleteSelected -> {
|
||||
viewModelScope.launch {
|
||||
val wallpapersRemoved = _state.value.wallpapers.filterNot { it.wallpaperUri in _state.value.selectedWallpapers }
|
||||
val foldersRemoved = _state.value.folders.filterNot { it.folderUri in _state.value.selectedFolders }
|
||||
_state.update { it.copy(
|
||||
wallpapers = wallpapersRemoved,
|
||||
folders = foldersRemoved
|
||||
) }
|
||||
updateIsEmpty()
|
||||
_state.update {
|
||||
val wallpapersRemoved = it.wallpapers.filterNot { it.wallpaperUri in _state.value.selectedWallpapers }
|
||||
val foldersRemoved = it.folders.filterNot { it.folderUri in _state.value.selectedFolders }
|
||||
it.copy(
|
||||
wallpapers = wallpapersRemoved,
|
||||
folders = foldersRemoved,
|
||||
isEmpty = wallpapersRemoved.isEmpty() && foldersRemoved.isEmpty()
|
||||
) }
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.SetAlbumName -> {
|
||||
@@ -98,55 +96,71 @@ class AddAlbumViewModel @Inject constructor(
|
||||
is AddAlbumEvent.ReflectAlbumName -> {
|
||||
if (event.newAlbumName != _state.value.initialAlbumName) {
|
||||
viewModelScope.launch {
|
||||
_state.update { it.copy(
|
||||
initialAlbumName = event.newAlbumName,
|
||||
displayedAlbumName = event.newAlbumName,
|
||||
coverUri = it.coverUri,
|
||||
wallpapers = it.wallpapers.map { wallpaper ->
|
||||
_state.update {
|
||||
val wallpapers = it.wallpapers.map { wallpaper ->
|
||||
wallpaper.copy(initialAlbumName = event.newAlbumName)
|
||||
},
|
||||
folders = it.folders.map { folder ->
|
||||
}
|
||||
val folders = it.folders.map { folder ->
|
||||
folder.copy(initialAlbumName = event.newAlbumName)
|
||||
},
|
||||
) }
|
||||
updateIsEmpty()
|
||||
}
|
||||
it.copy(
|
||||
initialAlbumName = event.newAlbumName,
|
||||
displayedAlbumName = event.newAlbumName,
|
||||
coverUri = it.coverUri,
|
||||
wallpapers = wallpapers,
|
||||
folders = folders,
|
||||
isEmpty = wallpapers.isEmpty() && folders.isEmpty()
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.AddWallpaper -> {
|
||||
is AddAlbumEvent.AddWallpapers -> {
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.wallpapers.any { it.wallpaperUri == event.wallpaperUri }) {
|
||||
_state.update { it.copy(
|
||||
wallpapers = it.wallpapers.plus(
|
||||
Wallpaper(
|
||||
initialAlbumName = it.initialAlbumName,
|
||||
wallpaperUri = event.wallpaperUri,
|
||||
key = event.wallpaperUri.hashCode() + it.initialAlbumName.hashCode(),
|
||||
)
|
||||
),
|
||||
) }
|
||||
updateIsEmpty()
|
||||
val newWallpaperUris = event.wallpaperUris.filterNot { it in _state.value.wallpapers.map { wallpaper -> wallpaper.wallpaperUri } }
|
||||
val newWallpapers = newWallpaperUris.map { uri ->
|
||||
Wallpaper(
|
||||
initialAlbumName = _state.value.initialAlbumName,
|
||||
wallpaperUri = uri,
|
||||
key = uri.hashCode() + _state.value.initialAlbumName.hashCode(),
|
||||
)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedFolders = emptyList(),
|
||||
selectedWallpapers = emptyList(),
|
||||
allSelected = false,
|
||||
selectedCount = 0,
|
||||
wallpapers = it.wallpapers.plus(newWallpapers),
|
||||
isEmpty = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.AddFolder -> {
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.folders.any { it.folderUri == event.directoryUri }) {
|
||||
if (event.directoryUri !in _state.value.folders.map { it.folderUri }) {
|
||||
val wallpapers: List<String> = getWallpaperFromFolder(event.directoryUri, context)
|
||||
if (wallpapers.isEmpty()) { return@launch }
|
||||
val folderName = getFolderNameFromUri(event.directoryUri, context)
|
||||
_state.update { state ->
|
||||
state.copy( folders = state.folders.plus(
|
||||
Folder(
|
||||
initialAlbumName = state.initialAlbumName,
|
||||
folderName = folderName,
|
||||
folderUri = event.directoryUri,
|
||||
coverUri = wallpapers.randomOrNull(),
|
||||
wallpapers = wallpapers,
|
||||
key = event.directoryUri.hashCode() + state.initialAlbumName.hashCode()
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedFolders = emptyList(),
|
||||
selectedWallpapers = emptyList(),
|
||||
allSelected = false,
|
||||
selectedCount = 0,
|
||||
isEmpty = false,
|
||||
folders = it.folders.plus(
|
||||
Folder(
|
||||
initialAlbumName = it.initialAlbumName,
|
||||
folderName = folderName,
|
||||
folderUri = event.directoryUri,
|
||||
coverUri = wallpapers.randomOrNull(),
|
||||
wallpapers = wallpapers,
|
||||
key = event.directoryUri.hashCode() + it.initialAlbumName.hashCode()
|
||||
)
|
||||
)
|
||||
),
|
||||
) }
|
||||
updateIsEmpty()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,9 +170,9 @@ class AddAlbumViewModel @Inject constructor(
|
||||
_state.update { it.copy(
|
||||
selectedFolders = _state.value.folders.map { folder -> folder.folderUri },
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,48 +189,57 @@ class AddAlbumViewModel @Inject constructor(
|
||||
is AddAlbumEvent.SelectFolder -> {
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
||||
_state.update { it.copy(
|
||||
selectedFolders = it.selectedFolders.plus(event.directoryUri),
|
||||
selectedCount = it.selectedCount + 1
|
||||
) }
|
||||
updateAllSelected()
|
||||
_state.update {
|
||||
val folders = it.selectedFolders.plus(event.directoryUri)
|
||||
it.copy(
|
||||
selectedFolders = folders,
|
||||
selectedCount = it.selectedCount + 1,
|
||||
allSelected = folders.size + it.selectedWallpapers.size >= it.wallpapers.size + it.folders.size
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.SelectWallpaper -> {
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
||||
_state.update { it.copy(
|
||||
selectedWallpapers = it.selectedWallpapers.plus(event.wallpaperUri),
|
||||
selectedCount = it.selectedCount + 1
|
||||
) }
|
||||
updateAllSelected()
|
||||
_state.update {
|
||||
val wallpapers = it.selectedWallpapers.plus(event.wallpaperUri)
|
||||
it.copy(
|
||||
selectedWallpapers = wallpapers,
|
||||
selectedCount = it.selectedCount + 1,
|
||||
allSelected = it.selectedFolders.size + wallpapers.size >= it.wallpapers.size + it.folders.size
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.RemoveFolderFromSelection -> {
|
||||
viewModelScope.launch {
|
||||
if (_state.value.selectedFolders.find { it == event.directoryUri } != null ) {
|
||||
_state.update { it.copy(
|
||||
selectedFolders = it.selectedFolders.minus(event.directoryUri),
|
||||
selectedCount = it.selectedCount - 1
|
||||
) }
|
||||
updateAllSelected()
|
||||
_state.update {
|
||||
val folders = it.selectedFolders.minus(event.directoryUri)
|
||||
it.copy(
|
||||
selectedFolders = folders,
|
||||
selectedCount = it.selectedCount - 1,
|
||||
allSelected = folders.size + it.selectedWallpapers.size >= it.wallpapers.size + it.folders.size
|
||||
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.RemoveWallpaperFromSelection -> {
|
||||
viewModelScope.launch {
|
||||
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null ) {
|
||||
_state.update { it.copy(
|
||||
selectedWallpapers = it.selectedWallpapers.minus(event.wallpaperUri),
|
||||
selectedCount = it.selectedCount - 1
|
||||
) }
|
||||
updateAllSelected()
|
||||
_state.update {
|
||||
val wallpapers = it.selectedWallpapers.minus(event.wallpaperUri)
|
||||
it.copy(
|
||||
selectedWallpapers = wallpapers,
|
||||
selectedCount = it.selectedCount - 1,
|
||||
allSelected = it.selectedFolders.size + wallpapers.size >= it.wallpapers.size + it.folders.size
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
is AddAlbumEvent.ClearState -> {
|
||||
is AddAlbumEvent.Reset -> {
|
||||
viewModelScope.launch {
|
||||
_state.update { it.copy(
|
||||
initialAlbumName = "",
|
||||
@@ -234,45 +257,4 @@ 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> {
|
||||
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
||||
return listFilesRecursive(folderDocumentFile, context)
|
||||
}
|
||||
|
||||
private fun listFilesRecursive(parent: DocumentFileCompat?, context: Context): List<String> {
|
||||
val files = mutableListOf<String>()
|
||||
parent?.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
||||
if (extension in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
private fun getFolderNameFromUri(folderUri: String, context: Context): String? {
|
||||
return DocumentFileCompat.fromTreeUri(context, folderUri.toUri())?.name
|
||||
}
|
||||
}
|
||||
+26
-10
@@ -21,12 +21,16 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Folder
|
||||
import androidx.compose.material.icons.filled.PhotoLibrary
|
||||
import androidx.compose.material.icons.filled.Remove
|
||||
import androidx.compose.material3.CardColors
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LargeFloatingActionButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -34,6 +38,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -46,7 +51,6 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.library_screen.comp
|
||||
*/
|
||||
@Composable
|
||||
fun AddAlbumAnimatedFab(
|
||||
menuOptions: AddAlbumFabMenuOptions,
|
||||
animate: Boolean,
|
||||
onImageClick: () -> Unit,
|
||||
onFolderClick: () -> Unit
|
||||
@@ -56,7 +60,7 @@ fun AddAlbumAnimatedFab(
|
||||
|
||||
BackHandler(expanded) { expanded = false }
|
||||
|
||||
val expandHorizontalSize = Pair(155.dp, 90.dp)
|
||||
val expandHorizontalSize = Pair(165.dp, 90.dp)
|
||||
val expandHorizontally by fabTransition.animateDp(
|
||||
transitionSpec = { spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow) }, label = "",
|
||||
targetValueByState = { isExpanded ->
|
||||
@@ -82,6 +86,12 @@ fun AddAlbumAnimatedFab(
|
||||
|
||||
if (animate) {
|
||||
ElevatedCard(
|
||||
colors = CardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = Color.Transparent,
|
||||
disabledContentColor = Color.Transparent,
|
||||
disabledContainerColor = Color.Transparent,
|
||||
),
|
||||
shape = RoundedCornerShape(28.dp),
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
@@ -99,8 +109,8 @@ fun AddAlbumAnimatedFab(
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
Column(modifier = Modifier.height(menuHeight)) {
|
||||
MenuRow(
|
||||
text = menuOptions.imageOption.text,
|
||||
icon = menuOptions.imageOption.icon,
|
||||
text = stringResource(R.string.add_images_btn),
|
||||
icon = Icons.Filled.PhotoLibrary,
|
||||
horizontalExpansion = expandHorizontally,
|
||||
onClick = {
|
||||
expanded = false
|
||||
@@ -108,8 +118,8 @@ fun AddAlbumAnimatedFab(
|
||||
}
|
||||
)
|
||||
MenuRow(
|
||||
text = menuOptions.folderOption.text,
|
||||
icon = menuOptions.folderOption.icon,
|
||||
text = stringResource(R.string.add_folder_btn),
|
||||
icon = Icons.Filled.Folder,
|
||||
horizontalExpansion = expandHorizontally,
|
||||
onClick = {
|
||||
expanded = false
|
||||
@@ -147,6 +157,12 @@ fun AddAlbumAnimatedFab(
|
||||
}
|
||||
else {
|
||||
ElevatedCard(
|
||||
colors = CardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = Color.Transparent,
|
||||
disabledContentColor = Color.Transparent,
|
||||
disabledContainerColor = Color.Transparent,
|
||||
),
|
||||
shape = RoundedCornerShape(28.dp),
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
@@ -159,8 +175,8 @@ fun AddAlbumAnimatedFab(
|
||||
Surface(tonalElevation = 5.dp) {
|
||||
Column(modifier = Modifier.height(if (expanded) menuHeightSize.first else menuHeightSize.second)) {
|
||||
MenuRow(
|
||||
text = menuOptions.imageOption.text,
|
||||
icon = menuOptions.imageOption.icon,
|
||||
text = stringResource(R.string.add_images_btn),
|
||||
icon = Icons.Filled.PhotoLibrary,
|
||||
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
||||
onClick = {
|
||||
expanded = false
|
||||
@@ -168,8 +184,8 @@ fun AddAlbumAnimatedFab(
|
||||
}
|
||||
)
|
||||
MenuRow(
|
||||
text = menuOptions.folderOption.text,
|
||||
icon = menuOptions.folderOption.icon,
|
||||
text = stringResource(R.string.add_folder_btn),
|
||||
icon = Icons.Filled.Folder,
|
||||
horizontalExpansion = if (expanded) expandHorizontalSize.first else expandHorizontalSize.second,
|
||||
onClick = {
|
||||
expanded = false
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ fun AddAlbumDialog(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
text = "New Album",
|
||||
text = stringResource(R.string.new_album),
|
||||
modifier = Modifier.padding(20.dp),
|
||||
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)
|
||||
)
|
||||
+74
-13
@@ -1,8 +1,16 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.add_album_screen.components
|
||||
|
||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
@@ -33,7 +41,9 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
@@ -54,17 +64,44 @@ fun AddAlbumSmallTopBar(
|
||||
title: String,
|
||||
isEmpty: Boolean,
|
||||
selectionMode: Boolean,
|
||||
showSpotlight: Boolean,
|
||||
onSelectAllClick: () -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onDeleteSelected: () -> Unit,
|
||||
onConfirmationClick: (String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
onConfirmationClick: (String) -> Unit
|
||||
) {
|
||||
val state = albumState.collectAsStateWithLifecycle()
|
||||
val focusManager = LocalFocusManager.current
|
||||
var editableTitle by rememberSaveable { mutableStateOf(title) }
|
||||
var showSelectionDeleteDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
val infiniteTransition = rememberInfiniteTransition(label = stringResource(R.string.spotlight_animation))
|
||||
val radius1 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 50f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_1_animation)
|
||||
)
|
||||
val radius2 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 60f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_2_animation)
|
||||
)
|
||||
|
||||
val radius3 by infiniteTransition.animateFloat(
|
||||
initialValue = 25f,
|
||||
targetValue = 75f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(2000, easing = LinearOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
), label = stringResource(R.string.circle_3_animation)
|
||||
)
|
||||
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||
title = {
|
||||
@@ -109,9 +146,7 @@ fun AddAlbumSmallTopBar(
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
IconButton(
|
||||
onClick = onSelectAllClick
|
||||
) {
|
||||
IconButton(onClick = onSelectAllClick) {
|
||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||
if (state.value.allSelected) {
|
||||
Icon(
|
||||
@@ -138,13 +173,39 @@ fun AddAlbumSmallTopBar(
|
||||
},
|
||||
actions = {
|
||||
if(!selectionMode) {
|
||||
if (!isEmpty) {
|
||||
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Add,
|
||||
contentDescription = stringResource(R.string.add_album),
|
||||
modifier = Modifier.padding(6.dp)
|
||||
)
|
||||
if (!isEmpty && editableTitle.isNotEmpty()) {
|
||||
Box {
|
||||
val primaryColor = MaterialTheme.colorScheme.inversePrimary
|
||||
val secondaryColor = MaterialTheme.colorScheme.secondary
|
||||
IconButton(onClick = { onConfirmationClick(editableTitle) }) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Add,
|
||||
contentDescription = stringResource(R.string.add_album),
|
||||
modifier = Modifier.padding(6.dp)
|
||||
)
|
||||
}
|
||||
if (!showSpotlight) {
|
||||
Canvas(modifier = Modifier.matchParentSize()) {
|
||||
drawCircle(
|
||||
color = primaryColor,
|
||||
radius = radius1,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
drawCircle(
|
||||
color = secondaryColor,
|
||||
radius = radius2,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
drawCircle(
|
||||
color = primaryColor,
|
||||
radius = radius3,
|
||||
center = Offset(size.width / 2, size.height / 2),
|
||||
style = Stroke(width = 5f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -22,17 +22,17 @@ fun DeleteImagesAlertDialog(
|
||||
icon = {
|
||||
Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
||||
},
|
||||
title = { Text(text = "Delete these?") },
|
||||
text = { Text(text = "Are you sure you want to delete these wallpapers?") },
|
||||
title = { Text(text = stringResource(R.string.delete_these)) },
|
||||
text = { Text(text = stringResource(R.string.are_you_sure_you_want_to_delete_these_wallpapers)) },
|
||||
onDismissRequest = { onDismissRequest() },
|
||||
confirmButton = {
|
||||
TextButton(onClick = { onConfirmation() }) {
|
||||
Text("Confirm")
|
||||
Text(stringResource(R.string.confirm))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
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
|
||||
sealed class AlbumsEvent {
|
||||
data object RefreshAlbums: AlbumsEvent()
|
||||
data object Reset: AlbumsEvent()
|
||||
|
||||
data class DeleteAlbumWithWallpapers(
|
||||
val albumWithWallpaperAndFolder: AlbumWithWallpaperAndFolder
|
||||
|
||||
+123
-88
@@ -2,19 +2,16 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.album
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.core.net.toUri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.anthonyla.paperize.core.findFirstValidUri
|
||||
import com.anthonyla.paperize.core.getWallpaperFromFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import com.lazygeniouz.dfc.file.DocumentFileCompat
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.first
|
||||
@@ -37,22 +34,20 @@ class AlbumsViewModel @Inject constructor (
|
||||
)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
|
||||
|
||||
fun onEvent(event: AlbumsEvent) {
|
||||
when (event) {
|
||||
is AlbumsEvent.DeleteAlbumWithWallpapers -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.cascadeDeleteAlbum(event.albumWithWallpaperAndFolder.album)
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.ChangeAlbumName -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (!(_state.value.albumsWithWallpapers.any { it.album.displayedAlbumName == event.title })) {
|
||||
repository.updateAlbum(
|
||||
event.albumWithWallpaperAndFolder.album.copy(displayedAlbumName = event.title)
|
||||
@@ -61,13 +56,11 @@ class AlbumsViewModel @Inject constructor (
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.RefreshAlbums -> {
|
||||
viewModelScope.launch {
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
updateAlbums()
|
||||
refreshAlbums()
|
||||
}
|
||||
is AlbumsEvent.InitializeAlbum -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.updateAlbum(
|
||||
event.albumWithWallpaperAndFolder.album.copy(
|
||||
initialized = true
|
||||
@@ -75,6 +68,12 @@ class AlbumsViewModel @Inject constructor (
|
||||
)
|
||||
}
|
||||
}
|
||||
is AlbumsEvent.Reset -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
_state.update { AlbumsState() }
|
||||
repository.deleteAllData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,39 +81,124 @@ class AlbumsViewModel @Inject constructor (
|
||||
* Verify and remove stale data in Room database
|
||||
*/
|
||||
private fun updateAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
var albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||
// Delete wallpaper if the URI is invalid
|
||||
val invalidWallpapers = albumWithWallpaper.wallpapers.filterNot { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
file?.exists() == true
|
||||
try {
|
||||
val file = DocumentFileCompat.fromSingleUri(
|
||||
context,
|
||||
wallpaper.wallpaperUri.toUri()
|
||||
)
|
||||
file?.exists() == true
|
||||
} catch (e: Exception) {
|
||||
val file =
|
||||
DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
file?.exists() == true
|
||||
}
|
||||
}
|
||||
if (invalidWallpapers.isNotEmpty()) {
|
||||
repository.deleteWallpaperList(invalidWallpapers)
|
||||
}
|
||||
|
||||
// Update folder cover uri and children uri
|
||||
// Update folder cover uri and wallpapers uri
|
||||
albumWithWallpaper.folders.forEach { folder ->
|
||||
DocumentFile.fromTreeUri(context, folder.folderUri.toUri())?.let { folderDirectory ->
|
||||
if (!folderDirectory.isDirectory) {
|
||||
repository.deleteFolder(folder)
|
||||
} else {
|
||||
val wallpapers = getWallpaperFromFolder(folder.folderUri, context)
|
||||
val folderCoverFile = folder.coverUri?.let { DocumentFile.fromSingleUri(context, it.toUri()) }
|
||||
val folderCover = folderCoverFile?.takeIf { it.exists() }?.uri?.toString() ?: wallpapers.randomOrNull()
|
||||
repository.updateFolder(folder.copy(coverUri = folderCover, wallpapers = wallpapers))
|
||||
}
|
||||
try {
|
||||
DocumentFileCompat.fromTreeUri(context, folder.folderUri.toUri())
|
||||
?.let { folderDirectory ->
|
||||
if (!folderDirectory.isDirectory()) {
|
||||
repository.deleteFolder(folder)
|
||||
} else {
|
||||
val wallpapers =
|
||||
getWallpaperFromFolder(folder.folderUri, context)
|
||||
val folderCoverFile = folder.coverUri?.let {
|
||||
DocumentFileCompat.fromSingleUri(
|
||||
context,
|
||||
it.toUri()
|
||||
)
|
||||
}
|
||||
val folderCover =
|
||||
folderCoverFile?.takeIf { it.exists() }?.uri?.toString()
|
||||
?: wallpapers.randomOrNull()
|
||||
repository.updateFolder(
|
||||
folder.copy(
|
||||
coverUri = folderCover,
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
DocumentFile.fromTreeUri(context, folder.folderUri.toUri())
|
||||
?.let { folderDirectory ->
|
||||
if (!folderDirectory.isDirectory) {
|
||||
repository.deleteFolder(folder)
|
||||
} else {
|
||||
val wallpapers =
|
||||
getWallpaperFromFolder(folder.folderUri, context)
|
||||
try {
|
||||
val folderCoverFile = folder.coverUri?.let {
|
||||
DocumentFileCompat.fromSingleUri(
|
||||
context,
|
||||
it.toUri()
|
||||
)
|
||||
}
|
||||
val folderCover =
|
||||
folderCoverFile?.takeIf { it.exists() }?.uri?.toString()
|
||||
?: wallpapers.randomOrNull()
|
||||
repository.updateFolder(
|
||||
folder.copy(
|
||||
coverUri = folderCover,
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
val folderCoverFile = folder.coverUri?.let {
|
||||
DocumentFile.fromSingleUri(
|
||||
context,
|
||||
it.toUri()
|
||||
)
|
||||
}
|
||||
val folderCover =
|
||||
folderCoverFile?.takeIf { it.exists() }?.uri?.toString()
|
||||
?: wallpapers.randomOrNull()
|
||||
repository.updateFolder(
|
||||
folder.copy(
|
||||
coverUri = folderCover,
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { albumWithWallpaper ->
|
||||
// Update album cover uri if null or invalid
|
||||
val albumCoverFile = albumWithWallpaper.album.coverUri?.toUri()?.let { DocumentFile.fromSingleUri(context, it) }
|
||||
if (albumCoverFile == null || !albumCoverFile.exists()) {
|
||||
val newCoverUri = findFirstValidUri(albumWithWallpaper.wallpapers, albumWithWallpaper.folders)
|
||||
repository.updateAlbum(albumWithWallpaper.album.copy(coverUri = newCoverUri))
|
||||
albumWithWallpapers = repository.getAlbumsWithWallpaperAndFolder().first()
|
||||
albumWithWallpapers.forEach { album ->
|
||||
// Delete empty albums
|
||||
if (album.wallpapers.isEmpty() && album.folders.all { it.wallpapers.isEmpty() }) {
|
||||
repository.deleteAlbum(album.album)
|
||||
} else {
|
||||
// Update album cover uri if null or invalid
|
||||
try {
|
||||
val albumCoverFile = album.album.coverUri?.toUri()
|
||||
?.let { DocumentFileCompat.fromSingleUri(context, it) }
|
||||
if (albumCoverFile == null || !albumCoverFile.exists()) {
|
||||
val newCoverUri =
|
||||
findFirstValidUri(context, album.wallpapers, album.folders)
|
||||
repository.updateAlbum(album.album.copy(coverUri = newCoverUri))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
val albumCoverFile = album.album.coverUri?.toUri()
|
||||
?.let { DocumentFile.fromSingleUri(context, it) }
|
||||
if (albumCoverFile == null || !albumCoverFile.exists()) {
|
||||
val newCoverUri =
|
||||
findFirstValidUri(context, album.wallpapers, album.folders)
|
||||
repository.updateAlbum(album.album.copy(coverUri = newCoverUri))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +208,7 @@ class AlbumsViewModel @Inject constructor (
|
||||
* Retrieve albums from database into viewModel
|
||||
*/
|
||||
private fun refreshAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getAlbumsWithWallpaperAndFolder().collect { albumWithWallpapers ->
|
||||
_state.update { it.copy(
|
||||
albumsWithWallpapers = albumWithWallpapers
|
||||
@@ -132,54 +216,5 @@ class AlbumsViewModel @Inject constructor (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve wallpaper URIs from a folder directory URI
|
||||
*/
|
||||
private fun getWallpaperFromFolder(folderUri: String, context: Context): List<String> {
|
||||
val folderDocumentFile = DocumentFileCompat.fromTreeUri(context, folderUri.toUri())
|
||||
return listFilesRecursive(folderDocumentFile, context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to recursively list files in a directory
|
||||
*/
|
||||
private fun listFilesRecursive(parent: DocumentFileCompat?, context: Context): List<String> {
|
||||
val files = mutableListOf<String>()
|
||||
parent?.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory()) {
|
||||
files.addAll(listFilesRecursive(file, context))
|
||||
} else {
|
||||
val extension = MimeTypeMap.getFileExtensionFromUrl(file.uri.toString())
|
||||
val allowedExtensions = listOf("jpg", "png", "heif", "webp")
|
||||
if (extension in allowedExtensions) {
|
||||
files.add(file.uri.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to find the first valid URI from a list of wallpapers
|
||||
* It will search through all wallpapers of an album first, and then all wallpapers of every folder of an album
|
||||
*/
|
||||
private fun findFirstValidUri(wallpapers: List<Wallpaper>, folders: List<Folder>): String? {
|
||||
wallpapers.forEach { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.wallpaperUri.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper.wallpaperUri
|
||||
}
|
||||
}
|
||||
folders.forEach { folder ->
|
||||
folder.wallpapers.forEach { wallpaper ->
|
||||
val file = DocumentFile.fromSingleUri(context, wallpaper.toUri())
|
||||
if (file?.exists() == true) {
|
||||
return wallpaper
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
+43
-25
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -14,16 +15,19 @@ import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Album
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -34,8 +38,22 @@ import com.skydoves.landscapist.glide.GlideImage
|
||||
fun AlbumItem(
|
||||
album: Album,
|
||||
onAlbumViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
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 by remember { mutableStateOf(album.coverUri != null && isValidUri(context, album.coverUri)) }
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
modifier = modifier
|
||||
@@ -49,27 +67,26 @@ fun AlbumItem(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box {
|
||||
GlideImage(
|
||||
imageModel = { album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(250, 250),
|
||||
),
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.padding(6.dp))
|
||||
@@ -78,7 +95,8 @@ fun AlbumItem(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 24.dp)
|
||||
.align(Alignment.Start),
|
||||
fontSize = 16.sp
|
||||
fontSize = 16.sp,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(8.dp))
|
||||
}
|
||||
|
||||
+39
-23
@@ -1,5 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.animation.core.animateDp
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
@@ -10,8 +11,8 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
@@ -27,23 +28,23 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
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.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
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.glide.GlideImage
|
||||
|
||||
@@ -59,9 +60,10 @@ fun FolderItem(
|
||||
onActivateSelectionMode: (Boolean) -> Unit,
|
||||
onItemSelection: () -> Unit,
|
||||
onFolderViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
animate: Boolean = true
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val context = LocalContext.current
|
||||
val haptics = LocalHapticFeedback.current
|
||||
val transition = updateTransition(itemSelected, label = "")
|
||||
|
||||
@@ -73,6 +75,18 @@ fun FolderItem(
|
||||
if (selected) 24.dp else 16.dp
|
||||
}
|
||||
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
val showCoverUri by remember { mutableStateOf(folder.coverUri != null && isValidUri(context, folder.coverUri)) }
|
||||
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
modifier = modifier
|
||||
@@ -81,8 +95,11 @@ fun FolderItem(
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
if (!selectionMode) { onFolderViewClick() }
|
||||
else { onItemSelection() }
|
||||
if (!selectionMode) {
|
||||
onFolderViewClick()
|
||||
} else {
|
||||
onItemSelection()
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
if (!selectionMode) {
|
||||
@@ -99,26 +116,23 @@ fun FolderItem(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box {
|
||||
if (folder.coverUri != null) {
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { folder.coverUri.toUri() },
|
||||
imageModel = { folder.coverUri?.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(250, 250),
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.height(configuration.screenHeightDp.dp / 4.0f)
|
||||
.aspectRatio(0.8f)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
)
|
||||
}
|
||||
@@ -150,16 +164,18 @@ fun FolderItem(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 24.dp)
|
||||
.align(Alignment.Start),
|
||||
fontSize = 16.sp
|
||||
fontSize = 16.sp,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = folder.wallpapers.size.toString().plus(" wallpapers"),
|
||||
text = folder.wallpapers.size.toString().plus(" " + stringResource(R.string.wallpapers)),
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 24.dp)
|
||||
.align(Alignment.Start),
|
||||
fontSize = 12.sp,
|
||||
color = MaterialTheme.colorScheme.tertiary
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(8.dp))
|
||||
}
|
||||
|
||||
+81
-42
@@ -1,8 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album.components
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.core.animateDp
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
@@ -23,21 +21,27 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.blur
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.BlendMode
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.times
|
||||
import androidx.core.net.toUri
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.anthonyla.paperize.R
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions.withCrossFade
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.getImageDimensions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -54,7 +58,14 @@ fun WallpaperItem(
|
||||
onItemSelection: () -> Unit,
|
||||
onWallpaperViewClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
wallpaperDrawable : Bitmap? = null
|
||||
aspectRatio: Float? = null,
|
||||
clickable: Boolean = true,
|
||||
animate: Boolean = true,
|
||||
darken: Boolean = false,
|
||||
darkenPercentage: Int? = null,
|
||||
blur: Boolean = false,
|
||||
blurPercentage: Int? = null,
|
||||
scaling: ScalingConstants? = null
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val haptics = LocalHapticFeedback.current
|
||||
@@ -67,17 +78,29 @@ fun WallpaperItem(
|
||||
if (selected) 24.dp else 16.dp
|
||||
}
|
||||
|
||||
val dimension = wallpaperDrawable?.let { Pair(it.width, it.height) } ?: wallpaperUri.toUri().getImageDimensions(context)
|
||||
val aspectRatio = (dimension.first.toFloat()/dimension.second.toFloat())
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
val showUri by remember { mutableStateOf(isValidUri(context, wallpaperUri)) }
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
val boxModifier = if (clickable) {
|
||||
modifier
|
||||
.padding(paddingTransition)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
if (!selectionMode) { onWallpaperViewClick() }
|
||||
else { onItemSelection() }
|
||||
if (!selectionMode) {
|
||||
onWallpaperViewClick()
|
||||
} else {
|
||||
onItemSelection()
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
if (!selectionMode) {
|
||||
@@ -87,26 +110,52 @@ fun WallpaperItem(
|
||||
}
|
||||
}
|
||||
)
|
||||
) {
|
||||
GlideImage(
|
||||
imageModel = { wallpaperDrawable ?: wallpaperUri.toUri() },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
},
|
||||
modifier = Modifier.aspectRatio(aspectRatio)
|
||||
)
|
||||
} else {
|
||||
modifier
|
||||
.padding(paddingTransition)
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
}
|
||||
|
||||
Box(modifier = boxModifier) {
|
||||
if (showUri) {
|
||||
val dimension = wallpaperUri.toUri().getImageDimensions(context)
|
||||
val imageAspectRatio = aspectRatio ?: ((dimension?.width?.toFloat() ?: 9f) / (dimension?.height?.toFloat() ?: 19.5f))
|
||||
GlideImage(
|
||||
imageModel = { wallpaperUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = if (scaling != null) {
|
||||
when (scaling) {
|
||||
ScalingConstants.FILL -> ContentScale.FillHeight
|
||||
ScalingConstants.FIT -> ContentScale.FillWidth
|
||||
ScalingConstants.STRETCH -> ContentScale.FillBounds
|
||||
}
|
||||
} else { ContentScale.Crop },
|
||||
requestSize = IntSize(250, 250),
|
||||
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))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(imageAspectRatio)
|
||||
.background(if (scaling != null) Color.Black else Color.Transparent)
|
||||
.blur(
|
||||
if (blur && blurPercentage != null && blurPercentage > 0 ) {
|
||||
blurPercentage.toFloat().div(100f) * 1.5.dp
|
||||
} else { 0.dp })
|
||||
.clip(RoundedCornerShape(roundedCornerShapeTransition))
|
||||
)
|
||||
}
|
||||
if (selectionMode) {
|
||||
val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
|
||||
if (itemSelected) {
|
||||
@@ -129,14 +178,4 @@ 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)
|
||||
}
|
||||
+11
@@ -11,6 +11,17 @@ sealed class AlbumViewEvent {
|
||||
data class DeleteSelected(
|
||||
val albumsWithWallpaper: AlbumWithWallpaperAndFolder
|
||||
): AlbumViewEvent()
|
||||
|
||||
data class AddWallpapers(
|
||||
val album: AlbumWithWallpaperAndFolder,
|
||||
val wallpaperUris: List<String>
|
||||
): AlbumViewEvent()
|
||||
|
||||
data class AddFolder(
|
||||
val album: AlbumWithWallpaperAndFolder,
|
||||
val directoryUri: String
|
||||
): AlbumViewEvent()
|
||||
|
||||
data class SelectWallpaper(
|
||||
val wallpaperUri: String
|
||||
): AlbumViewEvent()
|
||||
|
||||
+177
-59
@@ -1,6 +1,12 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -16,64 +22,110 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
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.album.components.FolderItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.WallpaperItem
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album_view_screen.components.AlbumViewTopBar
|
||||
|
||||
@Composable
|
||||
fun AlbumViewScreen(
|
||||
albumViewModel: AlbumViewScreenViewModel = hiltViewModel(),
|
||||
albumViewScreenViewModel: AlbumViewScreenViewModel = hiltViewModel(),
|
||||
album: AlbumWithWallpaperAndFolder,
|
||||
animate: Boolean,
|
||||
onBackClick: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
onShowFolderView: (String, String?, List<String>) -> Unit,
|
||||
onShowFolderView: (String?, List<String>) -> Unit,
|
||||
onDeleteAlbum: () -> Unit,
|
||||
onTitleChange: (String, AlbumWithWallpaperAndFolder) -> Unit,
|
||||
onSelectionDeleted: () -> Unit
|
||||
onSelectionDeleted: () -> Unit,
|
||||
) {
|
||||
albumViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size))
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.SetSize(album.wallpapers.size + album.folders.size)) // For selectedAll state
|
||||
val lazyListState = rememberLazyStaggeredGridState()
|
||||
val albumState = albumViewModel.state.collectAsStateWithLifecycle()
|
||||
val albumState = albumViewScreenViewModel.state.collectAsStateWithLifecycle()
|
||||
var selectionMode by rememberSaveable { mutableStateOf(false) }
|
||||
val context = LocalContext.current
|
||||
|
||||
BackHandler {
|
||||
if (selectionMode) {
|
||||
selectionMode = false
|
||||
albumViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
} else {
|
||||
onBackClick()
|
||||
albumViewModel.onEvent(AlbumViewEvent.ClearState)
|
||||
/** Image picker **/
|
||||
val imagePickerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.OpenMultipleDocuments(),
|
||||
onResult = { uris: List<Uri> ->
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
val uriList = uris.mapNotNull { uri ->
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) uri.toString() else null
|
||||
}
|
||||
if (uriList.isNotEmpty()) {
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.AddWallpapers(album, uriList))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** Folder picker **/
|
||||
val folderPickerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.OpenDocumentTree(),
|
||||
onResult = { uri: Uri? ->
|
||||
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
if (uri != null) {
|
||||
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
||||
val persistedUriPermissions = context.contentResolver.persistedUriPermissions
|
||||
if (persistedUriPermissions.any { it.uri == uri }) {
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.AddFolder(album, uri.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
BackHandler(
|
||||
enabled = selectionMode,
|
||||
onBack = {
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
selectionMode = false
|
||||
}
|
||||
)
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
AlbumViewTopBar(
|
||||
title = album.album.displayedAlbumName,
|
||||
selectionMode = selectionMode,
|
||||
albumState = albumViewModel.state,
|
||||
albumState = albumViewScreenViewModel.state,
|
||||
onBackClick = {
|
||||
albumViewModel.onEvent(AlbumViewEvent.ClearState)
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.ClearState)
|
||||
onBackClick()
|
||||
},
|
||||
onDeleteAlbum = onDeleteAlbum,
|
||||
onTitleChange = { onTitleChange(it, album) },
|
||||
onSelectAllClick = {
|
||||
if (!albumState.value.allSelected) albumViewModel.onEvent(AlbumViewEvent.SelectAll(album))
|
||||
else albumViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
if (!albumState.value.allSelected) albumViewScreenViewModel.onEvent(AlbumViewEvent.SelectAll(album))
|
||||
else albumViewScreenViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
},
|
||||
onDeleteSelected = {
|
||||
selectionMode = false
|
||||
albumViewModel.onEvent(AlbumViewEvent.DeleteSelected(album))
|
||||
albumViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.DeleteSelected(album))
|
||||
albumViewScreenViewModel.onEvent(AlbumViewEvent.DeselectAll)
|
||||
onSelectionDeleted()
|
||||
}
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
AddAlbumAnimatedFab(
|
||||
onImageClick = {
|
||||
selectionMode = false
|
||||
imagePickerLauncher.launch(arrayOf("image/*"))
|
||||
},
|
||||
onFolderClick = {
|
||||
selectionMode = false
|
||||
folderPickerLauncher.launch(null)
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
},
|
||||
content = { it ->
|
||||
LazyVerticalStaggeredGrid(
|
||||
state = lazyListState,
|
||||
@@ -84,49 +136,115 @@ fun AlbumViewScreen(
|
||||
contentPadding = PaddingValues(4.dp, 4.dp),
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
content = {
|
||||
items (items = album.folders, key = { folder -> folder.folderUri.hashCode() }
|
||||
items (items = album.folders, key = { folder -> folder.folderUri }
|
||||
) { folder ->
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
onShowFolderView(folder.folderUri, folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp)
|
||||
)
|
||||
if (animate) {
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
if (folder.wallpapers.isNotEmpty()) onShowFolderView(folder.folderName, folder.wallpapers)
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
FolderItem(
|
||||
folder = folder,
|
||||
itemSelected = albumState.value.selectedFolders.contains(folder.folderUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedFolders.contains(folder.folderUri))
|
||||
AlbumViewEvent.SelectFolder(folder.folderUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveFolderFromSelection(folder.folderUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onFolderViewClick = {
|
||||
if (folder.wallpapers.isNotEmpty()) 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 }
|
||||
) { wallpaper ->
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewModel.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)
|
||||
)
|
||||
if (animate) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
|
||||
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
)
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper.wallpaperUri,
|
||||
itemSelected = albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri),
|
||||
selectionMode = selectionMode,
|
||||
onActivateSelectionMode = { selectionMode = it },
|
||||
onItemSelection = {
|
||||
albumViewScreenViewModel.onEvent(
|
||||
if (!albumState.value.selectedWallpapers.contains(wallpaper.wallpaperUri))
|
||||
AlbumViewEvent.SelectWallpaper(wallpaper.wallpaperUri)
|
||||
else {
|
||||
AlbumViewEvent.RemoveWallpaperFromSelection(wallpaper.wallpaperUri)
|
||||
}
|
||||
)
|
||||
},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper.wallpaperUri)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+76
-25
@@ -5,6 +5,10 @@ import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.core.getFolderNameFromUri
|
||||
import com.anthonyla.paperize.core.getWallpaperFromFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Folder
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.repository.AlbumRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -34,10 +38,10 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
event.albumsWithWallpaper.let { album ->
|
||||
val folders = album.folders.filter { _state.value.selectedFolders.contains(it.folderUri)}
|
||||
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.deleteWallpaperList(wallpapers)
|
||||
if (doesContainCover) {
|
||||
if (containsCoverUri) {
|
||||
repository.updateAlbum(album.album.copy(coverUri = null))
|
||||
}
|
||||
}
|
||||
@@ -47,15 +51,15 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
event.albumsWithWallpaper.let { album ->
|
||||
if (!_state.value.allSelected) {
|
||||
_state.update { state ->
|
||||
state.copy(
|
||||
_state.update { it ->
|
||||
it.copy(
|
||||
selectedFolders = album.folders.map { it.folderUri },
|
||||
selectedWallpapers = album.wallpapers.map { it.wallpaperUri },
|
||||
selectedCount = album.folders.size + album.wallpapers.size,
|
||||
maxSize = album.folders.size + album.wallpapers.size
|
||||
maxSize = album.folders.size + album.wallpapers.size,
|
||||
allSelected = true
|
||||
)
|
||||
}
|
||||
updateAllSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,12 +82,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.selectedFolders.any { it == event.directoryUri }) {
|
||||
_state.update {
|
||||
val folders = it.selectedFolders.plus(event.directoryUri)
|
||||
it.copy(
|
||||
selectedFolders = it.selectedFolders.plus(event.directoryUri),
|
||||
selectedCount = it.selectedCount + 1
|
||||
selectedFolders = folders,
|
||||
selectedCount = it.selectedCount + 1,
|
||||
allSelected = folders.size + it.selectedWallpapers.size >= it.maxSize
|
||||
)
|
||||
}
|
||||
updateAllSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,12 +97,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
if (!_state.value.selectedWallpapers.any { it == event.wallpaperUri }) {
|
||||
_state.update {
|
||||
val wallpapers = it.selectedWallpapers.plus(event.wallpaperUri)
|
||||
it.copy(
|
||||
selectedWallpapers = it.selectedWallpapers.plus(event.wallpaperUri),
|
||||
selectedCount = it.selectedCount + 1
|
||||
selectedCount = it.selectedCount + 1,
|
||||
allSelected = it.selectedFolders.size + wallpapers.size >= it.maxSize
|
||||
)
|
||||
}
|
||||
updateAllSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,12 +112,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
if (_state.value.selectedFolders.find { it == event.directoryUri } != null) {
|
||||
_state.update {
|
||||
val folders = it.selectedFolders.minus(event.directoryUri)
|
||||
it.copy(
|
||||
selectedFolders = it.selectedFolders.minus(event.directoryUri),
|
||||
selectedCount = it.selectedCount - 1
|
||||
selectedFolders = folders,
|
||||
selectedCount = it.selectedCount - 1,
|
||||
allSelected = folders.size + it.selectedWallpapers.size >= it.maxSize
|
||||
)
|
||||
}
|
||||
updateAllSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,12 +127,13 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
if (_state.value.selectedWallpapers.find { it == event.wallpaperUri } != null) {
|
||||
_state.update {
|
||||
val wallpapers = it.selectedWallpapers.minus(event.wallpaperUri)
|
||||
it.copy(
|
||||
selectedWallpapers = it.selectedWallpapers.minus(event.wallpaperUri),
|
||||
selectedCount = it.selectedCount - 1
|
||||
selectedWallpapers = wallpapers,
|
||||
selectedCount = it.selectedCount - 1,
|
||||
allSelected = it.selectedFolders.size + wallpapers.size >= it.maxSize
|
||||
)
|
||||
}
|
||||
updateAllSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,16 +161,59 @@ class AlbumViewScreenViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAllSelected() {
|
||||
viewModelScope.launch {
|
||||
_state.update {
|
||||
it.copy(
|
||||
allSelected = it.selectedFolders.size + it.selectedWallpapers.size >= _state.value.maxSize
|
||||
)
|
||||
is AlbumViewEvent.AddWallpapers -> {
|
||||
viewModelScope.launch {
|
||||
val wallpaperUris = event.wallpaperUris.filterNot { it in event.album.wallpapers.map { wallpaper -> wallpaper.wallpaperUri } }
|
||||
val wallpapers = wallpaperUris.map { uri ->
|
||||
Wallpaper(
|
||||
initialAlbumName = event.album.album.initialAlbumName,
|
||||
wallpaperUri = uri,
|
||||
key = uri.hashCode() + event.album.album.initialAlbumName.hashCode(),
|
||||
)
|
||||
}
|
||||
repository.upsertWallpaperList(wallpapers)
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedFolders = emptyList(),
|
||||
selectedWallpapers = emptyList(),
|
||||
allSelected = false,
|
||||
selectedCount = 0,
|
||||
maxSize = it.maxSize + wallpapers.size
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is AlbumViewEvent.AddFolder -> {
|
||||
viewModelScope.launch {
|
||||
if (event.directoryUri !in event.album.folders.map { it.folderUri }) {
|
||||
val wallpapers: List<String> = getWallpaperFromFolder(event.directoryUri, context)
|
||||
if (wallpapers.isEmpty()) { return@launch }
|
||||
val folderName = getFolderNameFromUri(event.directoryUri, context)
|
||||
repository.upsertFolder(
|
||||
Folder(
|
||||
folderUri = event.directoryUri,
|
||||
folderName = folderName,
|
||||
initialAlbumName = event.album.album.initialAlbumName,
|
||||
key = event.directoryUri.hashCode() + event.album.album.initialAlbumName.hashCode(),
|
||||
coverUri = wallpapers.randomOrNull(),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
)
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedFolders = emptyList(),
|
||||
selectedWallpapers = emptyList(),
|
||||
allSelected = false,
|
||||
selectedCount = 0,
|
||||
maxSize = it.maxSize + 1
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-2
@@ -56,7 +56,6 @@ fun AlbumViewTopBar(
|
||||
onDeleteAlbum: () -> Unit,
|
||||
onDeleteSelected: () -> Unit,
|
||||
onTitleChange: (String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val state = albumState.collectAsStateWithLifecycle()
|
||||
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(Icons.Outlined.Delete, contentDescription = stringResource(R.string.delete_confirmation))
|
||||
},
|
||||
title = { Text(text = "Delete album?") },
|
||||
text = { Text(text = "Are you sure you want to delete this?") },
|
||||
title = { Text(text = stringResource(R.string.delete_album_question)) },
|
||||
text = { Text(text = stringResource(R.string.are_you_sure_you_want_to_delete_this)) },
|
||||
onDismissRequest = { onDismissRequest() },
|
||||
confirmButton = {
|
||||
TextButton(onClick = { onConfirmation() }) {
|
||||
Text("Confirm")
|
||||
Text(stringResource(R.string.confirm))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { onDismissRequest() }) {
|
||||
Text("Cancel")
|
||||
Text(stringResource(R.string.cancel))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+40
-16
@@ -1,6 +1,8 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.folder_view_screen
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -18,11 +20,11 @@ import com.anthonyla.paperize.feature.wallpaper.presentation.folder_view_screen.
|
||||
|
||||
@Composable
|
||||
fun FolderViewScreen(
|
||||
folder: String,
|
||||
folderName: String?,
|
||||
wallpapers: List<String>,
|
||||
onBackClick: () -> Unit,
|
||||
onShowWallpaperView: (String) -> Unit
|
||||
onShowWallpaperView: (String) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val lazyListState = rememberLazyStaggeredGridState()
|
||||
BackHandler { onBackClick() }
|
||||
@@ -31,9 +33,8 @@ fun FolderViewScreen(
|
||||
topBar = {
|
||||
FolderViewTopBar(
|
||||
title = folderName ?: "",
|
||||
) {
|
||||
onBackClick()
|
||||
}
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
},
|
||||
content = {
|
||||
LazyVerticalStaggeredGrid(
|
||||
@@ -47,17 +48,40 @@ fun FolderViewScreen(
|
||||
content = {
|
||||
items (items = wallpapers, key = { wallpaper -> wallpaper }
|
||||
) { wallpaper ->
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp)
|
||||
)
|
||||
if (animate) {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp).animateItem(
|
||||
placementSpec = tween(
|
||||
durationMillis = 800,
|
||||
delayMillis = 0,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
),
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
else {
|
||||
WallpaperItem(
|
||||
wallpaperUri = wallpaper,
|
||||
itemSelected = false,
|
||||
selectionMode = false,
|
||||
onActivateSelectionMode = {},
|
||||
onItemSelection = {},
|
||||
onWallpaperViewClick = {
|
||||
onShowWallpaperView(wallpaper)
|
||||
},
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+88
-28
@@ -1,6 +1,5 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.home_screen
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
@@ -20,33 +19,70 @@ import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.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.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.settings_screen.components.tabItems
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.WallpaperScreen
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun HomeScreen(
|
||||
onSettingsClick: () -> Unit,
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
animate : Boolean,
|
||||
darken: Boolean,
|
||||
darkenPercentage: Int,
|
||||
enableChanger: Boolean,
|
||||
homeEnabled : Boolean,
|
||||
interval1: Int,
|
||||
interval2: Int,
|
||||
lastSetTime: String?,
|
||||
lockEnabled : Boolean,
|
||||
navigateToAddWallpaperScreen: (String) -> Unit,
|
||||
nextSetTime: String?,
|
||||
onAlbumViewClick: (String) -> Unit,
|
||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||
onStop: () -> Unit
|
||||
onDarkCheck: (Boolean) -> Unit,
|
||||
onDarkenPercentage: (Int) -> Unit,
|
||||
onHomeCheckedChange: (Boolean) -> Unit,
|
||||
onLockCheckedChange: (Boolean) -> Unit,
|
||||
onScalingChange: (ScalingConstants) -> Unit,
|
||||
onScheduleWallpaperChanger1: (Int) -> Unit,
|
||||
onScheduleWallpaperChanger2: (Int) -> Unit,
|
||||
onSelectAlbum: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||
onScheduleSeparatelyChange: (Boolean) -> Unit,
|
||||
onTimeChange1: (Int) -> Unit,
|
||||
onTimeChange2: (Int) -> Unit,
|
||||
onSettingsClick: () -> Unit,
|
||||
onStop: () -> Unit,
|
||||
onToggleChanger: (Boolean) -> Unit,
|
||||
scaling: ScalingConstants,
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
scheduleSeparately: Boolean,
|
||||
blur: Boolean,
|
||||
onBlurPercentageChange: (Int) -> Unit,
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
blurPercentage: Int,
|
||||
) {
|
||||
var tabIndex by rememberSaveable { mutableIntStateOf(0) }
|
||||
val pagerState = rememberPagerState { tabItems.size }
|
||||
|
||||
val tabItems = getTabItems()
|
||||
val pagerState = rememberPagerState(0) { tabItems.size }
|
||||
var tabIndex by rememberSaveable { mutableIntStateOf(pagerState.currentPage) }
|
||||
var addAlbumDialog by rememberSaveable { mutableStateOf(false) }
|
||||
if (addAlbumDialog) AddAlbumDialog(
|
||||
onDismissRequest = { addAlbumDialog = false },
|
||||
onConfirmation = { navigateToAddWallpaperScreen(it) }
|
||||
)
|
||||
|
||||
LaunchedEffect(tabIndex) {
|
||||
pagerState.animateScrollToPage(tabIndex)
|
||||
}
|
||||
LaunchedEffect(pagerState.currentPage) {
|
||||
tabIndex = pagerState.currentPage
|
||||
}
|
||||
|
||||
Scaffold (
|
||||
topBar = {
|
||||
HomeTopBar(
|
||||
@@ -55,16 +91,12 @@ fun HomeScreen(
|
||||
onSettingsClick = onSettingsClick,
|
||||
)
|
||||
}
|
||||
) { padding ->
|
||||
LaunchedEffect(tabIndex) { pagerState.animateScrollToPage(tabIndex) }
|
||||
LaunchedEffect(pagerState) {
|
||||
snapshotFlow { pagerState.currentPage }.collect { page -> tabIndex = page }
|
||||
}
|
||||
Column(modifier = Modifier.padding(padding)) {
|
||||
) {
|
||||
Column(modifier = Modifier.padding(it)) {
|
||||
TabRow(
|
||||
selectedTabIndex = tabIndex,
|
||||
indicator = { tabPositions ->
|
||||
if (tabIndex < tabPositions.size) {
|
||||
if (tabIndex in tabPositions.indices) {
|
||||
TabRowDefaults.PrimaryIndicator(
|
||||
modifier = Modifier.tabIndicatorOffset(tabPositions[tabIndex]),
|
||||
shape = RoundedCornerShape(
|
||||
@@ -86,10 +118,8 @@ fun HomeScreen(
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector =
|
||||
if (index == tabIndex)
|
||||
item.filledIcon
|
||||
else
|
||||
item.unfilledIcon,
|
||||
if (index == tabIndex) item.filledIcon
|
||||
else item.unfilledIcon,
|
||||
contentDescription = item.title
|
||||
)
|
||||
}
|
||||
@@ -98,17 +128,47 @@ fun HomeScreen(
|
||||
}
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
beyondViewportPageCount = 1,
|
||||
userScrollEnabled = true,
|
||||
beyondViewportPageCount = 1
|
||||
) { index ->
|
||||
when(index) {
|
||||
when(index.coerceIn(tabItems.indices)) {
|
||||
0 -> WallpaperScreen(
|
||||
onScheduleWallpaperChanger = onScheduleWallpaperChanger,
|
||||
onStop = onStop
|
||||
albums = albums,
|
||||
animate = animate,
|
||||
darken = darken,
|
||||
darkenPercentage = darkenPercentage,
|
||||
enableChanger = enableChanger,
|
||||
homeEnabled = homeEnabled,
|
||||
interval1 = interval1,
|
||||
interval2 = interval2,
|
||||
lastSetTime = lastSetTime,
|
||||
lockEnabled = lockEnabled,
|
||||
nextSetTime = nextSetTime,
|
||||
onDarkCheck = onDarkCheck,
|
||||
onDarkenPercentage = onDarkenPercentage,
|
||||
onHomeCheckedChange = onHomeCheckedChange,
|
||||
onLockCheckedChange = onLockCheckedChange,
|
||||
scheduleSeparately = scheduleSeparately,
|
||||
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
|
||||
onScheduleWallpaperChanger1 = onScheduleWallpaperChanger1,
|
||||
onScheduleWallpaperChanger2 = onScheduleWallpaperChanger2,
|
||||
onScalingChange = onScalingChange,
|
||||
onSelectAlbum = onSelectAlbum,
|
||||
onTimeChange1 = onTimeChange1,
|
||||
onTimeChange2 = onTimeChange2,
|
||||
onStop = onStop,
|
||||
onToggleChanger = onToggleChanger,
|
||||
scaling = scaling,
|
||||
selectedAlbum = selectedAlbum,
|
||||
blur = blur,
|
||||
onBlurPercentageChange = onBlurPercentageChange,
|
||||
onBlurChange = onBlurChange,
|
||||
blurPercentage = blurPercentage
|
||||
)
|
||||
1 -> LibraryScreen(
|
||||
else -> LibraryScreen(
|
||||
albums = albums,
|
||||
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.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.CheckCircle
|
||||
@@ -45,7 +44,7 @@ fun HomeTopBar (
|
||||
) {
|
||||
CenterAlignedTopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
||||
title = { if (!showSelectionModeAppBar) Text(stringResource(R.string.appname)) },
|
||||
title = { if (!showSelectionModeAppBar) Text(stringResource(R.string.app_name)) },
|
||||
actions = {
|
||||
if (showSelectionModeAppBar) {
|
||||
var showAlertDialog by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -87,7 +86,7 @@ fun HomeTopBar (
|
||||
.background(bgColor)
|
||||
)
|
||||
}
|
||||
Text("$selectionCount selected")
|
||||
Text(stringResource(R.string.selected_count, selectionCount))
|
||||
}
|
||||
} else {
|
||||
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
|
||||
)
|
||||
)
|
||||
}
|
||||
+7
-8
@@ -18,20 +18,18 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.components.AlbumItem
|
||||
|
||||
@Composable
|
||||
fun LibraryScreen(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
onAddNewAlbumClick: () -> Unit,
|
||||
onViewAlbum: (String) -> Unit
|
||||
onViewAlbum: (String) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val lazyListState = rememberLazyGridState()
|
||||
val state = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
floatingActionButton = {
|
||||
@@ -55,12 +53,13 @@ fun LibraryScreen(
|
||||
contentPadding = PaddingValues(4.dp, 4.dp),
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
content = {
|
||||
items (state.value.albumsWithWallpapers, key = { album -> album.album.initialAlbumName}
|
||||
items (albums, key = { album -> album.album.initialAlbumName}
|
||||
) { album ->
|
||||
AlbumItem(
|
||||
album = album.album,
|
||||
onAlbumViewClick = { onViewAlbum(album.album.initialAlbumName) },
|
||||
modifier = Modifier.padding(4.dp)
|
||||
modifier = Modifier.padding(4.dp),
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -5,14 +5,15 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.data.rememberCurrentOffset
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseScrollableSettings
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseSmallTopAppBar
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components.LicenseTitle
|
||||
|
||||
@Composable
|
||||
fun LicensesScreen(
|
||||
topInsets: Dp,
|
||||
onBackClick: () -> Unit,
|
||||
) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
@@ -25,14 +26,15 @@ fun LicensesScreen(
|
||||
LicenseScrollableSettings(
|
||||
largeTopAppBarHeightPx = largeTopAppBarHeight,
|
||||
lazyListState = lazyListState,
|
||||
offset = offset
|
||||
offset = offset,
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
LicenseSmallTopAppBar(onBackClick = onBackClick)
|
||||
LicenseTitle(
|
||||
largeTopAppBarHeight = largeTopAppBarHeight,
|
||||
smallTopAppBarHeight = smallTopAppBarHeight,
|
||||
paddingMedium = paddingMedium,
|
||||
offset = offset
|
||||
offset = offset,
|
||||
topInset = topInsets
|
||||
)
|
||||
}
|
||||
}
|
||||
+57
-24
@@ -6,50 +6,83 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
|
||||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibraryDefaults
|
||||
|
||||
/**
|
||||
* Scrollable license screen to display open source licenses
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun LicenseScrollableSettings(
|
||||
largeTopAppBarHeightPx: Dp,
|
||||
lazyListState: LazyListState,
|
||||
offset: State<Int>
|
||||
offset: State<Int>,
|
||||
onBackClick: () -> Unit
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
val offsetInDp = offset.value.toFloat() / 2f.dp.value
|
||||
val newHeight = largeTopAppBarHeightPx - offsetInDp.dp
|
||||
Spacer(Modifier.height(newHeight))
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
LibrariesContainer(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
lazyListState = lazyListState,
|
||||
showVersion = false,
|
||||
colors = LibraryDefaults.libraryColors(
|
||||
backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = MaterialTheme.colorScheme.onSurface,
|
||||
badgeBackgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
badgeContentColor = MaterialTheme.colorScheme.primary,
|
||||
dialogConfirmButtonColor = MaterialTheme.colorScheme.onSurface
|
||||
Scaffold (
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
) { it
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
val offsetInDp = offset.value.toFloat() / 2f.dp.value
|
||||
val newHeight = largeTopAppBarHeightPx - offsetInDp.dp
|
||||
Spacer(Modifier.height(newHeight))
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
LibrariesContainer(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
lazyListState = lazyListState,
|
||||
showVersion = false,
|
||||
colors = LibraryDefaults.libraryColors(
|
||||
backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
contentColor = MaterialTheme.colorScheme.onSurface,
|
||||
badgeBackgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp),
|
||||
badgeContentColor = MaterialTheme.colorScheme.primary,
|
||||
dialogConfirmButtonColor = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.licenses_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Small top app bar for license screen to replace [LicenseLargeTopAppBar] when scrolling down
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun LicenseSmallTopAppBar(onBackClick: () -> Unit) {
|
||||
Surface {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
+7
-11
@@ -1,19 +1,11 @@
|
||||
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.Text
|
||||
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.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -35,7 +27,8 @@ fun LicenseTitle(
|
||||
smallTopAppBarHeight: Dp,
|
||||
paddingMedium: Dp,
|
||||
modifier: Modifier = Modifier,
|
||||
offset: State<Int>
|
||||
offset: State<Int>,
|
||||
topInset: Dp,
|
||||
) {
|
||||
val titlePaddingStart = 16.dp
|
||||
val titlePaddingEnd = 64.dp
|
||||
@@ -44,6 +37,9 @@ fun LicenseTitle(
|
||||
var titleHeightPx by remember { mutableFloatStateOf(0f) }
|
||||
var titleWidthPx by remember { mutableFloatStateOf(0f) }
|
||||
|
||||
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
|
||||
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.licenses),
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
@@ -63,7 +59,7 @@ fun LicenseTitle(
|
||||
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
|
||||
|
||||
val titleYFirstInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
|
||||
largeTopAppBarHeight / 2,
|
||||
collapseFraction
|
||||
)
|
||||
@@ -76,7 +72,7 @@ fun LicenseTitle(
|
||||
|
||||
val titleYSecondInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight / 2,
|
||||
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
collapseFraction
|
||||
)
|
||||
|
||||
|
||||
+11
-47
@@ -18,23 +18,18 @@ import androidx.compose.material3.ExtendedFloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarResult
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.airbnb.lottie.compose.LottieAnimation
|
||||
@@ -43,46 +38,21 @@ import com.airbnb.lottie.compose.LottieConstants
|
||||
import com.airbnb.lottie.compose.animateLottieCompositionAsState
|
||||
import com.airbnb.lottie.compose.rememberLottieComposition
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun NotificationScreen(
|
||||
onAgree: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val scope = rememberCoroutineScope()
|
||||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.notification_animation))
|
||||
val progress by animateLottieCompositionAsState(
|
||||
composition = composition,
|
||||
iterations = LottieConstants.IterateForever,
|
||||
)
|
||||
val askPermission = rememberSaveable { mutableStateOf(false) }
|
||||
val askCount = rememberSaveable { mutableIntStateOf(0) }
|
||||
|
||||
val requestPermissionLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestPermission()
|
||||
) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
onAgree()
|
||||
} else {
|
||||
if (++askCount.intValue >= 2) {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
onAgree()
|
||||
}
|
||||
scope.launch {
|
||||
val result = snackbarHostState.showSnackbar(
|
||||
message = context.getString(R.string.notification_permission_is_required_for_this_app_to_work_properly),
|
||||
actionLabel = context.getString(R.string.allow),
|
||||
duration = SnackbarDuration.Short,
|
||||
)
|
||||
when (result) {
|
||||
SnackbarResult.Dismissed -> {}
|
||||
SnackbarResult.ActionPerformed -> { askPermission.value = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) { onAgree() }
|
||||
|
||||
fun handleFabClick() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
@@ -100,30 +70,24 @@ fun NotificationScreen(
|
||||
LaunchedEffect (askPermission.value) {
|
||||
if (askPermission.value) {
|
||||
handleFabClick()
|
||||
askPermission.value = false
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState,
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp, vertical = 8.dp))
|
||||
)
|
||||
}
|
||||
) },
|
||||
content = { it
|
||||
Column (modifier = Modifier.padding(32.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))
|
||||
LottieAnimation(
|
||||
composition = composition,
|
||||
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(
|
||||
imageVector = Icons.Outlined.Info,
|
||||
|
||||
+5
-3
@@ -6,13 +6,14 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacyScrollableSettings
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacySmallTopAppBar
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components.PrivacyTitle
|
||||
|
||||
@Composable
|
||||
fun PrivacyScreen(
|
||||
topInsets: Dp,
|
||||
onBackClick: () -> Unit,
|
||||
) {
|
||||
val scroll: ScrollState = rememberScrollState(0)
|
||||
@@ -24,13 +25,14 @@ fun PrivacyScreen(
|
||||
PrivacyScrollableSettings(
|
||||
largeTopAppBarHeightPx = largeTopAppBarHeight,
|
||||
scroll = scroll,
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
PrivacySmallTopAppBar(onBackClick = onBackClick)
|
||||
PrivacyTitle(
|
||||
scroll = scroll,
|
||||
largeTopAppBarHeight = largeTopAppBarHeight,
|
||||
smallTopAppBarHeight = smallTopAppBarHeight,
|
||||
paddingMedium = paddingMedium
|
||||
paddingMedium = paddingMedium,
|
||||
topInset = topInsets
|
||||
)
|
||||
}
|
||||
}
|
||||
+54
-21
@@ -7,47 +7,80 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
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
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun PrivacyScrollableSettings(
|
||||
largeTopAppBarHeightPx: Dp,
|
||||
scroll: ScrollState,
|
||||
onBackClick: () -> Unit
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scroll)
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
PrivacyPolicyText()
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) { it
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scroll)
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
PrivacyNoticeText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PrivacyPolicyText() {
|
||||
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("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("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("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("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("Children’s Privacy", "Paperize is not intended for children under the age of 13. We do not knowingly collect any information from children.")
|
||||
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("Contact Us", "If you have any questions or concerns about this privacy policy, please contact me at anthonyyla.dev@gmail.com.")
|
||||
fun PrivacyNoticeText() {
|
||||
SectionText(stringResource(R.string.privacy_intro_title), stringResource(R.string.privacy_intro_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_data_collection_title), stringResource(R.string.privacy_data_collection_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_information_usage_title), stringResource(R.string.privacy_information_usage_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_data_security_title), stringResource(R.string.privacy_data_security_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_third_party_services_title), stringResource(R.string.privacy_third_party_services_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_children_privacy_title), stringResource(R.string.privacy_children_privacy_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_changes_notice_title), stringResource(R.string.privacy_changes_notice_content, stringResource(R.string.app_name)))
|
||||
SectionText(stringResource(R.string.privacy_contact_us_title), stringResource(R.string.privacy_contact_us_content, "anthonyyla.dev@gmail.com"))
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.privacy_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Small top app bar for privacy screen to replace [PrivacyLargeTopAppBar] when scrolling down
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun PrivacySmallTopAppBar(onBackClick: () -> Unit) {
|
||||
Surface {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -27,7 +27,8 @@ fun PrivacyTitle(
|
||||
smallTopAppBarHeight: Dp,
|
||||
paddingMedium: Dp,
|
||||
scroll: ScrollState,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
topInset: Dp,
|
||||
) {
|
||||
val titlePaddingStart = 16.dp
|
||||
val titlePaddingEnd = 64.dp
|
||||
@@ -36,6 +37,9 @@ fun PrivacyTitle(
|
||||
var titleHeightPx by remember { mutableFloatStateOf(0f) }
|
||||
var titleWidthPx by remember { mutableFloatStateOf(0f) }
|
||||
|
||||
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
|
||||
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.privacy_policy),
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
@@ -55,7 +59,7 @@ fun PrivacyTitle(
|
||||
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
|
||||
|
||||
val titleYFirstInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
|
||||
largeTopAppBarHeight / 2,
|
||||
collapseFraction
|
||||
)
|
||||
@@ -68,7 +72,7 @@ fun PrivacyTitle(
|
||||
|
||||
val titleYSecondInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight / 2,
|
||||
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
collapseFraction
|
||||
)
|
||||
|
||||
|
||||
+16
-2
@@ -1,12 +1,26 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
|
||||
|
||||
sealed class SettingsEvent {
|
||||
data object Refresh: SettingsEvent()
|
||||
data object Reset: SettingsEvent()
|
||||
data object SetFirstLaunch: SettingsEvent()
|
||||
data object RefreshNextSetTime: SettingsEvent()
|
||||
data class SetDarkMode(val darkMode: Boolean?): SettingsEvent()
|
||||
data class SetAmoledTheme(val amoledTheme: Boolean): SettingsEvent()
|
||||
data class SetDynamicTheming(val dynamicTheming: Boolean): SettingsEvent()
|
||||
data class SetAnimate(val animate: Boolean): SettingsEvent()
|
||||
data class SetWallpaperInterval(val interval: Int): SettingsEvent()
|
||||
data class SetLockWithHome(val lockWithHome: Boolean): SettingsEvent()
|
||||
data class SetDarken(val darken: Boolean): SettingsEvent()
|
||||
data class SetBlur(val blur: Boolean): SettingsEvent()
|
||||
data class SetLock(val lock: Boolean): SettingsEvent()
|
||||
data class SetHome(val home: Boolean): SettingsEvent()
|
||||
data class SetScheduleSeparately(val scheduleSeparately: Boolean): SettingsEvent()
|
||||
data class SetHomeWallpaperInterval(val interval: Int): SettingsEvent()
|
||||
data class SetLockWallpaperInterval(val interval: Int): SettingsEvent()
|
||||
data class SetDarkenPercentage(val darkenPercentage: Int): SettingsEvent()
|
||||
data class SetBlurPercentage(val blurPercentage: Int): SettingsEvent()
|
||||
data class SetChangerToggle(val toggle: Boolean): SettingsEvent()
|
||||
data class SetWallpaperScaling(val scaling: ScalingConstants): SettingsEvent()
|
||||
}
|
||||
+17
-7
@@ -4,27 +4,34 @@ import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import 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 kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
topInsets: Dp,
|
||||
onBackClick: () -> Unit,
|
||||
onDarkModeClick: (Boolean?) -> Unit,
|
||||
onAmoledClick: (Boolean) -> Unit,
|
||||
onDynamicThemingClick: (Boolean) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
onLicenseClick: () -> Unit
|
||||
onLicenseClick: () -> Unit,
|
||||
onResetClick: () -> Unit
|
||||
) {
|
||||
val scroll: ScrollState = rememberScrollState(0)
|
||||
val largeTopAppBarHeight = 152.dp
|
||||
val smallTopAppBarHeight = 64.dp
|
||||
val largeTopAppBarHeight = TopAppBarDefaults.LargeAppBarExpandedHeight
|
||||
val smallTopAppBarHeight = TopAppBarDefaults.LargeAppBarCollapsedHeight
|
||||
val paddingMedium = 16.dp
|
||||
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
@@ -33,17 +40,20 @@ fun SettingsScreen(
|
||||
largeTopAppBarHeightPx = largeTopAppBarHeight,
|
||||
scroll = scroll,
|
||||
onDarkModeClick = onDarkModeClick,
|
||||
onAmoledClick = onAmoledClick,
|
||||
onDynamicThemingClick = onDynamicThemingClick,
|
||||
onAnimateClick = onAnimateClick,
|
||||
onPrivacyClick = onPrivacyClick,
|
||||
onLicenseClick = onLicenseClick
|
||||
onLicenseClick = onLicenseClick,
|
||||
onResetClick = onResetClick,
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
SettingsSmallTopAppBar(onBackClick = onBackClick)
|
||||
SettingsTitle(
|
||||
scroll = scroll,
|
||||
largeTopAppBarHeight = largeTopAppBarHeight,
|
||||
smallTopAppBarHeight = smallTopAppBarHeight,
|
||||
paddingMedium = paddingMedium
|
||||
paddingMedium = paddingMedium,
|
||||
topInset = topInsets
|
||||
)
|
||||
}
|
||||
}
|
||||
+17
-4
@@ -1,13 +1,26 @@
|
||||
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
|
||||
|
||||
data class SettingsState (
|
||||
data class SettingsState(
|
||||
val firstLaunch: Boolean = true,
|
||||
// App settings
|
||||
val darkMode: Boolean? = null,
|
||||
val amoledTheme: Boolean = false,
|
||||
val dynamicTheming: Boolean = false,
|
||||
val animate: Boolean = true,
|
||||
val interval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
val setLockWithHome: Boolean = false,
|
||||
// Wallpaper settings
|
||||
val enableChanger: Boolean = false,
|
||||
val setHomeWallpaper: Boolean = false,
|
||||
val setLockWallpaper: Boolean = false,
|
||||
val scheduleSeparately: Boolean = false,
|
||||
val homeInterval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
val lockInterval: Int = WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
val lastSetTime: String? = null,
|
||||
val nextSetTime: String? = null
|
||||
val nextSetTime: String? = null,
|
||||
val darkenPercentage: Int = 100,
|
||||
val darken: Boolean = false,
|
||||
val blur: Boolean = false,
|
||||
val blurPercentage: Int = 0,
|
||||
val wallpaperScaling: ScalingConstants = ScalingConstants.FILL
|
||||
)
|
||||
+345
-74
@@ -1,8 +1,8 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.core.ScalingConstants
|
||||
import com.anthonyla.paperize.core.SettingsConstants
|
||||
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@@ -14,9 +14,9 @@ import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@@ -33,26 +33,48 @@ class SettingsViewModel @Inject constructor (
|
||||
var setKeepOnScreenCondition: Boolean = true
|
||||
|
||||
init {
|
||||
currentGetJob = viewModelScope.launch {
|
||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||
val wallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
val firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true }
|
||||
val setLockWithHome = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false }
|
||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
val amoledTheme = async { settingsDataStoreImpl.getBoolean(SettingsConstants.AMOLED_THEME_TYPE) ?: false }
|
||||
val dynamicTheming = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DYNAMIC_THEME_TYPE) ?: false }
|
||||
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: true }
|
||||
val setHomeWallpaper = async { settingsDataStoreImpl.getBoolean(SettingsConstants.HOME_WALLPAPER) ?: false }
|
||||
val setLockWallpaper = async { settingsDataStoreImpl.getBoolean(SettingsConstants.LOCK_WALLPAPER) ?: false }
|
||||
val homeWallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||
val lockWallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||
val 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) }
|
||||
val scheduleSeparately = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SCHEDULE_SEPARATELY) ?: false }
|
||||
val blur = async { settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false }
|
||||
val blurPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.BLUR_PERCENTAGE) ?: 0 }
|
||||
|
||||
_state.update { it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await()
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
amoledTheme = amoledTheme.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
homeInterval = homeWallpaperInterval.await(),
|
||||
lockInterval = lockWallpaperInterval.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await(),
|
||||
enableChanger = enableChanger.await(),
|
||||
darkenPercentage = darkenPercentage.await(),
|
||||
darken = darken.await(),
|
||||
wallpaperScaling = wallpaperScaling.await(),
|
||||
setHomeWallpaper = setHomeWallpaper.await(),
|
||||
setLockWallpaper = setLockWallpaper.await(),
|
||||
scheduleSeparately = scheduleSeparately.await(),
|
||||
blur = blur.await(),
|
||||
blurPercentage = blurPercentage.await()
|
||||
)
|
||||
}
|
||||
setKeepOnScreenCondition = false
|
||||
}
|
||||
}
|
||||
@@ -60,95 +82,344 @@ class SettingsViewModel @Inject constructor (
|
||||
fun onEvent(event: SettingsEvent) {
|
||||
when (event) {
|
||||
is SettingsEvent.SetFirstLaunch -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.FIRST_LAUNCH, false)
|
||||
_state.update { it.copy(
|
||||
firstLaunch = false
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
firstLaunch = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetChangerToggle -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.ENABLE_CHANGER, event.toggle)
|
||||
_state.update {
|
||||
it.copy(
|
||||
enableChanger = event.toggle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.Refresh -> {
|
||||
currentGetJob = viewModelScope.launch {
|
||||
currentGetJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
val darkMode = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
val amoledTheme = async { settingsDataStoreImpl.getBoolean(SettingsConstants.AMOLED_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 firstLaunch = async { settingsDataStoreImpl.getBoolean(SettingsConstants.FIRST_LAUNCH) ?: true }
|
||||
val setLockWithHome = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SET_LOCK_WITH_HOME) ?: false }
|
||||
val lastSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.LAST_SET_TIME) }
|
||||
val nextSetTime = async { settingsDataStoreImpl.getString(SettingsConstants.NEXT_SET_TIME) }
|
||||
val animate = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ANIMATE_TYPE) ?: true }
|
||||
|
||||
_state.update { it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
interval = wallpaperInterval.await(),
|
||||
setLockWithHome = setLockWithHome.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await()
|
||||
) }
|
||||
val enableChanger = async { settingsDataStoreImpl.getBoolean(SettingsConstants.ENABLE_CHANGER) ?: true }
|
||||
val darkenPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.DARKEN_PERCENTAGE) ?: 0 }
|
||||
val darken = async { settingsDataStoreImpl.getBoolean(SettingsConstants.DARKEN) ?: false }
|
||||
val setHomeWallpaper = async { settingsDataStoreImpl.getBoolean(SettingsConstants.HOME_WALLPAPER) ?: false }
|
||||
val setLockWallpaper = async { settingsDataStoreImpl.getBoolean(SettingsConstants.LOCK_WALLPAPER) ?: false }
|
||||
val homeWallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||
val lockWallpaperInterval = async { settingsDataStoreImpl.getInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL) ?: SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT }
|
||||
val scheduleSeparately = async { settingsDataStoreImpl.getBoolean(SettingsConstants.SCHEDULE_SEPARATELY) ?: false }
|
||||
val blur = async { settingsDataStoreImpl.getBoolean(SettingsConstants.BLUR) ?: false }
|
||||
val blurPercentage = async { settingsDataStoreImpl.getInt(SettingsConstants.BLUR_PERCENTAGE) ?: 0 }
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = darkMode.await(),
|
||||
amoledTheme = amoledTheme.await(),
|
||||
dynamicTheming = dynamicTheming.await(),
|
||||
firstLaunch = firstLaunch.await(),
|
||||
lastSetTime = lastSetTime.await(),
|
||||
nextSetTime = nextSetTime.await(),
|
||||
animate = animate.await(),
|
||||
enableChanger = enableChanger.await(),
|
||||
darkenPercentage = darkenPercentage.await(),
|
||||
darken = darken.await(),
|
||||
setHomeWallpaper = setHomeWallpaper.await(),
|
||||
setLockWallpaper = setLockWallpaper.await(),
|
||||
lockInterval = lockWallpaperInterval.await(),
|
||||
homeInterval = homeWallpaperInterval.await(),
|
||||
scheduleSeparately = scheduleSeparately.await(),
|
||||
blur = blur.await(),
|
||||
blurPercentage = blurPercentage.await(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetDarkMode -> {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (event.darkMode) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DARK_MODE_TYPE, false) }
|
||||
null -> { settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE) }
|
||||
}
|
||||
_state.update { it.copy(
|
||||
darkMode = event.darkMode
|
||||
) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = event.darkMode
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetAmoledTheme -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.AMOLED_THEME_TYPE, event.amoledTheme)
|
||||
if (event.amoledTheme) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
amoledTheme = event.amoledTheme,
|
||||
dynamicTheming = if (event.amoledTheme) false else it.dynamicTheming
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetDynamicTheming -> {
|
||||
viewModelScope.launch {
|
||||
when (event.dynamicTheming) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, false) }
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.DYNAMIC_THEME_TYPE, event.dynamicTheming)
|
||||
if (event.dynamicTheming) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.AMOLED_THEME_TYPE, false)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
amoledTheme = if (event.dynamicTheming) false else it.amoledTheme,
|
||||
dynamicTheming = event.dynamicTheming
|
||||
)
|
||||
}
|
||||
_state.update { it.copy(
|
||||
dynamicTheming = event.dynamicTheming
|
||||
) }
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetAnimate -> {
|
||||
viewModelScope.launch {
|
||||
when (event.animate) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, false) }
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.ANIMATE_TYPE, event.animate)
|
||||
_state.update {
|
||||
it.copy(
|
||||
animate = event.animate
|
||||
)
|
||||
}
|
||||
_state.update { it.copy(
|
||||
animate = event.animate
|
||||
) }
|
||||
}
|
||||
}
|
||||
is SettingsEvent.SetWallpaperInterval -> {
|
||||
viewModelScope.launch {
|
||||
val formatter = DateTimeFormatter.ofPattern("MM/dd/yy hh:mm\na")
|
||||
val time = LocalDateTime.now()
|
||||
val formattedLastSetTime = time.format(formatter)
|
||||
val formattedNextSetTime = time.plusMinutes(event.interval.toLong()).format(formatter)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, formattedLastSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, formattedNextSetTime)
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.WALLPAPER_CHANGE_INTERVAL, event.interval)
|
||||
_state.update { it.copy(
|
||||
interval = event.interval,
|
||||
lastSetTime = formattedLastSetTime,
|
||||
nextSetTime = formattedNextSetTime
|
||||
) }
|
||||
|
||||
is SettingsEvent.SetHomeWallpaperInterval -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL, event.interval)
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val currentTime = LocalDateTime.now()
|
||||
val nextSetTime: String?
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
if (_state.value.scheduleSeparately) {
|
||||
val nextSetTime1 = currentTime.plusMinutes(event.interval.toLong())
|
||||
val nextSetTime2 = currentTime.plusMinutes(_state.value.lockInterval.toLong())
|
||||
nextSetTime = (if (nextSetTime1!!.isBefore(nextSetTime2)) nextSetTime1 else nextSetTime2)!!.format(formatter)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, nextSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_1, nextSetTime1.toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_2, nextSetTime2.toString())
|
||||
}
|
||||
else {
|
||||
nextSetTime = currentTime.plusMinutes(event.interval.toLong()).format(formatter)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, nextSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_1, currentTime.plusMinutes(event.interval.toLong()).toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_2, currentTime.plusMinutes(event.interval.toLong()).toString())
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
homeInterval = event.interval,
|
||||
lastSetTime = currentTime.format(formatter),
|
||||
nextSetTime = nextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
is SettingsEvent.SetLockWithHome -> {
|
||||
|
||||
is SettingsEvent.SetLockWallpaperInterval -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL, event.interval)
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val currentTime = LocalDateTime.now()
|
||||
val nextSetTime: String?
|
||||
settingsDataStoreImpl.putString(SettingsConstants.LAST_SET_TIME, currentTime.format(formatter))
|
||||
if (_state.value.scheduleSeparately) {
|
||||
val nextSetTime1 = currentTime.plusMinutes(_state.value.homeInterval.toLong())
|
||||
val nextSetTime2 = currentTime.plusMinutes(event.interval.toLong())
|
||||
nextSetTime = (if (nextSetTime1!!.isBefore(nextSetTime2)) nextSetTime1 else nextSetTime2)!!.format(formatter)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, nextSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_1, nextSetTime1.toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_2, nextSetTime2.toString())
|
||||
}
|
||||
else {
|
||||
nextSetTime = currentTime.plusMinutes(event.interval.toLong()).format(formatter)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME, nextSetTime)
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_1, currentTime.plusMinutes(event.interval.toLong()).toString())
|
||||
settingsDataStoreImpl.putString(SettingsConstants.NEXT_SET_TIME_2, currentTime.plusMinutes(event.interval.toLong()).toString())
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
lockInterval = event.interval,
|
||||
lastSetTime = currentTime.format(formatter),
|
||||
nextSetTime = nextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.RefreshNextSetTime -> {
|
||||
viewModelScope.launch {
|
||||
when (event.lockWithHome) {
|
||||
true -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, true) }
|
||||
false -> { settingsDataStoreImpl.putBoolean(SettingsConstants.SET_LOCK_WITH_HOME, false) }
|
||||
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
val currentTime = LocalDateTime.now()
|
||||
val nextSetTime: String?
|
||||
if (_state.value.scheduleSeparately) {
|
||||
val nextSetTime1 = currentTime.plusMinutes(_state.value.homeInterval.toLong())
|
||||
val nextSetTime2 = currentTime.plusMinutes(_state.value.lockInterval.toLong())
|
||||
nextSetTime = (if (nextSetTime1!!.isBefore(nextSetTime2)) nextSetTime1 else nextSetTime2)!!.format(formatter)
|
||||
}
|
||||
else {
|
||||
nextSetTime = currentTime.plusMinutes(_state.value.homeInterval.toLong()).format(formatter)
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
lastSetTime = currentTime.format(formatter),
|
||||
nextSetTime = nextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetHome -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.HOME_WALLPAPER, event.home)
|
||||
_state.update {
|
||||
it.copy(
|
||||
setHomeWallpaper = event.home
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetLock -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.LOCK_WALLPAPER, event.lock)
|
||||
_state.update {
|
||||
it.copy(
|
||||
setLockWallpaper = event.lock
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.DARKEN, event.darken)
|
||||
_state.update {
|
||||
it.copy(
|
||||
darken = event.darken
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetWallpaperScaling -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putString(SettingsConstants.WALLPAPER_SCALING, event.scaling.name)
|
||||
_state.update {
|
||||
it.copy(
|
||||
wallpaperScaling = event.scaling
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetScheduleSeparately -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.SCHEDULE_SEPARATELY, event.scheduleSeparately)
|
||||
_state.update {
|
||||
it.copy(
|
||||
scheduleSeparately = event.scheduleSeparately
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetBlur -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putBoolean(SettingsConstants.BLUR, event.blur)
|
||||
_state.update {
|
||||
it.copy(
|
||||
blur = event.blur
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.SetBlurPercentage -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.putInt(SettingsConstants.BLUR_PERCENTAGE, event.blurPercentage)
|
||||
_state.update {
|
||||
it.copy(
|
||||
blurPercentage = event.blurPercentage
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is SettingsEvent.Reset -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARK_MODE_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.AMOLED_THEME_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DYNAMIC_THEME_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_LAUNCH)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.LAST_SET_TIME)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_SET_TIME)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.ANIMATE_TYPE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.ENABLE_CHANGER)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.DARKEN_PERCENTAGE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.DARKEN)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.WALLPAPER_SCALING)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.HOME_WALLPAPER)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.LOCK_WALLPAPER)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.LOCK_WALLPAPER_CHANGE_INTERVAL)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.HOME_WALLPAPER_CHANGE_INTERVAL)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.SCHEDULE_SEPARATELY)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.BLUR)
|
||||
settingsDataStoreImpl.deleteInt(SettingsConstants.BLUR_PERCENTAGE)
|
||||
settingsDataStoreImpl.deleteBoolean(SettingsConstants.FIRST_SET)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_SET_TIME_1)
|
||||
settingsDataStoreImpl.deleteString(SettingsConstants.NEXT_SET_TIME_2)
|
||||
|
||||
_state.update {
|
||||
it.copy(
|
||||
darkMode = null,
|
||||
amoledTheme = false,
|
||||
dynamicTheming = false,
|
||||
firstLaunch = true,
|
||||
lastSetTime = null,
|
||||
nextSetTime = null,
|
||||
animate = true,
|
||||
enableChanger = true,
|
||||
darkenPercentage = 100,
|
||||
darken = false,
|
||||
wallpaperScaling = ScalingConstants.FILL,
|
||||
setHomeWallpaper = false,
|
||||
setLockWallpaper = false,
|
||||
lockInterval = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
homeInterval = SettingsConstants.WALLPAPER_CHANGE_INTERVAL_DEFAULT,
|
||||
scheduleSeparately = false,
|
||||
blur = false,
|
||||
blurPercentage = 0
|
||||
)
|
||||
}
|
||||
_state.update { it.copy(
|
||||
setLockWithHome = event.lockWithHome
|
||||
) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
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.filled.DarkMode
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
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.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* AMOLED list item to enable AMOLED mode
|
||||
*/
|
||||
@Composable
|
||||
fun AmoledListItem(amoledMode: Boolean, onAmoledClick: (Boolean) -> Unit) {
|
||||
val context = LocalContext.current
|
||||
Row {
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.clickable { onAmoledClick(!amoledMode) },
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.amoled_mode),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = stringResource(R.string.full_dark_mode),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
trailingContent = {
|
||||
Switch(
|
||||
modifier = Modifier.semantics { contentDescription = context.getString(R.string.amoled_mode) },
|
||||
checked = amoledMode,
|
||||
onCheckedChange = onAmoledClick,
|
||||
enabled = true
|
||||
) },
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Filled.DarkMode,
|
||||
contentDescription = stringResource(R.string.amoled_mode),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
) },
|
||||
tonalElevation = 5.dp
|
||||
)
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Animation
|
||||
import androidx.compose.material.icons.outlined.Palette
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -14,15 +13,19 @@ 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.platform.LocalContext
|
||||
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 com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Enable animation switch
|
||||
*/
|
||||
@Composable
|
||||
fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
||||
val context = LocalContext.current
|
||||
Row {
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
@@ -30,17 +33,17 @@ fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
||||
.clickable { onAnimateClick(!animate) },
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = "Animation",
|
||||
text = stringResource(R.string.animation),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = "Increase visual appeal",
|
||||
text = stringResource(R.string.increase_visual_appeal),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
trailingContent = {
|
||||
Switch(
|
||||
modifier = Modifier.semantics { contentDescription = "Animation" },
|
||||
modifier = Modifier.semantics { contentDescription = context.getString(R.string.animation) },
|
||||
checked = animate,
|
||||
onCheckedChange = onAnimateClick,
|
||||
enabled = true
|
||||
@@ -48,7 +51,7 @@ fun AnimationListItem(animate: Boolean, onAnimateClick: (Boolean) -> Unit) {
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Outlined.Animation,
|
||||
contentDescription = "Animation",
|
||||
contentDescription = stringResource(R.string.animation),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
) },
|
||||
tonalElevation = 5.dp
|
||||
|
||||
-3
@@ -4,10 +4,7 @@ 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.ArrowCircleRight
|
||||
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.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
||||
+12
-10
@@ -15,7 +15,6 @@ import androidx.compose.material.icons.outlined.Brightness6
|
||||
import androidx.compose.material.icons.outlined.BrightnessAuto
|
||||
import androidx.compose.material.icons.outlined.DarkMode
|
||||
import androidx.compose.material.icons.outlined.LightMode
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -30,19 +29,20 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Three-state selector for dark mode in settings
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
val options = listOf(
|
||||
Triple("Dark Mode", Icons.Outlined.DarkMode, Icons.Filled.DarkMode),
|
||||
Triple("Automatic Device Mode", Icons.Outlined.BrightnessAuto, Icons.Filled.BrightnessAuto),
|
||||
Triple("Light Mode", Icons.Outlined.LightMode, Icons.Filled.LightMode)
|
||||
Triple(stringResource(R.string.dark_mode), Icons.Outlined.DarkMode, Icons.Filled.DarkMode),
|
||||
Triple(stringResource(R.string.automatic_device_mode), Icons.Outlined.BrightnessAuto, Icons.Filled.BrightnessAuto),
|
||||
Triple(stringResource(R.string.light_mode), Icons.Outlined.LightMode, Icons.Filled.LightMode)
|
||||
)
|
||||
var selectedIndex by remember {
|
||||
mutableIntStateOf(
|
||||
@@ -51,7 +51,8 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
false -> 2
|
||||
else -> 1
|
||||
}
|
||||
) }
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
@@ -70,16 +71,17 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
2 -> false
|
||||
else -> null
|
||||
}
|
||||
) },
|
||||
)
|
||||
},
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = "Dark Mode",
|
||||
text = stringResource(R.string.theme),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = "Easier on the eyes",
|
||||
text = stringResource(R.string.easier_on_the_eyes),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
) },
|
||||
@@ -116,7 +118,7 @@ fun DarkModeListItem(darkMode: Boolean?, onDarkModeClick: (Boolean?) -> Unit) {
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Outlined.Brightness6,
|
||||
contentDescription = "Dark Mode",
|
||||
contentDescription = stringResource(R.string.dark_mode),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
},
|
||||
|
||||
+8
-4
@@ -13,15 +13,19 @@ 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.platform.LocalContext
|
||||
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 com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Dynamic theming switch
|
||||
*/
|
||||
@Composable
|
||||
fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Boolean) -> Unit) {
|
||||
val context = LocalContext.current
|
||||
Row {
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
@@ -29,18 +33,18 @@ fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Bool
|
||||
.clickable { onDynamicThemingClick(!dynamicTheming) },
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = "Dynamic Theme",
|
||||
text = stringResource(R.string.dynamic_theme),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = "Material You",
|
||||
text = stringResource(R.string.material_you),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
trailingContent = {
|
||||
Switch(
|
||||
modifier = Modifier.semantics { contentDescription = "Dynamic Theme" },
|
||||
modifier = Modifier.semantics { contentDescription = context.getString(R.string.dynamic_theme) },
|
||||
checked = dynamicTheming,
|
||||
onCheckedChange = onDynamicThemingClick,
|
||||
enabled = true
|
||||
@@ -48,7 +52,7 @@ fun DynamicThemingListItem(dynamicTheming: Boolean, onDynamicThemingClick: (Bool
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Outlined.Palette,
|
||||
contentDescription = "Dynamic Theming",
|
||||
contentDescription = stringResource(R.string.dynamic_theming),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
) },
|
||||
tonalElevation = 5.dp
|
||||
|
||||
+1
-3
@@ -4,8 +4,6 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
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.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -34,7 +32,7 @@ fun LicenseListItem(onLicenseClick: () -> Unit) {
|
||||
) },
|
||||
supportingContent = {
|
||||
Text(
|
||||
text = "Click here to view the licenses",
|
||||
text = stringResource(R.string.click_here_to_view_the_licenses),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
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 = {
|
||||
Text(
|
||||
text = "Click here to view our privacy policy",
|
||||
text = stringResource(R.string.click_here_to_view_our_privacy_policy),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
) },
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+145
-42
@@ -1,32 +1,55 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
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.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.data.Contact
|
||||
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.launch
|
||||
|
||||
/**
|
||||
* Scrollable settings screen to wrap all settings components
|
||||
*/
|
||||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScrollableSettings(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
@@ -34,12 +57,17 @@ fun SettingsScrollableSettings(
|
||||
scroll: ScrollState,
|
||||
onDynamicThemingClick: (Boolean) -> Unit,
|
||||
onDarkModeClick: (Boolean?) -> Unit,
|
||||
onAmoledClick: (Boolean) -> Unit,
|
||||
onAnimateClick: (Boolean) -> Unit,
|
||||
onPrivacyClick: () -> Unit,
|
||||
onLicenseClick: () -> Unit
|
||||
onLicenseClick: () -> Unit,
|
||||
onResetClick: () -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
var toContact by rememberSaveable { mutableStateOf(false) }
|
||||
if (toContact) {
|
||||
@@ -47,45 +75,120 @@ fun SettingsScrollableSettings(
|
||||
toContact = false
|
||||
}
|
||||
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scroll)
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
val translateLink = "https://crowdin.com/project/paperize/invite?h=d8d7a7513d2beb0c96ba9b2a5f85473e2084922"
|
||||
val githubLink = "https://github.com/Anthonyy232/Paperize"
|
||||
val playstoreLink = "https://play.google.com/store/apps/details?id=com.anthonyla.paperize"
|
||||
val fdroidLink = ""
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
ListSectionTitle("Appearance")
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
DarkModeListItem(
|
||||
darkMode = state.value.darkMode,
|
||||
onDarkModeClick = { onDarkModeClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
DynamicThemingListItem(
|
||||
dynamicTheming = state.value.dynamicTheming,
|
||||
onDynamicThemingClick = { onDynamicThemingClick(it) }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
AnimationListItem(
|
||||
animate = state.value.animate,
|
||||
onAnimateClick = { onAnimateClick(it) }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ListSectionTitle("About")
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
PrivacyPolicyListItem (onPrivacyPolicyClick = onPrivacyClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
LicenseListItem(onLicenseClick = onLicenseClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ContactListItem(onContactClick = { toContact = true })
|
||||
//GPL and License and link to github etc, contact, terms of service, privacy policy
|
||||
}
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState,
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
content = {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scroll)
|
||||
.padding(horizontal = 24.dp),
|
||||
) {
|
||||
Spacer(Modifier.height(largeTopAppBarHeightPx))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ListSectionTitle(stringResource(R.string.appearance))
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
DarkModeListItem(
|
||||
darkMode = state.value.darkMode,
|
||||
onDarkModeClick = { onDarkModeClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
if (state.value.darkMode == null || state.value.darkMode == true) {
|
||||
AmoledListItem(
|
||||
amoledMode = state.value.amoledTheme,
|
||||
onAmoledClick = { onAmoledClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
DynamicThemingListItem(
|
||||
dynamicTheming = state.value.dynamicTheming,
|
||||
onDynamicThemingClick = { onDynamicThemingClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
AnimationListItem(
|
||||
animate = state.value.animate,
|
||||
onAnimateClick = { onAnimateClick(it) }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
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))
|
||||
PrivacyPolicyListItem (onPrivacyPolicyClick = onPrivacyClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
LicenseListItem(onLicenseClick = onLicenseClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ContactListItem(onContactClick = { toContact = true })
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
PaperizeListItem(
|
||||
onGitHubClick = {
|
||||
val openURL = Intent(Intent.ACTION_VIEW)
|
||||
openURL.data = Uri.parse(githubLink)
|
||||
context.startActivity(openURL)
|
||||
},
|
||||
onPlaystoreClick = {
|
||||
val openURL = Intent(Intent.ACTION_VIEW)
|
||||
openURL.data = Uri.parse(playstoreLink)
|
||||
context.startActivity(openURL)
|
||||
},
|
||||
onFdroidClick = {
|
||||
coroutineScope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = context.getString(R.string.coming_soon),
|
||||
actionLabel = context.getString(R.string.dismiss),
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ResetListItem(onResetClick = onResetClick)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Small top app bar for settings screen to replace [SettingsLargeTopAppBar] when scrolling down
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsSmallTopAppBar(onBackClick: () -> Unit) {
|
||||
Surface {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.Transparent),
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = onBackClick,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.size(24.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.home_screen)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -27,6 +27,7 @@ fun SettingsTitle(
|
||||
smallTopAppBarHeight: Dp,
|
||||
paddingMedium: Dp,
|
||||
scroll: ScrollState,
|
||||
topInset: Dp,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val titlePaddingStart = 16.dp
|
||||
@@ -35,6 +36,8 @@ fun SettingsTitle(
|
||||
val titleFontScaleEnd = 0.7f
|
||||
var titleHeightPx by remember { mutableFloatStateOf(0f) }
|
||||
var titleWidthPx by remember { mutableFloatStateOf(0f) }
|
||||
val fraction = (topInset - 74.dp) / (151.dp - 74.dp)
|
||||
val statusPadding = lerp(0.dp, 24.dp, fraction.coerceIn(0f, 1f))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.settings_screen),
|
||||
@@ -55,7 +58,7 @@ fun SettingsTitle(
|
||||
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2f
|
||||
|
||||
val titleYFirstInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium,
|
||||
largeTopAppBarHeight - titleHeightPx.toDp() - paddingMedium + statusPadding,
|
||||
largeTopAppBarHeight / 2,
|
||||
collapseFraction
|
||||
)
|
||||
@@ -68,7 +71,7 @@ fun SettingsTitle(
|
||||
|
||||
val titleYSecondInterpolatedPoint = lerp(
|
||||
largeTopAppBarHeight / 2,
|
||||
(smallTopAppBarHeight - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
(smallTopAppBarHeight + statusPadding - titleHeightPx.toDp() / 2) - 5.dp,
|
||||
collapseFraction
|
||||
)
|
||||
|
||||
|
||||
-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
|
||||
)
|
||||
}
|
||||
}
|
||||
+39
-36
@@ -1,5 +1,7 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.startup_screen
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
@@ -9,6 +11,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.sharp.CheckCircleOutline
|
||||
@@ -34,6 +37,8 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.airbnb.lottie.compose.LottieAnimation
|
||||
@@ -44,11 +49,11 @@ import com.airbnb.lottie.compose.rememberLottieComposition
|
||||
import com.anthonyla.paperize.R
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
// Inspired by https://github.com/Ashinch/ReadYou
|
||||
@Composable
|
||||
fun StartupScreen(
|
||||
onAgree: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.onboarding_animation))
|
||||
val progress by animateLottieCompositionAsState(
|
||||
composition = composition,
|
||||
@@ -59,6 +64,12 @@ fun StartupScreen(
|
||||
var showToS by remember { mutableStateOf(false) }
|
||||
var seenToS by remember { mutableStateOf(false) }
|
||||
|
||||
val context = LocalContext.current
|
||||
val activity = context as? Activity
|
||||
BackHandler {
|
||||
activity?.moveTaskToBack(true)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
@@ -66,7 +77,8 @@ fun StartupScreen(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 8.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
@@ -78,7 +90,14 @@ fun StartupScreen(
|
||||
LottieAnimation(
|
||||
composition = composition,
|
||||
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(
|
||||
imageVector = Icons.Outlined.Info,
|
||||
@@ -86,7 +105,7 @@ fun StartupScreen(
|
||||
modifier = Modifier.padding(PaddingValues(vertical = 16.dp))
|
||||
)
|
||||
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
|
||||
)
|
||||
Box(
|
||||
@@ -101,7 +120,7 @@ fun StartupScreen(
|
||||
} },
|
||||
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 {
|
||||
scope.launch {
|
||||
val result = snackbarHostState.showSnackbar(
|
||||
message = "Please read and agree to the privacy policy.",
|
||||
actionLabel = "View",
|
||||
message = context.getString(R.string.please_read_and_agree_to_the_privacy_notice),
|
||||
actionLabel = context.getString(R.string.view),
|
||||
duration = SnackbarDuration.Short,
|
||||
)
|
||||
when (result) {
|
||||
@@ -142,23 +161,23 @@ fun StartupScreen(
|
||||
if (showToS) {
|
||||
seenToS = true
|
||||
AlertDialog(
|
||||
modifier = Modifier.fillMaxHeight(0.8f),
|
||||
modifier = Modifier.fillMaxHeight(0.7f),
|
||||
onDismissRequest = { showToS = false },
|
||||
title = {
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
Text(
|
||||
text = "Privacy Policy",
|
||||
text = stringResource(R.string.privacy_notice),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
)
|
||||
}
|
||||
},
|
||||
text = { PrivacyPolicyText() },
|
||||
text = { PrivacyNoticeText() },
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { showToS = false },
|
||||
) {
|
||||
Text("Dismiss")
|
||||
Text(stringResource(R.string.dismiss))
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -166,32 +185,16 @@ fun StartupScreen(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PrivacyPolicyText() {
|
||||
fun PrivacyNoticeText() {
|
||||
LazyColumn {
|
||||
item {
|
||||
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("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("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("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.")
|
||||
}
|
||||
item { SectionText(stringResource(R.string.privacy_intro_title), stringResource(R.string.privacy_intro_content, stringResource(R.string.app_name))) }
|
||||
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 { SectionText(stringResource(R.string.privacy_data_security_title), stringResource(R.string.privacy_data_security_content, stringResource(R.string.app_name))) }
|
||||
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 { SectionText(stringResource(R.string.privacy_changes_notice_title), stringResource(R.string.privacy_changes_notice_content, stringResource(R.string.app_name))) }
|
||||
item { SectionText(stringResource(R.string.privacy_contact_us_title), stringResource(R.string.privacy_contact_us_content, "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
|
||||
|
||||
val md_theme_light_primary = Color(0xFF984061)
|
||||
|
||||
+42
-72
@@ -1,81 +1,19 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.themes
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Color.TRANSPARENT
|
||||
import android.os.Build
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsState
|
||||
import 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(
|
||||
@@ -143,25 +81,58 @@ private val DarkColors = darkColorScheme(
|
||||
scrim = md_theme_dark_scrim,
|
||||
)
|
||||
|
||||
private val AmoledDarkColors = darkColorScheme(
|
||||
primary = md_theme_light_primary,
|
||||
onPrimary = md_theme_light_onPrimary,
|
||||
primaryContainer = md_theme_light_primaryContainer,
|
||||
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
||||
secondary = Color.Black,
|
||||
onSecondary = Color.White,
|
||||
secondaryContainer = Color.Black,
|
||||
onSecondaryContainer = Color.White,
|
||||
tertiary = md_theme_light_tertiary,
|
||||
onTertiary = md_theme_light_onTertiary,
|
||||
tertiaryContainer = Color.Black,
|
||||
onTertiaryContainer = Color.White,
|
||||
error = Color.Red,
|
||||
errorContainer = Color.Black,
|
||||
onError = Color.White,
|
||||
onErrorContainer = Color.Black,
|
||||
background = Color.Black,
|
||||
onBackground = Color.White,
|
||||
surface = Color.Black,
|
||||
onSurface = Color.White,
|
||||
surfaceVariant = Color.Black,
|
||||
onSurfaceVariant = Color.White,
|
||||
outline = Color.White,
|
||||
inverseOnSurface = Color.Black,
|
||||
inverseSurface = Color.White,
|
||||
inversePrimary = Color.White,
|
||||
surfaceTint = Color.Black,
|
||||
outlineVariant = md_theme_dark_outlineVariant,
|
||||
scrim = md_theme_dark_scrim,
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* App theming for dynamic theming when supported and dark mode.
|
||||
*/
|
||||
@Composable
|
||||
fun PaperizeTheme(
|
||||
settingsState: StateFlow<SettingsState>,
|
||||
darkMode: Boolean?,
|
||||
amoledMode: Boolean,
|
||||
dynamicTheming: Boolean,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val state = settingsState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
|
||||
val isDarkMode = isDarkMode(darkMode = state.value.darkMode)
|
||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = state.value.dynamicTheming)
|
||||
val isDarkMode = isDarkMode(darkMode = darkMode)
|
||||
val isDynamicTheming = isDynamicTheming(dynamicTheming = dynamicTheming)
|
||||
val dynamicThemingSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
val colors = when {
|
||||
isDynamicTheming && dynamicThemingSupported && isDarkMode -> dynamicDarkColorScheme(context)
|
||||
isDynamicTheming && dynamicThemingSupported && !isDarkMode -> dynamicLightColorScheme(context)
|
||||
isDarkMode -> DarkColors
|
||||
isDarkMode && amoledMode -> AmoledDarkColors
|
||||
isDarkMode && !amoledMode -> DarkColors
|
||||
else -> LightColors
|
||||
}
|
||||
|
||||
@@ -170,9 +141,8 @@ fun PaperizeTheme(
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
window.statusBarColor = TRANSPARENT
|
||||
SystemBarStyle.light(TRANSPARENT, TRANSPARENT)
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !isDarkMode
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = !isDarkMode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-4
@@ -2,10 +2,15 @@ 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.SelectedAlbum
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.Wallpaper
|
||||
|
||||
sealed class WallpaperEvent {
|
||||
data class UpdateSelectedAlbum(val selectedAlbum: SelectedAlbum): WallpaperEvent()
|
||||
object Reset : WallpaperEvent()
|
||||
object Refresh : WallpaperEvent()
|
||||
data class UpdateSelectedAlbum(
|
||||
val selectedAlbum: SelectedAlbum?,
|
||||
val album: AlbumWithWallpaperAndFolder?,
|
||||
val scheduleSeparately: Boolean = false,
|
||||
val setHome: Boolean = false,
|
||||
val setLock: Boolean = false
|
||||
): WallpaperEvent()
|
||||
data object Reset : WallpaperEvent()
|
||||
data object Refresh : WallpaperEvent()
|
||||
}
|
||||
+285
-126
@@ -1,14 +1,21 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.WallpaperManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.provider.Settings
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
@@ -23,36 +30,71 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.core.content.ContextCompat
|
||||
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.Wallpaper
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.album.AlbumsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsEvent
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.settings_screen.SettingsViewModel
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.AlbumBottomSheet
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.BlurSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ChangerSelectionRow
|
||||
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.SetLockScreenSwitch
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.DarkenSwitchAndSlider
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.ShowLiveWallpaperEnabledDialog
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.TimeSliders
|
||||
import com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components.WallpaperPreviewAndScale
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun WallpaperScreen(
|
||||
albumsViewModel: AlbumsViewModel = hiltViewModel(),
|
||||
wallpaperScreenViewModel: WallpaperScreenViewModel = hiltViewModel(),
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
onScheduleWallpaperChanger: (Int) -> Unit,
|
||||
onStop: () -> Unit
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
animate: Boolean,
|
||||
darken: Boolean,
|
||||
darkenPercentage: Int,
|
||||
enableChanger: Boolean,
|
||||
homeEnabled: Boolean,
|
||||
interval1: Int,
|
||||
interval2: Int,
|
||||
lastSetTime: String?,
|
||||
lockEnabled: Boolean,
|
||||
nextSetTime: String?,
|
||||
onDarkCheck: (Boolean) -> Unit,
|
||||
onDarkenPercentage: (Int) -> Unit,
|
||||
onHomeCheckedChange: (Boolean) -> Unit,
|
||||
onLockCheckedChange: (Boolean) -> Unit,
|
||||
scheduleSeparately: Boolean,
|
||||
onScheduleSeparatelyChange: (Boolean) -> Unit,
|
||||
onScheduleWallpaperChanger1: (Int) -> Unit,
|
||||
onScheduleWallpaperChanger2: (Int) -> Unit,
|
||||
onScalingChange: (ScalingConstants) -> Unit,
|
||||
onSelectAlbum: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||
onTimeChange1: (Int) -> Unit,
|
||||
onTimeChange2: (Int) -> Unit,
|
||||
onStop: () -> Unit,
|
||||
onToggleChanger: (Boolean) -> Unit,
|
||||
scaling: ScalingConstants,
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
blur: Boolean,
|
||||
onBlurPercentageChange: (Int) -> Unit,
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
blurPercentage: Int
|
||||
) {
|
||||
val albumState = albumsViewModel.state.collectAsStateWithLifecycle()
|
||||
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
|
||||
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
|
||||
val scrollState = rememberScrollState()
|
||||
val context = LocalContext.current
|
||||
var openBottomSheet by rememberSaveable { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val openLiveDialog = rememberSaveable { mutableStateOf(false) }
|
||||
val showInterval = rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
if (openLiveDialog.value) {
|
||||
ShowLiveWallpaperEnabledDialog(
|
||||
onDismissRequest = { openLiveDialog.value = false }
|
||||
)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
@@ -61,155 +103,272 @@ fun WallpaperScreen(
|
||||
snackbar = { data ->
|
||||
Snackbar(
|
||||
snackbarData = data,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp))
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 16.dp, vertical = 24.dp)),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
) },
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
content = { it
|
||||
LazyColumn(
|
||||
content = { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(scrollState)
|
||||
.fillMaxSize()
|
||||
.padding(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
item {
|
||||
ChangerSelectionRow(
|
||||
homeEnabled = homeEnabled,
|
||||
lockEnabled = lockEnabled,
|
||||
onHomeCheckedChange = onHomeCheckedChange,
|
||||
onLockCheckedChange = onLockCheckedChange
|
||||
)
|
||||
if (homeEnabled || lockEnabled) {
|
||||
CurrentSelectedAlbum(
|
||||
selectedAlbum = selectedState.value.selectedAlbum,
|
||||
selectedAlbum = selectedAlbum,
|
||||
onOpenBottomSheet = {
|
||||
if (albumState.value.albumsWithWallpapers.firstOrNull() != null) openBottomSheet = true
|
||||
},
|
||||
onStop = {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.Reset)
|
||||
if (albums.firstOrNull() != null) {
|
||||
if (isLiveWallpaperSet(context)) {
|
||||
openLiveDialog.value = true
|
||||
} else {
|
||||
openBottomSheet = true
|
||||
}
|
||||
} else {
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = "${selectedState.value.selectedAlbum?.album?.displayedAlbumName} has been unselected.",
|
||||
actionLabel = "Dismiss",
|
||||
message = context.getString(R.string.no_albums_found),
|
||||
actionLabel = context.getString(R.string.dismiss),
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
onStop = {
|
||||
if (selectedAlbum != null) {
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = context.getString(
|
||||
R.string.has_been_unselected,
|
||||
selectedAlbum.album.displayedAlbumName
|
||||
),
|
||||
actionLabel = context.getString(R.string.dismiss),
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
onStop()
|
||||
}
|
||||
},
|
||||
animate = animate,
|
||||
enableChanger = enableChanger,
|
||||
onToggleChanger = {
|
||||
if (!it) {
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = context.getString(R.string.wallpaper_changer_has_been_disabled),
|
||||
actionLabel = context.getString(R.string.dismiss),
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
}
|
||||
}
|
||||
onToggleChanger(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (settingsState.value.animate) {
|
||||
item {
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
CurrentAndNextChange(
|
||||
settingsState.value.lastSetTime,
|
||||
settingsState.value.nextSetTime
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
SetLockScreenSwitch(
|
||||
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
|
||||
checked = settingsState.value.setLockWithHome,
|
||||
onCheckedChange = { isChecked ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
AnimatedVisibility(
|
||||
visible = selectedState.value.selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
TimeSliders(
|
||||
timeInMinutes = settingsState.value.interval,
|
||||
onTimeChange = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
settingsViewModel.onEvent(
|
||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
||||
)
|
||||
onScheduleWallpaperChanger(totalMinutes)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
CurrentAndNextChange(lastSetTime, nextSetTime)
|
||||
}
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
WallpaperPreviewAndScale(
|
||||
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
|
||||
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
|
||||
animate = true,
|
||||
darken = darken,
|
||||
darkenPercentage = darkenPercentage,
|
||||
scaling = scaling,
|
||||
onScalingChange = onScalingChange,
|
||||
homeEnabled = homeEnabled,
|
||||
lockEnabled = lockEnabled,
|
||||
blur = blur,
|
||||
blurPercentage = blurPercentage
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
CurrentAndNextChange(
|
||||
settingsState.value.lastSetTime,
|
||||
settingsState.value.nextSetTime
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
WallpaperPreviewAndScale(
|
||||
currentHomeWallpaper = selectedAlbum.album.currentHomeWallpaper,
|
||||
currentLockWallpaper = selectedAlbum.album.currentLockWallpaper,
|
||||
animate = false,
|
||||
darken = darken,
|
||||
darkenPercentage = darkenPercentage,
|
||||
scaling = scaling,
|
||||
onScalingChange = onScalingChange,
|
||||
homeEnabled = homeEnabled,
|
||||
lockEnabled = lockEnabled,
|
||||
blur = blur,
|
||||
blurPercentage = blurPercentage
|
||||
)
|
||||
}
|
||||
item {
|
||||
if (selectedState.value.selectedAlbum != null) {
|
||||
SetLockScreenSwitch(
|
||||
albumUri = selectedState.value.selectedAlbum!!.album.coverUri,
|
||||
checked = settingsState.value.setLockWithHome,
|
||||
onCheckedChange = { isChecked ->
|
||||
settingsViewModel.onEvent(SettingsEvent.SetLockWithHome(isChecked))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
TimeSliders(
|
||||
timeInMinutes = settingsState.value.interval,
|
||||
onTimeChange = { days, hours, minutes ->
|
||||
timeInMinutes1 = interval1,
|
||||
timeInMinutes2 = interval2,
|
||||
onTimeChange1 = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
settingsViewModel.onEvent(
|
||||
SettingsEvent.SetWallpaperInterval(totalMinutes)
|
||||
)
|
||||
onScheduleWallpaperChanger(totalMinutes)
|
||||
}
|
||||
onTimeChange1(totalMinutes)
|
||||
},
|
||||
onTimeChange2 = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
onTimeChange2(totalMinutes)
|
||||
},
|
||||
showInterval = showInterval.value,
|
||||
animate = true,
|
||||
onShowIntervalChange = { showInterval.value = it },
|
||||
scheduleSeparately = scheduleSeparately,
|
||||
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
|
||||
lockEnabled = lockEnabled,
|
||||
homeEnabled = homeEnabled
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
TimeSliders(
|
||||
timeInMinutes1 = interval1,
|
||||
timeInMinutes2 = interval2,
|
||||
onTimeChange1 = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
onScheduleWallpaperChanger1(totalMinutes)
|
||||
},
|
||||
onTimeChange2 = { days, hours, minutes ->
|
||||
val totalMinutes = 24 * days * 60 + hours * 60 + minutes
|
||||
onScheduleWallpaperChanger2(totalMinutes)
|
||||
},
|
||||
showInterval = showInterval.value,
|
||||
animate = false,
|
||||
onShowIntervalChange = { showInterval.value = it },
|
||||
scheduleSeparately = scheduleSeparately,
|
||||
onScheduleSeparatelyChange = onScheduleSeparatelyChange,
|
||||
lockEnabled = lockEnabled,
|
||||
homeEnabled = homeEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
DarkenSwitchAndSlider(
|
||||
onDarkCheck = onDarkCheck,
|
||||
darken = darken,
|
||||
onDarkenChange = onDarkenPercentage,
|
||||
darkenPercentage = darkenPercentage,
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
DarkenSwitchAndSlider(
|
||||
onDarkCheck = onDarkCheck,
|
||||
darken = darken,
|
||||
onDarkenChange = onDarkenPercentage,
|
||||
darkenPercentage = darkenPercentage,
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = ((homeEnabled || lockEnabled)) && selectedAlbum != null,
|
||||
enter = slideInVertically(initialOffsetY = { -it }),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
BlurSwitchAndSlider(
|
||||
onBlurPercentageChange = onBlurPercentageChange,
|
||||
onBlurChange = onBlurChange,
|
||||
blur = blur,
|
||||
blurPercentage = blurPercentage,
|
||||
animate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((homeEnabled || lockEnabled)) && selectedAlbum != null) {
|
||||
BlurSwitchAndSlider(
|
||||
onBlurPercentageChange = onBlurPercentageChange,
|
||||
onBlurChange = onBlurChange,
|
||||
blur = blur,
|
||||
blurPercentage = blurPercentage,
|
||||
animate = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (openBottomSheet) {
|
||||
if (((homeEnabled || lockEnabled)) && openBottomSheet) {
|
||||
AlbumBottomSheet(
|
||||
albums = albumState.value.albumsWithWallpapers,
|
||||
currentSelectedAlbum = selectedState.value.selectedAlbum,
|
||||
albums = albums,
|
||||
currentSelectedAlbum = selectedAlbum,
|
||||
onDismiss = { openBottomSheet = false },
|
||||
onSelect = { album ->
|
||||
val wallpapers: List<Wallpaper> = album.wallpapers + album.folders.flatMap { folder ->
|
||||
folder.wallpapers.map { wallpaper ->
|
||||
Wallpaper(
|
||||
initialAlbumName = album.album.initialAlbumName,
|
||||
wallpaperUri = wallpaper,
|
||||
key = wallpaper.hashCode() + album.album.initialAlbumName.hashCode(),
|
||||
)
|
||||
openBottomSheet = false
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val alarmManager = ContextCompat.getSystemService(context, AlarmManager::class.java)
|
||||
if (alarmManager?.canScheduleExactAlarms() == false) {
|
||||
Intent().also { intent ->
|
||||
intent.action = Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
else {
|
||||
onSelectAlbum(album)
|
||||
onScheduleWallpaperChanger1(interval1)
|
||||
}
|
||||
}
|
||||
val newSelectedAlbum = SelectedAlbum(
|
||||
album = album.album.copy(
|
||||
wallpapersInQueue = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
openBottomSheet = false
|
||||
scope.launch {
|
||||
snackbarHostState.currentSnackbarData?.dismiss()
|
||||
snackbarHostState.showSnackbar(
|
||||
message = "${album.album.displayedAlbumName} has been selected.",
|
||||
actionLabel = "Dismiss",
|
||||
duration = SnackbarDuration.Short
|
||||
)
|
||||
else {
|
||||
onSelectAlbum(album)
|
||||
onScheduleWallpaperChanger1(interval1)
|
||||
}
|
||||
wallpaperScreenViewModel.onEvent(WallpaperEvent.UpdateSelectedAlbum(newSelectedAlbum))
|
||||
onScheduleWallpaperChanger(settingsState.value.interval)
|
||||
}
|
||||
},
|
||||
animate = animate
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fun isLiveWallpaperSet(context: Context): Boolean {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
return wallpaperManager.wallpaperInfo != null
|
||||
}
|
||||
+53
-19
@@ -1,10 +1,6 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
@@ -14,11 +10,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@@ -33,32 +27,72 @@ class WallpaperScreenViewModel @Inject constructor (
|
||||
)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
refreshAlbums()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||
isDataLoaded = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onEvent(event: WallpaperEvent) {
|
||||
when (event) {
|
||||
is WallpaperEvent.UpdateSelectedAlbum -> {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (!event.setHome && !event.setLock) return@launch
|
||||
if (event.selectedAlbum != null) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = 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 shuffledWallpapers1 = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
val shuffledWallpapers2 = wallpapers.map { it.wallpaperUri }.shuffled()
|
||||
val newSelectedAlbum = SelectedAlbum(
|
||||
album = event.album.album.copy(
|
||||
homeWallpapersInQueue = shuffledWallpapers1,
|
||||
lockWallpapersInQueue = shuffledWallpapers2,
|
||||
currentHomeWallpaper = if (event.setHome) shuffledWallpapers1.firstOrNull() else null,
|
||||
currentLockWallpaper = if (event.scheduleSeparately && event.setLock) shuffledWallpapers2.firstOrNull() else if (event.setLock) shuffledWallpapers1.firstOrNull() else null,
|
||||
),
|
||||
wallpapers = wallpapers
|
||||
)
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = newSelectedAlbum
|
||||
)
|
||||
}
|
||||
repository.upsertSelectedAlbum(newSelectedAlbum)
|
||||
}
|
||||
}
|
||||
}
|
||||
is WallpaperEvent.Refresh -> {
|
||||
refreshAlbums()
|
||||
}
|
||||
is WallpaperEvent.Reset -> {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
repository.deleteAll()
|
||||
_state.update {
|
||||
it.copy(selectedAlbum = null)
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
selectedAlbum = null
|
||||
)
|
||||
}
|
||||
repository.deleteAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,10 +100,10 @@ class WallpaperScreenViewModel @Inject constructor (
|
||||
|
||||
// Retrieve album from database into viewModel
|
||||
private fun refreshAlbums() {
|
||||
viewModelScope.launch {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
repository.getSelectedAlbum().collect { selectedAlbum ->
|
||||
_state.update { it.copy(
|
||||
selectedAlbum = selectedAlbum.firstOrNull()
|
||||
selectedAlbum = selectedAlbum.firstOrNull(),
|
||||
) }
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -3,5 +3,6 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
|
||||
data class WallpaperState (
|
||||
val isDataLoaded: Boolean = false,
|
||||
val selectedAlbum: SelectedAlbum? = null
|
||||
)
|
||||
+43
-28
@@ -1,9 +1,13 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
@@ -28,12 +32,12 @@ import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.core.isValidUri
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.AlbumWithWallpaperAndFolder
|
||||
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.glide.GlideImage
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -47,7 +51,8 @@ fun AlbumBottomSheet(
|
||||
onDismiss: () -> Unit,
|
||||
currentSelectedAlbum: SelectedAlbum?,
|
||||
albums: List<AlbumWithWallpaperAndFolder>,
|
||||
onSelect: (AlbumWithWallpaperAndFolder) -> Unit
|
||||
onSelect: (AlbumWithWallpaperAndFolder) -> Unit,
|
||||
animate: Boolean
|
||||
) {
|
||||
val modalBottomSheetState = rememberModalBottomSheetState()
|
||||
val scope = rememberCoroutineScope()
|
||||
@@ -55,12 +60,18 @@ fun AlbumBottomSheet(
|
||||
onDismissRequest = { onDismiss() },
|
||||
sheetState = modalBottomSheetState,
|
||||
dragHandle = { BottomSheetDefaults.DragHandle() },
|
||||
windowInsets = WindowInsets(0.dp)
|
||||
containerColor = MaterialTheme.colorScheme.background,
|
||||
tonalElevation = 5.dp,
|
||||
modifier = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
Modifier.fillMaxSize().padding(bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding())
|
||||
} else {
|
||||
Modifier.padding(bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding())
|
||||
}
|
||||
) {
|
||||
albums.forEach {
|
||||
if (it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size == 0) return@forEach
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.clickable {
|
||||
scope.launch {
|
||||
modalBottomSheetState.hide()
|
||||
@@ -74,8 +85,9 @@ fun AlbumBottomSheet(
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
) },
|
||||
supportingContent = {
|
||||
val totalWallpapers = it.folders.sumOf { folder -> folder.wallpapers.size } + it.wallpapers.size
|
||||
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,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
@@ -84,28 +96,31 @@ fun AlbumBottomSheet(
|
||||
Box (
|
||||
modifier = Modifier.size(60.dp)
|
||||
) {
|
||||
GlideImage(
|
||||
imageModel = { it.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.FillBounds,
|
||||
alignment = Alignment.Center,
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(
|
||||
Alignment.Center))
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
val showCoverUri = isValidUri(LocalContext.current, it.album.coverUri)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { it.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(150, 150),
|
||||
),
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.align(
|
||||
Alignment.Center
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
trailingContent = {
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
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 for the user to adjust the blur effect of the wallpaper
|
||||
*/
|
||||
@Composable
|
||||
fun BlurSwitchAndSlider(
|
||||
onBlurPercentageChange: (Int) -> Unit,
|
||||
onBlurChange: (Boolean) -> Unit,
|
||||
blur: Boolean,
|
||||
blurPercentage: Int,
|
||||
animate: Boolean
|
||||
) {
|
||||
val view = LocalView.current
|
||||
val scope = rememberCoroutineScope()
|
||||
var job by remember { mutableStateOf<Job?>(null) }
|
||||
var percentage by rememberSaveable { mutableFloatStateOf(blurPercentage.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.change_blur),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
fontWeight = FontWeight.W500
|
||||
)
|
||||
Switch(
|
||||
checked = blur,
|
||||
onCheckedChange = onBlurChange
|
||||
)
|
||||
}
|
||||
if (animate) {
|
||||
AnimatedVisibility(
|
||||
visible = blur,
|
||||
enter = expandVertically(animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow)),
|
||||
exit = fadeOut(
|
||||
animationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = LinearOutSlowInEasing
|
||||
)
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(R.string.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)
|
||||
onBlurPercentageChange(it.roundToInt())
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (blur) {
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(R.string.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)
|
||||
onBlurPercentageChange(it.roundToInt())
|
||||
}
|
||||
},
|
||||
valueRange = 0f..100f,
|
||||
steps = 100,
|
||||
modifier = Modifier.padding(PaddingValues(horizontal = 30.dp))
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
||||
import androidx.compose.material3.SegmentedButton
|
||||
import androidx.compose.material3.SegmentedButtonDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
@Composable
|
||||
fun ChangerSelectionRow(
|
||||
homeEnabled : Boolean,
|
||||
lockEnabled : Boolean,
|
||||
onHomeCheckedChange: (Boolean) -> Unit,
|
||||
onLockCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
MultiChoiceSegmentedButtonRow (
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(PaddingValues(start = 16.dp, end = 16.dp,))
|
||||
) {
|
||||
SegmentedButton(
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2),
|
||||
onCheckedChange = onHomeCheckedChange,
|
||||
checked = homeEnabled
|
||||
) {
|
||||
Text(text = stringResource(R.string.home_screen_btn))
|
||||
}
|
||||
SegmentedButton(
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2),
|
||||
onCheckedChange = onLockCheckedChange,
|
||||
checked = lockEnabled
|
||||
) {
|
||||
Text(stringResource(R.string.lock_screen_btn))
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-10
@@ -10,7 +10,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.QueuePlayNext
|
||||
import androidx.compose.material.icons.outlined.RemoveFromQueue
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
@@ -18,13 +17,15 @@ 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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anthonyla.paperize.R
|
||||
|
||||
/**
|
||||
* Contains the current and next change components that shows the last and next set time
|
||||
*/
|
||||
@Composable
|
||||
fun CurrentAndNextChange(
|
||||
lastSetTime: String?,
|
||||
@@ -38,10 +39,10 @@ fun CurrentAndNextChange(
|
||||
) {
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(PaddingValues(16.dp, 8.dp, 8.dp, 8.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -56,10 +57,16 @@ fun CurrentAndNextChange(
|
||||
)
|
||||
Column {
|
||||
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(parts[0], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text("${parts[1]} ${parts[2]}", style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally)) }
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.last_change), style = textFirst, 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +74,10 @@ fun CurrentAndNextChange(
|
||||
}
|
||||
Surface(
|
||||
tonalElevation = 10.dp,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(PaddingValues(16.dp, 8.dp, 8.dp, 8.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -85,10 +92,16 @@ fun CurrentAndNextChange(
|
||||
)
|
||||
Column {
|
||||
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(parts[0], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text("${parts[1]} ${parts[2]}", style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally)) }
|
||||
Text(parts[0].replace(',', ' '), style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
Text(parts[1], style = textSecond, modifier = Modifier.align(Alignment.CenterHorizontally))
|
||||
}
|
||||
else if (parts.size == 3) {
|
||||
Text(stringResource(R.string.last_change), style = textFirst, 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+69
-31
@@ -1,8 +1,11 @@
|
||||
package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.components
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -18,20 +21,23 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import com.anthonyla.paperize.R
|
||||
import com.anthonyla.paperize.feature.wallpaper.domain.model.SelectedAlbum
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions
|
||||
import com.skydoves.landscapist.ImageOptions
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
||||
@@ -41,14 +47,36 @@ import com.skydoves.landscapist.glide.GlideImage
|
||||
@Composable
|
||||
fun CurrentSelectedAlbum(
|
||||
selectedAlbum: SelectedAlbum?,
|
||||
enableChanger: Boolean,
|
||||
onOpenBottomSheet: () -> Unit,
|
||||
onStop: () -> Unit
|
||||
onStop: () -> Unit,
|
||||
animate: Boolean,
|
||||
onToggleChanger: (Boolean) -> Unit
|
||||
) {
|
||||
fun isValidUri(context: Context, uriString: String?): Boolean {
|
||||
val uri = uriString?.toUri()
|
||||
return try {
|
||||
uri?.let {
|
||||
val inputStream = context.contentResolver.openInputStream(it)
|
||||
inputStream?.close()
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
val showCoverUri = isValidUri(LocalContext.current, selectedAlbum?.album?.coverUri)
|
||||
|
||||
ListItem(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.padding(PaddingValues(vertical = 8.dp, horizontal = 16.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.clickable { onOpenBottomSheet() },
|
||||
.clickable {
|
||||
if (selectedAlbum != null) {
|
||||
onToggleChanger(!enableChanger)
|
||||
} else {
|
||||
onOpenBottomSheet()
|
||||
}
|
||||
},
|
||||
headlineContent = {
|
||||
Text(
|
||||
text = selectedAlbum?.album?.displayedAlbumName ?: stringResource(R.string.no_album_selected),
|
||||
@@ -59,37 +87,35 @@ fun CurrentSelectedAlbum(
|
||||
supportingContent = {
|
||||
if (selectedAlbum != null) {
|
||||
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,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
} },
|
||||
leadingContent = {
|
||||
Box (
|
||||
modifier = Modifier.size(60.dp)
|
||||
) {
|
||||
Box (modifier = Modifier.size(60.dp)) {
|
||||
if (selectedAlbum != null) {
|
||||
GlideImage(
|
||||
imageModel = { selectedAlbum.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.FillBounds,
|
||||
alignment = Alignment.Center,
|
||||
),
|
||||
requestBuilder = {
|
||||
Glide
|
||||
.with(LocalContext.current)
|
||||
.asBitmap()
|
||||
.transition(BitmapTransitionOptions.withCrossFade())
|
||||
},
|
||||
loading = {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
if (showCoverUri) {
|
||||
GlideImage(
|
||||
imageModel = { selectedAlbum.album.coverUri },
|
||||
imageOptions = ImageOptions(
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
requestSize = IntSize(150, 150),
|
||||
),
|
||||
loading = {
|
||||
if (animate) {
|
||||
Box(modifier = Modifier.matchParentSize()) {
|
||||
CircularProgressIndicator(modifier = Modifier.align(
|
||||
Alignment.Center))
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.aspectRatio(1f)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Image(
|
||||
imageVector = Icons.Default.RadioButtonUnchecked,
|
||||
@@ -100,7 +126,10 @@ fun CurrentSelectedAlbum(
|
||||
}
|
||||
},
|
||||
trailingContent = {
|
||||
Row {
|
||||
Row (
|
||||
horizontalArrangement = Arrangement.spacedBy((-8).dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (selectedAlbum != null) {
|
||||
IconButton(onClick = { onStop() }) {
|
||||
Icon(imageVector = Icons.Default.Stop, contentDescription = stringResource(R.string.stop_the_album))
|
||||
@@ -112,6 +141,15 @@ fun CurrentSelectedAlbum(
|
||||
imageVector = Icons.Filled.ArrowDropDown,
|
||||
)
|
||||
}
|
||||
if (selectedAlbum != null) {
|
||||
Switch(
|
||||
checked = enableChanger,
|
||||
onCheckedChange = onToggleChanger,
|
||||
modifier = Modifier
|
||||
.rotate(270f)
|
||||
.scale(0.75f)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
tonalElevation = 10.dp
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
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.change_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.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.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))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
Loaded 100 of 221 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user