diff --git a/README.md b/README.md
index e187f06..f33764f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+Snow
+----
Snow is a simple monotone icon pack forked from [Frost](https://github.com/dkanada/frost). Snow is FOSS and provides mostly icons for open-source apps on F-Droid (but there are many other apps in this pack too). The design is aiming to be simple with easy recognisable shapes.
@@ -6,11 +8,14 @@ Sadly actual LineageOS comes with an issue in Trebuchet which makes it incompati
Submitting icon requests helps a lot, but maintaining the project (as you may imagine) takes a lot of time and effort, so please be patient about adding new icons. Contributions for new icons are always welcome, and no experience with programming is necessary.
+[](https://f-droid.org/packages/org.baitmooth.snow/)
+
## Screenshots
-
## Contributing
### Submitting icon requests
@@ -56,7 +61,7 @@ Read the full details here:
## License
-Snow is built with with [Arcticons's](https://github.com/Donnnno/Arcticons/) modified [CandyBar Dashboard](https://github.com/zixpo/candybar), licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) which is compatible with the [GNU General Public License, Version 3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) that we use.
+Snow is built with [Candybar-FOSS](https://github.com/Donnnno/candybar-foss), licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) which is compatible with the [GNU General Public License, Version 3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) that we use.
All icons are licensed under [Creative Commonns Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) ](https://creativecommons.org/licenses/by-sa/4.0/), with around 1100 of the first icons from [Frost](https://github.com/dkanada/frost).
diff --git a/app/build.gradle b/app/build.gradle
index ad53788..195eb56 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 30
+ compileSdkVersion 31
defaultConfig {
applicationId "org.baitmooth.snow"
@@ -43,23 +43,8 @@ android {
}
dependencies {
- /*
- * CandyBar Material Dashboard Library
- *
- * TODO: How to update the dashboard?!
- * Check this update guide for every version
- * - https://github.com/zixpo/candybar-sample/wiki/Updating-the-dashboard
- * If you've missed some versions you've to also follow update guide for those versions
- */
-
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
-
- implementation fileTree(dir: 'libs', include: ['*.jar'])
-
- implementation 'androidx.appcompat:appcompat:1.3.1'
-
- implementation project(':libs:candybar')
- implementation project(':libs:extLibs:PreLollipopTransitions')
+ implementation 'com.github.Donnnno:candybar-foss:3.13.3'
}
diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png
index cff95ed..9070fb1 100644
Binary files a/app/src/main/ic_launcher-playstore.png and b/app/src/main/ic_launcher-playstore.png differ
diff --git a/app/src/main/res/drawable-nodpi/ic_splash_screen.png b/app/src/main/res/drawable-nodpi/ic_splash_screen.png
new file mode 100644
index 0000000..3d9a99f
Binary files /dev/null and b/app/src/main/res/drawable-nodpi/ic_splash_screen.png differ
diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml
index 88294a0..e27a030 100644
--- a/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ b/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -3,233 +3,27 @@
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
-
+
+ android:pathData="m67.732,130.177 l-16.56,-28.683 16.56,-28.683 16.56,28.683z"
+ android:fillColor="#fff"/>
+ android:pathData="m67.732,5.292 l-16.56,28.683 16.56,28.683 16.56,-28.683z"
+ android:fillColor="#fff"/>
+ android:pathData="m7.553,35.105l33.12,0l16.56,28.683 -33.12,0z"
+ android:fillColor="#fff"/>
+ android:pathData="m7.553,100.36l33.12,0l16.56,-28.683 -33.12,-0z"
+ android:fillColor="#fff"/>
+ android:pathData="m127.912,100.36l-33.12,0l-16.56,-28.683 33.12,-0z"
+ android:fillColor="#fff"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:pathData="m127.912,35.105l-33.12,0l-16.56,28.683 33.12,0z"
+ android:fillColor="#fff"/>
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..7353dbd
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..7353dbd
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
index 959a246..2e33a3e 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..c4b6280
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
index 734b10c..4b4f958 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 11187b2..ecfd9fd 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..de51842
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
index c2d8dd7..3283881 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index eff1663..e533a48 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..0afd4bb
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
index 599bb4f..077a9dc 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 952944c..038e77d 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..fdecefc
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
index d426bc6..c9fadd9 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index 6e3b51d..6b18da9 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..43a2ad5
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
index db26559..1486fab 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/libs/candybar/src/main/res/xml/drawable.xml b/app/src/main/res/values/ic_launcher_background.xml
similarity index 52%
rename from libs/candybar/src/main/res/xml/drawable.xml
rename to app/src/main/res/values/ic_launcher_background.xml
index 8f3c292..b15a8af 100644
--- a/libs/candybar/src/main/res/xml/drawable.xml
+++ b/app/src/main/res/values/ic_launcher_background.xml
@@ -1,4 +1,4 @@
- 1
+ #1A1A1A
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index c5c10e5..07792b4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.0.4'
+ classpath 'com.android.tools.build:gradle:7.1.2'
}
}
diff --git a/fastlane/metadata/android/en-US/images/icon.png b/fastlane/metadata/android/en-US/images/icon.png
index 0c8fac6..6b18da9 100644
Binary files a/fastlane/metadata/android/en-US/images/icon.png and b/fastlane/metadata/android/en-US/images/icon.png differ
diff --git a/libs/.gitignore b/libs/.gitignore
deleted file mode 100644
index 98c9d03..0000000
--- a/libs/.gitignore
+++ /dev/null
@@ -1,165 +0,0 @@
-# Created by https://www.gitignore.io/api/android,intellij,osx,gradle,java
-
-### Android ###
-# Built application files
-*.apk
-*.ap_
-
-# Files for the ART/Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-out/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-# Intellij
-*.iml
-.idea/workspace.xml
-.idea/tasks.xml
-.idea/libraries
-
-# Keystore files
-*.jks
-
-# External native build folder generated in Android Studio 2.2 and later
-.externalNativeBuild
-
-### Android Patch ###
-gen-external-apklibs
-
-
-### Intellij ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff:
-
-# Sensitive or high-churn files:
-.idea/dataSources/
-.idea/dataSources.ids
-.idea/dataSources.xml
-.idea/dataSources.local.xml
-.idea/sqlDataSources.xml
-.idea/dynamic.xml
-.idea/uiDesigner.xml
-.idea/
-.idea/*
-.idea
-
-# Gradle:
-.idea/gradle.xml
-
-# Mongo Explorer plugin:
-.idea/mongoSettings.xml
-
-## File-based project format:
-*.iws
-
-## Plugin-specific files:
-
-# IntelliJ
-/out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-### Intellij Patch ###
-# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
-
-# *.iml
-# modules.xml
-# .idea/misc.xml
-# *.ipr
-
-
-### OSX ###
-*.DS_Store
-.AppleDouble
-.LSOverride
-
-# Icon must end with two \r
-Icon
-# Thumbnails
-._*
-# Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-# Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-
-### Java ###
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.ear
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-
-### Gradle ###
-.gradle
-/build/
-
-# Ignore Gradle GUI config
-gradle-app.setting
-
-# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
-!gradle-wrapper.jar
-
-# Cache of project
-.gradletasknamecache
-
-# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
-# gradle/wrapper/gradle-wrapper.properties
-debug/
-release/
\ No newline at end of file
diff --git a/libs/CHANGELOG.md b/libs/CHANGELOG.md
deleted file mode 100644
index 44a262f..0000000
--- a/libs/CHANGELOG.md
+++ /dev/null
@@ -1,217 +0,0 @@
-# v3.13.0
-- Added support for previewing Kustom presets
-- Fixed `Broken drawable` in bug reporter
-
-# v3.12.1
-- Use English date in icon requests' ZIP name
-- Fix issue with launcher apply
-- Upgraded to OneSignal 4
-
-# v3.12.0
-- Update Gradle and AGP
-- Added Hyperion launcher
-- Use CRLF in email related strings
-- Added support to search wallpapers
-
-# v3.11.7
-- Fixed crash
-- Added basic Kustom support
-- Improved themes
-
-# v3.11.6
-- Fixed icon search not working
-
-# v3.11.5
-- Fixed icon bookmarking not working when `show_icon_name` is set to false
-
-# v3.11.4
-- Added support for bookmarking icons
-
-# v3.11.1
-- Fixed link not working in markup
-
-# v3.11.0
-- Internal code refactorings
-- Removed deprecated stuffs
-- Now uses Material Components
-
-# v3.10.1
-- Fixed in-app billings
-- Fixed icon request limit not resetting when license checker is enabled
-
-# v3.10.0
-- Updated Gradle wrapper and plugin
-- Migrated away from JCenter
-- Added Hungarian language
-- Now launches clock app when tapped on the clock widget
-- Updated to In-app Billing v3
-- Added `System default` icon shape
-- Fixed icon shape of the random icon viewer
-- Improved wallpaper sorting
-- Update FAQs
-
-# v3.9.2
-- Add Ukrainian language
-- Updated translations
-- Updated Gradle wrapper and plugin
-- Now hides home title if it's empty
-- Upgrade storage system to support Android 11
-- Now targets Android 11
-
-# v3.9.1
-- Fix Gmail not showing up when sending icon request in Android 11
-
-# v3.9.0
-- Fix new wallpaper count badge
-- Add Indonesian language
-- Added option to set default theme
-- Now shows CandyBar version in the About section
-- Remove duplicates in icon search, fixed back press behaviour
-- Now sorts wallpapers in ascending order
-- Fixed locale not applying after a relaunch
-- Added configuration to customize email body
-- Updated translations
-
-# v3.8.1
-- Brought back support for Android Jelly Bean
-- Fixed issue with premium request email
-- Minor fixes
-
-# v3.8.0
-- Rewrote configuration JSON checkers
-- Added option to use different email, method or Arctic API key
- for regular and premium icon requests
-- Fixed Flick Launcher applier
-- Added support for auto light-dark mode
-- Fixed issues with icon requests
-- Fixed the wallpaper loading issue
-- Updated translations
-- Improved documentation comments
-- Improved wiki documentation
-- Lots of minor fixes
-
-# v3.7.4
-- Updated translations
-- Fix unable to disable regular icon request
-- Fix error when building icon requests on some devices
-
-# v3.7.2
-- Fix icon name generation
-
-# v3.7.0
-- Added Czech language
-- Updated translations
-- Updated Gradle
-- Improved Adaptive Icon support
-- Bumped minSdk to 21. Now the minimum supported Android version is 5.0 (Lollipop)
-- Minor design refreshment
-- Migrated to Glide
-- Improved fast scrollbar for icons section
-- Removed UIL completely
-- Now properly fixes icon name in Icon Requests
-- Redesigned Apply section
-- Redesigned Wallpaper section
-- Added Niagara and Square launcher
-- Fixed Microsoft launcher apply behaviour
-
-# v3.6.3
-- Updated Gradle Plugin.
-- Option to hide missing app count.
-- Fixed new wallpaper count badge.
-- Updated translations.
-- Added new translations.
-
-# v3.6.2
-- Support for customizing background color of navigation view header.
-- Fixed white status bar showing on pre Android Oreo devices.
-- Fixed proguard error.
-- Fixed icons being count even when automatic icon counting is disabled.
-- Now app names in icon request are normalized, Ex. `ů` is normalized to `u`.
-
-# v3.6.0
-- Better icon generation for requests.
-- Improved icon preview.
-- Added support for [Arctic Manager](https://arcticmanager.com).
-- Updated Gradle plugin.
-- Removed app lock.
-- Updated translations.
-- Minor Fixes.
-
-# v3.5.0-beta.6.7
-- Fixed Icon Request Limit not resetting after update.
-- Updated Gradle Versions.
-- Fixed Crash on Tablets.
-- Added Better Support for OnePlus Launcher.
-- Added BlackBerry Launcher.
-- Added Flick Launcher.
-
-
-# v3.5.0-beta.6.6
-- Fix wallpaper download issue with Android 10.
-- Show Loader while icon are being loaded.
-- Minor Fixes
-
-# v3.5.0-beta.6.5
-- Fix Playstore check.
-- New Outline Styled Card.
-- Hide `Reset Tutorial` in Settings if `show_intro` disabled.
-- Minor Fixes.
-- Fix Statusbar Color.
-
-# v3.5.0-beta.6.4
-- Enabled MultiDex
-- Support for Custom Drawable name, like this:
-```xml
-
-```
-- Fixed Icon Search
-- Support for Android 10
-- Lots of Fixes
-
-# v3.5.0-beta.6.3
-- Now you can exclude launchers.
-- Fixed Many Small Bugs.
-
-
-# v3.5.0-beta.6.1
-- Added support for Adaptive Icons.
-- Updated Gradle.
-- Fixed error when rebuilding Premium Request.
-- New NavigationView.
-- Updated Translations.
-
-# v3.5.0-beta.6
-- Added Ability to request app from non-mailing apps.
-- Added option to Disable Icon Request from JSON stored in Cloud.
-- Now shows Request Available, Used even for Regular Requests.
-- Option to Close app if installed outside of Playstore.
-- Option to Enable/Disable AppUpdater and Checking JSON Before Requesting.
-- Uses New Muzei API.
-- Now you can set Your Own Email Subject for Icon Requests.
-- Now it Loads Right Icon and Name from ComponentName instead of PackageName.
-- Fix to AndroidManifest.xml.
-- Updated Translators List.
-- Updated Italian Translations by Ciao Studio.
-- Added POCO, Posidon, Pixel Launcher. Minor Fixes to Old Launchers.
-- Added Support for Desktop Shortcuts(Sesame Shortcuts too).
-- Added Boolean to Disable Intros.
-- Fix Crash on Pre-Oreo Devices.
-- Better Stability.
-- Added Analog Clock Widget.
-
-# v3.5.0-b5
-- Updated Gradle Distribution and Gradle Plugin
-- Added Adaptive Icon Generation for Requests
-- Support for Android P
-- Use of New JSON Format for Wallpaper
-- Added Lawnchair Launcher to Apply Section
-- Added Turkish and Traditional Chinese Languages
-- Support for OneSignal Notifications
-- Support for [AppUpdater](https://github.com/javiersantos/AppUpdater)
-- Option to Edit Links of "Rate and Review" and "Share". Now You can Even Remove Them
-- Migrate to AndroidX
-- Improved Adaptive Icon Generation
-- Improved Icon Request App Image Quality
-- Update CandyBar Translators List
-- Added Support for Linking "Privacy Policy" and "Terms and Conditions"
-- Now shows from where the app installed in request
diff --git a/libs/LICENSE b/libs/LICENSE
deleted file mode 100644
index 8dada3e..0000000
--- a/libs/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/libs/README.md b/libs/README.md
deleted file mode 100644
index d2f6b96..0000000
--- a/libs/README.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# CandyBar
-[](https://jitpack.io/#zixpo/candybar)
-[](https://travis-ci.com/zixpo/candybar)
-[](/LICENSE)
-
-Improved version of the original [CandyBar Dashboard](https://github.com/danimahardhika/candybar-library).
-
-Check out [Blueprint Dashboard](https://github.com/jahirfiquitiva/blueprint/). It's modular and uses new build features. You may like it :D
-
-This is the library of CandyBar Dashboard. It is only used for development purpose. Use the [sample implementation](https://github.com/zixpo/candybar-sample) for making icon packs.
-
-
-
-
-
-
-App screenshots (Click to expand)
-
Tip: Click image to enlarge it
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# How to use
-Just explore the wiki to get started.
-### [Wiki ➜](https://github.com/zixpo/candybar-sample/wiki)
-
-# Features
-- License checker
-- Apply: 32 launchers
-- Icon picker: See all icons
-- Icon request
- - Regular request: Free to request
- - Premium request: Pay to request
- - Support for [Arctic Request Manager](https://arcticmanager.com)
-- Cloud based wallpaper
- - Preview wallpaper
- - Apply wallpaper
- - Download wallpaper
-- Settings
- - Clear cache
- - Switch themes - Auto/Light/Dark
- - Restore purchases: Restore premium requests after reinstalling
-- Frequently asked questions with search
-- About
-- Donation
-- Changelog: Shown on every update
-- Muzei live wallpaper
-- Localization: Supports many languages
-- Support for OneSignal notifications
-- Check for updates
-- Control your dashboard remotely with configuration JSON
-
-# What's new?
-Check out the [changelog](/CHANGELOG.md) to find out what's new.
-
-# Translation
-Help us translate CandyBar in many other languages. [Translate CandyBar](https://crowdin.com/project/candybar).
-
-# Need help?
-Need help in something or maybe you have some question, just head out
-to [Q&A Discussions](https://github.com/zixpo/candybar/discussions/categories/q-a).
-Try to find your answer there or ask a new question if you can't find your answer.
-
-# Support me
-I am doing this work for free, but you can show your appreciation
-and support me by donating. It would keep me motivated to work on
-the dashboard.
-
-[](https://ko-fi.com/J3J7WR0M)
-
-You can also donate from the [CandyBar App](https://play.google.com/store/apps/details?id=com.candybar.dev) published on Google Play Store.
-
-### Social
-
-[](https://twitter.com/sarsamurmu)\
-[](https://github.com/sarsamurmu)
-
-**Thanks! Have fun with the dashboard 😉**
-
-# License
-```
-Copyright (c) 2014-2016 Dani Mahardhika
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-```
diff --git a/libs/build.gradle b/libs/build.gradle
deleted file mode 100644
index bda50a4..0000000
--- a/libs/build.gradle
+++ /dev/null
@@ -1,36 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- google()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:7.0.4'
- }
-}
-
-allprojects {
- repositories {
- mavenCentral()
- google()
- maven { url 'https://jitpack.io' }
- maven { url 'https://maven.google.com' }
- }
-
- rootProject.ext {
- def major = 3
- def minor = 13
- def patch = 0
-
- VersionCode = major * 10000 + minor * 100 + patch
- VersionName = "$major.$minor.$patch"
-
- MinSdk = 16
- TargetSdk = 30
- CompileSdk = 30
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/libs/candybar/build.gradle b/libs/candybar/build.gradle
deleted file mode 100644
index 8b2e1d7..0000000
--- a/libs/candybar/build.gradle
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-buildscript {
- repositories {
- mavenCentral()
- maven { url 'https://jitpack.io' }
- }
-}
-
-plugins {
- id 'com.android.library'
- id 'maven-publish'
-}
-
-project.afterEvaluate {
- publishing {
- publications {
- release(MavenPublication) {
- from components.release
- }
- }
- }
-}
-
-android {
- compileSdkVersion rootProject.ext.CompileSdk
-
- defaultConfig {
- minSdkVersion rootProject.ext.MinSdk
- targetSdkVersion rootProject.ext.TargetSdk
- vectorDrawables.useSupportLibrary true
- multiDexEnabled true
- buildConfigField 'String', 'VERSION_NAME', "\"${rootProject.ext.VersionName}\""
- }
-
- buildTypes {
- release {
- minifyEnabled false
- }
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- lintOptions {
- abortOnError false
- disable 'MissingTranslation'
- }
-
- packagingOptions {
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE'
- return true
- }
-}
-
-dependencies {
- implementation project(':libs:extLibs:PreLollipopTransitions')
-
- api 'androidx.annotation:annotation:1.2.0'
- api 'androidx.appcompat:appcompat:1.3.1'
- api 'androidx.multidex:multidex:2.0.1'
- api 'com.google.android.apps.muzei:muzei-api:3.4.0'
- api 'dev.jahir.KustomAPI:api:6369c37'
- api 'dev.jahir.KustomAPI:preset:6369c37'
-
- implementation 'androidx.work:work-runtime:2.5.0'
- implementation 'androidx.recyclerview:recyclerview:1.2.1'
- implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
- implementation 'androidx.palette:palette:1.0.0'
- implementation 'com.google.android.material:material:1.3.0'
- implementation 'androidx.viewpager2:viewpager2:1.0.0'
-
- implementation 'com.bluelinelabs:logansquare:1.3.7'
- implementation 'androidx.legacy:legacy-support-v4:1.0.0'
- annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'
-
- implementation 'com.github.bumptech.glide:glide:4.11.0'
- annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
-
- implementation 'com.squareup.okhttp3:okhttp:4.3.0'
- implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
- implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
- implementation 'com.mikhaellopez:circularimageview:3.0.2'
- implementation 'com.github.chrisbanes:PhotoView:1.3.1'
- implementation 'me.grantland:autofittextview:0.2.1'
- implementation 'com.github.KeepSafe:TapTargetView:1.9.1'
- implementation 'com.github.sarsamurmu:AdaptiveIconBitmap:1.0.0'
- implementation 'com.github.zixpo:recycler-fast-scroll:6add4dff39'
-
- implementation 'com.github.danimahardhika:cafebar:1.3.2'
- implementation 'com.github.danimahardhika.android-helpers:core:-SNAPSHOT'
- implementation 'com.github.danimahardhika.android-helpers:animation:0.1.0'
- implementation 'com.github.danimahardhika.android-helpers:permission:0.1.0'
- implementation 'com.github.danimahardhika:DrawMe:4a672e78fc'
-}
diff --git a/libs/candybar/src/main/AndroidManifest.xml b/libs/candybar/src/main/AndroidManifest.xml
deleted file mode 100644
index 2e0f4bb..0000000
--- a/libs/candybar/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarCrashReport.java b/libs/candybar/src/main/java/candybar/lib/activities/CandyBarCrashReport.java
deleted file mode 100644
index 94b75ef..0000000
--- a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarCrashReport.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package candybar.lib.activities;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.FileHelper;
-
-import java.io.File;
-
-import candybar.lib.R;
-import candybar.lib.helpers.DeviceHelper;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.ReportBugsHelper;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CandyBarCrashReport extends AppCompatActivity {
-
- public static final String EXTRA_STACKTRACE = "stacktrace";
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- try {
- Bundle bundle = getIntent().getExtras();
- if (bundle == null) {
- finish();
- return;
- }
-
- LocaleHelper.setLocale(this);
-
- String stackTrace = bundle.getString(EXTRA_STACKTRACE);
- String deviceInfo = DeviceHelper.getDeviceInfoForCrashReport(this);
-
- String message = getResources().getString(R.string.crash_report_message, getResources().getString(R.string.app_name));
- String emailAddress = getResources().getString(R.string.regular_request_email).length() > 0
- ? getResources().getString(R.string.regular_request_email)
- // Fallback to dev_email
- : getResources().getString(R.string.dev_email);
-
- new MaterialDialog.Builder(this)
- .title(R.string.crash_report)
- .content(message)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .positiveText(R.string.crash_report_send)
- .negativeText(R.string.close)
- .onPositive((dialog, which) -> {
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("text/plain");
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddress});
- intent.putExtra(Intent.EXTRA_SUBJECT, "CandyBar: Crash Report");
-
- prepareUri(deviceInfo, stackTrace, intent);
-
- startActivity(Intent.createChooser(intent,
- getResources().getString(R.string.app_client)));
- dialog.dismiss();
- })
- .dismissListener(dialogInterface -> finish())
- .show();
- } catch (Exception e) {
- finish();
- }
- }
-
- private void prepareUri(String deviceInfo, String stackTrace, Intent intent) {
- File crashLog = ReportBugsHelper.buildCrashLog(this, stackTrace);
- if (crashLog != null) {
- Uri uri = FileHelper.getUriFromFile(this, getPackageName(), crashLog);
- if (uri != null) {
- intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + "\r\n");
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- return;
- }
- }
-
- intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + stackTrace);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarMainActivity.java b/libs/candybar/src/main/java/candybar/lib/activities/CandyBarMainActivity.java
deleted file mode 100644
index 394d3d1..0000000
--- a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarMainActivity.java
+++ /dev/null
@@ -1,760 +0,0 @@
-package candybar.lib.activities;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.ColorStateList;
-import android.content.res.Configuration;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
-import android.webkit.URLUtil;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.ActionBarDrawerToggle;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.app.AppCompatDelegate;
-import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
-import androidx.appcompat.widget.Toolbar;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-import androidx.core.view.GravityCompat;
-import androidx.drawerlayout.widget.DrawerLayout;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.SoftKeyboardHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.danimahardhika.android.helpers.permission.PermissionCode;
-import com.google.android.material.navigation.NavigationView;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.AboutFragment;
-import candybar.lib.fragments.ApplyFragment;
-import candybar.lib.fragments.FAQsFragment;
-import candybar.lib.fragments.HomeFragment;
-import candybar.lib.fragments.IconsBaseFragment;
-import candybar.lib.fragments.PresetsFragment;
-import candybar.lib.fragments.RequestFragment;
-import candybar.lib.fragments.SettingsFragment;
-import candybar.lib.fragments.WallpapersFragment;
-import candybar.lib.fragments.dialog.ChangelogFragment;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.ConfigurationHelper;
-import candybar.lib.helpers.IntentHelper;
-import candybar.lib.helpers.JsonHelper;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.NavigationViewHelper;
-import candybar.lib.helpers.PlayStoreCheckHelper;
-import candybar.lib.helpers.RequestHelper;
-import candybar.lib.helpers.ThemeHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.helpers.WallpaperHelper;
-import candybar.lib.items.Home;
-import candybar.lib.items.Icon;
-import candybar.lib.items.InAppBilling;
-import candybar.lib.items.Request;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.services.CandyBarService;
-import candybar.lib.tasks.IconRequestTask;
-import candybar.lib.tasks.IconsLoaderTask;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.listeners.RequestListener;
-import candybar.lib.utils.listeners.SearchListener;
-import candybar.lib.utils.listeners.WallpapersListener;
-import candybar.lib.utils.views.HeaderView;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public abstract class CandyBarMainActivity extends AppCompatActivity implements
- ActivityCompat.OnRequestPermissionsResultCallback, RequestListener,
- SearchListener, WallpapersListener {
-
- private TextView mToolbarTitle;
- private DrawerLayout mDrawerLayout;
- private NavigationView mNavigationView;
-
- private Extras.Tag mFragmentTag;
- private int mPosition, mLastPosition;
- private ActionBarDrawerToggle mDrawerToggle;
- private FragmentManager mFragManager;
-
- private boolean mIsMenuVisible = true;
- private boolean prevIsDarkTheme;
-
- public static List sMissedApps;
- public static List sSections;
- public static Home sHomeIcon;
- public static int sInstalledAppsCount;
- public static int sIconsCount;
-
- private ActivityConfiguration mConfig;
-
- @NonNull
- public abstract ActivityConfiguration onInit();
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- final boolean isDarkTheme = prevIsDarkTheme = ThemeHelper.isDarkTheme(this);
-
- final int nightMode;
- switch (Preferences.get(this).getTheme()) {
- case LIGHT:
- nightMode = AppCompatDelegate.MODE_NIGHT_NO;
- break;
- case DARK:
- nightMode = AppCompatDelegate.MODE_NIGHT_YES;
- break;
- default:
- nightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
- }
- AppCompatDelegate.setDefaultNightMode(nightMode);
-
- LocaleHelper.setLocale(this);
- super.setTheme(R.style.CandyBar_Theme_App);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- mDrawerLayout = findViewById(R.id.drawer_layout);
- mNavigationView = findViewById(R.id.navigation_view);
- Toolbar toolbar = findViewById(R.id.toolbar);
- mToolbarTitle = findViewById(R.id.toolbar_title);
-
- toolbar.setPopupTheme(R.style.CandyBar_Theme_App);
- toolbar.setTitle("");
- setSupportActionBar(toolbar);
-
- mFragManager = getSupportFragmentManager();
-
- initNavigationView(toolbar);
- initNavigationViewHeader();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- getWindow().clearFlags(
- WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.navigationBar));
- getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
- mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
- int visibilityFlags = 0;
- if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)) &&
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
- visibilityFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
- if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.navigationBar)) &&
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
- visibilityFlags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
- getWindow().getDecorView().setSystemUiVisibility(visibilityFlags);
- }
-
- try {
- startService(new Intent(this, CandyBarService.class));
- } catch (IllegalStateException e) {
- LogUtil.e("Unable to start CandyBarService. App is probably running in background.");
- }
-
- //Todo: wait until google fix the issue, then enable wallpaper crop again on API 26+
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- Preferences.get(this).setCropWallpaper(false);
- }
-
- mConfig = onInit();
-
- mPosition = mLastPosition = 0;
- if (savedInstanceState != null) {
- mPosition = mLastPosition = savedInstanceState.getInt(Extras.EXTRA_POSITION, 0);
- onSearchExpanded(false);
- }
-
- Bundle bundle = getIntent().getExtras();
- if (bundle != null) {
- int position = bundle.getInt(Extras.EXTRA_POSITION, -1);
- if (position >= 0 && position < 6) {
- mPosition = mLastPosition = position;
- }
- }
-
- IntentHelper.sAction = IntentHelper.getAction(getIntent());
- if (IntentHelper.sAction == IntentHelper.ACTION_DEFAULT) {
- setFragment(getFragment(mPosition));
- } else {
- setFragment(getActionFragment(IntentHelper.sAction));
- }
-
- checkWallpapers();
- new IconRequestTask(this).executeOnThreadPool();
- new IconsLoaderTask(this).execute();
-
- /*
- The below code does this
- #1. If new version - set `firstRun` to `true`
- #2. If `firstRun` equals `true`, run the following steps
- #X. Play store check
- - Enabled: Run check, when completed run #Y
- - Disabled: Run #Y
- #Y. License check
- - Enabled: Run check, when completed run #Z
- - Disabled: Run #Z
- #Z. Reset icon request limit, clear cache and show changelog
- */
-
- if (Preferences.get(this).isNewVersion()) {
- // Check licenses on new version
- Preferences.get(this).setFirstRun(true);
- }
-
- final Runnable onNewVersion = () -> {
- ChangelogFragment.showChangelog(mFragManager);
- File cache = getCacheDir();
- FileHelper.clearDirectory(cache);
- };
-
- if (Preferences.get(this).isFirstRun()) {
- final Runnable checkLicenseIfEnabled = () -> {
- final Runnable onAllChecksCompleted = () -> {
- Preferences.get(this).setFirstRun(false);
- onNewVersion.run();
- };
-
- onAllChecksCompleted.run();
- };
-
- if (Preferences.get(this).isPlayStoreCheckEnabled()) {
- new PlayStoreCheckHelper(this, checkLicenseIfEnabled).run();
- } else {
- checkLicenseIfEnabled.run();
- }
- return;
- }
-
- if (mConfig.isLicenseCheckerEnabled() && !Preferences.get(this).isLicensed()) {
- finish();
- }
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- mDrawerToggle.syncState();
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- if (prevIsDarkTheme != ThemeHelper.isDarkTheme(this)) {
- recreate();
- return;
- }
- LocaleHelper.setLocale(this);
- if (mIsMenuVisible) mDrawerToggle.onConfigurationChanged(newConfig);
- }
-
- @Override
- protected void attachBaseContext(Context newBase) {
- LocaleHelper.setLocale(newBase);
- super.attachBaseContext(newBase);
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- int action = IntentHelper.getAction(intent);
- if (action != IntentHelper.ACTION_DEFAULT)
- setFragment(getActionFragment(action));
- super.onNewIntent(intent);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- outState.putInt(Extras.EXTRA_POSITION, mPosition);
- Database.get(this.getApplicationContext()).closeDatabase();
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public void onBackPressed() {
- if (mFragManager.getBackStackEntryCount() > 0) {
- clearBackStack();
- return;
- }
-
- if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
- mDrawerLayout.closeDrawers();
- return;
- }
-
- if (mFragmentTag != Extras.Tag.HOME) {
- mPosition = mLastPosition = 0;
- setFragment(getFragment(mPosition));
- return;
- }
- super.onBackPressed();
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
- @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- if (requestCode == PermissionCode.STORAGE) {
- if (grantResults.length > 0 &&
- grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- recreate();
- return;
- }
- Toast.makeText(this, R.string.permission_storage_denied, Toast.LENGTH_LONG).show();
- }
- }
-
-
- @Override
- public void onRequestSelected(int count) {
- if (mFragmentTag == Extras.Tag.REQUEST) {
- String title = getResources().getString(R.string.navigation_view_request);
- if (count > 0) title += " (" + count + ")";
- mToolbarTitle.setText(title);
- }
- }
-
-
- @Override
- public void onRequestBuilt(Intent intent, int type) {
- if (type == IntentChooserFragment.ICON_REQUEST) {
- if (RequestFragment.sSelectedRequests == null)
- return;
-
- if (Preferences.get(this).isPremiumRequest()) {
- int count = Preferences.get(this).getPremiumRequestCount() - RequestFragment.sSelectedRequests.size();
- Preferences.get(this).setPremiumRequestCount(count);
- if (count == 0) {
- }
- } else {
- if (getResources().getBoolean(R.bool.enable_icon_request_limit)) {
- int used = Preferences.get(this).getRegularRequestUsed();
- Preferences.get(this).setRegularRequestUsed((used + RequestFragment.sSelectedRequests.size()));
- }
- }
-
- if (mFragmentTag == Extras.Tag.REQUEST) {
- RequestFragment fragment = (RequestFragment) mFragManager.findFragmentByTag(Extras.Tag.REQUEST.value);
- if (fragment != null) fragment.refreshIconRequest();
- }
- }
-
- if (intent != null) {
- try {
- startActivity(intent);
- } catch (IllegalArgumentException e) {
- startActivity(Intent.createChooser(intent,
- getResources().getString(R.string.app_client)));
- }
- }
-
- CandyBarApplication.sRequestProperty = null;
- CandyBarApplication.sZipPath = null;
- }
-
-
- @Override
- public void onWallpapersChecked(int wallpaperCount) {
- Preferences.get(this).setAvailableWallpapersCount(wallpaperCount);
-
- if (mFragmentTag == Extras.Tag.HOME) {
- HomeFragment fragment = (HomeFragment) mFragManager.findFragmentByTag(Extras.Tag.HOME.value);
- if (fragment != null) fragment.resetWallpapersCount();
- }
- }
-
- @Override
- public void onSearchExpanded(boolean expand) {
- Toolbar toolbar = findViewById(R.id.toolbar);
- mIsMenuVisible = !expand;
-
- if (expand) {
- int color = ContextCompat.getColor(this, R.color.toolbarIcon);
- toolbar.setNavigationIcon(DrawableHelper.getTintedDrawable(
- this, R.drawable.ic_toolbar_back, color));
- toolbar.setNavigationOnClickListener(view -> onBackPressed());
- } else {
- SoftKeyboardHelper.closeKeyboard(this);
- ColorHelper.setStatusBarColor(this, Color.TRANSPARENT, true);
- if (CandyBarApplication.getConfiguration().getNavigationIcon() == CandyBarApplication.NavigationIcon.DEFAULT) {
- mDrawerToggle.setDrawerArrowDrawable(new DrawerArrowDrawable(this));
- } else {
- toolbar.setNavigationIcon(ConfigurationHelper.getNavigationIcon(this,
- CandyBarApplication.getConfiguration().getNavigationIcon()));
- }
-
- toolbar.setNavigationOnClickListener(view ->
- mDrawerLayout.openDrawer(GravityCompat.START));
- }
-
- mDrawerLayout.setDrawerLockMode(expand ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED :
- DrawerLayout.LOCK_MODE_UNLOCKED);
- supportInvalidateOptionsMenu();
- }
-
-
- private void initNavigationView(Toolbar toolbar) {
- mDrawerToggle = new ActionBarDrawerToggle(
- this, mDrawerLayout, toolbar, R.string.txt_open, R.string.txt_close) {
-
- @Override
- public void onDrawerOpened(View drawerView) {
- super.onDrawerOpened(drawerView);
- SoftKeyboardHelper.closeKeyboard(CandyBarMainActivity.this);
- }
-
- @Override
- public void onDrawerClosed(View drawerView) {
- super.onDrawerClosed(drawerView);
- selectPosition(mPosition);
- }
- };
- mDrawerToggle.setDrawerIndicatorEnabled(false);
- toolbar.setNavigationIcon(ConfigurationHelper.getNavigationIcon(this,
- CandyBarApplication.getConfiguration().getNavigationIcon()));
- toolbar.setNavigationOnClickListener(view ->
- mDrawerLayout.openDrawer(GravityCompat.START));
-
- if (CandyBarApplication.getConfiguration().getNavigationIcon() == CandyBarApplication.NavigationIcon.DEFAULT) {
- DrawerArrowDrawable drawerArrowDrawable = new DrawerArrowDrawable(this);
- drawerArrowDrawable.setColor(ContextCompat.getColor(this, R.color.toolbarIcon));
- drawerArrowDrawable.setSpinEnabled(true);
- mDrawerToggle.setDrawerArrowDrawable(drawerArrowDrawable);
- mDrawerToggle.setDrawerIndicatorEnabled(true);
- }
-
- mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
- mDrawerLayout.addDrawerListener(mDrawerToggle);
-
- NavigationViewHelper.initApply(mNavigationView);
- NavigationViewHelper.initIconRequest(mNavigationView);
- NavigationViewHelper.initWallpapers(mNavigationView);
- NavigationViewHelper.initPresets(mNavigationView);
-
- ColorStateList itemStateList = ContextCompat.getColorStateList(this,
- ThemeHelper.isDarkTheme(this) ?
- R.color.navigation_view_item_highlight_dark :
- R.color.navigation_view_item_highlight);
- mNavigationView.setItemTextColor(itemStateList);
- mNavigationView.setItemIconTintList(itemStateList);
- Drawable background = ContextCompat.getDrawable(this,
- ThemeHelper.isDarkTheme(this) ?
- R.drawable.navigation_view_item_background_dark :
- R.drawable.navigation_view_item_background);
- mNavigationView.setItemBackground(background);
- mNavigationView.setNavigationItemSelectedListener(item -> {
- int id = item.getItemId();
- if (id == R.id.navigation_view_home) mPosition = Extras.Tag.HOME.idx;
- else if (id == R.id.navigation_view_apply) mPosition = Extras.Tag.APPLY.idx;
- else if (id == R.id.navigation_view_icons) mPosition = Extras.Tag.ICONS.idx;
- else if (id == R.id.navigation_view_request) mPosition = Extras.Tag.REQUEST.idx;
- else if (id == R.id.navigation_view_wallpapers) mPosition = Extras.Tag.WALLPAPERS.idx;
- else if (id == R.id.navigation_view_presets) mPosition = Extras.Tag.PRESETS.idx;
- else if (id == R.id.navigation_view_settings) mPosition = Extras.Tag.SETTINGS.idx;
- else if (id == R.id.navigation_view_faqs) mPosition = Extras.Tag.FAQS.idx;
- else if (id == R.id.navigation_view_about) mPosition = Extras.Tag.ABOUT.idx;
-
- item.setChecked(true);
- mDrawerLayout.closeDrawers();
- return true;
- });
- }
-
- private void initNavigationViewHeader() {
- if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.NONE) {
- mNavigationView.removeHeaderView(mNavigationView.getHeaderView(0));
- return;
- }
-
- String imageUrl = getResources().getString(R.string.navigation_view_header);
- String titleText = getResources().getString(R.string.navigation_view_header_title);
- View header = mNavigationView.getHeaderView(0);
- HeaderView image = header.findViewById(R.id.header_image);
- LinearLayout container = header.findViewById(R.id.header_title_container);
- TextView title = header.findViewById(R.id.header_title);
- TextView version = header.findViewById(R.id.header_version);
-
- if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.MINI) {
- image.setRatio(16, 9);
- }
-
- if (titleText.length() == 0) {
- container.setVisibility(View.GONE);
- } else {
- title.setText(titleText);
- try {
- String versionText = "v" + getPackageManager()
- .getPackageInfo(getPackageName(), 0).versionName;
- version.setText(versionText);
- } catch (Exception ignored) {
- }
- }
-
- if (ColorHelper.isValidColor(imageUrl)) {
- image.setBackgroundColor(Color.parseColor(imageUrl));
- return;
- }
-
- if (!URLUtil.isValidUrl(imageUrl)) {
- imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl);
- }
-
- Glide.with(this)
- .load(imageUrl)
- .override(720)
- .optionalCenterInside()
- .diskCacheStrategy(imageUrl.contains("drawable://")
- ? DiskCacheStrategy.NONE
- : DiskCacheStrategy.RESOURCE)
- .into(image);
- }
-
- private void checkWallpapers() {
- if (Preferences.get(this).isConnectedToNetwork()) {
- new Thread(() -> {
- try {
- if (WallpaperHelper.getWallpaperType(this) != WallpaperHelper.CLOUD_WALLPAPERS)
- return;
-
- String wallpaperUrl = getResources().getString(R.string.wallpaper_json);
- URL url = new URL(wallpaperUrl);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setConnectTimeout(15000);
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- InputStream stream = connection.getInputStream();
- List> list = JsonHelper.parseList(stream);
- if (list == null) return;
-
- List wallpapers = new ArrayList<>();
- for (int i = 0; i < list.size(); i++) {
- Wallpaper wallpaper = JsonHelper.getWallpaper(list.get(i));
- if (wallpaper != null) {
- if (!wallpapers.contains(wallpaper)) {
- wallpapers.add(wallpaper);
- } else {
- LogUtil.e("Duplicate wallpaper found: " + wallpaper.getURL());
- }
- }
- }
-
- this.runOnUiThread(() -> onWallpapersChecked(wallpapers.size()));
- }
- } catch (IOException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }).start();
- }
-
- int size = Preferences.get(this).getAvailableWallpapersCount();
- if (size > 0) {
- onWallpapersChecked(size);
- }
- }
-
- private void clearBackStack() {
- if (mFragManager.getBackStackEntryCount() > 0) {
- mFragManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
- onSearchExpanded(false);
- }
- }
-
- public void selectPosition(int position) {
- if (position == 3) {
- if (!getResources().getBoolean(R.bool.enable_icon_request) &&
- getResources().getBoolean(R.bool.enable_premium_request)) {
- if (!Preferences.get(this).isPremiumRequestEnabled())
- return;
-
- }
- }
-
- if (position == 4) {
- if (WallpaperHelper.getWallpaperType(this)
- == WallpaperHelper.EXTERNAL_APP) {
- mPosition = mLastPosition;
- mNavigationView.getMenu().getItem(mPosition).setChecked(true);
- WallpaperHelper.launchExternalApp(CandyBarMainActivity.this);
- return;
- }
- }
-
- if (position != mLastPosition) {
- mLastPosition = mPosition = position;
- setFragment(getFragment(position));
- }
- }
-
- private void setFragment(Fragment fragment) {
- clearBackStack();
-
- FragmentTransaction ft = mFragManager.beginTransaction()
- .replace(R.id.container, fragment, mFragmentTag.value);
- try {
- ft.commit();
- } catch (Exception e) {
- ft.commitAllowingStateLoss();
- }
-
- Menu menu = mNavigationView.getMenu();
- menu.getItem(mPosition).setChecked(true);
- mToolbarTitle.setText(menu.getItem(mPosition).getTitle());
- }
-
- private Fragment getFragment(int position) {
- mFragmentTag = Extras.Tag.HOME;
- if (position == Extras.Tag.HOME.idx) {
- mFragmentTag = Extras.Tag.HOME;
- return new HomeFragment();
- } else if (position == Extras.Tag.APPLY.idx) {
- mFragmentTag = Extras.Tag.APPLY;
- return new ApplyFragment();
- } else if (position == Extras.Tag.ICONS.idx) {
- mFragmentTag = Extras.Tag.ICONS;
- return new IconsBaseFragment();
- } else if (position == Extras.Tag.REQUEST.idx) {
- mFragmentTag = Extras.Tag.REQUEST;
- return new RequestFragment();
- } else if (position == Extras.Tag.WALLPAPERS.idx) {
- mFragmentTag = Extras.Tag.WALLPAPERS;
- return new WallpapersFragment();
- } else if (position == Extras.Tag.PRESETS.idx) {
- mFragmentTag = Extras.Tag.PRESETS;
- return new PresetsFragment();
- } else if (position == Extras.Tag.SETTINGS.idx) {
- mFragmentTag = Extras.Tag.SETTINGS;
- return new SettingsFragment();
- } else if (position == Extras.Tag.FAQS.idx) {
- mFragmentTag = Extras.Tag.FAQS;
- return new FAQsFragment();
- } else if (position == Extras.Tag.ABOUT.idx) {
- mFragmentTag = Extras.Tag.ABOUT;
- return new AboutFragment();
- }
- return new HomeFragment();
- }
-
- private Fragment getActionFragment(int action) {
- switch (action) {
- case IntentHelper.ICON_PICKER:
- case IntentHelper.IMAGE_PICKER:
- mPosition = mLastPosition = (mFragmentTag = Extras.Tag.ICONS).idx;
- return new IconsBaseFragment();
- case IntentHelper.WALLPAPER_PICKER:
- if (WallpaperHelper.getWallpaperType(this) == WallpaperHelper.CLOUD_WALLPAPERS) {
- mPosition = mLastPosition = (mFragmentTag = Extras.Tag.WALLPAPERS).idx;
- return new WallpapersFragment();
- }
- default:
- mPosition = mLastPosition = (mFragmentTag = Extras.Tag.HOME).idx;
- return new HomeFragment();
- }
- }
-
- public static class ActivityConfiguration {
-
- private boolean mIsLicenseCheckerEnabled;
- private byte[] mRandomString;
- private String mLicenseKey;
- private String[] mDonationProductsId;
- private String[] mPremiumRequestProductsId;
- private int[] mPremiumRequestProductsCount;
-
- public ActivityConfiguration setLicenseCheckerEnabled(boolean enabled) {
- mIsLicenseCheckerEnabled = enabled;
- return this;
- }
-
- public ActivityConfiguration setRandomString(@NonNull byte[] randomString) {
- mRandomString = randomString;
- return this;
- }
-
- public ActivityConfiguration setLicenseKey(@NonNull String licenseKey) {
- mLicenseKey = licenseKey;
- return this;
- }
-
- public ActivityConfiguration setDonationProductsId(@NonNull String[] productsId) {
- mDonationProductsId = productsId;
- return this;
- }
-
- public ActivityConfiguration setPremiumRequestProducts(@NonNull String[] ids, @NonNull int[] counts) {
- mPremiumRequestProductsId = ids;
- mPremiumRequestProductsCount = counts;
- return this;
- }
-
- public boolean isLicenseCheckerEnabled() {
- return mIsLicenseCheckerEnabled;
- }
-
- public byte[] getRandomString() {
- return mRandomString;
- }
-
- public String getLicenseKey() {
- return mLicenseKey;
- }
-
- public String[] getDonationProductsId() {
- return mDonationProductsId;
- }
-
- public String[] getPremiumRequestProductsId() {
- return mPremiumRequestProductsId;
- }
-
- public int[] getPremiumRequestProductsCount() {
- return mPremiumRequestProductsCount;
- }
- }
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarSplashActivity.java b/libs/candybar/src/main/java/candybar/lib/activities/CandyBarSplashActivity.java
deleted file mode 100644
index 030572f..0000000
--- a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarSplashActivity.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package candybar.lib.activities;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.InputStream;
-import java.lang.ref.WeakReference;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.helpers.JsonHelper;
-import candybar.lib.helpers.WallpaperHelper;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.ImageConfig;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public abstract class CandyBarSplashActivity extends AppCompatActivity {
-
- private AsyncTaskBase mSplashScreenLoader;
- private AsyncTaskBase mWallpaperThumbPreloader;
-
- @NonNull
- public abstract Class> getMainActivity();
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mSplashScreenLoader = new SplashScreenLoader(this)
- .mainActivity(getMainActivity())
- .executeOnThreadPool();
-
- mWallpaperThumbPreloader = new WallpaperThumbPreloader(this).execute();
- }
-
- @Override
- public void onBackPressed() {
- if (mWallpaperThumbPreloader != null) {
- mWallpaperThumbPreloader.cancel(true);
- }
- Database.get(this.getApplicationContext()).closeDatabase();
- super.onBackPressed();
- }
-
- @Override
- protected void onDestroy() {
- if (mSplashScreenLoader != null) {
- mSplashScreenLoader.cancel(true);
- }
- super.onDestroy();
- }
-
- private static class SplashScreenLoader extends AsyncTaskBase {
-
- private final WeakReference context;
- private Class> mainActivity;
-
- private SplashScreenLoader(@NonNull Context context) {
- this.context = new WeakReference<>(context);
- }
-
- private SplashScreenLoader mainActivity(@NonNull Class> mainActivity) {
- this.mainActivity = mainActivity;
- return this;
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(400);
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (context.get() == null) return;
- if (context.get() instanceof Activity) {
- if (((Activity) context.get()).isFinishing()) return;
- }
-
- Intent intent = new Intent(context.get(), mainActivity);
- intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-
- Activity activity = (Activity) context.get();
- activity.startActivity(intent);
- activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
- activity.finish();
- }
- }
-
- private static class WallpaperThumbPreloader extends AsyncTaskBase {
-
- private final WeakReference context;
-
- private WallpaperThumbPreloader(@NonNull Context context) {
- this.context = new WeakReference<>(context);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
-
- if (WallpaperHelper.getWallpaperType(context.get()) != WallpaperHelper.CLOUD_WALLPAPERS)
- return true;
-
- URL url = new URL(context.get().getString(R.string.wallpaper_json));
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setConnectTimeout(15000);
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- InputStream stream = connection.getInputStream();
- List> list = JsonHelper.parseList(stream);
- if (list == null) {
- LogUtil.e("Json error, no array with name: "
- + CandyBarApplication.getConfiguration().getWallpaperJsonStructure().getArrayName());
- return false;
- }
-
- if (list.size() > 0 && list.get(0) instanceof Map) {
- Map, ?> map = (Map, ?>) list.get(0);
- String thumbUrl = JsonHelper.getThumbUrl(map);
-
- // Preload the first wallpaper's thumbnail
- // It should show up immediately without any delay on first run
- // so that the intro popup works correctly
- if (context.get() != null) {
- Glide.with(context.get())
- .load(thumbUrl)
- .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
- .override(ImageConfig.getThumbnailSize())
- .preload();
- }
- }
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
- }
-}
-
diff --git a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarWallpaperActivity.java b/libs/candybar/src/main/java/candybar/lib/activities/CandyBarWallpaperActivity.java
deleted file mode 100644
index 704c3b2..0000000
--- a/libs/candybar/src/main/java/candybar/lib/activities/CandyBarWallpaperActivity.java
+++ /dev/null
@@ -1,509 +0,0 @@
-package candybar.lib.activities;
-
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.graphics.PorterDuff;
-import android.graphics.RectF;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.transition.Transition;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-import androidx.palette.graphics.Palette;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.DataSource;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.engine.GlideException;
-import com.bumptech.glide.request.RequestListener;
-import com.bumptech.glide.request.target.CustomTarget;
-import com.bumptech.glide.request.target.Target;
-import com.danimahardhika.android.helpers.animation.AnimationHelper;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.WindowHelper;
-import com.danimahardhika.android.helpers.permission.PermissionCode;
-import com.kogitune.activitytransition.ActivityTransition;
-import com.kogitune.activitytransition.ExitActivityTransition;
-
-import candybar.lib.R;
-import candybar.lib.adapters.WallpapersAdapter;
-import candybar.lib.databases.Database;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.TapIntroHelper;
-import candybar.lib.helpers.ThemeHelper;
-import candybar.lib.items.PopupItem;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.tasks.WallpaperApplyTask;
-import candybar.lib.tasks.WallpaperPropertiesLoaderTask;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.Popup;
-import candybar.lib.utils.WallpaperDownloader;
-import uk.co.senab.photoview.PhotoViewAttacher;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CandyBarWallpaperActivity extends AppCompatActivity implements View.OnClickListener, View.OnLongClickListener,
- ActivityCompat.OnRequestPermissionsResultCallback, WallpaperPropertiesLoaderTask.Callback {
-
- private ImageView mImageView;
- private ProgressBar mProgress;
- private LinearLayout mBottomBar;
- private TextView mName;
- private TextView mAuthor;
- private ImageView mBack;
- private ImageView mMenuApply;
- private ImageView mMenuSave;
-
- private boolean mIsEnter;
- private boolean mIsResumed = false;
-
- private Wallpaper mWallpaper;
- private Runnable mRunnable;
- private Handler mHandler;
- private PhotoViewAttacher mAttacher;
- private ExitActivityTransition mExitTransition;
-
- private boolean prevIsDarkTheme;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- prevIsDarkTheme = ThemeHelper.isDarkTheme(this);
- super.setTheme(R.style.CandyBar_Theme_Wallpaper);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_wallpaper);
- mIsEnter = true;
-
- mImageView = findViewById(R.id.wallpaper);
- mProgress = findViewById(R.id.progress);
- mBottomBar = findViewById(R.id.bottom_bar);
- mName = findViewById(R.id.name);
- mAuthor = findViewById(R.id.author);
- mBack = findViewById(R.id.back);
- mMenuApply = findViewById(R.id.menu_apply);
- mMenuSave = findViewById(R.id.menu_save);
-
- mProgress.getIndeterminateDrawable().setColorFilter(
- Color.parseColor("#CCFFFFFF"), PorterDuff.Mode.SRC_IN);
- mBack.setImageDrawable(DrawableHelper.getTintedDrawable(
- this, R.drawable.ic_toolbar_back, Color.WHITE));
- mBack.setOnClickListener(this);
-
- String url = "";
- if (savedInstanceState != null) {
- url = savedInstanceState.getString(Extras.EXTRA_URL);
- }
-
- Bundle bundle = getIntent().getExtras();
- if (bundle != null) {
- url = bundle.getString(Extras.EXTRA_URL);
- }
-
- mWallpaper = Database.get(this.getApplicationContext()).getWallpaper(url);
- if (mWallpaper == null) {
- finish();
- return;
- }
-
- initBottomBar();
- resetBottomBarPadding();
-
- if (!mIsResumed) {
- mExitTransition = ActivityTransition
- .with(getIntent())
- .to(this, mImageView, Extras.EXTRA_IMAGE)
- .duration(300)
- .start(savedInstanceState);
- }
-
- if (mImageView.getDrawable() == null) {
- int color = mWallpaper.getColor();
- if (color == 0) {
- color = ContextCompat.getColor(this, R.color.cardBackground);
- }
-
- AnimationHelper.setBackgroundColor(findViewById(R.id.rootview), Color.TRANSPARENT, color).start();
- mProgress.getIndeterminateDrawable().setColorFilter(
- ColorHelper.setColorAlpha(ColorHelper.getTitleTextColor(color), 0.7f),
- PorterDuff.Mode.SRC_IN);
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && savedInstanceState == null) {
- Transition transition = getWindow().getSharedElementEnterTransition();
-
- if (transition != null) {
- transition.addListener(new Transition.TransitionListener() {
- @Override
- public void onTransitionStart(Transition transition) {
- }
-
- @Override
- public void onTransitionEnd(Transition transition) {
- if (mIsEnter) {
- mIsEnter = false;
-
- AnimationHelper.fade(mBottomBar).duration(400).start();
- loadWallpaper();
- }
- }
-
- @Override
- public void onTransitionCancel(Transition transition) {
- }
-
- @Override
- public void onTransitionPause(Transition transition) {
- }
-
- @Override
- public void onTransitionResume(Transition transition) {
- }
- });
-
- return;
- }
- }
-
- mRunnable = () -> {
- AnimationHelper.fade(mBottomBar).duration(400).start();
- loadWallpaper();
-
- mRunnable = null;
- mHandler = null;
- };
- mHandler = new Handler();
- mHandler.postDelayed(mRunnable, 700);
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- if (prevIsDarkTheme != ThemeHelper.isDarkTheme(this)) {
- recreate();
- return;
- }
- LocaleHelper.setLocale(this);
- resetBottomBarPadding();
- }
-
- @Override
- protected void attachBaseContext(Context newBase) {
- LocaleHelper.setLocale(newBase);
- super.attachBaseContext(newBase);
- }
-
- @Override
- protected void onSaveInstanceState(@NonNull Bundle outState) {
- if (mWallpaper != null) {
- outState.putString(Extras.EXTRA_URL, mWallpaper.getURL());
- }
-
- outState.putBoolean(Extras.EXTRA_RESUMED, true);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- if (Preferences.get(this).isCropWallpaper()) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
- }
- Glide.get(this).clearMemory();
- if (mAttacher != null) mAttacher.cleanup();
- super.onDestroy();
- }
-
- @Override
- public void onBackPressed() {
- WallpapersAdapter.sIsClickable = true;
- if (mHandler != null && mRunnable != null)
- mHandler.removeCallbacks(mRunnable);
-
- if (mExitTransition != null) {
- mExitTransition.exit(this);
- return;
- }
- super.onBackPressed();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == android.R.id.home) {
- onBackPressed();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.back) {
- onBackPressed();
- } else if (id == R.id.menu_apply) {
- Popup popup = Popup.Builder(this)
- .to(mMenuApply)
- .list(PopupItem.getApplyItems(this))
- .callback((p, position) -> {
- PopupItem item = p.getItems().get(position);
- if (item.getType() == PopupItem.Type.WALLPAPER_CROP) {
- Preferences.get(this).setCropWallpaper(!item.getCheckboxValue());
- item.setCheckboxValue(Preferences.get(this).isCropWallpaper());
-
- p.updateItem(position, item);
- if (Preferences.get(this).isCropWallpaper()) {
- if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- return;
- }
-
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- return;
- } else {
- RectF rectF = null;
- if (Preferences.get(this).isCropWallpaper()) {
- if (mAttacher != null)
- rectF = mAttacher.getDisplayRect();
- }
-
- WallpaperApplyTask task = new WallpaperApplyTask(this, mWallpaper)
- .crop(rectF);
-
- if (item.getType() == PopupItem.Type.LOCKSCREEN) {
- task.to(WallpaperApplyTask.Apply.LOCKSCREEN);
- } else if (item.getType() == PopupItem.Type.HOMESCREEN) {
- task.to(WallpaperApplyTask.Apply.HOMESCREEN);
- } else if (item.getType() == PopupItem.Type.HOMESCREEN_LOCKSCREEN) {
- task.to(WallpaperApplyTask.Apply.HOMESCREEN_LOCKSCREEN);
- }
-
- task.executeOnThreadPool();
- }
-
- p.dismiss();
- })
- .build();
-
- if (getResources().getBoolean(R.bool.enable_wallpaper_download)) {
- popup.removeItem(popup.getItems().size() - 1);
- }
- popup.show();
- } else if (id == R.id.menu_save) {
- WallpaperDownloader.prepare(this)
- .wallpaper(mWallpaper)
- .start();
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- int id = view.getId();
- int res = 0;
- if (id == R.id.menu_apply) {
- res = R.string.wallpaper_apply;
- } else if (id == R.id.menu_save) {
- res = R.string.wallpaper_save_to_device;
- }
-
- if (res == 0) return false;
-
- Toast.makeText(this, res, Toast.LENGTH_SHORT).show();
- return true;
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
- @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- if (requestCode == PermissionCode.STORAGE) {
- if (grantResults.length > 0 &&
- grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- WallpaperDownloader.prepare(this).wallpaper(mWallpaper).start();
- } else {
- Toast.makeText(this, R.string.permission_storage_denied, Toast.LENGTH_LONG).show();
- }
- }
- }
-
- @Override
- public void onPropertiesReceived(Wallpaper wallpaper) {
- if (wallpaper == null) return;
-
- mWallpaper.setDimensions(wallpaper.getDimensions());
- mWallpaper.setSize(wallpaper.getSize());
- mWallpaper.setMimeType(wallpaper.getMimeType());
- }
-
- private void initBottomBar() {
- mName.setText(mWallpaper.getName());
- mName.setTextColor(Color.WHITE);
- mAuthor.setText(mWallpaper.getAuthor());
- mAuthor.setTextColor(ColorHelper.setColorAlpha(Color.WHITE, 0.7f));
- mMenuSave.setImageDrawable(DrawableHelper.getTintedDrawable(
- this, R.drawable.ic_toolbar_download, Color.WHITE));
- mMenuApply.setImageDrawable(DrawableHelper.getTintedDrawable(
- this, R.drawable.ic_toolbar_apply_options, Color.WHITE));
-
- if (getResources().getBoolean(R.bool.enable_wallpaper_download)) {
- mMenuSave.setVisibility(View.VISIBLE);
- }
-
- mMenuApply.setOnClickListener(this);
- mMenuSave.setOnClickListener(this);
-
- mMenuApply.setOnLongClickListener(this);
- mMenuSave.setOnLongClickListener(this);
- }
-
- private void resetBottomBarPadding() {
- LinearLayout container = findViewById(R.id.bottom_bar_container);
- int height = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
- int bottom = 0;
- int right = WindowHelper.getNavigationBarHeight(this);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (mBack.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) {
- CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mBack.getLayoutParams();
- params.topMargin = WindowHelper.getStatusBarHeight(this);
- }
-
- boolean tabletMode = getResources().getBoolean(R.bool.android_helpers_tablet_mode);
- if (tabletMode || getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
- bottom = right;
- right = 0;
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- if (isInMultiWindowMode()) {
- bottom = right = 0;
- }
- }
- }
-
- container.setPadding(0, 0, right, bottom);
-
- if (container.getLayoutParams() instanceof LinearLayout.LayoutParams) {
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) container.getLayoutParams();
- params.height = height + bottom;
- }
- }
-
- private void loadWallpaper() {
- if (mAttacher != null) {
- mAttacher.cleanup();
- mAttacher = null;
- }
-
- new WallpaperPropertiesLoaderTask(this, mWallpaper, this)
- .executeOnThreadPool();
-
- Glide.with(this)
- .asBitmap()
- .load(mWallpaper.getURL())
- .override(2000)
- .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
- .timeout(10000)
- .listener(new RequestListener() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
- if (mWallpaper.getColor() == 0) {
- mWallpaper.setColor(ColorHelper.getAttributeColor(
- CandyBarWallpaperActivity.this, R.attr.colorSecondary));
- }
-
- return true;
- }
-
- @Override
- public boolean onResourceReady(Bitmap loadedImage, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
- if (loadedImage != null && mWallpaper.getColor() == 0) {
- Palette.from(loadedImage).generate(palette -> {
- if (palette != null) {
- int accent = ColorHelper.getAttributeColor(
- CandyBarWallpaperActivity.this, R.attr.colorSecondary);
- int color = palette.getVibrantColor(accent);
- if (color == accent)
- color = palette.getMutedColor(accent);
-
- mWallpaper.setColor(color);
- Database.get(CandyBarWallpaperActivity.this).updateWallpaper(mWallpaper);
- }
-
- onWallpaperLoaded();
- });
- } else {
- onWallpaperLoaded();
- }
-
- return false;
- }
- })
- .into(new CustomTarget() {
- @Override
- public void onResourceReady(@NonNull Bitmap resource, @Nullable com.bumptech.glide.request.transition.Transition super Bitmap> transition) {
- mImageView.setImageBitmap(resource);
- }
-
- @Override
- public void onLoadCleared(@Nullable Drawable placeholder) { /* Do nothing */ }
- });
-
- if (Preferences.get(CandyBarWallpaperActivity.this).isCropWallpaper()) {
- if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
-
- AnimationHelper.fade(mProgress).start();
- }
-
- private void onWallpaperLoaded() {
- mAttacher = new PhotoViewAttacher(mImageView);
- mAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP);
-
- AnimationHelper.fade(mProgress).start();
- mRunnable = null;
- mHandler = null;
- mIsResumed = false;
-
- if (this.getResources().getBoolean(R.bool.show_intro)) {
- TapIntroHelper.showWallpaperPreviewIntro(this, mWallpaper.getColor());
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/AboutAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/AboutAdapter.java
deleted file mode 100644
index cf1f43e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/AboutAdapter.java
+++ /dev/null
@@ -1,444 +0,0 @@
-package candybar.lib.adapters;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Color;
-import android.net.Uri;
-import android.os.Build;
-import android.text.method.LinkMovementMethod;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.URLUtil;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.text.HtmlCompat;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.card.MaterialCardView;
-import com.mikhaellopez.circularimageview.CircularImageView;
-
-import candybar.lib.BuildConfig;
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.CreditsFragment;
-import candybar.lib.helpers.ConfigurationHelper;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class AboutAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
-
- private int mItemCount;
-
- private final boolean mShowExtraInfo;
-
- private final boolean mShowContributors;
- private final boolean mShowPrivacyPolicy;
- private final boolean mShowTerms;
-
- private static final int TYPE_HEADER = 0;
- private static final int TYPE_EXTRA_INFO = 1;
- private static final int TYPE_FOOTER = 2;
- private static final int TYPE_BOTTOM_SHADOW = 3;
-
- public AboutAdapter(@NonNull Context context, int spanCount) {
- mContext = context;
-
- mItemCount = 2;
- boolean cardMode = (spanCount > 1);
- if (!cardMode) {
- mItemCount += 1;
- }
-
- mShowContributors = mContext.getResources().getBoolean(R.bool.show_contributors_dialog);
-
- mShowPrivacyPolicy = mContext.getResources().getString(R.string.privacy_policy_link).length() > 0;
-
- mShowTerms = mContext.getResources().getString(R.string.terms_and_conditions_link).length() > 0;
-
- mShowExtraInfo = mShowContributors || mShowPrivacyPolicy || mShowTerms;
-
- if (mShowExtraInfo) {
- mItemCount += 1;
- }
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if (viewType == TYPE_HEADER) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_header, parent, false);
- return new HeaderViewHolder(view);
- } else if (viewType == TYPE_EXTRA_INFO) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_sub, parent, false);
- return new ExtraInfoViewHolder(view);
- }
-
- if (viewType == TYPE_FOOTER) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_footer, parent, false);
- if (CandyBarApplication.getConfiguration().getSocialIconColor() == CandyBarApplication.IconColor.ACCENT) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_footer_accent, parent, false);
- }
- return new FooterViewHolder(view);
- }
-
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_settings_item_footer, parent, false);
- return new ShadowViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder.getItemViewType() == TYPE_HEADER) {
- HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
-
- String imageUri = mContext.getString(R.string.about_image);
-
- if (ColorHelper.isValidColor(imageUri)) {
- headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri));
- } else {
- if (!URLUtil.isValidUrl(imageUri)) {
- imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri);
- }
-
- Glide.with(mContext)
- .load(imageUri)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(imageUri.contains("drawable://")
- ? DiskCacheStrategy.NONE
- : DiskCacheStrategy.RESOURCE)
- .into(headerViewHolder.image);
- }
-
- String profileUri = mContext.getResources().getString(R.string.about_profile_image);
- if (!URLUtil.isValidUrl(profileUri)) {
- profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri);
- }
-
- Glide.with(mContext)
- .load(profileUri)
- .skipMemoryCache(true)
- .diskCacheStrategy(profileUri.contains("drawable://")
- ? DiskCacheStrategy.NONE
- : DiskCacheStrategy.RESOURCE)
- .into(headerViewHolder.profile);
- }
- }
-
- @Override
- public int getItemCount() {
- return mItemCount;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == 0) return TYPE_HEADER;
- if (position == 1) {
- if (mShowExtraInfo) return TYPE_EXTRA_INFO;
- else return TYPE_FOOTER;
- }
-
- if (position == 2 && mShowExtraInfo) return TYPE_FOOTER;
- return TYPE_BOTTOM_SHADOW;
- }
-
- private class HeaderViewHolder extends RecyclerView.ViewHolder {
-
- private final ImageView image;
- private final CircularImageView profile;
-
- HeaderViewHolder(View itemView) {
- super(itemView);
- image = itemView.findViewById(R.id.image);
- profile = itemView.findViewById(R.id.profile);
- TextView subtitle = itemView.findViewById(R.id.subtitle);
- RecyclerView recyclerView = itemView.findViewById(R.id.recyclerview);
- recyclerView.setItemAnimator(new DefaultItemAnimator());
- recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
- recyclerView.setHasFixedSize(true);
-
- String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
- if (urls.length == 0) {
- recyclerView.setVisibility(View.GONE);
-
- subtitle.setPadding(
- subtitle.getPaddingLeft(),
- subtitle.getPaddingTop(),
- subtitle.getPaddingRight(),
- subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
- } else {
- if (recyclerView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
- if (urls.length < 7) {
- params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
- params.gravity = Gravity.CENTER_HORIZONTAL;
- recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
- }
- }
- recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
- }
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
- card != null) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card) && card != null) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- if (card != null) card.setCardElevation(0);
-
- profile.setShadowRadius(0f);
- profile.setShadowColor(Color.TRANSPARENT);
- }
-
- subtitle.setText(HtmlCompat.fromHtml(
- mContext.getResources().getString(R.string.about_desc), HtmlCompat.FROM_HTML_MODE_COMPACT));
- subtitle.setMovementMethod(LinkMovementMethod.getInstance());
- }
- }
-
- private class ExtraInfoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- ExtraInfoViewHolder(View itemView) {
- super(itemView);
- LinearLayout contributorsHolder = itemView.findViewById(R.id.contributors);
- TextView contributorsTitle = itemView.findViewById(R.id.contributors_title);
- LinearLayout privacyPolicyHolder = itemView.findViewById(R.id.privacy_policy);
- TextView privacyPolicyTitle = itemView.findViewById(R.id.privacy_policy_title);
- LinearLayout termsHolder = itemView.findViewById(R.id.terms);
- TextView termsTitle = itemView.findViewById(R.id.terms_title);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
- card != null) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card) && card != null) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- if (card != null) card.setCardElevation(0);
- }
-
-
- if (!mShowContributors)
- contributorsHolder.setVisibility(View.GONE);
- if (!mShowPrivacyPolicy)
- privacyPolicyHolder.setVisibility(View.GONE);
- if (!mShowTerms)
- termsHolder.setVisibility(View.GONE);
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
-
- contributorsTitle.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_people, color), null, null, null);
- contributorsTitle.setText(mContext.getResources().getString(R.string.about_contributors_title));
-
- privacyPolicyTitle.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_link, color), null, null, null);
- privacyPolicyTitle.setText(mContext.getResources().getString(R.string.about_privacy_policy_title));
-
- termsTitle.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_link, color), null, null, null);
- termsTitle.setText(mContext.getResources().getString(R.string.about_terms_and_conditions_title));
-
- contributorsTitle.setOnClickListener(this);
- privacyPolicyTitle.setOnClickListener(this);
- termsTitle.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.contributors_title) {
- CreditsFragment.showCreditsDialog(((AppCompatActivity) mContext).getSupportFragmentManager(),
- CreditsFragment.TYPE_ICON_PACK_CONTRIBUTORS);
- } else if (id == R.id.privacy_policy_title) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext.getResources().getString(R.string.privacy_policy_link)));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- } else if (id == R.id.terms_title) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext.getResources().getString(R.string.terms_and_conditions_link)));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- }
- }
- }
-
- private class FooterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- FooterViewHolder(View itemView) {
- super(itemView);
- ImageView github = itemView.findViewById(R.id.about_dashboard_github);
- TextView title = itemView.findViewById(R.id.about_dashboard_title);
- TextView licenses = itemView.findViewById(R.id.about_dashboard_licenses);
- TextView contributors = itemView.findViewById(R.id.about_dashboard_contributors);
- TextView translator = itemView.findViewById(R.id.about_dashboard_translator);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
- card != null) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card) && card != null) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- if (card != null) card.setCardElevation(0);
- }
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);
- title.append(" v" + BuildConfig.VERSION_NAME);
-
- color = ConfigurationHelper.getSocialIconColor(mContext,
- CandyBarApplication.getConfiguration().getSocialIconColor());
- github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));
-
- github.setOnClickListener(this);
- licenses.setOnClickListener(this);
- contributors.setOnClickListener(this);
- translator.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
-
- if (id == R.id.about_dashboard_contributors) {
- CreditsFragment.showCreditsDialog(((AppCompatActivity) mContext).getSupportFragmentManager(),
- CreditsFragment.TYPE_DASHBOARD_CONTRIBUTORS);
- return;
- }
-
- if (id == R.id.about_dashboard_translator) {
- CreditsFragment.showCreditsDialog(((AppCompatActivity) mContext).getSupportFragmentManager(),
- CreditsFragment.TYPE_DASHBOARD_TRANSLATOR);
- return;
- }
-
- Intent intent = null;
- if (id == R.id.about_dashboard_github) {
- intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext
- .getResources().getString(R.string.about_dashboard_github_url)));
- }
-
- try {
- mContext.startActivity(intent);
- } catch (NullPointerException | ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
- }
-
- private class ShadowViewHolder extends RecyclerView.ViewHolder {
-
- ShadowViewHolder(View itemView) {
- super(itemView);
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- View shadow = itemView.findViewById(R.id.shadow);
- shadow.setVisibility(View.GONE);
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/AboutSocialAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/AboutSocialAdapter.java
deleted file mode 100644
index 7c3cbca..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/AboutSocialAdapter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package candybar.lib.adapters;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.UrlHelper;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class AboutSocialAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final String[] mUrls;
-
- public AboutSocialAdapter(@NonNull Context context, @NonNull String[] urls) {
- mContext = context;
- mUrls = urls;
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_social, parent, false);
- if (CandyBarApplication.getConfiguration().getSocialIconColor() == CandyBarApplication.IconColor.ACCENT) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_about_item_social_accent, parent, false);
- }
- return new SocialViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
- SocialViewHolder socialViewHolder = (SocialViewHolder) holder;
- UrlHelper.Type type = UrlHelper.getType(mUrls[position]);
- Drawable drawable = UrlHelper.getSocialIcon(mContext, type);
-
- if (drawable != null && type != UrlHelper.Type.INVALID) {
- socialViewHolder.image.setImageDrawable(drawable);
- socialViewHolder.image.setVisibility(View.VISIBLE);
- } else {
- socialViewHolder.image.setVisibility(View.GONE);
- }
- }
-
- @Override
- public int getItemCount() {
- return mUrls.length;
- }
-
- private class SocialViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final ImageView image;
-
- SocialViewHolder(View itemView) {
- super(itemView);
- image = itemView.findViewById(R.id.image);
-
- image.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (position < 0 || position > mUrls.length) return;
-
- if (id == R.id.image) {
- UrlHelper.Type type = UrlHelper.getType(mUrls[position]);
- if (type == UrlHelper.Type.INVALID) return;
-
- if (type == UrlHelper.Type.EMAIL) {
- try {
- final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
- "mailto", mUrls[position], null));
- email.putExtra(Intent.EXTRA_SUBJECT, (mContext.getResources().getString(
- R.string.app_name)));
- mContext.startActivity(Intent.createChooser(email,
- mContext.getResources().getString(R.string.app_client)));
- } catch (ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return;
- }
-
- try {
- mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mUrls[position])));
- } catch (ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/FAQsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/FAQsAdapter.java
deleted file mode 100644
index 21e25cf..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/FAQsAdapter.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package candybar.lib.adapters;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.items.FAQs;
-import candybar.lib.preferences.Preferences;
-
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class FAQsAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mFAQs;
- private final List mFAQsAll;
-
- private static final int TYPE_CONTENT = 0;
- private static final int TYPE_FOOTER = 1;
-
- public FAQsAdapter(@NonNull Context context, @NonNull List faqs) {
- mContext = context;
- mFAQs = faqs;
- mFAQsAll = new ArrayList<>(mFAQs);
- }
-
- @NonNull
- @Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = null;
- if (viewType == TYPE_CONTENT) {
- view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fragment_faqs_item_list, parent, false);
- } else if (viewType == TYPE_FOOTER) {
- view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fragment_settings_item_footer, parent, false);
- }
- return new ViewHolder(view, viewType);
- }
-
- @Override
- public void onViewRecycled(@NonNull ViewHolder holder) {
- super.onViewRecycled(holder);
- if (holder.holderId == TYPE_CONTENT) {
- holder.divider.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- if (holder.holderId == TYPE_CONTENT) {
- holder.question.setText(mFAQs.get(position).getQuestion());
- holder.answer.setText(mFAQs.get(position).getAnswer());
-
- if (position == (mFAQs.size() - 1)) {
- holder.divider.setVisibility(View.GONE);
- }
- }
- }
-
- @Override
- public int getItemCount() {
- return mFAQs.size() + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == getItemCount() - 1) return TYPE_FOOTER;
- return TYPE_CONTENT;
- }
-
- class ViewHolder extends RecyclerView.ViewHolder {
-
- private TextView question;
- private TextView answer;
- private View divider;
-
- private int holderId;
-
- ViewHolder(View itemView, int viewType) {
- super(itemView);
- if (viewType == TYPE_CONTENT) {
- question = itemView.findViewById(R.id.question);
- answer = itemView.findViewById(R.id.answer);
- divider = itemView.findViewById(R.id.divider);
- holderId = TYPE_CONTENT;
- } else if (viewType == TYPE_FOOTER) {
- holderId = TYPE_FOOTER;
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- View shadow = itemView.findViewById(R.id.shadow);
- shadow.setVisibility(View.GONE);
- }
- }
- }
- }
-
- public void search(String string) {
- String query = string.toLowerCase(Locale.getDefault()).trim();
- mFAQs.clear();
- if (query.length() == 0) mFAQs.addAll(mFAQsAll);
- else {
- for (int i = 0; i < mFAQsAll.size(); i++) {
- FAQs faq = mFAQsAll.get(i);
- String question = faq.getQuestion().toLowerCase(Locale.getDefault());
- String answer = faq.getAnswer().toLowerCase(Locale.getDefault());
- if (question.contains(query) || answer.contains(query)) {
- mFAQs.add(faq);
- }
- }
- }
- notifyDataSetChanged();
- }
-
- public int getFaqsCount() {
- return mFAQs.size();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/HomeAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/HomeAdapter.java
deleted file mode 100644
index 27ef4ab..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/HomeAdapter.java
+++ /dev/null
@@ -1,964 +0,0 @@
-package candybar.lib.adapters;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.res.Configuration;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.graphics.PorterDuff;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.method.LinkMovementMethod;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.URLUtil;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.graphics.drawable.RoundedBitmapDrawable;
-import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
-import androidx.core.text.HtmlCompat;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.DataSource;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.engine.GlideException;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.bumptech.glide.request.RequestListener;
-import com.bumptech.glide.request.target.Target;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.card.MaterialCardView;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.adapters.dialog.ChangelogAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.DonationLinksFragment;
-import candybar.lib.fragments.dialog.IconPreviewFragment;
-import candybar.lib.fragments.dialog.OtherAppsFragment;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.helpers.ViewHelper;
-import candybar.lib.helpers.WallpaperHelper;
-import candybar.lib.items.Home;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.views.HeaderView;
-import me.grantland.widget.AutofitTextView;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class HomeAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mHomes;
- private final Home.Style mImageStyle;
-
- private int mItemsCount;
- private int mOrientation;
- private boolean mShowWallpapers;
- private boolean mShowIconRequest;
- private boolean mShowMoreApps;
-
- private static final int TYPE_HEADER = 0;
- private static final int TYPE_CONTENT = 1;
- private static final int TYPE_ICON_REQUEST = 2;
- private static final int TYPE_WALLPAPERS = 3;
- private static final int TYPE_GOOGLE_PLAY_DEV = 4;
-
- public HomeAdapter(@NonNull Context context, @NonNull List homes, int orientation) {
- mContext = context;
- mHomes = homes;
- mOrientation = orientation;
-
- String viewStyle = mContext.getResources().getString(R.string.home_image_style);
- mImageStyle = ViewHelper.getHomeImageViewStyle(viewStyle);
-
- mItemsCount = 1;
- if (WallpaperHelper.getWallpaperType(mContext) == WallpaperHelper.CLOUD_WALLPAPERS) {
- mItemsCount += 1;
- mShowWallpapers = true;
- }
-
- if (mContext.getResources().getBoolean(R.bool.enable_icon_request) ||
- mContext.getResources().getBoolean(R.bool.enable_premium_request)) {
- mItemsCount += 1;
- mShowIconRequest = true;
- }
-
- String link = mContext.getResources().getString(R.string.google_play_dev);
- if (link.length() > 0) {
- mItemsCount += 1;
- mShowMoreApps = true;
- }
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if (viewType == TYPE_HEADER) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_header, parent, false);
- if (mImageStyle.getType() == Home.Style.Type.LANDSCAPE ||
- mImageStyle.getType() == Home.Style.Type.SQUARE) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_header_alt, parent, false);
- }
- return new HeaderViewHolder(view);
- } else if (viewType == TYPE_CONTENT) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_content, parent, false);
- return new ContentViewHolder(view);
- } else if (viewType == TYPE_ICON_REQUEST) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_icon_request, parent, false);
- return new IconRequestViewHolder(view);
- } else if (viewType == TYPE_WALLPAPERS) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_wallpapers, parent, false);
- return new WallpapersViewHolder(view);
- }
-
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_home_item_more_apps, parent, false);
- return new GooglePlayDevViewHolder(view);
- }
-
- @Override
- public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
- super.onViewRecycled(holder);
- if (holder.getItemViewType() == TYPE_CONTENT) {
- ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
-
- contentViewHolder.title.setSingleLine(false);
- contentViewHolder.title.setMaxLines(10);
- contentViewHolder.title.setSizeToFit(false);
- contentViewHolder.title.setGravity(Gravity.CENTER_VERTICAL);
- contentViewHolder.title.setIncludeFontPadding(true);
- contentViewHolder.title.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
- contentViewHolder.subtitle.setVisibility(View.GONE);
- contentViewHolder.subtitle.setGravity(Gravity.CENTER_VERTICAL);
- }
- }
-
- @SuppressLint("StringFormatInvalid")
- @Override
- public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
- try {
- if (holder.itemView != null) {
- StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams)
- holder.itemView.getLayoutParams();
- layoutParams.setFullSpan(isFullSpan(holder.getItemViewType()));
- }
- } catch (Exception e) {
- LogUtil.d(Log.getStackTraceString(e));
- }
-
- if (holder.getItemViewType() == TYPE_HEADER) {
- HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
-
- String home_title_text = mContext.getResources().getString(R.string.home_title);
- if (home_title_text.length() > 0) {
- headerViewHolder.title.setText(home_title_text);
- } else {
- headerViewHolder.title.setVisibility(View.GONE);
- }
-
- headerViewHolder.content.setText(HtmlCompat.fromHtml(
- mContext.getResources().getString(R.string.home_description), HtmlCompat.FROM_HTML_MODE_COMPACT));
- headerViewHolder.content.setMovementMethod(LinkMovementMethod.getInstance());
-
- String uri = mContext.getResources().getString(R.string.home_image);
- if (ColorHelper.isValidColor(uri)) {
- headerViewHolder.image.setBackgroundColor(Color.parseColor(uri));
- } else {
- if (!URLUtil.isValidUrl(uri)) {
- uri = "drawable://" + DrawableHelper.getResourceId(mContext, uri);
- }
-
- Glide.with(mContext)
- .load(uri)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(uri.contains("drawable://")
- ? DiskCacheStrategy.NONE
- : DiskCacheStrategy.RESOURCE)
- .into(headerViewHolder.image);
- }
- } else if (holder.getItemViewType() == TYPE_CONTENT) {
- ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
- int finalPosition = position - 1;
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- if (mHomes.get(finalPosition).getIcon() != -1) {
- if (mHomes.get(finalPosition).getType() == Home.Type.DIMENSION) {
- Glide.with(mContext)
- .asBitmap()
- .load("drawable://" + mHomes.get(finalPosition).getIcon())
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .listener(new RequestListener() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
- return true;
- }
-
- @Override
- public boolean onResourceReady(Bitmap bitmap, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
- new Handler(Looper.getMainLooper()).post(() -> {
- // Using RoundedBitmapDrawable because BitmapDrawable is deprecated
- RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(
- mContext.getResources(), bitmap);
- drawable.setCornerRadius(0);
- contentViewHolder.title.setCompoundDrawablesWithIntrinsicBounds(
- DrawableHelper.getResizedDrawable(mContext, drawable, 40),
- null, null, null);
- });
- return true;
- }
- })
- .submit();
- } else {
- contentViewHolder.title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, mHomes.get(finalPosition).getIcon(), color), null, null, null);
- }
- }
-
- if (mHomes.get(finalPosition).getType() == Home.Type.ICONS) {
- if (mHomes.get(finalPosition).isLoading() && CandyBarMainActivity.sIconsCount == 0 && CandyBarApplication.getConfiguration().isAutomaticIconsCountEnabled()) {
- contentViewHolder.progressBar.setVisibility(View.VISIBLE);
- contentViewHolder.title.setVisibility(View.GONE);
- } else {
- contentViewHolder.progressBar.setVisibility(View.GONE);
- contentViewHolder.title.setVisibility(View.VISIBLE);
- }
-
- contentViewHolder.title.setSingleLine(true);
- contentViewHolder.title.setMaxLines(1);
- contentViewHolder.title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- mContext.getResources().getDimension(R.dimen.text_max_size));
- contentViewHolder.title.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
- contentViewHolder.title.setIncludeFontPadding(false);
- contentViewHolder.title.setSizeToFit(true);
-
- contentViewHolder.subtitle.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
- } else {
- contentViewHolder.title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- mContext.getResources().getDimension(R.dimen.text_content_title));
- }
-
- contentViewHolder.title.setTypeface(TypefaceHelper.getMedium(mContext));
- contentViewHolder.title.setText(mHomes.get(finalPosition).getTitle());
-
- if (mHomes.get(finalPosition).getSubtitle().length() > 0) {
- contentViewHolder.subtitle.setText(mHomes.get(finalPosition).getSubtitle());
- contentViewHolder.subtitle.setVisibility(View.VISIBLE);
- }
- } else if (holder.getItemViewType() == TYPE_ICON_REQUEST) {
- IconRequestViewHolder iconRequestViewHolder = (IconRequestViewHolder) holder;
- if (mContext.getResources().getBoolean(R.bool.hide_missing_app_count)) {
- iconRequestViewHolder.dataContainer.setVisibility(View.GONE);
- iconRequestViewHolder.progressBar.setVisibility(View.GONE);
- } else if (CandyBarMainActivity.sMissedApps == null) {
- // Missing apps are not yet loaded, show the progressbar
- iconRequestViewHolder.dataContainer.setVisibility(View.GONE);
- iconRequestViewHolder.progressBar.setVisibility(View.VISIBLE);
- } else {
- iconRequestViewHolder.dataContainer.setVisibility(View.VISIBLE);
- iconRequestViewHolder.progressBar.setVisibility(View.GONE);
- }
-
- int installed = CandyBarMainActivity.sInstalledAppsCount;
- int missed = CandyBarMainActivity.sMissedApps == null ?
- installed : CandyBarMainActivity.sMissedApps.size();
- int themed = installed - missed;
-
- iconRequestViewHolder.installedApps.setText(mContext.getResources().getString(
- R.string.home_icon_request_installed_apps, installed));
- iconRequestViewHolder.missedApps.setText(mContext.getResources().getString(
- R.string.home_icon_request_missed_apps, missed));
- iconRequestViewHolder.themedApps.setText(mContext.getResources().getString(
- R.string.home_icon_request_themed_apps, themed));
-
- iconRequestViewHolder.progress.setMax(installed);
- iconRequestViewHolder.progress.setProgress(themed);
- } else if (holder.getItemViewType() == TYPE_WALLPAPERS) {
- WallpapersViewHolder wallpapersViewHolder = (WallpapersViewHolder) holder;
-
- wallpapersViewHolder.title.setText(mContext.getResources().getString(
- R.string.home_loud_wallpapers, Preferences.get(mContext).getAvailableWallpapersCount()));
- }
- }
-
- @Override
- public int getItemCount() {
- return mHomes.size() + mItemsCount;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == 0) return TYPE_HEADER;
- if (position == (mHomes.size() + 1) && mShowIconRequest) return TYPE_ICON_REQUEST;
-
- if (position == (getItemCount() - 2) && mShowWallpapers && mShowMoreApps)
- return TYPE_WALLPAPERS;
-
- if (position == (getItemCount() - 1)) {
- if (mShowMoreApps) return TYPE_GOOGLE_PLAY_DEV;
- else if (mShowWallpapers) return TYPE_WALLPAPERS;
- }
- return TYPE_CONTENT;
- }
-
- private class HeaderViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final HeaderView image;
- private final TextView title;
- private final TextView content;
-
- HeaderViewHolder(View itemView) {
- super(itemView);
- image = itemView.findViewById(R.id.header_image);
- title = itemView.findViewById(R.id.title);
- content = itemView.findViewById(R.id.content);
- Button rate = itemView.findViewById(R.id.rate);
- ImageView share = itemView.findViewById(R.id.share);
- ImageView update = itemView.findViewById(R.id.update);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- } else if (card.getLayoutParams() instanceof LinearLayout.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) card.getLayoutParams();
- if (mImageStyle.getType() == Home.Style.Type.LANDSCAPE ||
- mImageStyle.getType() == Home.Style.Type.SQUARE) {
- params.setMargins(margin,
- mContext.getResources().getDimensionPixelSize(R.dimen.content_padding_reverse),
- margin, margin);
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- if (mContext.getResources().getString(R.string.rate_and_review_link).length() == 0) {
- rate.setVisibility(View.GONE);
- }
-
- if (mContext.getResources().getString(R.string.share_link).length() == 0) {
- share.setVisibility(View.GONE);
- }
-
- if ((!mContext.getResources().getBoolean(R.bool.enable_check_update)) || (mContext.getResources().getString(R.string.config_json).length() == 0)) {
- update.setVisibility(View.GONE);
- }
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary);
- rate.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_rate, color), null, null, null);
- share.setImageDrawable(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_share, color));
- update.setImageDrawable(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_update, color));
-
- image.setRatio(mImageStyle.getPoint().x, mImageStyle.getPoint().y);
-
- rate.setOnClickListener(this);
- share.setOnClickListener(this);
- update.setOnClickListener(this);
- }
-
- @Override
- @SuppressLint("StringFormatInvalid")
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.rate) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext.getResources().getString(R.string.rate_and_review_link)
- .replaceAll("\\{\\{packageName\\}\\}", mContext.getPackageName())));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- } else if (id == R.id.share) {
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("text/plain");
- intent.putExtra(Intent.EXTRA_SUBJECT, mContext.getResources().getString(
- R.string.share_app_title, mContext.getResources().getString(R.string.app_name)));
- intent.putExtra(Intent.EXTRA_TEXT,
- mContext.getResources().getString(R.string.share_app_body,
- mContext.getResources().getString(R.string.app_name),
- "\n" + mContext.getResources().getString(R.string.share_link)
- .replaceAll("\\{\\{packageName\\}\\}", mContext.getPackageName())));
- mContext.startActivity(Intent.createChooser(intent,
- mContext.getResources().getString(R.string.app_client)));
- } else if (id == R.id.update) {
- new UpdateChecker().execute();
- }
- }
- }
-
- private class UpdateChecker extends AsyncTaskBase {
-
- private MaterialDialog loadingDialog;
- private String latestVersion;
- private String updateUrl;
- private String[] changelog;
- private boolean isUpdateAvailable;
-
- @Override
- protected void preRun() {
- loadingDialog = new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .content(R.string.checking_for_update)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .progress(true, 0)
- .progressIndeterminateStyle(true)
- .build();
-
- loadingDialog.show();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- boolean isSuccess = true;
- String configJsonUrl = mContext.getResources().getString(R.string.config_json);
- URLConnection urlConnection;
- BufferedReader bufferedReader = null;
-
- try {
- urlConnection = new URL(configJsonUrl).openConnection();
- bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
-
- String line;
- StringBuilder stringBuilder = new StringBuilder();
- while ((line = bufferedReader.readLine()) != null) {
- stringBuilder.append(line);
- }
-
- JSONObject configJson = new JSONObject(stringBuilder.toString());
- latestVersion = configJson.getString("latestVersion");
- updateUrl = configJson.getString("url");
-
- PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
- long latestVersionCode = configJson.getLong("latestVersionCode");
- long appVersionCode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
-
- if (latestVersionCode > appVersionCode) {
- isUpdateAvailable = true;
- JSONArray changelogArray = configJson.getJSONArray("releaseNotes");
- changelog = new String[changelogArray.length()];
- for (int i = 0; i < changelogArray.length(); i++) {
- changelog[i] = changelogArray.getString(i);
- }
- }
- } catch (Exception ex) {
- LogUtil.e("Error loading Configuration JSON " + Log.getStackTraceString(ex));
- isSuccess = false;
- } finally {
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (IOException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
- }
-
- return isSuccess;
- }
- return false;
- }
-
- @Override
- @SuppressLint("SetTextI18n")
- protected void postRun(boolean ok) {
- loadingDialog.dismiss();
- loadingDialog = null;
-
- if (ok) {
- MaterialDialog.Builder builder = new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .customView(R.layout.fragment_update, false);
-
- if (isUpdateAvailable) {
- builder
- .positiveText(R.string.update)
- .negativeText(R.string.close)
- .onPositive((dialog, which) -> {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(updateUrl));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- });
- } else {
- builder.positiveText(R.string.close);
- }
-
- MaterialDialog dialog = builder.build();
-
- TextView changelogVersion = (TextView) dialog.findViewById(R.id.changelog_version);
- ListView mChangelogList = (ListView) dialog.findViewById(R.id.changelog_list);
-
- if (isUpdateAvailable) {
- changelogVersion.setText(
- mContext.getResources().getString(R.string.update_available) + "\n" +
- mContext.getResources().getString(R.string.changelog_version) + " " +
- latestVersion);
- mChangelogList.setAdapter(new ChangelogAdapter(mContext, changelog));
- } else {
- changelogVersion.setText(mContext.getResources().getString(R.string.no_update_available));
- mChangelogList.setVisibility(View.GONE);
- }
-
- dialog.show();
- } else {
- new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .content(R.string.unable_to_load_config)
- .positiveText(R.string.close)
- .build()
- .show();
- }
- }
- }
-
- private class ContentViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final TextView subtitle;
- private final AutofitTextView title;
- private final ProgressBar progressBar;
-
- ContentViewHolder(View itemView) {
- super(itemView);
- LinearLayout container = itemView.findViewById(R.id.container);
- title = itemView.findViewById(R.id.title);
- subtitle = itemView.findViewById(R.id.subtitle);
- progressBar = itemView.findViewById(R.id.progressBar);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- container.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- int position = getBindingAdapterPosition() - 1;
- if (position < 0 || position > mHomes.size()) return;
-
- switch (mHomes.get(position).getType()) {
- case APPLY:
- ((CandyBarMainActivity) mContext).selectPosition(1);
- break;
- case DONATE:
- if (mContext instanceof CandyBarMainActivity) {
- if (CandyBarApplication.getConfiguration().getDonationLinks() != null) {
- DonationLinksFragment.showDonationLinksDialog(((AppCompatActivity) mContext).getSupportFragmentManager());
- break;
- }
- }
- break;
- case ICONS:
- ((CandyBarMainActivity) mContext).selectPosition(2);
- break;
- case DIMENSION:
- Home home = mHomes.get(position);
- IconPreviewFragment.showIconPreview(
- ((AppCompatActivity) mContext).getSupportFragmentManager(),
- home.getTitle(), home.getIcon(), null);
- break;
- }
- }
- }
- }
-
- private class IconRequestViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final TextView installedApps;
- private final TextView themedApps;
- private final TextView missedApps;
- private final ProgressBar progress;
- private final ProgressBar progressBar;
- private final LinearLayout dataContainer;
-
- IconRequestViewHolder(View itemView) {
- super(itemView);
- TextView title = itemView.findViewById(R.id.title);
- installedApps = itemView.findViewById(R.id.installed_apps);
- missedApps = itemView.findViewById(R.id.missed_apps);
- themedApps = itemView.findViewById(R.id.themed_apps);
- progress = itemView.findViewById(R.id.progress);
- LinearLayout container = itemView.findViewById(R.id.container);
- progressBar = itemView.findViewById(R.id.progressBar);
- dataContainer = itemView.findViewById(R.id.dataContainer);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_icon_request, color), null, null, null);
-
- int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary);
- progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);
-
- container.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- ((CandyBarMainActivity) mContext).selectPosition(3);
- }
- }
- }
-
- private class WallpapersViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final TextView title;
-
- WallpapersViewHolder(View itemView) {
- super(itemView);
- title = itemView.findViewById(R.id.title);
- TextView muzei = itemView.findViewById(R.id.muzei);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_wallpapers, color), null, null, null);
-
- muzei.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.get(
- mContext, R.drawable.ic_home_app_muzei), null, null, null);
-
- title.setOnClickListener(this);
- muzei.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.title) {
- ((CandyBarMainActivity) mContext).selectPosition(4);
- } else if (id == R.id.muzei) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
- "https://play.google.com/store/apps/details?id=net.nurik.roman.muzei"));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- }
- }
- }
-
- private class GooglePlayDevViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- GooglePlayDevViewHolder(View itemView) {
- super(itemView);
- LinearLayout container = itemView.findViewById(R.id.container);
- TextView title = itemView.findViewById(R.id.title);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_google_play_more_apps, color), null, null, null);
-
- container.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- if (CandyBarApplication.getConfiguration().getOtherApps() != null) {
- OtherAppsFragment.showOtherAppsDialog(((AppCompatActivity) mContext).getSupportFragmentManager());
- return;
- }
-
- String link = mContext.getResources().getString(R.string.google_play_dev);
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- mContext.startActivity(intent);
- }
- }
- }
-
- public int getApplyIndex() {
- int index = -1;
- for (int i = 0; i < getItemCount(); i++) {
- int type = getItemViewType(i);
- if (type == TYPE_CONTENT) {
- int pos = i - 1;
- if (mHomes.get(pos).getType() == Home.Type.APPLY) {
- index = i;
- break;
- }
- }
- }
- return index;
- }
-
- public Home getItem(int position) {
- return mHomes.get(position - 1);
- }
-
- public int getIconsIndex() {
- int index = -1;
- for (int i = 0; i < getItemCount(); i++) {
- int type = getItemViewType(i);
- if (type == TYPE_CONTENT) {
- int pos = i - 1;
- if (mHomes.get(pos).getType() == Home.Type.ICONS) {
- index = i;
- break;
- }
- }
- }
- return index;
- }
-
- public int getDimensionsIndex() {
- int index = -1;
- for (int i = 0; i < getItemCount(); i++) {
- int type = getItemViewType(i);
- if (type == TYPE_CONTENT) {
- int pos = i - 1;
- if (mHomes.get(pos).getType() == Home.Type.DIMENSION) {
- index = i;
- break;
- }
- }
- }
- return index;
- }
-
- public int getIconRequestIndex() {
- int index = -1;
- for (int i = 0; i < getItemCount(); i++) {
- int type = getItemViewType(i);
- if (type == TYPE_ICON_REQUEST) {
- index = i;
- break;
- }
- }
- return index;
- }
-
- public int getWallpapersIndex() {
- int index = -1;
- for (int i = 0; i < getItemCount(); i++) {
- int type = getItemViewType(i);
- if (type == TYPE_WALLPAPERS) {
- index = i;
- break;
- }
- }
- return index;
- }
-
- public void addNewContent(@Nullable Home home) {
- if (home == null) return;
-
- mHomes.add(home);
- notifyItemInserted(mHomes.size());
- }
-
- public void setOrientation(int orientation) {
- mOrientation = orientation;
- notifyDataSetChanged();
- }
-
- private boolean isFullSpan(int viewType) {
- if (viewType == TYPE_HEADER) {
- if (mOrientation == Configuration.ORIENTATION_PORTRAIT) {
- return true;
- } else return mImageStyle.getType() == Home.Style.Type.SQUARE ||
- mImageStyle.getType() == Home.Style.Type.LANDSCAPE;
- }
- return false;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/IconsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/IconsAdapter.java
deleted file mode 100644
index 419d978..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/IconsAdapter.java
+++ /dev/null
@@ -1,373 +0,0 @@
-package candybar.lib.adapters;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.app.Activity;
-import android.content.Context;
-import android.util.TypedValue;
-import android.view.ActionMode;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.drawerlayout.widget.DrawerLayout;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.viewpager2.widget.ViewPager2;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.SoftKeyboardHelper;
-import com.google.android.material.tabs.TabLayout;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import candybar.lib.R;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.IconsFragment;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.helpers.IntentHelper;
-import candybar.lib.items.Icon;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private List mIcons;
- private List mIconsAll;
- private final Fragment mFragment;
- private final List mViewHolders;
-
- private List mSelectedIcons = new ArrayList<>();
-
- private final boolean mIsShowIconName;
- private final boolean mIsBookmarkMode;
-
- private ActionMode actionMode;
- private final ActionMode.Callback actionModeCallback = new ActionMode.Callback() {
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- actionMode = mode;
- mode.getMenuInflater().inflate(R.menu.menu_bookmark_icons, menu);
- Activity activity = (Activity) mContext;
- TabLayout tabLayout = activity.findViewById(R.id.tab);
- View shadow = activity.findViewById(R.id.shadow);
- if (shadow != null) {
- shadow.animate().translationY(-tabLayout.getHeight()).setDuration(200).start();
- }
- tabLayout.animate().translationY(-tabLayout.getHeight()).setDuration(200)
- .setListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- tabLayout.setVisibility(View.GONE);
- if (shadow != null) {
- shadow.setTranslationY(0);
- }
- tabLayout.animate().setListener(null);
- }
- }).start();
- ((ViewPager2) activity.findViewById(R.id.pager)).setUserInputEnabled(false);
- ((DrawerLayout) activity.findViewById(R.id.drawer_layout))
- .setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
- for (ViewHolder holder : mViewHolders) {
- holder.onActionModeChange();
- }
- return true;
- }
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- mode.setTitle(mContext.getResources().getString(R.string.items_selected, mSelectedIcons.size()));
- menu.findItem(R.id.menu_select_all).setIcon(mSelectedIcons.size() == mIcons.size()
- ? R.drawable.ic_toolbar_select_all_selected : R.drawable.ic_toolbar_select_all);
- menu.findItem(R.id.menu_delete).setVisible(mSelectedIcons.size() > 0);
- return true;
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem menuItem) {
- int itemId = menuItem.getItemId();
- if (itemId == R.id.menu_delete) {
- List drawableNames = new ArrayList<>();
- for (Icon icon : mSelectedIcons) drawableNames.add(icon.getDrawableName());
- Database.get(mContext).deleteBookmarkedIcons(drawableNames);
- IconsFragment.reloadBookmarks();
- mode.finish();
- return true;
- } else if (itemId == R.id.menu_select_all) {
- if (mSelectedIcons.size() != mIcons.size()) {
- for (ViewHolder holder : mViewHolders) {
- holder.setChecked(true, true);
- }
- mSelectedIcons = new ArrayList<>(mIcons);
- } else {
- for (ViewHolder holder : mViewHolders) {
- holder.setChecked(false, true);
- }
- mSelectedIcons = new ArrayList<>();
- }
- actionMode.invalidate();
- }
- return false;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
- actionMode = null;
- mSelectedIcons = new ArrayList<>();
- Activity activity = (Activity) mContext;
- TabLayout tabLayout = activity.findViewById(R.id.tab);
- View shadow = activity.findViewById(R.id.shadow);
- if (shadow != null) {
- shadow.setTranslationY(-tabLayout.getHeight());
- shadow.animate().translationY(0).setDuration(200).start();
- }
- tabLayout.setVisibility(View.VISIBLE);
- tabLayout.animate().translationY(0).setDuration(200).start();
- ((ViewPager2) activity.findViewById(R.id.pager)).setUserInputEnabled(true);
- ((DrawerLayout) activity.findViewById(R.id.drawer_layout))
- .setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
- for (ViewHolder holder : mViewHolders) {
- holder.onActionModeChange();
- }
- }
- };
-
- public IconsAdapter(@NonNull Context context, @NonNull List icons, Fragment fragment, boolean isBookmarkMode) {
- mContext = context;
- mFragment = fragment;
- mIcons = icons;
- mIsShowIconName = mContext.getResources().getBoolean(R.bool.show_icon_name);
- mViewHolders = new ArrayList<>();
- mIsBookmarkMode = isBookmarkMode;
- }
-
- public void setIcons(@NonNull List icons) {
- mIcons = icons;
- notifyDataSetChanged();
- }
-
- @NonNull
- @Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_icons_item_grid, parent, false);
- return new ViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- Icon icon = mIcons.get(position);
- holder.name.setText(icon.getTitle());
- mViewHolders.add(holder);
- loadIconInto(holder.icon, position);
- if (mIsBookmarkMode) {
- holder.setCheckChangedListener(null);
- holder.setChecked(mSelectedIcons.contains(icon), false);
- holder.setCheckChangedListener(isChecked -> {
- if (isChecked) {
- mSelectedIcons.add(icon);
- } else {
- mSelectedIcons.remove(icon);
- }
- if (actionMode != null) actionMode.invalidate();
- });
- }
- }
-
- @Override
- public void onViewRecycled(@NonNull ViewHolder holder) {
- mViewHolders.remove(holder);
- super.onViewRecycled(holder);
- }
-
- private void loadIconInto(ImageView imageView, int position) {
- Glide.with(mFragment)
- .load("drawable://" + mIcons.get(position).getRes())
- .skipMemoryCache(true)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .into(imageView);
- }
-
- public void reloadIcons() {
- Glide.get(mContext).clearMemory();
- for (ViewHolder holder : mViewHolders) {
- int position = holder.getBindingAdapterPosition();
- if (position < 0 || position > getItemCount()) continue;
- loadIconInto(holder.icon, holder.getBindingAdapterPosition());
- }
- }
-
- @Override
- public int getItemCount() {
- return mIcons.size();
- }
-
- interface CheckChangedListener {
- void onCheckChanged(boolean isChecked);
- }
-
- class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
- private final ImageView icon;
- private final TextView name;
-
- private final View container;
- private final View innerContainer;
- private final View checkBackground;
- private boolean isChecked;
- private CheckChangedListener checkChangedListener;
-
- ViewHolder(View itemView) {
- super(itemView);
- icon = itemView.findViewById(R.id.icon);
- name = itemView.findViewById(R.id.name);
- innerContainer = itemView.findViewById(R.id.inner_container);
- checkBackground = itemView.findViewById(R.id.check_background);
-
- container = itemView.findViewById(R.id.container);
- container.setOnClickListener(this);
-
- if (mIsBookmarkMode) {
- container.setOnLongClickListener(this);
- int color = ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary);
- ((ImageView) checkBackground.findViewById(R.id.checkmark))
- .setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_check_circle, color));
- }
-
- if (!mIsShowIconName) {
- name.setVisibility(View.GONE);
- }
-
- onActionModeChange();
- }
-
- private void onActionModeChange() {
- TypedValue outValue = new TypedValue();
- if (actionMode != null) {
- mContext.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true);
- container.setBackgroundResource(outValue.resourceId);
- innerContainer.setBackgroundResource(0);
- } else {
- mContext.getTheme().resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true);
- container.setBackgroundResource(0);
- innerContainer.setBackgroundResource(outValue.resourceId);
- setChecked(false, true);
- }
- }
-
- private void setCheckChangedListener(CheckChangedListener checkChangedListener) {
- this.checkChangedListener = checkChangedListener;
- }
-
- private void setChecked(boolean isChecked, boolean animate) {
- this.isChecked = isChecked;
- float scale = isChecked ? (float) 0.6 : 1;
- if (animate) {
- checkBackground.animate().alpha(isChecked ? 1 : 0).setDuration(200).start();
- icon.animate().scaleX(scale).scaleY(scale).setDuration(200).start();
- } else {
- checkBackground.setAlpha(isChecked ? 1 : 0);
- icon.setScaleX(scale);
- icon.setScaleY(scale);
- }
- if (checkChangedListener != null) {
- checkChangedListener.onCheckChanged(isChecked);
- }
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (id == R.id.container) {
- if (position < 0 || position > mIcons.size()) return;
- if (actionMode != null) {
- setChecked(!isChecked, true);
- } else {
- SoftKeyboardHelper.closeKeyboard(mContext);
- IconsHelper.selectIcon(mContext, IntentHelper.sAction, mIcons.get(position));
- }
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- if (actionMode == null) {
- ((Activity) mContext).startActionMode(actionModeCallback);
- }
- setChecked(!isChecked, true);
- return true;
- }
- }
-
- public void search(String string) {
- // Initialize mIconsAll if not initialized
- // Also remove duplicates
- if (mIconsAll == null) {
- if (!mContext.getResources().getBoolean(R.bool.show_icon_name)) {
- // It means the title of icon is not yet computed, so compute it
- IconsHelper.computeTitles(mContext, mIcons);
- }
-
- mIconsAll = new ArrayList<>();
- Set addedNames = new HashSet<>();
- Locale defaultLocale = Locale.getDefault();
- for (int i = 0; i < mIcons.size(); i++) {
- Icon icon = mIcons.get(i);
- String name = icon.getTitle();
- name = name.toLowerCase(defaultLocale);
- if (!addedNames.contains(name)) {
- mIconsAll.add(icon);
- addedNames.add(name);
- }
- }
- }
-
- String query = string.toLowerCase(Locale.getDefault()).trim();
- mIcons = new ArrayList<>();
- if (query.length() == 0) mIcons.addAll(mIconsAll);
- else {
- Locale defaultLocale = Locale.getDefault();
- for (int i = 0; i < mIconsAll.size(); i++) {
- Icon icon = mIconsAll.get(i);
- String name = icon.getTitle();
- name = name.toLowerCase(defaultLocale);
- if (name.contains(query)) {
- mIcons.add(icon);
- }
- }
- }
- notifyDataSetChanged();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/LauncherAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/LauncherAdapter.java
deleted file mode 100644
index b568bd9..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/LauncherAdapter.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package candybar.lib.adapters;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.helpers.LauncherHelper;
-import candybar.lib.items.Icon;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class LauncherAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mLaunchers;
-
- private static final int TYPE_HEADER = 0;
- private static final int TYPE_CONTENT = 1;
- private static final int TYPE_FOOTER = 2;
-
- public LauncherAdapter(@NonNull Context context, @NonNull List launchers) {
- mContext = context;
- mLaunchers = launchers;
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = null;
- if (viewType == TYPE_HEADER) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_apply_item_header, parent, false);
- } else if (viewType == TYPE_CONTENT) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_apply_item_list, parent, false);
- } else if (viewType == TYPE_FOOTER) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_apply_item_footer, parent, false);
-
- return new FooterViewHolder(view);
- }
- return new ViewHolder(view, viewType);
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder.getItemViewType() == TYPE_HEADER) {
- ((ViewHolder) holder).name.setText(mLaunchers.get(position).getTitle());
- } else if (holder.getItemViewType() == TYPE_CONTENT) {
- ViewHolder contentViewHolder = ((ViewHolder) holder);
- contentViewHolder.name.setText(mLaunchers.get(position).getTitle());
-
- Glide.with(mContext)
- .asBitmap()
- .load("drawable://" + mLaunchers.get(position).getRes())
- .transition(BitmapTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .into(contentViewHolder.icon);
- }
- }
-
- @Override
- public int getItemCount() {
- return mLaunchers.size() + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == getFirstHeaderPosition() || position == getLastHeaderPosition()) {
- return TYPE_HEADER;
- }
- if (position == getItemCount() - 1) return TYPE_FOOTER;
- return TYPE_CONTENT;
- }
-
- class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private TextView name;
- private ImageView icon;
-
- ViewHolder(View itemView, int viewType) {
- super(itemView);
- if (viewType == TYPE_HEADER) {
- name = itemView.findViewById(R.id.name);
- } else if (viewType == TYPE_CONTENT) {
- icon = itemView.findViewById(R.id.icon);
- name = itemView.findViewById(R.id.name);
- LinearLayout container = itemView.findViewById(R.id.container);
-
- container.setOnClickListener(this);
- }
- }
-
- @SuppressLint("StringFormatInvalid")
- @Override
- public void onClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (id == R.id.container) {
- if (position < 0 || position > getItemCount()) return;
- try {
- LauncherHelper.apply(mContext,
- mLaunchers.get(position).getPackageName(),
- mLaunchers.get(position).getTitle());
- } catch (Exception e) {
- Toast.makeText(mContext, mContext.getResources().getString(
- R.string.apply_launch_failed, mLaunchers.get(position).getTitle()),
- Toast.LENGTH_LONG).show();
- }
-
- }
- }
- }
-
- class FooterViewHolder extends RecyclerView.ViewHolder {
-
- FooterViewHolder(View itemView) {
- super(itemView);
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- View shadow = itemView.findViewById(R.id.shadow);
- shadow.setVisibility(View.GONE);
- }
- }
- }
-
- public int getFirstHeaderPosition() {
- return mLaunchers.indexOf(new Icon(
- mContext.getResources().getString(R.string.apply_installed), -1, null));
- }
-
- public int getLastHeaderPosition() {
- return mLaunchers.indexOf(new Icon(
- mContext.getResources().getString(R.string.apply_supported), -2, null));
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/PresetsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/PresetsAdapter.java
deleted file mode 100644
index 3a2b711..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/PresetsAdapter.java
+++ /dev/null
@@ -1,314 +0,0 @@
-package candybar.lib.adapters;
-
-import android.animation.AnimatorInflater;
-import android.animation.StateListAnimator;
-import android.app.WallpaperManager;
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Build;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.card.MaterialCardView;
-
-import org.kustom.api.preset.AssetPresetFile;
-import org.kustom.api.preset.PresetInfoLoader;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Preset;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.views.HeaderView;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class PresetsAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mPresets;
- private Drawable wallpaperDrawable = null;
-
- private final int TYPE_HEADER = 0;
- private final int TYPE_CONTENT = 1;
-
- public PresetsAdapter(@NonNull Context context, List presets) {
- mContext = context;
- mPresets = presets;
- try {
- wallpaperDrawable = WallpaperManager.getInstance(context).getDrawable();
- } catch (Exception ignored) {
- LogUtil.e("Unable to load wallpaper. Storage permission is not granted.");
- }
- }
-
- @NonNull
- @Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = null;
- if (viewType == TYPE_HEADER) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_presets_item_header, parent, false);
- } else if (viewType == TYPE_CONTENT) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_presets_item_grid, parent, false);
- }
- return new ViewHolder(view, viewType);
- }
-
- @Override
- public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
- Preset preset = mPresets.get(position);
-
- if (holder.getItemViewType() == TYPE_HEADER) {
- holder.name.setText(preset.getHeaderText());
- holder.setType(preset.getHeaderText());
- } else if (holder.getItemViewType() == TYPE_CONTENT) {
- PresetInfoLoader.create(new AssetPresetFile(preset.getPath()))
- .load(mContext, info -> holder.name.setText(info.getTitle()));
-
- Glide.with(mContext)
- .asBitmap()
- .load(new AssetPresetFile(preset.getPath()))
- .transition(BitmapTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .into(holder.image);
- }
- }
-
- public boolean isHeader(int position) {
- return mPresets.get(position).isHeader();
- }
-
- @Override
- public int getItemCount() {
- return mPresets.size();
- }
-
- @Override
- public int getItemViewType(int position) {
- if (isHeader(position)) return TYPE_HEADER;
- return TYPE_CONTENT;
- }
-
- class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private HeaderView image;
- private TextView name;
- private final MaterialCardView card;
-
- ViewHolder(View itemView, int viewType) {
- super(itemView);
-
- name = itemView.findViewById(R.id.name);
- card = itemView.findViewById(R.id.card);
-
- if (viewType == TYPE_HEADER) {
- if (mContext.getResources().getBoolean(R.bool.use_flat_card)) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
- } else if (viewType == TYPE_CONTENT) {
- name = itemView.findViewById(R.id.name);
- image = itemView.findViewById(R.id.image);
-
- if (CandyBarApplication.getConfiguration().getWallpapersGrid() == CandyBarApplication.GridStyle.FLAT) {
- card.setCardElevation(0);
- card.setMaxCardElevation(0);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- StateListAnimator stateListAnimator = AnimatorInflater
- .loadStateListAnimator(mContext, R.animator.card_lift);
- card.setStateListAnimator(stateListAnimator);
- }
-
- if (wallpaperDrawable != null) {
- ((HeaderView) itemView.findViewById(R.id.wallpaper_bg)).setImageDrawable(wallpaperDrawable);
- }
-
- card.setOnClickListener(this);
- }
- }
-
- public boolean isPackageInstalled(String pkgName) {
- try {
- mContext.getPackageManager().getPackageInfo(pkgName, 0);
- return true;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
- public List getRequiredApps(String type) {
- type = type.toLowerCase(Locale.ROOT);
- String nameBase = "";
- String pkgBase = "";
-
- switch (type) {
- case "lockscreens":
- nameBase = "KLCK";
- pkgBase = "org.kustom.lockscreen";
- break;
- case "wallpapers":
- nameBase = "KLWP";
- pkgBase = "org.kustom.wallpaper";
- break;
- case "widgets":
- nameBase = "KWGT";
- pkgBase = "org.kustom.widget";
- break;
- }
-
- String namePro = nameBase + " Pro";
- String pkgPro = pkgBase + ".pro";
-
- List requiredApps = new ArrayList<>();
-
- if (!isPackageInstalled(pkgBase)) {
- requiredApps.add(new String[]{nameBase, pkgBase});
- }
- if (!isPackageInstalled(pkgPro)) {
- requiredApps.add(new String[]{namePro, pkgPro});
- }
-
- return requiredApps;
- }
-
- public void setType(String type) {
- List requiredApps = getRequiredApps(type);
- LinearLayout linearLayout = itemView.findViewById(R.id.container);
-
- if (requiredApps.size() > 0) {
- for (String[] requiredApp : requiredApps) {
- View item = LayoutInflater.from(mContext).inflate(R.layout.fragment_presets_item_header_list, linearLayout, false);
- ((TextView) item.findViewById(R.id.name)).setText(requiredApp[0]);
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- ((ImageView) item.findViewById(R.id.kustom_icon)).setImageDrawable(
- DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_drawer_presets, color));
- item.setOnClickListener(v -> {
- try {
- Intent store = new Intent(Intent.ACTION_VIEW, Uri.parse(
- "https://play.google.com/store/apps/details?id=" + requiredApp[1]));
- mContext.startActivity(store);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(mContext, mContext.getResources().getString(
- R.string.no_browser), Toast.LENGTH_LONG).show();
- }
- });
- ((ImageView) item.findViewById(R.id.forward_icon)).setImageDrawable(
- DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_arrow_forward, color));
- linearLayout.addView(item);
- }
- } else {
- card.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (id == R.id.card) {
- Preset preset = mPresets.get(position);
- String type = preset.getPath().split("/")[0];
-
- if (!type.equals("komponents")) {
- String pkg = null, cls = null;
-
- switch (type) {
- case "lockscreens":
- pkg = "org.kustom.lockscreen";
- cls = "org.kustom.lib.editor.LockAdvancedEditorActivity";
- break;
- case "wallpapers":
- pkg = "org.kustom.wallpaper";
- cls = "org.kustom.lib.editor.WpAdvancedEditorActivity";
- break;
- case "widgets":
- pkg = "org.kustom.widget";
- cls = "org.kustom.widget.picker.WidgetPicker";
- break;
- }
-
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(pkg, cls));
-
- try {
- intent.setData(new Uri.Builder()
- .scheme("kfile")
- .authority(mContext.getPackageName() + ".kustom.provider")
- .appendPath(preset.getPath())
- .build());
- } catch (Exception ignored) {
- intent.setData(Uri.parse("kfile://" + mContext.getPackageName() + "/" + preset.getPath()));
- }
-
- if (getRequiredApps(type).size() > 0) {
- new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .content(R.string.presets_required_apps_not_installed)
- .positiveText(R.string.close)
- .show();
- } else {
- mContext.startActivity(intent);
- }
- } else {
- // TODO: Handle Komponent click
- }
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/RequestAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/RequestAdapter.java
deleted file mode 100644
index 4a5c33a..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/RequestAdapter.java
+++ /dev/null
@@ -1,533 +0,0 @@
-package candybar.lib.adapters;
-
-import android.content.Context;
-import android.graphics.PorterDuff;
-import android.os.Build;
-import android.util.Log;
-import android.util.SparseBooleanArray;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.card.MaterialCardView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.items.Request;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.listeners.RequestListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class RequestAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mRequests;
- private SparseBooleanArray mSelectedItems;
-
- private final int mTextColorSecondary;
- private final int mTextColorAccent;
- private boolean mSelectedAll = false;
-
- private final boolean mShowShadow;
- private final boolean mShowPremiumRequest;
- private final boolean mShowRegularRequest;
-
- private static final int TYPE_HEADER = 0;
- private static final int TYPE_CONTENT = 1;
- private static final int TYPE_FOOTER = 2;
-
- public RequestAdapter(@NonNull Context context, @NonNull List requests, int spanCount) {
- mContext = context;
- mRequests = requests;
- mTextColorSecondary = ColorHelper.getAttributeColor(mContext,
- android.R.attr.textColorSecondary);
- mTextColorAccent = ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary);
- mSelectedItems = new SparseBooleanArray();
-
- mShowShadow = (spanCount == 1);
- mShowPremiumRequest = Preferences.get(mContext).isPremiumRequestEnabled();
- mShowRegularRequest = Preferences.get(mContext).isRegularRequestLimit();
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if (viewType == TYPE_HEADER) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_request_item_header, parent, false);
-
- StaggeredGridLayoutManager.LayoutParams params = getLayoutParams(view);
- if (params != null) params.setFullSpan(false);
- return new HeaderViewHolder(view);
- } else if (viewType == TYPE_CONTENT) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_request_item_list, parent, false);
-
- StaggeredGridLayoutManager.LayoutParams params = getLayoutParams(view);
- if (params != null) params.setFullSpan(false);
- return new ContentViewHolder(view);
- }
-
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_request_item_footer, parent, false);
-
- StaggeredGridLayoutManager.LayoutParams params = getLayoutParams(view);
- if (params != null) params.setFullSpan(true);
- return new FooterViewHolder(view);
- }
-
- @Override
- public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
- super.onViewRecycled(holder);
- if (holder.getItemViewType() == TYPE_CONTENT) {
- ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
- contentViewHolder.content.setTextColor(mTextColorSecondary);
-
- if (mShowShadow) {
- contentViewHolder.divider.setVisibility(View.VISIBLE);
- }
- }
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder.getItemViewType() == TYPE_HEADER) {
- HeaderViewHolder HeaderViewHolder = (HeaderViewHolder) holder;
- if (Preferences.get(mContext).isPremiumRequestEnabled()) {
- if (Preferences.get(mContext).isPremiumRequest()) {
- HeaderViewHolder.button.setVisibility(View.GONE);
- HeaderViewHolder.premContent.setVisibility(View.GONE);
- HeaderViewHolder.premContainer.setVisibility(View.VISIBLE);
-
- int total = Preferences.get(mContext).getPremiumRequestTotal();
- int available = Preferences.get(mContext).getPremiumRequestCount();
-
- HeaderViewHolder.premTotal.setText(mContext.getResources().getString(
- R.string.premium_request_count, total));
- HeaderViewHolder.premAvailable.setText(mContext.getResources().getString(
- R.string.premium_request_available, available));
- HeaderViewHolder.premUsed.setText(mContext.getResources().getString(
- R.string.premium_request_used, (total - available)));
-
- HeaderViewHolder.premProgress.setMax(total);
- HeaderViewHolder.premProgress.setProgress(available);
- } else {
- HeaderViewHolder.button.setVisibility(View.VISIBLE);
- HeaderViewHolder.premContent.setVisibility(View.VISIBLE);
- HeaderViewHolder.premContainer.setVisibility(View.GONE);
- }
- } else {
- HeaderViewHolder.premWholeContainer.setVisibility(View.GONE);
- }
-
- if (Preferences.get(mContext).isRegularRequestLimit()) {
- int total = mContext.getResources().getInteger(R.integer.icon_request_limit);
- int used = Preferences.get(mContext).getRegularRequestUsed();
- int available = total - used;
-
- HeaderViewHolder.regTotal.setText(mContext.getResources().getString(
- R.string.regular_request_count, total));
- HeaderViewHolder.regAvailable.setText(mContext.getResources().getString(
- R.string.regular_request_available, available));
- HeaderViewHolder.regUsed.setText(mContext.getResources().getString(
- R.string.regular_request_used, used));
-
- HeaderViewHolder.regProgress.setMax(total);
- HeaderViewHolder.regProgress.setProgress(available);
- } else {
- HeaderViewHolder.regWholeContainer.setVisibility(View.GONE);
- }
-
- if (!mContext.getResources().getBoolean(R.bool.enable_icon_request)) {
- HeaderViewHolder.regWholeContainer.setVisibility(View.GONE);
- }
- } else if (holder.getItemViewType() == TYPE_CONTENT) {
- int finalPosition = mShowPremiumRequest ? position - 1 : position;
- ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
-
- Glide.with(mContext)
- .load("package://" + mRequests.get(finalPosition).getActivity())
- .override(272)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .into(contentViewHolder.icon);
-
- contentViewHolder.title.setText(mRequests.get(finalPosition).getName());
-
- if (mRequests.get(finalPosition).isRequested()) {
- contentViewHolder.content.setTextColor(mTextColorAccent);
- contentViewHolder.content.setText(mContext.getResources().getString(
- R.string.request_already_requested));
- } else {
- contentViewHolder.content.setText(mContext.getResources().getString(
- R.string.request_not_requested));
- }
-
- contentViewHolder.checkbox.setChecked(mSelectedItems.get(finalPosition, false));
-
- if (finalPosition == (mRequests.size() - 1) && mShowShadow) {
- contentViewHolder.divider.setVisibility(View.GONE);
- }
- }
- }
-
- @Override
- public int getItemCount() {
- int count = mRequests == null ? 0 : mRequests.size();
- if (mShowShadow) count += 1;
- if (mShowPremiumRequest) count += 1;
- return count;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == 0 && (mShowPremiumRequest || mShowRegularRequest)) return TYPE_HEADER;
- if (position == (getItemCount() - 1) && mShowShadow) return TYPE_FOOTER;
- return TYPE_CONTENT;
- }
-
- private class HeaderViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final TextView premContent;
- private final TextView premTotal;
- private final TextView premAvailable;
- private final TextView premUsed;
- private final Button button;
- private final LinearLayout premContainer;
- private final LinearLayout premWholeContainer;
- private final ProgressBar premProgress;
-
- private final TextView regTotal;
- private final TextView regAvailable;
- private final TextView regUsed;
- private final LinearLayout regWholeContainer;
- private final ProgressBar regProgress;
-
- HeaderViewHolder(View itemView) {
- super(itemView);
- TextView premTitle = itemView.findViewById(R.id.premium_request_title);
- premContent = itemView.findViewById(R.id.premium_request_content);
- button = itemView.findViewById(R.id.buy);
-
- premWholeContainer = itemView.findViewById(R.id.premium_request_container);
- premContainer = itemView.findViewById(R.id.premium_request);
- premTotal = itemView.findViewById(R.id.premium_request_total);
- premAvailable = itemView.findViewById(R.id.premium_request_available);
- premUsed = itemView.findViewById(R.id.premium_request_used);
- premProgress = itemView.findViewById(R.id.premium_request_progress);
-
-
- TextView regTitle = itemView.findViewById(R.id.regular_request_title);
- TextView regContent = itemView.findViewById(R.id.regular_request_content);
- regWholeContainer = itemView.findViewById(R.id.regular_request_container);
- LinearLayout regContainer = itemView.findViewById(R.id.regular_request);
- regTotal = itemView.findViewById(R.id.regular_request_total);
- regAvailable = itemView.findViewById(R.id.regular_request_available);
- regUsed = itemView.findViewById(R.id.regular_request_used);
- regProgress = itemView.findViewById(R.id.regular_request_progress);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
- card != null) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card) && card != null) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled() && card != null) {
- card.setCardElevation(0);
- }
-
- int padding = mContext.getResources().getDimensionPixelSize(R.dimen.content_margin) + mContext.getResources().getDimensionPixelSize(R.dimen.icon_size_small);
- premContent.setPadding(padding, 0, 0, 0);
- premContainer.setPadding(padding, 0, padding, 0);
-
- regContent.setPadding(padding, 0, 0, 0);
- regContainer.setPadding(padding, 0, padding, 0);
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- premTitle.setCompoundDrawablesWithIntrinsicBounds(
- DrawableHelper.getTintedDrawable(mContext,
- R.drawable.ic_toolbar_premium_request, color),
- null, null, null);
-
- regTitle.setCompoundDrawablesWithIntrinsicBounds(
- DrawableHelper.getTintedDrawable(mContext,
- R.drawable.ic_toolbar_icon_request, color),
- null, null, null);
-
- int primary = ColorHelper.getAttributeColor(mContext, R.attr.colorPrimary);
- int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary);
- button.setTextColor(ColorHelper.getTitleTextColor(primary));
-
- premProgress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);
- regProgress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);
-
- button.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.buy) {
- RequestListener listener = (RequestListener) mContext;
- }
- }
- }
-
- private class ContentViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
-
- private final TextView title;
- private final TextView content;
- private final ImageView icon;
- private final CheckBox checkbox;
- private final View divider;
-
- ContentViewHolder(View itemView) {
- super(itemView);
- title = itemView.findViewById(R.id.name);
- content = itemView.findViewById(R.id.requested);
- icon = itemView.findViewById(R.id.icon);
- checkbox = itemView.findViewById(R.id.checkbox);
- LinearLayout container = itemView.findViewById(R.id.container);
- divider = itemView.findViewById(R.id.divider);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
- card != null) {
- if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
- card.setRadius(0f);
- card.setUseCompatPadding(false);
- int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(0, 0, margin, margin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- params.setMarginEnd(margin);
- }
- }
- }
-
- if (mContext.getResources().getBoolean(R.bool.use_flat_card) && card != null) {
- card.setStrokeWidth(mContext.getResources().getDimensionPixelSize(R.dimen.card_stroke_width));
- card.setCardElevation(0);
- card.setUseCompatPadding(false);
- int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_top);
- int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_left);
- int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_right);
- int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin_bottom);
- StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
- params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- if (card != null) card.setCardElevation(0);
- }
-
- container.setOnClickListener(this);
- container.setOnLongClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- int position = mShowPremiumRequest ?
- getBindingAdapterPosition() - 1 : getBindingAdapterPosition();
- if (toggleSelection(position)) {
- checkbox.toggle();
- }
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- int position = mShowPremiumRequest ?
- getBindingAdapterPosition() - 1 : getBindingAdapterPosition();
- if (toggleSelection(position)) {
- checkbox.toggle();
- return true;
- }
- }
- return false;
- }
- }
-
- private class FooterViewHolder extends RecyclerView.ViewHolder {
-
- FooterViewHolder(View itemView) {
- super(itemView);
- View shadow = itemView.findViewById(R.id.shadow);
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- shadow.setVisibility(View.GONE);
- }
- }
- }
-
- @Nullable
- private StaggeredGridLayoutManager.LayoutParams getLayoutParams(@Nullable View view) {
- if (view != null) {
- try {
- return (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
- } catch (Exception e) {
- LogUtil.d(Log.getStackTraceString(e));
- }
- }
- return null;
- }
-
- private boolean toggleSelection(int position) {
- if (position >= 0 && position < mRequests.size()) {
- if (mSelectedItems.get(position, false))
- mSelectedItems.delete(position);
- else mSelectedItems.put(position, true);
- try {
- RequestListener listener = (RequestListener) mContext;
- listener.onRequestSelected(getSelectedItemsSize());
- return true;
- } catch (Exception ignored) {
- }
- }
- return false;
- }
-
- public boolean selectAll() {
- if (mSelectedAll) {
- mSelectedAll = false;
- resetSelectedItems();
- return false;
- }
-
- mSelectedItems.clear();
- for (int i = 0; i < mRequests.size(); i++) {
- if (!mRequests.get(i).isRequested())
- mSelectedItems.put(i, true);
- }
- mSelectedAll = mSelectedItems.size() > 0;
- notifyDataSetChanged();
-
- try {
- RequestListener listener = (RequestListener) mContext;
- listener.onRequestSelected(getSelectedItemsSize());
- } catch (Exception ignored) {
- }
- return mSelectedAll;
- }
-
- public void setRequested(int position, boolean requested) {
- mRequests.get(position).setRequested(requested);
- }
-
- public int getSelectedItemsSize() {
- return mSelectedItems.size();
- }
-
- public List getSelectedItems() {
- List selected = new ArrayList<>();
- for (int i = 0; i < mSelectedItems.size(); i++) {
- selected.add(mSelectedItems.keyAt(i));
- }
- return selected;
- }
-
- public SparseBooleanArray getSelectedItemsArray() {
- return mSelectedItems;
- }
-
- public void setSelectedItemsArray(SparseBooleanArray selectedItems) {
- mSelectedItems = selectedItems;
- notifyDataSetChanged();
- }
-
- public void resetSelectedItems() {
- mSelectedAll = false;
- mSelectedItems.clear();
- try {
- RequestListener listener = (RequestListener) mContext;
- listener.onRequestSelected(getSelectedItemsSize());
- } catch (Exception ignored) {
- }
- notifyDataSetChanged();
- }
-
- public List getSelectedApps() {
- List items = new ArrayList<>(mSelectedItems.size());
- for (int i = 0; i < mSelectedItems.size(); i++) {
- int position = mSelectedItems.keyAt(i);
- if (position >= 0 && position < mRequests.size()) {
- Request request = mRequests.get(mSelectedItems.keyAt(i));
- items.add(request);
- }
- }
- return items;
- }
-
- public boolean isContainsRequested() {
- List requests = getSelectedApps();
- boolean requested = false;
- for (int i = 0; i < requests.size(); i++) {
- if (requests.get(i).isRequested()) {
- requested = true;
- break;
- }
- }
- return requested;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/SettingsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/SettingsAdapter.java
deleted file mode 100644
index d3ab6e4..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/SettingsAdapter.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package candybar.lib.adapters;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.SettingsFragment;
-import candybar.lib.fragments.dialog.ChangelogFragment;
-import candybar.lib.fragments.dialog.LanguagesFragment;
-import candybar.lib.fragments.dialog.ThemeChooserFragment;
-import candybar.lib.helpers.ReportBugsHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Setting;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.tasks.IconRequestTask;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class SettingsAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mSettings;
-
- private static final int TYPE_CONTENT = 0;
- private static final int TYPE_FOOTER = 1;
-
- public SettingsAdapter(@NonNull Context context, @NonNull List settings) {
- mContext = context;
- mSettings = settings;
- }
-
- @NonNull
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if (viewType == TYPE_CONTENT) {
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_settings_item_list, parent, false);
- return new ContentViewHolder(view);
- }
-
- View view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_settings_item_footer, parent, false);
- return new FooterViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder.getItemViewType() == TYPE_CONTENT) {
- ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
- Setting setting = mSettings.get(position);
-
- if (setting.getTitle().length() == 0) {
- contentViewHolder.title.setVisibility(View.GONE);
- contentViewHolder.divider.setVisibility(View.GONE);
- contentViewHolder.container.setVisibility(View.VISIBLE);
-
- contentViewHolder.subtitle.setText(setting.getSubtitle());
-
- if (setting.getContent().length() == 0) {
- contentViewHolder.content.setVisibility(View.GONE);
- } else {
- contentViewHolder.content.setText(setting.getContent());
- contentViewHolder.content.setVisibility(View.VISIBLE);
- }
-
- if (setting.getFooter().length() == 0) {
- contentViewHolder.footer.setVisibility(View.GONE);
- } else {
- contentViewHolder.footer.setText(setting.getFooter());
- contentViewHolder.footer.setVisibility(View.VISIBLE);
- }
- } else {
- contentViewHolder.container.setVisibility(View.GONE);
- contentViewHolder.title.setVisibility(View.VISIBLE);
- contentViewHolder.title.setText(setting.getTitle());
-
- if (position > 0) {
- contentViewHolder.divider.setVisibility(View.VISIBLE);
- } else {
- contentViewHolder.divider.setVisibility(View.GONE);
- }
-
- if (setting.getIcon() != -1) {
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
- contentViewHolder.title.setCompoundDrawablesWithIntrinsicBounds(
- DrawableHelper.getTintedDrawable(mContext, setting.getIcon(), color), null, null, null);
- }
- }
- }
- }
-
- @Override
- public int getItemCount() {
- return mSettings.size() + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- if (position == getItemCount() - 1) return TYPE_FOOTER;
- return TYPE_CONTENT;
- }
-
- private class ContentViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
-
- private final TextView title;
- private final TextView subtitle;
- private final TextView content;
- private final TextView footer;
- private final LinearLayout container;
- private final View divider;
-
- ContentViewHolder(View itemView) {
- super(itemView);
- title = itemView.findViewById(R.id.title);
- subtitle = itemView.findViewById(R.id.subtitle);
- content = itemView.findViewById(R.id.content);
- footer = itemView.findViewById(R.id.footer);
- divider = itemView.findViewById(R.id.divider);
- container = itemView.findViewById(R.id.container);
-
- container.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.container) {
- int position = getBindingAdapterPosition();
-
- if (position < 0 || position > mSettings.size()) return;
-
- Setting setting = mSettings.get(position);
- switch (setting.getType()) {
- case CACHE:
- new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .content(R.string.pref_data_cache_clear_dialog)
- .positiveText(R.string.clear)
- .negativeText(android.R.string.cancel)
- .onPositive((dialog, which) -> {
- try {
- File cache = mContext.getCacheDir();
- FileHelper.clearDirectory(cache);
-
- double size = (double) FileHelper.getDirectorySize(cache) / FileHelper.MB;
- NumberFormat formatter = new DecimalFormat("#0.00");
-
- setting.setFooter(mContext.getResources().getString(
- R.string.pref_data_cache_size, formatter.format(size) + " MB"));
- notifyItemChanged(position);
-
- Toast.makeText(mContext, R.string.pref_data_cache_cleared,
- Toast.LENGTH_LONG).show();
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- })
- .show();
- break;
- case ICON_REQUEST:
- new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .content(R.string.pref_data_request_clear_dialog)
- .positiveText(R.string.clear)
- .negativeText(android.R.string.cancel)
- .onPositive((dialog, which) -> {
- Database.get(mContext).deleteIconRequestData();
-
- CandyBarMainActivity.sMissedApps = null;
- new IconRequestTask(mContext).executeOnThreadPool();
-
- Toast.makeText(mContext, R.string.pref_data_request_cleared,
- Toast.LENGTH_LONG).show();
- })
- .show();
- break;
- case RESTORE:
- try {
- } catch (Exception ignored) {
- }
- break;
- case PREMIUM_REQUEST:
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag("settings");
- if (fragment == null) return;
-
- if (fragment instanceof SettingsFragment) {
- ((SettingsFragment) fragment).rebuildPremiumRequest();
- }
- break;
- case THEME:
- ThemeChooserFragment.showThemeChooser(((AppCompatActivity) mContext).getSupportFragmentManager());
- break;
- case LANGUAGE:
- LanguagesFragment.showLanguageChooser(((AppCompatActivity) mContext).getSupportFragmentManager());
- break;
- case REPORT_BUGS:
- ReportBugsHelper.prepareReportBugs(mContext);
- break;
- case CHANGELOG:
- ChangelogFragment.showChangelog(((AppCompatActivity) mContext).getSupportFragmentManager());
- break;
- case RESET_TUTORIAL:
- Preferences.get(mContext).setTimeToShowHomeIntro(true);
- Preferences.get(mContext).setTimeToShowIconsIntro(true);
- Preferences.get(mContext).setTimeToShowRequestIntro(true);
- Preferences.get(mContext).setTimeToShowWallpapersIntro(true);
- Preferences.get(mContext).setTimeToShowWallpaperPreviewIntro(true);
-
- Toast.makeText(mContext, R.string.pref_others_reset_tutorial_reset, Toast.LENGTH_LONG).show();
- break;
- }
- }
- }
- }
-
- private class FooterViewHolder extends RecyclerView.ViewHolder {
-
- FooterViewHolder(View itemView) {
- super(itemView);
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- View shadow = itemView.findViewById(R.id.shadow);
- shadow.setVisibility(View.GONE);
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/WallpapersAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/WallpapersAdapter.java
deleted file mode 100644
index d85fc96..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/WallpapersAdapter.java
+++ /dev/null
@@ -1,256 +0,0 @@
-package candybar.lib.adapters;
-
-import android.animation.AnimatorInflater;
-import android.animation.StateListAnimator;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Point;
-import android.os.Build;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.DataSource;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.engine.GlideException;
-import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions;
-import com.bumptech.glide.request.RequestListener;
-import com.bumptech.glide.request.target.Target;
-import com.google.android.material.card.MaterialCardView;
-import com.kogitune.activitytransition.ActivityTransitionLauncher;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarWallpaperActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.ViewHelper;
-import candybar.lib.items.PopupItem;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.tasks.WallpaperApplyTask;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.ImageConfig;
-import candybar.lib.utils.Popup;
-import candybar.lib.utils.WallpaperDownloader;
-import candybar.lib.utils.views.HeaderView;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class WallpapersAdapter extends RecyclerView.Adapter {
-
- private final Context mContext;
- private final List mWallpapers;
- private final List mWallpapersAll;
-
- public static boolean sIsClickable = true;
- private final boolean mIsShowName;
-
- public WallpapersAdapter(@NonNull Context context, @NonNull List wallpapers) {
- mContext = context;
- mWallpapers = wallpapers;
- mWallpapersAll = new ArrayList<>(wallpapers);
- mIsShowName = mContext.getResources().getBoolean(R.bool.wallpaper_show_name_author);
- }
-
- @NonNull
- @Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view;
- if (mIsShowName) {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_wallpapers_item_grid, parent, false);
- } else {
- view = LayoutInflater.from(mContext).inflate(
- R.layout.fragment_wallpapers_item_grid_alt, parent, false);
- }
- return new ViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
- Wallpaper wallpaper = mWallpapers.get(position);
- if (mIsShowName) {
- holder.name.setText(wallpaper.getName());
- holder.author.setText(wallpaper.getAuthor());
- }
-
- Glide.with(mContext)
- .asBitmap()
- .load(wallpaper.getThumbUrl())
- .override(ImageConfig.getThumbnailSize())
- .transition(BitmapTransitionOptions.withCrossFade(300))
- .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
- .listener(new RequestListener() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
- return false;
- }
-
- @Override
- public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
- holder.thumbnailBitmap = resource;
- return false;
- }
- })
- .into(holder.image);
- }
-
- public void search(String string) {
- String query = string.toLowerCase(Locale.getDefault()).trim();
- mWallpapers.clear();
- if (query.length() == 0) mWallpapers.addAll(mWallpapersAll);
- else {
- for (int i = 0; i < mWallpapersAll.size(); i++) {
- Wallpaper wallpaper = mWallpapersAll.get(i);
- if (wallpaper.getName().toLowerCase(Locale.getDefault()).contains(query)) {
- mWallpapers.add(wallpaper);
- }
- }
- }
- notifyDataSetChanged();
- }
-
- @Override
- public int getItemCount() {
- return mWallpapers.size();
- }
-
- class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,
- View.OnLongClickListener {
-
- private final HeaderView image;
- private TextView name;
- private TextView author;
- private Bitmap thumbnailBitmap;
-
- ViewHolder(View itemView) {
- super(itemView);
- String viewStyle = mContext.getResources().getString(
- R.string.wallpaper_grid_preview_style);
- Point ratio = ViewHelper.getWallpaperViewRatio(viewStyle);
-
- image = itemView.findViewById(R.id.image);
- image.setRatio(ratio.x, ratio.y);
-
- MaterialCardView card = itemView.findViewById(R.id.card);
- if (CandyBarApplication.getConfiguration().getWallpapersGrid() == CandyBarApplication.GridStyle.FLAT) {
- card.setCardElevation(0);
- card.setMaxCardElevation(0);
- }
-
- if (!Preferences.get(mContext).isCardShadowEnabled()) {
- card.setCardElevation(0);
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- StateListAnimator stateListAnimator = AnimatorInflater
- .loadStateListAnimator(mContext, R.animator.card_lift);
- card.setStateListAnimator(stateListAnimator);
- }
-
- if (mIsShowName) {
- name = itemView.findViewById(R.id.name);
- author = itemView.findViewById(R.id.author);
- }
-
- card.setOnClickListener(this);
- card.setOnLongClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (id == R.id.card) {
- if (sIsClickable) {
- sIsClickable = false;
- try {
- final Intent intent = new Intent(mContext, CandyBarWallpaperActivity.class);
- intent.putExtra(Extras.EXTRA_URL, mWallpapers.get(position).getURL());
-
- ActivityTransitionLauncher.with((AppCompatActivity) mContext)
- .from(image, Extras.EXTRA_IMAGE)
- .image(thumbnailBitmap)
- .launch(intent);
- } catch (Exception e) {
- sIsClickable = true;
- }
- }
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- int id = view.getId();
- int position = getBindingAdapterPosition();
- if (id == R.id.card) {
- if (position < 0 || position > mWallpapers.size()) {
- return false;
- }
-
- Popup popup = Popup.Builder(mContext)
- .to(name != null ? name : view)
- .list(PopupItem.getApplyItems(mContext))
- .callback((applyPopup, i) -> {
- PopupItem item = applyPopup.getItems().get(i);
- if (item.getType() == PopupItem.Type.WALLPAPER_CROP) {
- Preferences.get(mContext).setCropWallpaper(!item.getCheckboxValue());
- item.setCheckboxValue(Preferences.get(mContext).isCropWallpaper());
-
- applyPopup.updateItem(i, item);
- return;
- } else if (item.getType() == PopupItem.Type.DOWNLOAD) {
- WallpaperDownloader.prepare(mContext)
- .wallpaper(mWallpapers.get(position))
- .start();
- } else {
- WallpaperApplyTask task = new WallpaperApplyTask(mContext, mWallpapers.get(position));
-
- if (item.getType() == PopupItem.Type.LOCKSCREEN) {
- task.to(WallpaperApplyTask.Apply.LOCKSCREEN);
- } else if (item.getType() == PopupItem.Type.HOMESCREEN) {
- task.to(WallpaperApplyTask.Apply.HOMESCREEN);
- } else if (item.getType() == PopupItem.Type.HOMESCREEN_LOCKSCREEN) {
- task.to(WallpaperApplyTask.Apply.HOMESCREEN_LOCKSCREEN);
- }
-
- task.executeOnThreadPool();
- }
- applyPopup.dismiss();
- })
- .build();
-
- popup.show();
- return true;
- }
- return false;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ChangelogAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ChangelogAdapter.java
deleted file mode 100644
index 6482db8..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ChangelogAdapter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.Context;
-import android.text.method.LinkMovementMethod;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.core.text.HtmlCompat;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-
-import candybar.lib.R;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ChangelogAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final String[] mChangelog;
-
- public ChangelogAdapter(@NonNull Context context, @NonNull String[] changelog) {
- mContext = context;
- mChangelog = changelog;
- }
-
- @Override
- public int getCount() {
- return mChangelog.length;
- }
-
- @Override
- public String getItem(int position) {
- return mChangelog[position];
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_changelog_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
-
- holder.changelog.setText(HtmlCompat.fromHtml(mChangelog[position], HtmlCompat.FROM_HTML_MODE_COMPACT));
- holder.changelog.setMovementMethod(LinkMovementMethod.getInstance());
-
- return view;
- }
-
- private class ViewHolder {
-
- private final TextView changelog;
-
- ViewHolder(View view) {
- changelog = view.findViewById(R.id.changelog);
- int color = ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary);
- changelog.setCompoundDrawablesWithIntrinsicBounds(
- DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_changelog_dot, color),
- null, null, null);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/CreditsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/CreditsAdapter.java
deleted file mode 100644
index 1b7046f..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/CreditsAdapter.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.URLUtil;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.core.view.ViewCompat;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.items.Credit;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CreditsAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final List mCredits;
- private final Drawable mPlaceholder;
-
- public CreditsAdapter(@NonNull Context context, @NonNull List credits) {
- mContext = context;
- mCredits = credits;
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary);
- mPlaceholder = DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_default_profile, color);
- }
-
- @Override
- public int getCount() {
- return mCredits.size();
- }
-
- @Override
- public Credit getItem(int position) {
- return mCredits.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_credits_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
-
- Credit credit = mCredits.get(position);
- holder.title.setText(credit.getName());
- holder.subtitle.setText(credit.getContribution());
- holder.container.setOnClickListener(view1 -> {
- String link = credit.getLink();
- if (URLUtil.isValidUrl(link)) {
- try {
- mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
- } catch (ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
- });
-
- if (credit.getContribution().length() == 0) {
- holder.subtitle.setVisibility(View.GONE);
- } else {
- holder.subtitle.setVisibility(View.VISIBLE);
- }
-
- Glide.with(mContext)
- .load(credit.getImage())
- .override(144)
- .optionalCenterInside()
- .circleCrop()
- .placeholder(mPlaceholder)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
- .into(holder.image);
-
- return view;
- }
-
- class ViewHolder {
-
- private final LinearLayout container;
- private final TextView title;
- private final TextView subtitle;
- private final ImageView image;
-
- ViewHolder(View view) {
- container = view.findViewById(R.id.container);
- title = view.findViewById(R.id.title);
- subtitle = view.findViewById(R.id.subtitle);
- image = view.findViewById(R.id.image);
-
- int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary);
- ViewCompat.setBackground(image, DrawableHelper.getTintedDrawable(
- mContext, R.drawable.ic_toolbar_circle, ColorHelper.setColorAlpha(color, 0.4f)));
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IconShapeAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IconShapeAdapter.java
deleted file mode 100644
index 2dc4b52..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IconShapeAdapter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.fragments.dialog.IconShapeChooserFragment;
-import candybar.lib.items.IconShape;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconShapeAdapter extends BaseAdapter {
- private final Context mContext;
- private final List mShapes;
- private final int mSelectedIndex;
- private final List mHolders;
-
- public IconShapeAdapter(@NonNull Context context, @NonNull List shapes, int selectedIndex) {
- mContext = context;
- mShapes = shapes;
- mSelectedIndex = selectedIndex;
- mHolders = new ArrayList<>();
- }
-
- @Override
- public int getCount() {
- return mShapes.size();
- }
-
- @Override
- public IconShape getItem(int position) {
- return mShapes.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- IconShapeAdapter.ViewHolder holder;
-
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_inapp_dialog_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- mHolders.add(holder);
- } else {
- holder = (IconShapeAdapter.ViewHolder) view.getTag();
- }
-
- holder.radio.setChecked(mSelectedIndex == position);
- holder.name.setText(mShapes.get(position).getName());
-
- holder.container.setOnClickListener(v -> {
- for (ViewHolder aHolder : mHolders) {
- if (aHolder != holder) aHolder.radio.setChecked(false);
- }
- holder.radio.setChecked(true);
-
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag(IconShapeChooserFragment.TAG);
- if (fragment == null) return;
-
- if (fragment instanceof IconShapeChooserFragment) {
- ((IconShapeChooserFragment) fragment).setShape(mShapes.get(position).getShape());
- }
- });
-
- return view;
- }
-
- private static class ViewHolder {
- private final RadioButton radio;
- private final TextView name;
- private final LinearLayout container;
-
- ViewHolder(View view) {
- radio = view.findViewById(R.id.radio);
- name = view.findViewById(R.id.name);
- container = view.findViewById(R.id.container);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/InAppBillingAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/InAppBillingAdapter.java
deleted file mode 100644
index fd5dd76..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/InAppBillingAdapter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.items.InAppBilling;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class InAppBillingAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final List mInAppBillings;
-
- private int mSelectedPosition = 0;
-
- public InAppBillingAdapter(@NonNull Context context, @NonNull List inAppBillings) {
- mContext = context;
- mInAppBillings = inAppBillings;
- }
-
- @Override
- public int getCount() {
- return mInAppBillings.size();
- }
-
- @Override
- public InAppBilling getItem(int position) {
- return mInAppBillings.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View view, ViewGroup viewGroup) {
- ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_inapp_dialog_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
-
- return view;
- }
-
- private static class ViewHolder {
-
- private final RadioButton radio;
- private final TextView name;
- private final LinearLayout container;
-
- ViewHolder(View view) {
- radio = view.findViewById(R.id.radio);
- name = view.findViewById(R.id.name);
- container = view.findViewById(R.id.container);
- }
- }
-
- public InAppBilling getSelectedProduct() {
- return mInAppBillings.get(mSelectedPosition);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IntentAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IntentAdapter.java
deleted file mode 100644
index b3f7eb6..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/IntentAdapter.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.graphics.Color;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.DrawableHelper;
-import candybar.lib.items.IntentChooser;
-import candybar.lib.items.Request;
-import candybar.lib.tasks.IconRequestBuilderTask;
-import candybar.lib.tasks.PremiumRequestBuilderTask;
-import candybar.lib.utils.AsyncTaskBase;
-import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IntentAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final List mApps;
- private final int mType;
- private AsyncTaskBase mAsyncTask;
-
- public IntentAdapter(@NonNull Context context, @NonNull List apps, int type) {
- mContext = context;
- mApps = apps;
- mType = type;
- }
-
- @Override
- public int getCount() {
- return mApps.size();
- }
-
- @Override
- public IntentChooser getItem(int position) {
- return mApps.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View view, ViewGroup viewGroup) {
- ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_intent_chooser_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
-
- holder.icon.setImageDrawable(DrawableHelper.getAppIcon(mContext, mApps.get(position).getApp()));
- holder.name.setText(mApps.get(position).getApp().loadLabel(mContext.getPackageManager()).toString());
-
- if (mApps.get(position).getType() == IntentChooser.TYPE_SUPPORTED) {
- holder.type.setTextColor(ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary));
- holder.type.setText(mContext.getResources().getString(R.string.intent_email_supported));
- } else if (mApps.get(position).getType() == IntentChooser.TYPE_RECOMMENDED) {
- holder.type.setTextColor(ColorHelper.getAttributeColor(mContext, R.attr.colorSecondary));
- holder.type.setText(mContext.getResources().getString(R.string.intent_email_recommended));
- } else {
- holder.type.setTextColor(Color.parseColor("#F44336"));
- holder.type.setText(mContext.getResources().getString(R.string.intent_email_not_supported));
- }
-
- holder.container.setOnClickListener(v -> {
- ActivityInfo app = mApps.get(position).getApp().activityInfo;
- if (mApps.get(position).getType() == IntentChooser.TYPE_RECOMMENDED ||
- mApps.get(position).getType() == IntentChooser.TYPE_SUPPORTED) {
- if (mAsyncTask != null) return;
-
- holder.icon.setVisibility(View.GONE);
- holder.progressBar.setVisibility(View.VISIBLE);
-
- if (CandyBarApplication.sRequestProperty == null) {
- CandyBarApplication.sRequestProperty = new Request.Property(null, null, null);
- }
- CandyBarApplication.sRequestProperty.setComponentName(
- new ComponentName(app.applicationInfo.packageName, app.name));
-
- if (mType == IntentChooserFragment.ICON_REQUEST) {
- mAsyncTask = new IconRequestBuilderTask(mContext, () -> {
- mAsyncTask = null;
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm != null) {
- DialogFragment dialog = (DialogFragment) fm.findFragmentByTag(
- IntentChooserFragment.TAG);
- if (dialog != null) {
- dialog.dismiss();
- }
- }
- }).executeOnThreadPool();
- } else if (mType == IntentChooserFragment.REBUILD_ICON_REQUEST) {
- mAsyncTask = new PremiumRequestBuilderTask(mContext, () -> {
- mAsyncTask = null;
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm != null) {
- DialogFragment dialog = (DialogFragment) fm.findFragmentByTag(
- IntentChooserFragment.TAG);
- if (dialog != null) {
- dialog.dismiss();
- }
- }
- }).executeOnThreadPool();
- } else {
- LogUtil.e("Intent chooser type unknown: " + mType);
- }
- return;
- }
-
- Toast.makeText(mContext, R.string.intent_email_not_supported_message,
- Toast.LENGTH_LONG).show();
- });
-
- return view;
- }
-
- public boolean isAsyncTaskRunning() {
- return mAsyncTask != null;
- }
-
- private static class ViewHolder {
-
- private final TextView name;
- private final TextView type;
- private final ImageView icon;
- private final LinearLayout container;
- private final MaterialProgressBar progressBar;
-
- ViewHolder(View view) {
- name = view.findViewById(R.id.name);
- type = view.findViewById(R.id.type);
- icon = view.findViewById(R.id.icon);
- container = view.findViewById(R.id.container);
- progressBar = view.findViewById(R.id.progress);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/LanguagesAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/LanguagesAdapter.java
deleted file mode 100644
index 0d85ade..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/LanguagesAdapter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.fragments.dialog.LanguagesFragment;
-import candybar.lib.items.Language;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class LanguagesAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final List mLanguages;
- private final int mSelectedIndex;
-
- public LanguagesAdapter(@NonNull Context context, @NonNull List languages, int selectedIndex) {
- mContext = context;
- mLanguages = languages;
- mSelectedIndex = selectedIndex;
- }
-
- @Override
- public int getCount() {
- return mLanguages.size();
- }
-
- @Override
- public Language getItem(int position) {
- return mLanguages.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- LanguagesAdapter.ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_inapp_dialog_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (LanguagesAdapter.ViewHolder) view.getTag();
- }
-
- holder.radio.setChecked(mSelectedIndex == position);
- holder.name.setText(mLanguages.get(position).getName());
-
- holder.container.setOnClickListener(v -> {
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag(LanguagesFragment.TAG);
- if (fragment == null) return;
-
- if (fragment instanceof LanguagesFragment) {
- ((LanguagesFragment) fragment).setLanguage(mLanguages.get(position).getLocale());
- }
- });
- return view;
- }
-
- private static class ViewHolder {
-
- private final RadioButton radio;
- private final TextView name;
- private final LinearLayout container;
-
- ViewHolder(View view) {
- radio = view.findViewById(R.id.radio);
- name = view.findViewById(R.id.name);
- container = view.findViewById(R.id.container);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/OtherAppsAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/OtherAppsAdapter.java
deleted file mode 100644
index 6c9bcba..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/OtherAppsAdapter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.URLUtil;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class OtherAppsAdapter extends BaseAdapter {
-
- private final Context mContext;
- private final List mOtherApps;
-
- public OtherAppsAdapter(@NonNull Context context, @NonNull List extends CandyBarApplication.OtherApp> otherApps) {
- mContext = context;
- mOtherApps = (List) otherApps;
- }
-
- @Override
- public int getCount() {
- return mOtherApps.size();
- }
-
- @Override
- public CandyBarApplication.OtherApp getItem(int position) {
- return mOtherApps.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- ViewHolder holder;
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_other_apps_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
-
- CandyBarApplication.OtherApp otherApp = mOtherApps.get(position);
- String uri = otherApp.getIcon();
- if (!URLUtil.isValidUrl(uri)) {
- uri = "drawable://" + DrawableHelper.getResourceId(mContext, uri);
- }
-
- Glide.with(mContext)
- .load(uri)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(uri.contains("drawable://")
- ? DiskCacheStrategy.NONE
- : DiskCacheStrategy.RESOURCE)
- .into(holder.image);
-
- holder.title.setText(otherApp.getTitle());
-
- if (otherApp.getDescription() == null || otherApp.getDescription().length() == 0) {
- holder.desc.setVisibility(View.GONE);
- } else {
- holder.desc.setText(otherApp.getDescription());
- holder.desc.setVisibility(View.VISIBLE);
- }
-
- holder.container.setOnClickListener(v -> {
- if (!URLUtil.isValidUrl(otherApp.getUrl())) return;
-
- try {
- mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(otherApp.getUrl())));
- } catch (ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- });
- return view;
- }
-
- private static class ViewHolder {
-
- private final LinearLayout container;
- private final ImageView image;
- private final TextView title;
- private final TextView desc;
-
- ViewHolder(View view) {
- container = view.findViewById(R.id.container);
- image = view.findViewById(R.id.image);
- title = view.findViewById(R.id.title);
- desc = view.findViewById(R.id.desc);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ThemeAdapter.java b/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ThemeAdapter.java
deleted file mode 100644
index 3823924..0000000
--- a/libs/candybar/src/main/java/candybar/lib/adapters/dialog/ThemeAdapter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package candybar.lib.adapters.dialog;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.fragments.dialog.ThemeChooserFragment;
-import candybar.lib.items.Theme;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ThemeAdapter extends BaseAdapter {
- private final Context mContext;
- private final List mThemes;
- private final int mSelectedIndex;
- private final List mHolders;
-
- public ThemeAdapter(@NonNull Context context, @NonNull List themes, int selectedIndex) {
- mContext = context;
- mThemes = themes;
- mSelectedIndex = selectedIndex;
- mHolders = new ArrayList<>();
- }
-
- @Override
- public int getCount() {
- return mThemes.size();
- }
-
- @Override
- public Theme getItem(int position) {
- return mThemes.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View view, ViewGroup viewGroup) {
- ThemeAdapter.ViewHolder holder;
-
- if (view == null) {
- view = View.inflate(mContext, R.layout.fragment_inapp_dialog_item_list, null);
- holder = new ViewHolder(view);
- view.setTag(holder);
- mHolders.add(holder);
- } else {
- holder = (ThemeAdapter.ViewHolder) view.getTag();
- }
-
- holder.radio.setChecked(mSelectedIndex == position);
- holder.name.setText(mThemes.get(position).displayName(mContext));
-
- holder.container.setOnClickListener(v -> {
- for (ViewHolder aHolder : mHolders) {
- if (aHolder != holder) aHolder.radio.setChecked(false);
- }
- holder.radio.setChecked(true);
-
- FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag(ThemeChooserFragment.TAG);
- if (fragment == null) return;
-
- if (fragment instanceof ThemeChooserFragment) {
- ((ThemeChooserFragment) fragment).setTheme(mThemes.get(position));
- }
- });
-
- return view;
- }
-
- private static class ViewHolder {
- private final RadioButton radio;
- private final TextView name;
- private final LinearLayout container;
-
- ViewHolder(View view) {
- radio = view.findViewById(R.id.radio);
- name = view.findViewById(R.id.name);
- container = view.findViewById(R.id.container);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/applications/CandyBarApplication.java b/libs/candybar/src/main/java/candybar/lib/applications/CandyBarApplication.java
deleted file mode 100644
index 316bac1..0000000
--- a/libs/candybar/src/main/java/candybar/lib/applications/CandyBarApplication.java
+++ /dev/null
@@ -1,533 +0,0 @@
-package candybar.lib.applications;
-
-import android.content.Intent;
-
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.multidex.MultiDexApplication;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarCrashReport;
-import candybar.lib.databases.Database;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.items.Request;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.JsonStructure;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public abstract class CandyBarApplication extends MultiDexApplication {
-
- private static Configuration mConfiguration;
- private Thread.UncaughtExceptionHandler mHandler;
-
- public static Request.Property sRequestProperty;
- public static String sZipPath = null;
-
- @NonNull
- public abstract Configuration onInit();
-
- public static Configuration getConfiguration() {
- if (mConfiguration == null) {
- mConfiguration = new Configuration();
- }
- return mConfiguration;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- Database.get(this).openDatabase();
-
- // Enable or disable logging
- LogUtil.setLoggingTag(getString(R.string.app_name));
- LogUtil.setLoggingEnabled(true);
-
- mConfiguration = onInit();
-
- if (mConfiguration.mIsCrashReportEnabled) {
- mHandler = Thread.getDefaultUncaughtExceptionHandler();
- Thread.setDefaultUncaughtExceptionHandler(this::handleUncaughtException);
- }
-
- if (Preferences.get(this).isTimeToSetLanguagePreference()) {
- Preferences.get(this).setLanguagePreference();
- return;
- }
-
- LocaleHelper.setLocale(this);
- }
-
- private void handleUncaughtException(Thread thread, Throwable throwable) {
- try {
- StringBuilder sb = new StringBuilder();
- SimpleDateFormat dateFormat = new SimpleDateFormat(
- "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
- String dateTime = dateFormat.format(new Date());
- sb.append("Crash Time : ").append(dateTime).append("\r\n");
- sb.append("Class Name : ").append(throwable.getClass().getName()).append("\r\n");
- sb.append("Caused By : ").append(throwable.toString()).append("\r\n");
-
- for (StackTraceElement element : throwable.getStackTrace()) {
- sb.append("\r\n");
- sb.append(element.toString());
- }
-
- Preferences.get(this).setLatestCrashLog(sb.toString());
-
- Intent intent = new Intent(this, CandyBarCrashReport.class);
- intent.putExtra(CandyBarCrashReport.EXTRA_STACKTRACE, sb.toString());
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- startActivity(intent);
- } catch (Exception e) {
- if (mHandler != null) {
- mHandler.uncaughtException(thread, throwable);
- return;
- }
- }
- System.exit(1);
- }
-
- public static class Configuration {
-
- public interface EmailBodyGenerator {
- String generate(List requests);
- }
-
- private EmailBodyGenerator mEmailBodyGenerator;
-
- private NavigationIcon mNavigationIcon = NavigationIcon.STYLE_1;
- private NavigationViewHeader mNavigationViewHeader = NavigationViewHeader.NORMAL;
-
- private GridStyle mHomeGrid = GridStyle.CARD;
- private GridStyle mApplyGrid = GridStyle.CARD;
- private Style mRequestStyle = Style.PORTRAIT_FLAT_LANDSCAPE_CARD;
- private GridStyle mWallpapersGrid = GridStyle.CARD;
- private Style mAboutStyle = Style.PORTRAIT_FLAT_LANDSCAPE_CARD;
- private IconColor mIconColor = IconColor.PRIMARY_TEXT;
- private List mOtherApps = null;
- private List mDonationLinks = null;
-
- private boolean mIsHighQualityPreviewEnabled = false;
- private boolean mIsColoredApplyCard = true;
- private boolean mIsAutomaticIconsCountEnabled = true;
- private int mCustomIconsCount = 0;
- private boolean mIsShowTabIconsCount = false;
- private boolean mIsShowTabAllIcons = false;
- private String mTabAllIconsTitle = "All Icons";
- private String[] mCategoryForTabAllIcons = null;
-
- private ShadowOptions mShadowOptions = new ShadowOptions();
- private boolean mIsDashboardThemingEnabled = true;
- private int mWallpaperGridPreviewQuality = 4;
-
- private boolean mIsGenerateAppFilter = true;
- private boolean mIsGenerateAppMap = false;
- private boolean mIsGenerateThemeResources = false;
- private boolean mIsIncludeIconRequestToEmailBody = true;
-
- private boolean mIsCrashReportEnabled = true;
- private JsonStructure mWallpaperJsonStructure = new JsonStructure.Builder(null).build();
-
- public Configuration setEmailBodyGenerator(EmailBodyGenerator emailBodyGenerator) {
- mEmailBodyGenerator = emailBodyGenerator;
- return this;
- }
-
- public Configuration setDonationLinks(@NonNull DonationLink[] donationLinks) {
- mDonationLinks = Arrays.asList(donationLinks);
- return this;
- }
-
- public Configuration setNavigationIcon(@NonNull NavigationIcon navigationIcon) {
- mNavigationIcon = navigationIcon;
- return this;
- }
-
- public Configuration setNavigationViewHeaderStyle(@NonNull NavigationViewHeader navigationViewHeader) {
- mNavigationViewHeader = navigationViewHeader;
- return this;
- }
-
- public Configuration setAutomaticIconsCountEnabled(boolean automaticIconsCountEnabled) {
- mIsAutomaticIconsCountEnabled = automaticIconsCountEnabled;
- return this;
- }
-
- public Configuration setHomeGridStyle(@NonNull GridStyle gridStyle) {
- mHomeGrid = gridStyle;
- return this;
- }
-
- public Configuration setApplyGridStyle(@NonNull GridStyle gridStyle) {
- mApplyGrid = gridStyle;
- return this;
- }
-
- public Configuration setRequestStyle(@NonNull Style style) {
- mRequestStyle = style;
- return this;
- }
-
- public Configuration setWallpapersGridStyle(@NonNull GridStyle gridStyle) {
- mWallpapersGrid = gridStyle;
- return this;
- }
-
- public Configuration setAboutStyle(@NonNull Style style) {
- mAboutStyle = style;
- return this;
- }
-
- public Configuration setSocialIconColor(@NonNull IconColor iconColor) {
- mIconColor = iconColor;
- return this;
- }
-
- public Configuration setColoredApplyCard(boolean coloredApplyCard) {
- mIsColoredApplyCard = coloredApplyCard;
- return this;
- }
-
- public Configuration setCustomIconsCount(int customIconsCount) {
- mCustomIconsCount = customIconsCount;
- return this;
- }
-
- public Configuration setShowTabIconsCount(boolean showTabIconsCount) {
- mIsShowTabIconsCount = showTabIconsCount;
- return this;
- }
-
- public Configuration setShowTabAllIcons(boolean showTabAllIcons) {
- mIsShowTabAllIcons = showTabAllIcons;
- return this;
- }
-
- public Configuration setTabAllIconsTitle(@NonNull String title) {
- mTabAllIconsTitle = title;
- if (mTabAllIconsTitle.length() == 0) mTabAllIconsTitle = "All Icons";
- return this;
- }
-
- public Configuration setCategoryForTabAllIcons(@NonNull String[] categories) {
- mCategoryForTabAllIcons = categories;
- return this;
- }
-
- public Configuration setShadowEnabled(boolean shadowEnabled) {
- mShadowOptions = new ShadowOptions(shadowEnabled);
- return this;
- }
-
- public Configuration setShadowEnabled(@NonNull ShadowOptions shadowOptions) {
- mShadowOptions = shadowOptions;
- return this;
- }
-
- public Configuration setDashboardThemingEnabled(boolean dashboardThemingEnabled) {
- mIsDashboardThemingEnabled = dashboardThemingEnabled;
- return this;
- }
-
- public Configuration setWallpaperGridPreviewQuality(@IntRange(from = 1, to = 10) int quality) {
- mWallpaperGridPreviewQuality = quality;
- return this;
- }
-
- public Configuration setGenerateAppFilter(boolean generateAppFilter) {
- mIsGenerateAppFilter = generateAppFilter;
- return this;
- }
-
- public Configuration setGenerateAppMap(boolean generateAppMap) {
- mIsGenerateAppMap = generateAppMap;
- return this;
- }
-
- public Configuration setGenerateThemeResources(boolean generateThemeResources) {
- mIsGenerateThemeResources = generateThemeResources;
- return this;
- }
-
- public Configuration setIncludeIconRequestToEmailBody(boolean includeIconRequestToEmailBody) {
- mIsIncludeIconRequestToEmailBody = includeIconRequestToEmailBody;
- return this;
- }
-
- public Configuration setCrashReportEnabled(boolean crashReportEnabled) {
- mIsCrashReportEnabled = crashReportEnabled;
- return this;
- }
-
- public Configuration setWallpaperJsonStructure(@NonNull JsonStructure jsonStructure) {
- mWallpaperJsonStructure = jsonStructure;
- return this;
- }
-
- public Configuration setOtherApps(@NonNull OtherApp[] otherApps) {
- mOtherApps = Arrays.asList(otherApps);
- return this;
- }
-
- public Configuration setHighQualityPreviewEnabled(boolean highQualityPreviewEnabled) {
- mIsHighQualityPreviewEnabled = highQualityPreviewEnabled;
- return this;
- }
-
- public EmailBodyGenerator getEmailBodyGenerator() {
- return mEmailBodyGenerator;
- }
-
- public List getDonationLinks() {
- return mDonationLinks;
- }
-
- public NavigationIcon getNavigationIcon() {
- return mNavigationIcon;
- }
-
- public NavigationViewHeader getNavigationViewHeader() {
- return mNavigationViewHeader;
- }
-
- public GridStyle getHomeGrid() {
- return mHomeGrid;
- }
-
- public GridStyle getApplyGrid() {
- return mApplyGrid;
- }
-
- public Style getRequestStyle() {
- return mRequestStyle;
- }
-
- public GridStyle getWallpapersGrid() {
- return mWallpapersGrid;
- }
-
- public Style getAboutStyle() {
- return mAboutStyle;
- }
-
- public IconColor getSocialIconColor() {
- return mIconColor;
- }
-
- public boolean isColoredApplyCard() {
- return mIsColoredApplyCard;
- }
-
- public boolean isAutomaticIconsCountEnabled() {
- return mIsAutomaticIconsCountEnabled;
- }
-
- public int getCustomIconsCount() {
- return mCustomIconsCount;
- }
-
- public boolean isShowTabIconsCount() {
- return mIsShowTabIconsCount;
- }
-
- public boolean isShowTabAllIcons() {
- return mIsShowTabAllIcons;
- }
-
- public String getTabAllIconsTitle() {
- return mTabAllIconsTitle;
- }
-
- public String[] getCategoryForTabAllIcons() {
- return mCategoryForTabAllIcons;
- }
-
- @NonNull
- public ShadowOptions getShadowOptions() {
- return mShadowOptions;
- }
-
- public boolean isDashboardThemingEnabled() {
- return mIsDashboardThemingEnabled;
- }
-
- public int getWallpaperGridPreviewQuality() {
- return mWallpaperGridPreviewQuality;
- }
-
- public boolean isGenerateAppFilter() {
- return mIsGenerateAppFilter;
- }
-
- public boolean isGenerateAppMap() {
- return mIsGenerateAppMap;
- }
-
- public boolean isGenerateThemeResources() {
- return mIsGenerateThemeResources;
- }
-
- public boolean isIncludeIconRequestToEmailBody() {
- return mIsIncludeIconRequestToEmailBody;
- }
-
- public boolean isHighQualityPreviewEnabled() {
- return mIsHighQualityPreviewEnabled;
- }
-
- public JsonStructure getWallpaperJsonStructure() {
- return mWallpaperJsonStructure;
- }
-
- @Nullable
- public List getOtherApps() {
- return mOtherApps;
- }
- }
-
- public enum NavigationIcon {
- DEFAULT,
- STYLE_1,
- STYLE_2,
- STYLE_3,
- STYLE_4
- }
-
- public enum NavigationViewHeader {
- NORMAL,
- MINI,
- NONE
- }
-
- public enum GridStyle {
- CARD,
- FLAT
- }
-
- public enum Style {
- PORTRAIT_FLAT_LANDSCAPE_CARD,
- PORTRAIT_FLAT_LANDSCAPE_FLAT
- }
-
- public enum IconColor {
- PRIMARY_TEXT,
- ACCENT
- }
-
- public static class ShadowOptions {
-
- private boolean mIsToolbarEnabled;
- private boolean mIsCardEnabled;
- private boolean mIsFabEnabled;
- private boolean mIsTapIntroEnabled;
-
- public ShadowOptions() {
- mIsToolbarEnabled = mIsCardEnabled = mIsFabEnabled = mIsTapIntroEnabled = true;
- }
-
- public ShadowOptions(boolean shadowEnabled) {
- mIsToolbarEnabled = mIsCardEnabled = mIsFabEnabled = mIsTapIntroEnabled = shadowEnabled;
- }
-
- public ShadowOptions setToolbarEnabled(boolean toolbarEnabled) {
- mIsToolbarEnabled = toolbarEnabled;
- return this;
- }
-
- public ShadowOptions setCardEnabled(boolean cardEnabled) {
- mIsCardEnabled = cardEnabled;
- return this;
- }
-
- public ShadowOptions setFabEnabled(boolean fabEnabled) {
- mIsFabEnabled = fabEnabled;
- return this;
- }
-
- public ShadowOptions setTapIntroEnabled(boolean tapIntroEnabled) {
- mIsTapIntroEnabled = tapIntroEnabled;
- return this;
- }
-
- public boolean isToolbarEnabled() {
- return mIsToolbarEnabled;
- }
-
- public boolean isCardEnabled() {
- return mIsCardEnabled;
- }
-
- public boolean isFabEnabled() {
- return mIsFabEnabled;
- }
-
- public boolean isTapIntroEnabled() {
- return mIsTapIntroEnabled;
- }
- }
-
- public static class OtherApp {
-
- private final String mIcon;
- private final String mTitle;
- private final String mDescription;
- private final String mUrl;
-
- public OtherApp(String icon, String title, String description, String url) {
- mIcon = icon;
- mTitle = title;
- mDescription = description;
- mUrl = url;
- }
-
- public String getIcon() {
- return mIcon;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public String getDescription() {
- return mDescription;
- }
-
- public String getUrl() {
- return mUrl;
- }
- }
-
- public static class DonationLink extends OtherApp {
- public DonationLink(String icon, String title, String description, String url) {
- super(icon, title, description, url);
- }
- }
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/databases/Database.java b/libs/candybar/src/main/java/candybar/lib/databases/Database.java
deleted file mode 100644
index fc3d456..0000000
--- a/libs/candybar/src/main/java/candybar/lib/databases/Database.java
+++ /dev/null
@@ -1,656 +0,0 @@
-package candybar.lib.databases;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteException;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.database.sqlite.SQLiteStatement;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.TimeHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.helpers.JsonHelper;
-import candybar.lib.items.Icon;
-import candybar.lib.items.ImageSize;
-import candybar.lib.items.Request;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Database extends SQLiteOpenHelper {
-
- private static final String DATABASE_NAME = "candybar_database";
- private static final int DATABASE_VERSION = 11;
-
- private static final String TABLE_REQUEST = "icon_request";
- private static final String TABLE_PREMIUM_REQUEST = "premium_request";
- private static final String TABLE_WALLPAPERS = "wallpapers";
- private static final String TABLE_BOOKMARKED_ICONS = "bookmarked_icons";
-
- private static final String KEY_ID = "id";
-
- private static final String KEY_ORDER_ID = "order_id";
- private static final String KEY_PRODUCT_ID = "product_id";
-
- private static final String KEY_NAME = "name";
- private static final String KEY_ACTIVITY = "activity";
- private static final String KEY_REQUESTED_ON = "requested_on";
-
- private static final String KEY_AUTHOR = "author";
- private static final String KEY_THUMB_URL = "thumbUrl";
- private static final String KEY_URL = "url";
- private static final String KEY_MIME_TYPE = "mimeType";
- private static final String KEY_COLOR = "color";
- private static final String KEY_WIDTH = "width";
- private static final String KEY_HEIGHT = "height";
- private static final String KEY_SIZE = "size";
-
- private static final String KEY_TITLE = "title";
-
- private final Context mContext;
-
- private static WeakReference mDatabase;
- private SQLiteDatabase mSQLiteDatabase;
-
- public static Database get(@NonNull Context context) {
- if (mDatabase == null || mDatabase.get() == null) {
- mDatabase = new WeakReference<>(new Database(context));
- }
- return mDatabase.get();
- }
-
- private Database(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- mContext = context;
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- String CREATE_TABLE_REQUEST = "CREATE TABLE IF NOT EXISTS " + TABLE_REQUEST + "(" +
- KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
- KEY_NAME + " TEXT NOT NULL, " +
- KEY_ACTIVITY + " TEXT NOT NULL, " +
- KEY_REQUESTED_ON + " DATETIME DEFAULT CURRENT_TIMESTAMP, " +
- "UNIQUE (" + KEY_ACTIVITY + ") ON CONFLICT REPLACE)";
- String CREATE_TABLE_PREMIUM_REQUEST = "CREATE TABLE IF NOT EXISTS " + TABLE_PREMIUM_REQUEST + "(" +
- KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
- KEY_ORDER_ID + " TEXT NOT NULL, " +
- KEY_PRODUCT_ID + " TEXT NOT NULL, " +
- KEY_NAME + " TEXT NOT NULL, " +
- KEY_ACTIVITY + " TEXT NOT NULL, " +
- KEY_REQUESTED_ON + " DATETIME DEFAULT CURRENT_TIMESTAMP, " +
- "UNIQUE (" + KEY_ACTIVITY + ") ON CONFLICT REPLACE)";
- String CREATE_TABLE_WALLPAPER = "CREATE TABLE IF NOT EXISTS " + TABLE_WALLPAPERS + "(" +
- KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
- KEY_NAME + " TEXT NOT NULL, " +
- KEY_AUTHOR + " TEXT NOT NULL, " +
- KEY_URL + " TEXT NOT NULL, " +
- KEY_THUMB_URL + " TEXT NOT NULL, " +
- KEY_MIME_TYPE + " TEXT, " +
- KEY_SIZE + " INTEGER DEFAULT 0, " +
- KEY_COLOR + " INTEGER DEFAULT 0, " +
- KEY_WIDTH + " INTEGER DEFAULT 0, " +
- KEY_HEIGHT + " INTEGER DEFAULT 0, " +
- "UNIQUE (" + KEY_URL + "))";
- String CREATE_TABLE_BOOKMARKED_ICONS = "CREATE TABLE IF NOT EXISTS " + TABLE_BOOKMARKED_ICONS + "(" +
- KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
- KEY_NAME + " TEXT NOT NULL, " +
- KEY_TITLE + " TEXT NOT NULL, " +
- "UNIQUE (" + KEY_NAME + ") ON CONFLICT IGNORE)";
- db.execSQL(CREATE_TABLE_REQUEST);
- db.execSQL(CREATE_TABLE_PREMIUM_REQUEST);
- db.execSQL(CREATE_TABLE_WALLPAPER);
- db.execSQL(CREATE_TABLE_BOOKMARKED_ICONS);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- // Need to clear shared preferences with version 3.4.0
- if (newVersion == 9) {
- Preferences.get(mContext).clearPreferences();
- }
- resetDatabase(db, oldVersion);
- }
-
- @Override
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- resetDatabase(db, oldVersion);
- }
-
- private void resetDatabase(SQLiteDatabase db, int oldVersion) {
- Cursor cursor = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);
- List tables = new ArrayList<>();
- if (cursor.moveToFirst()) {
- do {
- tables.add(cursor.getString(0));
- } while (cursor.moveToNext());
- }
- cursor.close();
-
- List requests = getRequestedApps(db);
- List premiumRequest = getPremiumRequest(db);
- List wallpapers = getWallpapers(db);
-
- for (int i = 0; i < tables.size(); i++) {
- try {
- String dropQuery = "DROP TABLE IF EXISTS " + tables.get(i);
- if (!tables.get(i).equalsIgnoreCase("SQLITE_SEQUENCE"))
- db.execSQL(dropQuery);
- } catch (Exception ignored) {
- }
- }
- onCreate(db);
-
- for (Request request : requests) {
- addRequest(db, request);
- }
-
- addWallpapers(db, wallpapers);
-
- if (oldVersion <= 3) {
- return;
- }
-
- for (Request premium : premiumRequest) {
- Request r = Request.Builder()
- .name(premium.getName())
- .activity(premium.getActivity())
- .orderId(premium.getOrderId())
- .productId(premium.getProductId())
- .requestedOn(premium.getRequestedOn())
- .build();
- addPremiumRequest(db, r);
- }
- }
-
- public boolean openDatabase() {
- try {
- if (mDatabase == null || mDatabase.get() == null) {
- LogUtil.e("Database error: openDatabase() database instance is null");
- return false;
- }
-
- if (mDatabase.get().mSQLiteDatabase == null) {
- mDatabase.get().mSQLiteDatabase = mDatabase.get().getWritableDatabase();
- }
-
- if (!mDatabase.get().mSQLiteDatabase.isOpen()) {
- LogUtil.e("Database error: database openable false, trying to open the database again");
- mDatabase.get().mSQLiteDatabase = mDatabase.get().getWritableDatabase();
- }
- return mDatabase.get().mSQLiteDatabase.isOpen();
- } catch (SQLiteException | NullPointerException e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
-
- public void closeDatabase() {
- try {
- if (mDatabase == null || mDatabase.get() == null) {
- LogUtil.e("Database error: closeDatabase() database instance is null");
- return;
- }
-
- if (mDatabase.get().mSQLiteDatabase == null) {
- LogUtil.e("Database error: trying to close database which is not opened");
- return;
- }
- mDatabase.get().mSQLiteDatabase.close();
- } catch (SQLiteException | NullPointerException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
-
- public void addRequest(@Nullable SQLiteDatabase db, Request request) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: addRequest() failed to open database");
- return;
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- ContentValues values = new ContentValues();
- values.put(KEY_NAME, request.getName());
- values.put(KEY_ACTIVITY, request.getActivity());
-
- String requestedOn = request.getRequestedOn();
- if (requestedOn == null) requestedOn = TimeHelper.getLongDateTime();
- values.put(KEY_REQUESTED_ON, requestedOn);
-
- database.insert(TABLE_REQUEST, null, values);
- }
-
- public boolean isRequested(String activity) {
- if (!openDatabase()) {
- LogUtil.e("Database error: isRequested() failed to open database");
- return false;
- }
-
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_REQUEST, null, KEY_ACTIVITY + " = ?",
- new String[]{activity}, null, null, null, null);
- int rowCount = cursor.getCount();
- cursor.close();
- return rowCount > 0;
- }
-
- private List getRequestedApps(@Nullable SQLiteDatabase db) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: getRequestedApps() failed to open database");
- return new ArrayList<>();
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- List requests = new ArrayList<>();
- Cursor cursor = database.query(TABLE_REQUEST, null, null, null, null, null, null);
- if (cursor.moveToFirst()) {
- do {
- Request request = Request.Builder()
- .name(cursor.getString(cursor.getColumnIndex(KEY_NAME)))
- .activity(cursor.getString(cursor.getColumnIndex(KEY_ACTIVITY)))
- .requestedOn(cursor.getString(cursor.getColumnIndex(KEY_REQUESTED_ON)))
- .requested(true)
- .build();
-
- requests.add(request);
- } while (cursor.moveToNext());
- }
- cursor.close();
- return requests;
- }
-
- public void addPremiumRequest(@Nullable SQLiteDatabase db, Request request) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: addPremiumRequest() failed to open database");
- return;
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- ContentValues values = new ContentValues();
- values.put(KEY_ORDER_ID, request.getOrderId());
- values.put(KEY_PRODUCT_ID, request.getProductId());
- values.put(KEY_NAME, request.getName());
- values.put(KEY_ACTIVITY, request.getActivity());
-
- String requestedOn = request.getRequestedOn();
- if (requestedOn == null) requestedOn = TimeHelper.getLongDateTime();
- values.put(KEY_REQUESTED_ON, requestedOn);
-
- database.insert(TABLE_PREMIUM_REQUEST, null, values);
- }
-
- public List getPremiumRequest(@Nullable SQLiteDatabase db) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: getPremiumRequest() failed to open database");
- return new ArrayList<>();
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- List requests = new ArrayList<>();
-
- Cursor cursor = database.query(TABLE_PREMIUM_REQUEST,
- null, null, null, null, null, null);
- if (cursor.moveToFirst()) {
- do {
- Request request = Request.Builder()
- .name(cursor.getString(cursor.getColumnIndex(KEY_NAME)))
- .activity(cursor.getString(cursor.getColumnIndex(KEY_ACTIVITY)))
- .orderId(cursor.getString(cursor.getColumnIndex(KEY_ORDER_ID)))
- .productId(cursor.getString(cursor.getColumnIndex(KEY_PRODUCT_ID)))
- .build();
- requests.add(request);
- } while (cursor.moveToNext());
- }
- cursor.close();
- return requests;
- }
-
- public void addWallpapers(@Nullable SQLiteDatabase db, List> list) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: addWallpapers() failed to open database");
- return;
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- String query = "INSERT OR IGNORE INTO " + TABLE_WALLPAPERS + " (" + KEY_NAME + "," + KEY_AUTHOR + "," + KEY_URL + ","
- + KEY_THUMB_URL + ") VALUES (?,?,?,?);";
- SQLiteStatement statement = database.compileStatement(query);
- database.beginTransaction();
-
- for (int i = 0; i < list.size(); i++) {
- statement.clearBindings();
-
- Wallpaper wallpaper;
- if (list.get(i) instanceof Wallpaper) {
- wallpaper = (Wallpaper) list.get(i);
- } else {
- wallpaper = JsonHelper.getWallpaper(list.get(i));
- }
-
- if (wallpaper != null) {
- if (wallpaper.getURL() != null) {
- String name = wallpaper.getName();
- if (name == null) name = "";
-
- statement.bindString(1, name);
-
- if (wallpaper.getAuthor() != null) {
- statement.bindString(2, wallpaper.getAuthor());
- } else {
- statement.bindNull(2);
- }
-
- statement.bindString(3, wallpaper.getURL());
- statement.bindString(4, wallpaper.getThumbUrl());
- statement.execute();
- }
- }
- }
-
- database.setTransactionSuccessful();
- database.endTransaction();
- }
-
- public void updateWallpaper(Wallpaper wallpaper) {
- if (!openDatabase()) {
- LogUtil.e("Database error: updateWallpaper() failed to open database");
- return;
- }
-
- if (wallpaper == null) return;
-
- ContentValues values = new ContentValues();
- if (wallpaper.getSize() > 0) {
- values.put(KEY_SIZE, wallpaper.getSize());
- }
-
- if (wallpaper.getMimeType() != null) {
- values.put(KEY_MIME_TYPE, wallpaper.getMimeType());
- }
-
- if (wallpaper.getDimensions() != null) {
- values.put(KEY_WIDTH, wallpaper.getDimensions().width);
- values.put(KEY_HEIGHT, wallpaper.getDimensions().height);
- }
-
- if (wallpaper.getColor() != 0) {
- values.put(KEY_COLOR, wallpaper.getColor());
- }
-
- if (values.size() > 0) {
- mDatabase.get().mSQLiteDatabase.update(TABLE_WALLPAPERS,
- values, KEY_URL + " = ?", new String[]{wallpaper.getURL()});
- }
- }
-
- public int getWallpapersCount() {
- if (!openDatabase()) {
- LogUtil.e("Database error: getWallpapersCount() failed to open database");
- return 0;
- }
-
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_WALLPAPERS,
- null, null, null, null, null, null, null);
- int rowCount = cursor.getCount();
- cursor.close();
- return rowCount;
- }
-
- @Nullable
- public Wallpaper getWallpaper(String url) {
- if (!openDatabase()) {
- LogUtil.e("Database error: getWallpaper() failed to open database");
- return null;
- }
-
- Wallpaper wallpaper = null;
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_WALLPAPERS,
- null, KEY_URL + " = ?", new String[]{url}, null, null, null, "1");
- if (cursor.moveToFirst()) {
- do {
- int width = cursor.getInt(cursor.getColumnIndex(KEY_WIDTH));
- int height = cursor.getInt(cursor.getColumnIndex(KEY_HEIGHT));
- ImageSize dimensions = null;
- if (width > 0 && height > 0) {
- dimensions = new ImageSize(width, height);
- }
-
- int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
- String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
- if (name.length() == 0) {
- name = "Wallpaper " + id;
- }
-
- wallpaper = Wallpaper.Builder()
- .name(name)
- .author(cursor.getString(cursor.getColumnIndex(KEY_AUTHOR)))
- .url(cursor.getString(cursor.getColumnIndex(KEY_URL)))
- .thumbUrl(cursor.getString(cursor.getColumnIndex(KEY_THUMB_URL)))
- .dimensions(dimensions)
- .mimeType(cursor.getString(cursor.getColumnIndex(KEY_MIME_TYPE)))
- .size(cursor.getInt(cursor.getColumnIndex(KEY_SIZE)))
- .color(cursor.getInt(cursor.getColumnIndex(KEY_COLOR)))
- .build();
- } while (cursor.moveToNext());
- }
- cursor.close();
- return wallpaper;
- }
-
- public List getWallpapers(@Nullable SQLiteDatabase db) {
- SQLiteDatabase database = db;
- if (database == null) {
- if (!openDatabase()) {
- LogUtil.e("Database error: getWallpapers() failed to open database");
- return new ArrayList<>();
- }
-
- database = mDatabase.get().mSQLiteDatabase;
- }
-
- List wallpapers = new ArrayList<>();
- Cursor cursor = database.query(TABLE_WALLPAPERS,
- null, null, null, null, null, KEY_ID + " ASC");
- if (cursor.moveToFirst()) {
- do {
- int width = cursor.getInt(cursor.getColumnIndex(KEY_WIDTH));
- int height = cursor.getInt(cursor.getColumnIndex(KEY_HEIGHT));
- ImageSize dimensions = null;
- if (width > 0 && height > 0) {
- dimensions = new ImageSize(width, height);
- }
-
- int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
- String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
- if (name.length() == 0) {
- name = "Wallpaper " + id;
- }
-
- Wallpaper wallpaper = Wallpaper.Builder()
- .name(name)
- .author(cursor.getString(cursor.getColumnIndex(KEY_AUTHOR)))
- .url(cursor.getString(cursor.getColumnIndex(KEY_URL)))
- .thumbUrl(cursor.getString(cursor.getColumnIndex(KEY_THUMB_URL)))
- .color(cursor.getInt(cursor.getColumnIndex(KEY_COLOR)))
- .mimeType(cursor.getString(cursor.getColumnIndex(KEY_MIME_TYPE)))
- .dimensions(dimensions)
- .size(cursor.getInt(cursor.getColumnIndex(KEY_SIZE)))
- .build();
- wallpapers.add(wallpaper);
- } while (cursor.moveToNext());
- }
- cursor.close();
- return wallpapers;
- }
-
- @Nullable
- public Wallpaper getRandomWallpaper() {
- if (!openDatabase()) {
- LogUtil.e("Database error: getRandomWallpaper() failed to open database");
- return null;
- }
-
- Wallpaper wallpaper = null;
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_WALLPAPERS,
- null, null, null, null, null, "RANDOM()", "1");
- if (cursor.moveToFirst()) {
- do {
- int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
- String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
- if (name.length() == 0) {
- name = "Wallpaper " + id;
- }
-
- wallpaper = Wallpaper.Builder()
- .name(name)
- .author(cursor.getString(cursor.getColumnIndex(KEY_AUTHOR)))
- .url(cursor.getString(cursor.getColumnIndex(KEY_URL)))
- .thumbUrl(cursor.getString(cursor.getColumnIndex(KEY_THUMB_URL)))
- .build();
- } while (cursor.moveToNext());
- }
- cursor.close();
- return wallpaper;
- }
-
- public void addBookmarkedIcon(String drawableName, String title) {
- if (!openDatabase()) {
- LogUtil.e("Database error: addBookmarkedIcon() failed to open database");
- return;
- }
-
- ContentValues values = new ContentValues();
- values.put(KEY_NAME, drawableName);
- values.put(KEY_TITLE, title);
-
- mDatabase.get().mSQLiteDatabase.insert(TABLE_BOOKMARKED_ICONS, null, values);
- }
-
- public void deleteBookmarkedIcon(String drawableName) {
- if (!openDatabase()) {
- LogUtil.e("Database error: deleteBookmarkedIcon() failed to open database");
- return;
- }
-
- mDatabase.get().mSQLiteDatabase
- .delete(TABLE_BOOKMARKED_ICONS, KEY_NAME + " = ?", new String[]{drawableName});
- }
-
- public void deleteBookmarkedIcons(List drawableNames) {
- if (!openDatabase()) {
- LogUtil.e("Database error: deleteBookmarkedIcons() failed to open database");
- return;
- }
-
- final String inPart = "\"" + TextUtils.join("\", \"", drawableNames) + "\"";
-
- mDatabase.get().mSQLiteDatabase.execSQL("DELETE FROM " + TABLE_BOOKMARKED_ICONS +
- " WHERE " + KEY_NAME + " IN (" + inPart + ")");
- }
-
- public boolean isIconBookmarked(String drawableName) {
- if (!openDatabase()) {
- LogUtil.e("Database error: isIconBookmarked() failed to open database");
- return false;
- }
-
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_BOOKMARKED_ICONS, null, KEY_NAME + " = ?",
- new String[]{drawableName}, null, null, null, null);
- int rowCount = cursor.getCount();
- cursor.close();
- return rowCount > 0;
- }
-
- public List getBookmarkedIcons(Context context) {
- if (!openDatabase()) {
- LogUtil.e("Database error: getBookmarkedIcons() failed to open database");
- return new ArrayList<>();
- }
-
- List icons = new ArrayList<>();
- Cursor cursor = mDatabase.get().mSQLiteDatabase.query(TABLE_BOOKMARKED_ICONS,
- null, null, null, null, null, null);
- if (cursor.moveToFirst()) {
- do {
- String drawableName = cursor.getString(cursor.getColumnIndex(KEY_NAME));
- String title = cursor.getString(cursor.getColumnIndex(KEY_TITLE));
- int resId = DrawableHelper.getResourceId(context, drawableName);
- icons.add(new Icon(drawableName, null, resId).setTitle(title));
- } while (cursor.moveToNext());
- }
- cursor.close();
-
- Collections.sort(icons, Icon.TitleComparator);
-
- return icons;
- }
-
- public void deleteIconRequestData() {
- if (!openDatabase()) {
- LogUtil.e("Database error: deleteIconRequestData() failed to open database");
- return;
- }
-
- mDatabase.get().mSQLiteDatabase.delete("SQLITE_SEQUENCE", "NAME = ?", new String[]{TABLE_REQUEST});
- mDatabase.get().mSQLiteDatabase.delete(TABLE_REQUEST, null, null);
- }
-
- public void deleteWallpapers() {
- if (!openDatabase()) {
- LogUtil.e("Database error: deleteWallpapers() failed to open database");
- return;
- }
-
- mDatabase.get().mSQLiteDatabase.delete("SQLITE_SEQUENCE", "NAME = ?", new String[]{TABLE_WALLPAPERS});
- mDatabase.get().mSQLiteDatabase.delete(TABLE_WALLPAPERS, null, null);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/AboutFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/AboutFragment.java
deleted file mode 100644
index 98ee4d4..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/AboutFragment.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package candybar.lib.fragments;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.danimahardhika.android.helpers.core.ViewHelper;
-
-import candybar.lib.R;
-import candybar.lib.adapters.AboutAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class AboutFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_about, container, false);
- mRecyclerView = view.findViewById(R.id.recyclerview);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- resetRecyclerViewPadding(requireActivity().getResources().getConfiguration().orientation);
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
-
- int spanCount = requireActivity().getResources().getInteger(R.integer.about_column_count);
- mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(
- spanCount, StaggeredGridLayoutManager.VERTICAL));
- mRecyclerView.setAdapter(new AboutAdapter(requireActivity(), spanCount));
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- resetRecyclerViewPadding(newConfig.orientation);
- ViewHelper.resetSpanCount(mRecyclerView,
- requireActivity().getResources().getInteger(R.integer.about_column_count));
-
- StaggeredGridLayoutManager manager = (StaggeredGridLayoutManager) mRecyclerView.getLayoutManager();
- assert manager != null;
- mRecyclerView.setAdapter(new AboutAdapter(requireActivity(), manager.getSpanCount()));
- }
-
- private void resetRecyclerViewPadding(int orientation) {
- if (mRecyclerView == null) return;
-
- int padding = 0;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.content_padding);
-
- if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT) {
- padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
- }
- }
-
- mRecyclerView.setPadding(padding, padding, 0, 0);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/ApplyFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/ApplyFragment.java
deleted file mode 100644
index ede9fac..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/ApplyFragment.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package candybar.lib.fragments;
-
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.content.res.TypedArray;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.LauncherAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.items.Icon;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ApplyFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
- private AsyncTaskBase mAsyncTask;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_apply, container, false);
- mRecyclerView = view.findViewById(R.id.recyclerview);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));
-
- if (CandyBarApplication.getConfiguration().getApplyGrid() == CandyBarApplication.GridStyle.FLAT) {
- int padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
- mRecyclerView.setPadding(padding, padding, 0, 0);
- }
-
- mAsyncTask = new LaunchersLoader().executeOnThreadPool();
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- super.onDestroy();
- }
-
- private boolean isPackageInstalled(String pkg) {
- try {
- PackageInfo packageInfo = requireActivity().getPackageManager().getPackageInfo(
- pkg, PackageManager.GET_ACTIVITIES);
- return packageInfo != null;
- } catch (Exception e) {
- return false;
- }
- }
-
- private boolean isLauncherInstalled(String pkg1, String pkg2, String pkg3) {
- return isPackageInstalled(pkg1) | isPackageInstalled(pkg2) | isPackageInstalled(pkg3);
- }
-
- private boolean isLauncherShouldBeAdded(String packageName) {
- assert getActivity() != null;
- if (("com.dlto.atom.launcher").equals(packageName)) {
- int id = getResources().getIdentifier("appmap", "xml", getActivity().getPackageName());
- return id > 0;
- } else if (("com.lge.launcher2").equals(packageName) ||
- ("com.lge.launcher3").equals(packageName)) {
- int id = getResources().getIdentifier("theme_resources", "xml", getActivity().getPackageName());
- return id > 0;
- }
- return true;
- }
-
- private class LaunchersLoader extends AsyncTaskBase {
-
- private List launchers;
-
- @Override
- protected void preRun() {
- launchers = new ArrayList<>();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- String[] launcherNames = getResources().getStringArray(
- R.array.launcher_names);
- TypedArray launcherIcons = getResources().obtainTypedArray(
- R.array.launcher_icons);
- String[] launcherPackages1 = getResources().getStringArray(
- R.array.launcher_packages_1);
- String[] launcherPackages2 = getResources().getStringArray(
- R.array.launcher_packages_2);
- String[] launcherPackages3 = getResources().getStringArray(
- R.array.launcher_packages_3);
- String[] showableLauncherNames = getResources().getStringArray(
- R.array.dashboard_launchers);
-
- List installed = new ArrayList<>();
- List supported = new ArrayList<>();
-
- List showable = new ArrayList<>();
-
- for (String name : showableLauncherNames) {
- String filtered_name = name.toLowerCase().replaceAll(" ", "_");
- showable.add(filtered_name);
- }
-
- for (int i = 0; i < launcherNames.length; i++) {
- String lowercaseLauncherName = launcherNames[i].toLowerCase().replaceAll(" ", "_");
-
- if (!showable.contains(lowercaseLauncherName)) {
- LogUtil.d("Launcher Excluded: " + lowercaseLauncherName);
- continue;
- }
-
- boolean isInstalled = isLauncherInstalled(
- launcherPackages1[i],
- launcherPackages2[i],
- launcherPackages3[i]);
-
- int icon = R.drawable.ic_app_default;
- if (i < launcherIcons.length())
- icon = launcherIcons.getResourceId(i, icon);
-
- String launcherPackage = launcherPackages1[i];
- if (launcherPackages1[i].equals("com.lge.launcher2")) {
- boolean lghome3 = isPackageInstalled(launcherPackages2[i]);
- if (lghome3) launcherPackage = launcherPackages2[i];
- }
-
- Icon launcher = new Icon(launcherNames[i], icon, launcherPackage);
- if (isLauncherShouldBeAdded(launcherPackage)) {
- if (isInstalled) installed.add(launcher);
- else supported.add(launcher);
- }
- }
-
- try {
- Collections.sort(installed, Icon.TitleComparator);
- } catch (Exception ignored) {
- }
-
- try {
- Collections.sort(supported, Icon.TitleComparator);
- } catch (Exception ignored) {
- }
-
- if (installed.size() > 0) {
- launchers.add(new Icon(getResources().getString(
- R.string.apply_installed), -1, null));
- }
-
- launchers.addAll(installed);
- launchers.add(new Icon(getResources().getString(
- R.string.apply_supported), -2, null));
- launchers.addAll(supported);
-
- launcherIcons.recycle();
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- if (ok) {
- mRecyclerView.setAdapter(new LauncherAdapter(getActivity(), launchers));
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/FAQsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/FAQsFragment.java
deleted file mode 100644
index a19200e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/FAQsFragment.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package candybar.lib.fragments;
-
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-import android.annotation.SuppressLint;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.danimahardhika.android.helpers.core.SoftKeyboardHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.FAQsAdapter;
-import candybar.lib.items.FAQs;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class FAQsFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
- private TextView mSearchResult;
- private RecyclerFastScroller mFastScroll;
-
- private FAQsAdapter mAdapter;
- private AsyncTaskBase mAsyncTask;
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_faqs, container, false);
- mRecyclerView = view.findViewById(R.id.faqs_list);
- mSearchResult = view.findViewById(R.id.search_result);
- mFastScroll = view.findViewById(R.id.fastscroll);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setHasFixedSize(true);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
-
- mAsyncTask = new FAQsLoader().executeOnThreadPool();
- }
-
- @Override
- public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
- inflater.inflate(R.menu.menu_search, menu);
- MenuItem search = menu.findItem(R.id.menu_search);
-
- View searchView = search.getActionView();
- EditText searchInput = searchView.findViewById(R.id.search_input);
- View clearQueryButton = searchView.findViewById(R.id.clear_query_button);
-
- searchInput.setHint(requireActivity().getResources().getString(R.string.search_faqs));
-
- searchInput.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- String query = charSequence.toString();
- filterSearch(query);
- clearQueryButton.setVisibility(query.contentEquals("") ? View.GONE : View.VISIBLE);
- }
- });
-
- clearQueryButton.setOnClickListener(view -> searchInput.setText(""));
-
- search.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(MenuItem menuItem) {
- searchInput.requestFocus();
-
- new Handler(Looper.getMainLooper()).postDelayed(() -> {
- if (getActivity() != null) {
- SoftKeyboardHelper.openKeyboard(getActivity());
- }
- }, 1000);
-
- return true;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(MenuItem menuItem) {
- searchInput.setText("");
- return true;
- }
- });
-
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- setHasOptionsMenu(false);
- super.onDestroy();
- }
-
- @SuppressLint("StringFormatInvalid")
- private void filterSearch(String query) {
- try {
- mAdapter.search(query);
- if (mAdapter.getFaqsCount() == 0) {
- String text = requireActivity().getResources().getString(R.string.search_noresult, query);
- mSearchResult.setText(text);
- mSearchResult.setVisibility(View.VISIBLE);
- } else mSearchResult.setVisibility(View.GONE);
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
-
- private class FAQsLoader extends AsyncTaskBase {
-
- private List faqs;
- private String[] questions;
- private String[] answers;
-
- @Override
- protected void preRun() {
- faqs = new ArrayList<>();
- questions = getResources().getStringArray(R.array.questions);
- answers = getResources().getStringArray(R.array.answers);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- for (int i = 0; i < questions.length; i++) {
- if (i < answers.length) {
- FAQs faq = new FAQs(questions[i], answers[i]);
- faqs.add(faq);
- }
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- if (ok) {
- setHasOptionsMenu(true);
- mAdapter = new FAQsAdapter(getActivity(), faqs);
- mRecyclerView.setAdapter(mAdapter);
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/HomeFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/HomeFragment.java
deleted file mode 100644
index 39cae95..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/HomeFragment.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package candybar.lib.fragments;
-
-import android.annotation.SuppressLint;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.adapters.HomeAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.TapIntroHelper;
-import candybar.lib.helpers.WallpaperHelper;
-import candybar.lib.items.Home;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.listeners.HomeListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class HomeFragment extends Fragment implements HomeListener {
-
- private RecyclerView mRecyclerView;
- private StaggeredGridLayoutManager mManager;
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_home, container, false);
- mRecyclerView = view.findViewById(R.id.recyclerview);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mManager = new StaggeredGridLayoutManager(
- requireActivity().getResources().getInteger(R.integer.home_column_count),
- StaggeredGridLayoutManager.VERTICAL);
- mRecyclerView.setHasFixedSize(true);
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setLayoutManager(mManager);
-
- if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
- int padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
- mRecyclerView.setPadding(padding, padding, 0, 0);
- }
-
- initHome();
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- HomeAdapter adapter = (HomeAdapter) mRecyclerView.getAdapter();
- if (adapter != null) adapter.setOrientation(newConfig.orientation);
- }
-
- @Override
- public void onHomeDataUpdated(Home home) {
- if (mRecyclerView == null) return;
- if (mRecyclerView.getAdapter() == null) return;
-
- if (home != null) {
- HomeAdapter adapter = (HomeAdapter) mRecyclerView.getAdapter();
- if (CandyBarApplication.getConfiguration().isAutomaticIconsCountEnabled()) {
- int index = adapter.getIconsIndex();
- if (index >= 0 && index < adapter.getItemCount()) {
- adapter.getItem(index).setTitle(String.valueOf(CandyBarMainActivity.sIconsCount));
- adapter.getItem(index).setLoading(false);
- adapter.notifyItemChanged(index);
- }
- }
-
- int dimensionsIndex = adapter.getDimensionsIndex();
- if (dimensionsIndex < 0) {
- adapter.addNewContent(home);
- }
- return;
- }
-
- RecyclerView.Adapter> adapter = mRecyclerView.getAdapter();
- if (adapter.getItemCount() > 8) {
- // Probably the original adapter already modified
- adapter.notifyDataSetChanged();
- return;
- }
-
- if (adapter instanceof HomeAdapter) {
- HomeAdapter homeAdapter = (HomeAdapter) adapter;
- int index = homeAdapter.getIconRequestIndex();
- if (index >= 0 && index < adapter.getItemCount()) {
- adapter.notifyItemChanged(index);
- }
- }
- }
-
- @Override
- public void onHomeIntroInit() {
- if (requireActivity().getResources().getBoolean(R.bool.show_intro)) {
- TapIntroHelper.showHomeIntros(requireActivity(),
- mRecyclerView, mManager,
- ((HomeAdapter) Objects.requireNonNull(mRecyclerView.getAdapter())).getApplyIndex());
- }
- }
-
- @SuppressLint("StringFormatInvalid")
- private void initHome() {
- List homes = new ArrayList<>();
- final Resources resources = requireActivity().getResources();
-
- if (resources.getBoolean(R.bool.enable_apply)) {
- homes.add(new Home(
- R.drawable.ic_toolbar_apply_launcher,
- resources.getString(R.string.home_apply_icon_pack,
- resources.getString(R.string.app_name)),
- "",
- Home.Type.APPLY,
- false));
- }
-
- if (resources.getBoolean(R.bool.enable_donation)) {
- homes.add(new Home(
- R.drawable.ic_toolbar_donate,
- resources.getString(R.string.home_donate),
- resources.getString(R.string.home_donate_desc),
- Home.Type.DONATE,
- false));
- }
-
- homes.add(new Home(
- -1,
- CandyBarApplication.getConfiguration().isAutomaticIconsCountEnabled() ?
- String.valueOf(CandyBarMainActivity.sIconsCount) :
- String.valueOf(CandyBarApplication.getConfiguration().getCustomIconsCount()),
- resources.getString(R.string.home_icons),
- Home.Type.ICONS,
- true));
-
- if (CandyBarMainActivity.sHomeIcon != null) {
- homes.add(CandyBarMainActivity.sHomeIcon);
- }
-
- mRecyclerView.setAdapter(new HomeAdapter(requireActivity(), homes,
- resources.getConfiguration().orientation));
- }
-
- public void resetWallpapersCount() {
- if (WallpaperHelper.getWallpaperType(requireActivity()) == WallpaperHelper.CLOUD_WALLPAPERS) {
- if (mRecyclerView == null) return;
- if (mRecyclerView.getAdapter() == null) return;
-
- RecyclerView.Adapter> adapter = mRecyclerView.getAdapter();
- if (adapter.getItemCount() > 8) {
- //Probably the original adapter already modified
- adapter.notifyDataSetChanged();
- return;
- }
-
- if (adapter instanceof HomeAdapter) {
- HomeAdapter homeAdapter = (HomeAdapter) adapter;
- int index = homeAdapter.getWallpapersIndex();
- if (index >= 0 && index < adapter.getItemCount()) {
- adapter.notifyItemChanged(index);
- }
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/IconsBaseFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/IconsBaseFragment.java
deleted file mode 100644
index d7e6b33..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/IconsBaseFragment.java
+++ /dev/null
@@ -1,333 +0,0 @@
-package candybar.lib.fragments;
-
-import android.animation.AnimatorListenerAdapter;
-import android.app.Activity;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ProgressBar;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.interpolator.view.animation.LinearOutSlowInInterpolator;
-import androidx.lifecycle.Lifecycle;
-import androidx.viewpager2.adapter.FragmentStateAdapter;
-import androidx.viewpager2.widget.ViewPager2;
-
-import com.bumptech.glide.Glide;
-import com.danimahardhika.android.helpers.animation.AnimationHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.tabs.TabLayout;
-import com.google.android.material.tabs.TabLayoutMediator;
-
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.IconShapeChooserFragment;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.helpers.TapIntroHelper;
-import candybar.lib.items.Icon;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.listeners.SearchListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsBaseFragment extends Fragment {
-
- private ViewPager2 mPager;
- private ProgressBar mProgress;
- private TabLayout mTabLayout;
-
- private AsyncTaskBase mGetIcons;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_icons_base, container, false);
- mTabLayout = view.findViewById(R.id.tab);
- mPager = view.findViewById(R.id.pager);
- mProgress = view.findViewById(R.id.progress);
- initTabs();
- mPager.setOffscreenPageLimit(2);
- return view;
- }
-
- @Override
- public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
- super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.menu_icons_search, menu);
- MenuItem search = menu.findItem(R.id.menu_search);
- MenuItem iconShape = menu.findItem(R.id.menu_icon_shape);
-
- search.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(MenuItem item) {
- FragmentManager fm = requireActivity().getSupportFragmentManager();
- if (fm == null) return false;
-
- setHasOptionsMenu(false);
- View view = requireActivity().findViewById(R.id.shadow);
- if (view != null) view.animate().translationY(-mTabLayout.getHeight())
- .setDuration(200).start();
- mTabLayout.animate().translationY(-mTabLayout.getHeight()).setDuration(200)
- .setListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(android.animation.Animator animation) {
- super.onAnimationEnd(animation);
- Fragment prev = fm.findFragmentByTag("home");
- if (prev != null) return;
-
- PagerIconsAdapter adapter = (PagerIconsAdapter) mPager.getAdapter();
- if (adapter == null) return;
-
- SearchListener listener = (SearchListener) requireActivity();
- listener.onSearchExpanded(true);
-
- FragmentTransaction ft = fm.beginTransaction()
- .replace(R.id.container, new IconsSearchFragment(), IconsSearchFragment.TAG)
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
- .addToBackStack(null);
-
- try {
- ft.commit();
- } catch (Exception e) {
- ft.commitAllowingStateLoss();
- }
- }
- }).start();
-
- return true;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(MenuItem item) {
- return true;
- }
- });
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
- !requireActivity().getResources().getBoolean(R.bool.includes_adaptive_icons)) {
- iconShape.setVisible(false);
- }
-
- iconShape.setOnMenuItemClickListener(menuItem -> {
- IconShapeChooserFragment.showIconShapeChooser(requireActivity().getSupportFragmentManager());
- return false;
- });
- }
-
- @Override
- public void onDestroy() {
- if (mGetIcons != null) {
- mGetIcons.cancel(true);
- }
- Activity activity = getActivity();
- if (activity != null) Glide.get(activity).clearMemory();
- super.onDestroy();
- }
-
- private void initTabs() {
- AnimationHelper.slideDownIn(mTabLayout)
- .interpolator(new LinearOutSlowInInterpolator())
- .callback(new AnimationHelper.Callback() {
- @Override
- public void onAnimationStart() {
-
- }
-
- @Override
- public void onAnimationEnd() {
- if (getActivity() == null) return;
-
- if (Preferences.get(getActivity()).isToolbarShadowEnabled()) {
- AnimationHelper.fade(getActivity().findViewById(R.id.shadow)).start();
- }
-
- mGetIcons = new IconsLoader().execute();
- }
- })
- .start();
- }
-
- private class IconsLoader extends AsyncTaskBase {
- @Override
- protected void preRun() {
- if (CandyBarMainActivity.sSections == null) {
- mProgress.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (CandyBarMainActivity.sSections == null) {
- CandyBarMainActivity.sSections = IconsHelper.getIconsList(requireActivity());
-
- for (int i = 0; i < CandyBarMainActivity.sSections.size(); i++) {
- List icons = CandyBarMainActivity.sSections.get(i).getIcons();
- if (requireActivity().getResources().getBoolean(R.bool.show_icon_name)) {
- IconsHelper.computeTitles(requireActivity(), icons);
- }
-
- if (requireActivity().getResources().getBoolean(R.bool.enable_icons_sort)) {
- Collections.sort(icons, Icon.TitleComparator);
-
- CandyBarMainActivity.sSections.get(i).setIcons(icons);
- }
- }
-
- if (CandyBarApplication.getConfiguration().isShowTabAllIcons()) {
- List icons = IconsHelper.getTabAllIcons();
- CandyBarMainActivity.sSections.add(new Icon(
- CandyBarApplication.getConfiguration().getTabAllIconsTitle(), icons));
- }
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mGetIcons = null;
- mProgress.setVisibility(View.GONE);
- if (ok) {
- setHasOptionsMenu(true);
-
- PagerIconsAdapter adapter = new PagerIconsAdapter(
- getChildFragmentManager(), getLifecycle(), CandyBarMainActivity.sSections);
- mPager.setAdapter(adapter);
-
- new TabLayoutMediator(mTabLayout, mPager, (tab, position) -> {
- }).attach();
- mPager.setCurrentItem(1);
-
- new TabTypefaceChanger().executeOnThreadPool();
-
- if (getActivity().getResources().getBoolean(R.bool.show_intro)) {
- TapIntroHelper.showIconsIntro(getActivity());
- }
- } else {
- Toast.makeText(getActivity(), R.string.icons_load_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-
- private class TabTypefaceChanger extends AsyncTaskBase {
-
- PagerIconsAdapter adapter;
-
- @Override
- protected void preRun() {
- adapter = (PagerIconsAdapter) mPager.getAdapter();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- for (int i = 0; i < adapter.getItemCount(); i++) {
- int j = i;
- runOnUiThread(() -> {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
- if (mTabLayout == null) return;
-
- if (j < mTabLayout.getTabCount()) {
- TabLayout.Tab tab = mTabLayout.getTabAt(j);
- if (tab != null) {
- if (j == 0) {
- tab.setIcon(R.drawable.ic_bookmarks);
- } else if (j < adapter.getItemCount()) {
- tab.setCustomView(R.layout.fragment_icons_base_tab);
- tab.setText(adapter.getPageTitle(j - 1));
- }
- }
- }
- });
- }
- return true;
- } catch (Exception ignored) {
- return false;
- }
- }
- return false;
- }
- }
-
- private static class PagerIconsAdapter extends FragmentStateAdapter {
-
- private final List mIcons;
-
- PagerIconsAdapter(@NonNull FragmentManager fm, @NonNull Lifecycle lifecycle,
- @NonNull List icons) {
- super(fm, lifecycle);
- mIcons = icons;
- }
-
- public CharSequence getPageTitle(int position) {
- String title = mIcons.get(position).getTitle();
- if (CandyBarApplication.getConfiguration().isShowTabIconsCount()) {
- title += " (" + mIcons.get(position).getIcons().size() + ")";
- }
- return title;
- }
-
- @NonNull
- @Override
- public Fragment createFragment(int position) {
- return IconsFragment.newInstance(position - 1);
- }
-
- @Override
- public int getItemCount() {
- return mIcons.size() + 1;
- }
-
- public List getIcons() {
- return mIcons;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/IconsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/IconsFragment.java
deleted file mode 100644
index 545175d..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/IconsFragment.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package candybar.lib.fragments;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-import com.danimahardhika.android.helpers.core.ViewHelper;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.adapters.IconsAdapter;
-import candybar.lib.databases.Database;
-import candybar.lib.items.Icon;
-
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsFragment extends Fragment {
-
- private View mNoBookmarksFoundView;
- private RecyclerView mRecyclerView;
- private RecyclerFastScroller mFastScroll;
- private IconsAdapter mAdapter;
-
- private List mIcons;
- private boolean isBookmarksFragment;
- private boolean prevIsEmpty = false;
-
- private static final String INDEX = "index";
-
- private static final List> iconsAdapters = new ArrayList<>();
- private static WeakReference bookmarksIconFragment = new WeakReference<>(null);
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_icons, container, false);
- mNoBookmarksFoundView = view.findViewById(R.id.no_bookmarks_found_container);
- mRecyclerView = view.findViewById(R.id.icons_grid);
- mFastScroll = view.findViewById(R.id.fastscroll);
- return view;
- }
-
- public static IconsFragment newInstance(int index) {
- IconsFragment fragment = new IconsFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(INDEX, index);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mIcons = new ArrayList<>();
- int index = requireArguments().getInt(INDEX);
- if (index == -1) {
- mIcons = Database.get(requireActivity()).getBookmarkedIcons(requireActivity());
- bookmarksIconFragment = new WeakReference<>(this);
- isBookmarksFragment = true;
- prevIsEmpty = mIcons.size() == 0;
- } else if (CandyBarMainActivity.sSections != null) {
- mIcons = CandyBarMainActivity.sSections.get(index).getIcons();
- }
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- setupViewVisibility();
-
- mRecyclerView.setHasFixedSize(true);
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
- requireActivity().getResources().getInteger(R.integer.icons_column_count)));
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
-
- ((ImageView) mNoBookmarksFoundView.findViewById(R.id.bookmark_image))
- .setImageDrawable(DrawableHelper.getTintedDrawable(requireActivity(), R.drawable.ic_bookmark,
- ColorHelper.getAttributeColor(requireActivity(), android.R.attr.textColorSecondary)));
-
- mAdapter = new IconsAdapter(requireActivity(), mIcons, this, isBookmarksFragment);
- mRecyclerView.setAdapter(mAdapter);
- iconsAdapters.add(new WeakReference<>(mAdapter));
- }
-
- private void setupViewVisibility() {
- if (isBookmarksFragment && mIcons.size() == 0) {
- mNoBookmarksFoundView.setVisibility(View.VISIBLE);
- mRecyclerView.setVisibility(View.GONE);
- } else {
- mNoBookmarksFoundView.setVisibility(View.GONE);
- mRecyclerView.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- ViewHelper.resetSpanCount(mRecyclerView,
- requireActivity().getResources().getInteger(R.integer.icons_column_count));
- }
-
- public void refreshBookmarks() {
- if (isBookmarksFragment) {
- mIcons = Database.get(requireActivity()).getBookmarkedIcons(requireActivity());
- mAdapter.setIcons(mIcons);
- setupViewVisibility();
- }
- }
-
- public static void reloadIcons() {
- for (WeakReference adapterRef : iconsAdapters) {
- if (adapterRef.get() != null) adapterRef.get().reloadIcons();
- }
- }
-
- public static void reloadBookmarks() {
- if (bookmarksIconFragment.get() != null) {
- bookmarksIconFragment.get().refreshBookmarks();
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/IconsSearchFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/IconsSearchFragment.java
deleted file mode 100644
index 2c7d0ce..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/IconsSearchFragment.java
+++ /dev/null
@@ -1,269 +0,0 @@
-package candybar.lib.fragments;
-
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-import android.annotation.SuppressLint;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.danimahardhika.android.helpers.core.SoftKeyboardHelper;
-import com.danimahardhika.android.helpers.core.ViewHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.adapters.IconsAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.IconShapeChooserFragment;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.items.Icon;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsSearchFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
- private RecyclerFastScroller mFastScroll;
- private TextView mSearchResult;
- private EditText mSearchInput;
- private final Fragment mFragment = this;
-
- private IconsAdapter mAdapter;
- private AsyncTaskBase mAsyncTask;
-
- public static final String TAG = "icons_search";
-
- private static WeakReference currentAdapter;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_icons_search, container, false);
- mRecyclerView = view.findViewById(R.id.icons_grid);
- mFastScroll = view.findViewById(R.id.fastscroll);
- mSearchResult = view.findViewById(R.id.search_result);
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- setHasOptionsMenu(true);
-
- mRecyclerView.setHasFixedSize(true);
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
- requireActivity().getResources().getInteger(R.integer.icons_column_count)));
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
- mAsyncTask = new IconsLoader().execute();
- }
-
- @Override
- public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
- super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.menu_icons_search, menu);
- MenuItem search = menu.findItem(R.id.menu_search);
- MenuItem iconShape = menu.findItem(R.id.menu_icon_shape);
- View searchView = search.getActionView();
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
- !requireActivity().getResources().getBoolean(R.bool.includes_adaptive_icons)) {
- iconShape.setVisible(false);
- } else {
- searchView.findViewById(R.id.container).setPadding(0, 0, 0, 0);
- }
-
- View clearQueryButton = searchView.findViewById(R.id.clear_query_button);
- mSearchInput = searchView.findViewById(R.id.search_input);
- mSearchInput.setHint(R.string.search_icon);
-
- search.expandActionView();
-
- search.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(MenuItem item) {
- return true;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(MenuItem item) {
- requireActivity().onBackPressed();
- return true;
- }
- });
-
- mSearchInput.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- String query = charSequence.toString();
- filterSearch(query);
- clearQueryButton.setVisibility(query.contentEquals("") ? View.GONE : View.VISIBLE);
- }
- });
-
- clearQueryButton.setOnClickListener(view -> mSearchInput.setText(""));
-
- iconShape.setOnMenuItemClickListener(menuItem -> {
- IconShapeChooserFragment.showIconShapeChooser(requireActivity().getSupportFragmentManager());
- return false;
- });
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- ViewHelper.resetSpanCount(mRecyclerView, requireActivity().getResources().getInteger(R.integer.icons_column_count));
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) mAsyncTask.cancel(true);
- currentAdapter = null;
- super.onDestroy();
- }
-
- @SuppressLint("StringFormatInvalid")
- private void filterSearch(String query) {
- try {
- mAdapter.search(query);
- if (mAdapter.getItemCount() == 0) {
- String text = requireActivity().getResources().getString(R.string.search_noresult, query);
- mSearchResult.setText(text);
- mSearchResult.setVisibility(View.VISIBLE);
- } else mSearchResult.setVisibility(View.GONE);
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
-
- public static void reloadIcons() {
- if (currentAdapter != null && currentAdapter.get() != null)
- currentAdapter.get().reloadIcons();
- }
-
- private class IconsLoader extends AsyncTaskBase {
-
- private List icons;
-
- @Override
- protected void preRun() {
- icons = new ArrayList<>();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (CandyBarMainActivity.sSections == null) {
- CandyBarMainActivity.sSections = IconsHelper.getIconsList(requireActivity());
-
- for (Icon section : CandyBarMainActivity.sSections) {
- if (requireActivity().getResources().getBoolean(R.bool.show_icon_name)) {
- IconsHelper.computeTitles(requireActivity(), section.getIcons());
- }
- }
-
- if (CandyBarApplication.getConfiguration().isShowTabAllIcons()) {
- List icons = IconsHelper.getTabAllIcons();
- CandyBarMainActivity.sSections.add(new Icon(
- CandyBarApplication.getConfiguration().getTabAllIconsTitle(), icons));
- }
- }
-
- for (Icon icon : CandyBarMainActivity.sSections) {
- if (CandyBarApplication.getConfiguration().isShowTabAllIcons()) {
- if (!icon.getTitle().equals(CandyBarApplication.getConfiguration().getTabAllIconsTitle())) {
- icons.addAll(icon.getIcons());
- }
- } else {
- icons.addAll(icon.getIcons());
- }
- }
-
- Collections.sort(icons, Icon.TitleComparator);
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- if (ok) {
- mAdapter = new IconsAdapter(getActivity(), icons, mFragment, false);
- currentAdapter = new WeakReference<>(mAdapter);
- mRecyclerView.setAdapter(mAdapter);
- filterSearch("");
- mSearchInput.requestFocus();
- SoftKeyboardHelper.openKeyboard(getActivity());
- } else {
- // Unable to load all icons
- Toast.makeText(getActivity(), R.string.icons_load_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/PresetsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/PresetsFragment.java
deleted file mode 100644
index df08ee9..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/PresetsFragment.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package candybar.lib.fragments;
-
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-import android.Manifest;
-import android.app.Activity;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.graphics.PorterDuff;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ProgressBar;
-import android.widget.Toast;
-
-import androidx.activity.result.contract.ActivityResultContracts;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
-import androidx.core.view.ViewCompat;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.bumptech.glide.Glide;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.danimahardhika.cafebar.CafeBar;
-import com.danimahardhika.cafebar.CafeBarTheme;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import candybar.lib.R;
-import candybar.lib.adapters.PresetsAdapter;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Preset;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class PresetsFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
- private ProgressBar mProgress;
- private RecyclerFastScroller mFastScroll;
-
- private AsyncTaskBase mAsyncTask;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_presets, container, false);
- mRecyclerView = view.findViewById(R.id.presets_grid);
- mProgress = view.findViewById(R.id.progress);
- mFastScroll = view.findViewById(R.id.fastscroll);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- ViewCompat.setNestedScrollingEnabled(mRecyclerView, false);
-
- mProgress.getIndeterminateDrawable().setColorFilter(
- ColorHelper.getAttributeColor(getActivity(), R.attr.colorSecondary),
- PorterDuff.Mode.SRC_IN);
-
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setHasFixedSize(false);
- mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
- requireActivity().getResources().getInteger(R.integer.presets_column_count)));
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
-
- CountDownLatch permissionDone = new CountDownLatch(1);
-
- if (ContextCompat.checkSelfPermission(requireActivity(),
- Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
- registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
- if (!isGranted) {
- CafeBar.builder(requireActivity())
- .theme(CafeBarTheme.Custom(ContextCompat.getColor(requireActivity(), R.color.cardBackground)))
- .floating(true)
- .fitSystemWindow()
- .duration(CafeBar.Duration.MEDIUM)
- .typeface(TypefaceHelper.getRegular(requireActivity()), TypefaceHelper.getBold(requireActivity()))
- .content(R.string.presets_storage_permission)
- .show();
- }
-
- mAsyncTask = new PresetsLoader().execute();
- }).launch(Manifest.permission.READ_EXTERNAL_STORAGE);
- } else {
- mAsyncTask = new PresetsLoader().execute();
- }
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- resetSpanSizeLookUp();
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) mAsyncTask.cancel(true);
- Activity activity = getActivity();
- if (activity != null) Glide.get(activity).clearMemory();
- setHasOptionsMenu(false);
- super.onDestroy();
- }
-
- private void resetSpanSizeLookUp() {
- int column = requireActivity().getResources().getInteger(R.integer.presets_column_count);
- PresetsAdapter adapter = (PresetsAdapter) mRecyclerView.getAdapter();
- GridLayoutManager manager = (GridLayoutManager) mRecyclerView.getLayoutManager();
-
- try {
- manager.setSpanCount(column);
-
- manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
- @Override
- public int getSpanSize(int position) {
- if (adapter.isHeader(position)) return column;
- return 1;
- }
- });
- } catch (Exception ignored) {
- }
- }
-
- private class PresetsLoader extends AsyncTaskBase {
-
- private final List presets = new ArrayList<>();
-
- private List loadPresets(String sectionName, String directory) throws IOException {
- List presets = new ArrayList<>();
- presets.add(new Preset("", sectionName));
- for (String item : requireActivity().getAssets().list(directory)) {
- presets.add(new Preset(directory + "/" + item, null));
- }
- if (presets.size() == 1) presets.clear();
- return presets;
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
-
- presets.addAll(loadPresets("Komponents", "komponents"));
- presets.addAll(loadPresets("Lockscreens", "lockscreens"));
- presets.addAll(loadPresets("Wallpapers", "wallpapers"));
- presets.addAll(loadPresets("Widgets", "widgets"));
-
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- mProgress.setVisibility(View.GONE);
-
- if (ok) {
- mRecyclerView.setAdapter(new PresetsAdapter(requireActivity(), presets));
- } else {
- Toast.makeText(getActivity(), R.string.presets_load_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/RequestFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/RequestFragment.java
deleted file mode 100644
index d54e6f8..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/RequestFragment.java
+++ /dev/null
@@ -1,617 +0,0 @@
-package candybar.lib.fragments;
-
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.ResolveInfo;
-import android.content.res.Configuration;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.Log;
-import android.util.SparseBooleanArray;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ProgressBar;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.res.ResourcesCompat;
-import androidx.fragment.app.Fragment;
-import androidx.interpolator.view.animation.LinearOutSlowInInterpolator;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.animation.AnimationHelper;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.ViewHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.adapters.RequestAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.helpers.RequestHelper;
-import candybar.lib.helpers.TapIntroHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Request;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.listeners.RequestListener;
-
-import static candybar.lib.helpers.DrawableHelper.getReqIcon;
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class RequestFragment extends Fragment implements View.OnClickListener {
-
- private RecyclerView mRecyclerView;
- private FloatingActionButton mFab;
- private RecyclerFastScroller mFastScroll;
- private ProgressBar mProgress;
-
- private MenuItem mMenuItem;
- private RequestAdapter mAdapter;
- private StaggeredGridLayoutManager mManager;
- private AsyncTaskBase mAsyncTask;
-
- public static List sSelectedRequests;
-
- private boolean noEmailClientError = false;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_request, container, false);
- mRecyclerView = view.findViewById(R.id.request_list);
- mFab = view.findViewById(R.id.fab);
- mFastScroll = view.findViewById(R.id.fastscroll);
- mProgress = view.findViewById(R.id.progress);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- setHasOptionsMenu(false);
- resetRecyclerViewPadding(getResources().getConfiguration().orientation);
-
- mProgress.getIndeterminateDrawable().setColorFilter(
- ColorHelper.getAttributeColor(getActivity(), R.attr.colorSecondary),
- PorterDuff.Mode.SRC_IN);
-
- int color = ColorHelper.getTitleTextColor(ColorHelper
- .getAttributeColor(getActivity(), R.attr.colorSecondary));
- Drawable tintedDrawable = ResourcesCompat.getDrawable(requireActivity().getResources(), R.drawable.ic_fab_send, null);
- assert tintedDrawable != null;
- tintedDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- mFab.setImageDrawable(tintedDrawable);
- mFab.setOnClickListener(this);
-
- if (!Preferences.get(requireActivity()).isFabShadowEnabled()) {
- mFab.setCompatElevation(0f);
- }
-
- RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
- itemAnimator.setChangeDuration(0);
- mRecyclerView.setItemAnimator(itemAnimator);
- mManager = new StaggeredGridLayoutManager(
- requireActivity().getResources().getInteger(R.integer.request_column_count),
- StaggeredGridLayoutManager.VERTICAL);
- mRecyclerView.setLayoutManager(mManager);
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
-
- mAsyncTask = new MissingAppsLoader().execute();
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- resetRecyclerViewPadding(newConfig.orientation);
- if (mAsyncTask != null) return;
-
- int[] positions = mManager.findFirstVisibleItemPositions(null);
-
- SparseBooleanArray selectedItems = mAdapter.getSelectedItemsArray();
- ViewHelper.resetSpanCount(mRecyclerView,
- requireActivity().getResources().getInteger(R.integer.request_column_count));
-
- mAdapter = new RequestAdapter(requireActivity(),
- CandyBarMainActivity.sMissedApps,
- mManager.getSpanCount());
- mRecyclerView.setAdapter(mAdapter);
- mAdapter.setSelectedItemsArray(selectedItems);
-
- if (positions.length > 0)
- mRecyclerView.scrollToPosition(positions[0]);
- }
-
- @Override
- public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
- inflater.inflate(R.menu.menu_request, menu);
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- super.onDestroy();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.menu_select_all) {
- mMenuItem = item;
- if (mAdapter == null) return false;
- if (mAdapter.selectAll()) {
- item.setIcon(R.drawable.ic_toolbar_select_all_selected);
- return true;
- }
-
- item.setIcon(R.drawable.ic_toolbar_select_all);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onClick(View view) {
- int id = view.getId();
- if (id == R.id.fab) {
- if (mAdapter == null) return;
-
- int selected = mAdapter.getSelectedItemsSize();
- if (selected > 0) {
- if (mAdapter.isContainsRequested()) {
- RequestHelper.showAlreadyRequestedDialog(requireActivity());
- return;
- }
-
- boolean requestLimit = getResources().getBoolean(
- R.bool.enable_icon_request_limit);
- boolean iconRequest = getResources().getBoolean(
- R.bool.enable_icon_request);
- boolean premiumRequest = getResources().getBoolean(
- R.bool.enable_premium_request);
-
- if (Preferences.get(requireActivity()).isPremiumRequest()) {
- int count = Preferences.get(requireActivity()).getPremiumRequestCount();
- if (selected > count) {
- RequestHelper.showPremiumRequestLimitDialog(requireActivity(), selected);
- return;
- }
-
- if (!RequestHelper.isReadyToSendPremiumRequest(requireActivity())) return;
-
- try {
-
- } catch (Exception ignored) {
- }
- return;
- }
-
- if (!iconRequest && premiumRequest) {
- RequestHelper.showPremiumRequestRequired(requireActivity());
- return;
- }
-
- if (requestLimit) {
- int limit = requireActivity().getResources().getInteger(R.integer.icon_request_limit);
- int used = Preferences.get(requireActivity()).getRegularRequestUsed();
- if (selected > (limit - used)) {
- RequestHelper.showIconRequestLimitDialog(requireActivity());
- return;
- }
- }
-
- if ((requireActivity().getResources().getBoolean(R.bool.json_check_before_request)) &&
- (requireActivity().getResources().getString(R.string.config_json).length() != 0)) {
- mAsyncTask = new CheckConfig().executeOnThreadPool();
- } else {
- mAsyncTask = new RequestLoader().executeOnThreadPool();
- }
-
- } else {
- Toast.makeText(getActivity(), R.string.request_not_selected,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-
- private void resetRecyclerViewPadding(int orientation) {
- if (mRecyclerView == null) return;
-
- int padding = 0;
- boolean tabletMode = getResources().getBoolean(R.bool.android_helpers_tablet_mode);
- if (tabletMode || orientation == Configuration.ORIENTATION_LANDSCAPE) {
- padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.content_padding);
-
- if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT) {
- padding = requireActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
- }
- }
-
- int size = requireActivity().getResources().getDimensionPixelSize(R.dimen.fab_size);
- int marginGlobal = requireActivity().getResources().getDimensionPixelSize(R.dimen.fab_margin_global);
-
- mRecyclerView.setPadding(padding, padding, 0, size + (marginGlobal * 2));
- }
-
- public void prepareRequest() {
- if (mAsyncTask != null) return;
-
- mAsyncTask = new RequestLoader().executeOnThreadPool();
- }
-
- public void refreshIconRequest() {
- if (mAdapter == null) {
- RequestFragment.sSelectedRequests = null;
- return;
- }
-
- if (RequestFragment.sSelectedRequests == null) {
- mAdapter.notifyItemChanged(0);
- return;
- }
-
- for (Integer integer : RequestFragment.sSelectedRequests) {
- mAdapter.setRequested(integer, true);
- }
-
- mAdapter.notifyDataSetChanged();
- RequestFragment.sSelectedRequests = null;
- }
-
- private class MissingAppsLoader extends AsyncTaskBase {
-
- private List requests;
-
- @Override
- protected void preRun() {
- if (CandyBarMainActivity.sMissedApps == null) {
- mProgress.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (CandyBarMainActivity.sMissedApps == null) {
- CandyBarMainActivity.sMissedApps = RequestHelper.getMissingApps(requireActivity());
- }
-
- requests = CandyBarMainActivity.sMissedApps;
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- mProgress.setVisibility(View.GONE);
-
- if (ok) {
- setHasOptionsMenu(true);
- mAdapter = new RequestAdapter(getActivity(),
- requests, mManager.getSpanCount());
- mRecyclerView.setAdapter(mAdapter);
-
- AnimationHelper.show(mFab)
- .interpolator(new LinearOutSlowInInterpolator())
- .start();
-
- if (getActivity().getResources().getBoolean(R.bool.show_intro)) {
- TapIntroHelper.showRequestIntro(getActivity(), mRecyclerView);
- }
- } else {
- mRecyclerView.setAdapter(null);
- Toast.makeText(getActivity(), R.string.request_appfilter_failed, Toast.LENGTH_LONG).show();
- }
- }
- }
-
- private class RequestLoader extends AsyncTaskBase {
-
- private MaterialDialog dialog;
- private boolean isArctic;
- private String arcticApiKey;
- private String errorMessage;
-
- @Override
- protected void preRun() {
- if (Preferences.get(requireActivity()).isPremiumRequest()) {
- isArctic = RequestHelper.isPremiumArcticEnabled(requireActivity());
- arcticApiKey = RequestHelper.getPremiumArcticApiKey(requireActivity());
- } else {
- isArctic = RequestHelper.isRegularArcticEnabled(requireActivity());
- arcticApiKey = RequestHelper.getRegularArcticApiKey(requireActivity());
- }
-
- dialog = new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .content(R.string.request_building)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .progress(true, 0)
- .progressIndeterminateStyle(true)
- .build();
-
- dialog.show();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(2);
-
- RequestFragment.sSelectedRequests = mAdapter.getSelectedItems();
- List requests = mAdapter.getSelectedApps();
-
- File directory = requireActivity().getCacheDir();
- List files = new ArrayList<>();
-
- for (Request request : requests) {
- Drawable drawable = getReqIcon(requireActivity(), request.getActivity());
- String icon = IconsHelper.saveIcon(files, directory, drawable,
- isArctic ? request.getPackageName() : RequestHelper.fixNameForRequest(request.getName()));
- if (icon != null) files.add(icon);
- }
-
- if (isArctic) {
- errorMessage = RequestHelper.sendArcticRequest(requests, files, directory, arcticApiKey);
- return errorMessage == null;
- } else {
- boolean nonMailingAppSend = getResources().getBoolean(R.bool.enable_non_mail_app_request);
- Intent intent;
-
- if (!nonMailingAppSend) {
- intent = new Intent(Intent.ACTION_SENDTO);
- intent.setData(Uri.parse("mailto:"));
- } else {
- intent = new Intent(Intent.ACTION_SEND);
- intent.setType("application/zip");
- }
-
- List resolveInfos = requireActivity().getPackageManager()
- .queryIntentActivities(intent, 0);
- if (resolveInfos.size() == 0) {
- noEmailClientError = true;
- return false;
- }
-
- File appFilter = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.APPFILTER);
- File appMap = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.APPMAP);
- File themeResources = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);
-
- if (appFilter != null) files.add(appFilter.toString());
-
- if (appMap != null) files.add(appMap.toString());
-
- if (themeResources != null) files.add(themeResources.toString());
-
- CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
- RequestHelper.getGeneratedZipName(RequestHelper.ZIP)));
- }
- return true;
- } catch (RuntimeException | InterruptedException e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- dialog.dismiss();
- mAsyncTask = null;
- dialog = null;
-
- if (ok) {
- if (isArctic) {
- Toast.makeText(getActivity(), R.string.request_arctic_success, Toast.LENGTH_LONG).show();
- ((RequestListener) getActivity()).onRequestBuilt(null, IntentChooserFragment.ICON_REQUEST);
- } else {
- IntentChooserFragment.showIntentChooserDialog(getActivity().getSupportFragmentManager(),
- IntentChooserFragment.ICON_REQUEST);
- }
- mAdapter.resetSelectedItems();
- if (mMenuItem != null) mMenuItem.setIcon(R.drawable.ic_toolbar_select_all);
- } else {
- if (isArctic) {
- new MaterialDialog.Builder(getActivity())
- .typeface(TypefaceHelper.getMedium(getActivity()), TypefaceHelper.getRegular(getActivity()))
- .content(R.string.request_arctic_error, "\"" + errorMessage + "\"")
- .cancelable(true)
- .canceledOnTouchOutside(false)
- .positiveText(R.string.close)
- .build()
- .show();
- } else if (noEmailClientError) {
- Toast.makeText(getActivity(), R.string.no_email_app,
- Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(getActivity(), R.string.request_build_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
- }
-
- public class CheckConfig extends AsyncTaskBase {
-
- private MaterialDialog dialog;
- private boolean canRequest = true;
- private String updateUrl;
-
- @Override
- protected void preRun() {
- dialog = new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .content(R.string.request_fetching_data)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .progress(true, 0)
- .progressIndeterminateStyle(true)
- .build();
-
- dialog.show();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- String configJsonUrl = requireActivity().getResources().getString(R.string.config_json);
- URLConnection urlConnection;
- BufferedReader bufferedReader = null;
-
- try {
- urlConnection = new URL(configJsonUrl).openConnection();
- bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
-
- String line;
- StringBuilder stringBuilder = new StringBuilder();
- while ((line = bufferedReader.readLine()) != null) {
- stringBuilder.append(line);
- }
-
- JSONObject configJson = new JSONObject(stringBuilder.toString());
- updateUrl = configJson.getString("url");
-
- JSONObject disableRequestObj = configJson.getJSONObject("disableRequest");
- long disableRequestBelow = disableRequestObj.optLong("below", 0);
- String disableRequestOn = disableRequestObj.optString("on", "");
- PackageInfo packageInfo = requireActivity().getPackageManager()
- .getPackageInfo(requireActivity().getPackageName(), 0);
- long appVersionCode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
- ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
-
- if ((appVersionCode < disableRequestBelow) ||
- disableRequestOn.matches(".*\\b" + appVersionCode + "\\b.*")) {
- canRequest = false;
- }
-
- return true;
- } catch (Exception ex) {
- LogUtil.e("Error loading Configuration JSON " + Log.getStackTraceString(ex));
- } finally {
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (IOException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- dialog.dismiss();
- dialog = null;
-
- if (ok) {
- if (!canRequest) {
- new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .content(R.string.request_app_disabled)
- .negativeText(R.string.close)
- .positiveText(R.string.update)
- .onPositive(((dialog, which) -> {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(updateUrl));
- intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- requireActivity().startActivity(intent);
- }))
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .build()
- .show();
-
- mAdapter.resetSelectedItems();
- if (mMenuItem != null) mMenuItem.setIcon(R.drawable.ic_toolbar_select_all);
- } else {
- mAsyncTask = new RequestLoader().executeOnThreadPool();
- }
- } else {
- new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .content(R.string.unable_to_load_config)
- .canceledOnTouchOutside(false)
- .positiveText(R.string.close)
- .build()
- .show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/SettingsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/SettingsFragment.java
deleted file mode 100644
index 47abf37..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/SettingsFragment.java
+++ /dev/null
@@ -1,311 +0,0 @@
-package candybar.lib.fragments;
-
-import static candybar.lib.helpers.DrawableHelper.getReqIcon;
-
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.SettingsAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.RequestHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Language;
-import candybar.lib.items.Request;
-import candybar.lib.items.Setting;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.listeners.RequestListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class SettingsFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_settings, container, false);
- mRecyclerView = view.findViewById(R.id.recyclerview);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
-
- initSettings();
- }
-
- public void restorePurchases(List productsId, String[] premiumRequestProductsId,
- int[] premiumRequestProductsCount) {
- int index = -1;
- for (String productId : productsId) {
- for (int i = 0; i < premiumRequestProductsId.length; i++) {
- if (premiumRequestProductsId[i].equals(productId)) {
- index = i;
- break;
- }
- }
- if (index > -1 && index < premiumRequestProductsCount.length) {
- final Preferences preferences = Preferences.get(requireActivity());
- if (!preferences.isPremiumRequest()) {
- preferences.setPremiumRequestProductId(productId);
- preferences.setPremiumRequestCount(premiumRequestProductsCount[index]);
- preferences.setPremiumRequestTotal(premiumRequestProductsCount[index]);
- preferences.setPremiumRequest(true);
- }
- }
- }
- int message = index > -1 ?
- R.string.pref_premium_request_restore_success :
- R.string.pref_premium_request_restore_empty;
- Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
- }
-
- private void initSettings() {
- List settings = new ArrayList<>();
-
- double cache = (double) FileHelper.getDirectorySize(requireActivity().getCacheDir()) / FileHelper.MB;
- NumberFormat formatter = new DecimalFormat("#0.00");
- final Resources resources = requireActivity().getResources();
-
- settings.add(new Setting(R.drawable.ic_toolbar_storage,
- resources.getString(R.string.pref_data_header),
- "", "", "", Setting.Type.HEADER));
-
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_data_cache),
- resources.getString(R.string.pref_data_cache_desc),
- resources.getString(R.string.pref_data_cache_size,
- formatter.format(cache) + " MB"),
- Setting.Type.CACHE));
-
- if (resources.getBoolean(R.bool.enable_icon_request) ||
- Preferences.get(requireActivity()).isPremiumRequestEnabled() &&
- !resources.getBoolean(R.bool.enable_icon_request_limit)) {
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_data_request),
- resources.getString(R.string.pref_data_request_desc),
- "", Setting.Type.ICON_REQUEST));
- }
-
- if (Preferences.get(requireActivity()).isPremiumRequestEnabled()) {
- settings.add(new Setting(R.drawable.ic_toolbar_premium_request,
- resources.getString(R.string.pref_premium_request_header),
- "", "", "", Setting.Type.HEADER));
-
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_premium_request_restore),
- resources.getString(R.string.pref_premium_request_restore_desc),
- "", Setting.Type.RESTORE));
-
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_premium_request_rebuild),
- resources.getString(R.string.pref_premium_request_rebuild_desc),
- "", Setting.Type.PREMIUM_REQUEST));
- }
-
- if (CandyBarApplication.getConfiguration().isDashboardThemingEnabled()) {
- settings.add(new Setting(R.drawable.ic_toolbar_theme,
- resources.getString(R.string.pref_theme_header),
- "", "", "", Setting.Type.HEADER));
-
- settings.add(new Setting(-1, "",
- Preferences.get(requireActivity()).getTheme().displayName(requireActivity()),
- "", "", Setting.Type.THEME));
- }
-
- settings.add(new Setting(R.drawable.ic_toolbar_language,
- resources.getString(R.string.pref_language_header),
- "", "", "", Setting.Type.HEADER));
-
- Language language = LocaleHelper.getCurrentLanguage(requireActivity());
- settings.add(new Setting(-1, "",
- language.getName(),
- "", "", Setting.Type.LANGUAGE));
-
- settings.add(new Setting(R.drawable.ic_toolbar_others,
- resources.getString(R.string.pref_others_header),
- "", "", "", Setting.Type.HEADER));
-
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_others_changelog),
- "", "", Setting.Type.CHANGELOG));
-
- if (resources.getBoolean(R.bool.enable_apply)) {
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_others_report_bugs),
- "", "", Setting.Type.REPORT_BUGS));
- }
-
- if (resources.getBoolean(R.bool.show_intro)) {
- settings.add(new Setting(-1, "",
- resources.getString(R.string.pref_others_reset_tutorial),
- "", "", Setting.Type.RESET_TUTORIAL));
- }
-
- mRecyclerView.setAdapter(new SettingsAdapter(requireActivity(), settings));
- }
-
- public void rebuildPremiumRequest() {
- new PremiumRequestRebuilder().execute();
- }
-
- private class PremiumRequestRebuilder extends AsyncTaskBase {
-
- private MaterialDialog dialog;
- private boolean isArctic;
- private String arcticApiKey;
- private List requests;
- private String errorMessage = "";
-
- @Override
- protected void preRun() {
- isArctic = RequestHelper.isPremiumArcticEnabled(requireActivity());
- arcticApiKey = RequestHelper.getPremiumArcticApiKey(requireActivity());
-
- dialog = new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .content(R.string.premium_request_rebuilding)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .progress(true, 0)
- .progressIndeterminateStyle(true)
- .build();
-
- dialog.show();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- File directory = requireActivity().getCacheDir();
- requests = Database.get(requireActivity()).getPremiumRequest(null);
- if (requests.size() == 0) return true;
-
- List files = new ArrayList<>();
-
- for (Request request : requests) {
- Drawable drawable = getReqIcon(requireActivity(), request.getActivity());
- String icon = IconsHelper.saveIcon(files, directory, drawable,
- isArctic ? request.getPackageName() : RequestHelper.fixNameForRequest(request.getName()));
- if (icon != null) files.add(icon);
- }
-
- if (isArctic) {
- errorMessage = RequestHelper.sendArcticRequest(requests, files, directory, arcticApiKey);
- return errorMessage == null;
- } else {
- File appFilter = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.APPFILTER);
- File appMap = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.APPMAP);
- File themeResources = RequestHelper.buildXml(requireActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);
-
- if (appFilter != null) {
- files.add(appFilter.toString());
- }
-
- if (appMap != null) {
- files.add(appMap.toString());
- }
-
- if (themeResources != null) {
- files.add(themeResources.toString());
- }
-
- CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
- RequestHelper.getGeneratedZipName(RequestHelper.REBUILD_ZIP)));
- }
- return true;
- } catch (Exception e) {
- errorMessage = e.toString();
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- dialog.dismiss();
- dialog = null;
-
- if (ok) {
- if (requests.size() == 0) {
- Toast.makeText(getActivity(), R.string.premium_request_rebuilding_empty,
- Toast.LENGTH_LONG).show();
- return;
- }
-
- if (isArctic) {
- Toast.makeText(getActivity(), R.string.request_arctic_success, Toast.LENGTH_LONG).show();
- ((RequestListener) getActivity()).onRequestBuilt(null, IntentChooserFragment.REBUILD_ICON_REQUEST);
- } else {
- IntentChooserFragment.showIntentChooserDialog(
- getActivity().getSupportFragmentManager(), IntentChooserFragment.REBUILD_ICON_REQUEST);
- }
- } else {
- Toast.makeText(getActivity(), "Failed: " + errorMessage, Toast.LENGTH_LONG).show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/WallpapersFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/WallpapersFragment.java
deleted file mode 100644
index b5d781c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/WallpapersFragment.java
+++ /dev/null
@@ -1,305 +0,0 @@
-package candybar.lib.fragments;
-
-import static candybar.lib.helpers.ViewHelper.setFastScrollColor;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.graphics.PorterDuff;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.EditText;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
-import androidx.core.view.ViewCompat;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.DefaultItemAnimator;
-import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
-
-import com.bumptech.glide.Glide;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.SoftKeyboardHelper;
-import com.danimahardhika.android.helpers.core.ViewHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.WallpapersAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.helpers.JsonHelper;
-import candybar.lib.helpers.TapIntroHelper;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.listeners.WallpapersListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class WallpapersFragment extends Fragment {
-
- private RecyclerView mRecyclerView;
- private SwipeRefreshLayout mSwipe;
- private ProgressBar mProgress;
- private TextView mSearchResult;
- private RecyclerFastScroller mFastScroll;
-
- private AsyncTaskBase mAsyncTask;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_wallpapers, container, false);
- mRecyclerView = view.findViewById(R.id.wallpapers_grid);
- mSwipe = view.findViewById(R.id.swipe);
- mProgress = view.findViewById(R.id.progress);
- mSearchResult = view.findViewById(R.id.search_result);
- mFastScroll = view.findViewById(R.id.fastscroll);
-
- if (!Preferences.get(requireActivity()).isToolbarShadowEnabled()) {
- View shadow = view.findViewById(R.id.shadow);
- if (shadow != null) shadow.setVisibility(View.GONE);
- }
- return view;
- }
-
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- ViewCompat.setNestedScrollingEnabled(mRecyclerView, false);
-
- mProgress.getIndeterminateDrawable().setColorFilter(
- ColorHelper.getAttributeColor(getActivity(), R.attr.colorSecondary),
- PorterDuff.Mode.SRC_IN);
- mSwipe.setColorSchemeColors(
- ContextCompat.getColor(requireActivity(), R.color.swipeRefresh));
-
- mRecyclerView.setItemAnimator(new DefaultItemAnimator());
- mRecyclerView.setHasFixedSize(false);
- mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
- requireActivity().getResources().getInteger(R.integer.wallpapers_column_count)));
-
- setFastScrollColor(mFastScroll);
- mFastScroll.attachRecyclerView(mRecyclerView);
-
- mSwipe.setOnRefreshListener(() -> {
- if (mProgress.getVisibility() == View.GONE)
- mAsyncTask = new WallpapersLoader(true).execute();
- else mSwipe.setRefreshing(false);
- });
-
- mAsyncTask = new WallpapersLoader(false).execute();
- }
-
- @Override
- public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
- inflater.inflate(R.menu.menu_search, menu);
- MenuItem search = menu.findItem(R.id.menu_search);
-
- View searchView = search.getActionView();
- EditText searchInput = searchView.findViewById(R.id.search_input);
- View clearQueryButton = searchView.findViewById(R.id.clear_query_button);
-
- searchInput.setHint(requireActivity().getResources().getString(R.string.search_wallpapers));
- searchInput.requestFocus();
-
- new Handler(Looper.getMainLooper()).postDelayed(() -> {
- if (getActivity() != null) {
- SoftKeyboardHelper.openKeyboard(getActivity());
- }
- }, 1000);
-
- searchInput.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- String query = charSequence.toString();
- filterSearch(query);
- clearQueryButton.setVisibility(query.contentEquals("") ? View.GONE : View.VISIBLE);
- }
- });
-
- clearQueryButton.setOnClickListener(view -> searchInput.setText(""));
-
- search.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
- @Override
- public boolean onMenuItemActionExpand(MenuItem menuItem) {
- searchInput.requestFocus();
-
- new Handler(Looper.getMainLooper()).postDelayed(() -> {
- if (getActivity() != null) {
- SoftKeyboardHelper.openKeyboard(getActivity());
- }
- }, 1000);
-
- return true;
- }
-
- @Override
- public boolean onMenuItemActionCollapse(MenuItem menuItem) {
- searchInput.setText("");
- return true;
- }
- });
-
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- ViewHelper.resetSpanCount(mRecyclerView,
- requireActivity().getResources().getInteger(R.integer.wallpapers_column_count));
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) mAsyncTask.cancel(true);
- Activity activity = getActivity();
- if (activity != null) Glide.get(activity).clearMemory();
- setHasOptionsMenu(false);
- super.onDestroy();
- }
-
- @SuppressLint("StringFormatInvalid")
- private void filterSearch(String query) {
- if (mRecyclerView.getAdapter() != null) {
- WallpapersAdapter adapter = (WallpapersAdapter) mRecyclerView.getAdapter();
- adapter.search(query);
- if (adapter.getItemCount() == 0) {
- String text = requireActivity().getResources().getString(R.string.search_noresult, query);
- mSearchResult.setText(text);
- mSearchResult.setVisibility(View.VISIBLE);
- } else mSearchResult.setVisibility(View.GONE);
- }
- }
-
- private class WallpapersLoader extends AsyncTaskBase {
-
- private List wallpapers;
- private final boolean refreshing;
-
- private WallpapersLoader(boolean refreshing) {
- this.refreshing = refreshing;
- }
-
- @Override
- protected void preRun() {
- if (!refreshing) mProgress.setVisibility(View.VISIBLE);
- else mSwipe.setRefreshing(true);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
-
- URL url = new URL(getString(R.string.wallpaper_json));
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setConnectTimeout(15000);
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- InputStream stream = connection.getInputStream();
- List> list = JsonHelper.parseList(stream);
- if (list == null) {
- LogUtil.e("Json error, no array with name: "
- + CandyBarApplication.getConfiguration().getWallpaperJsonStructure().getArrayName());
- return false;
- }
-
- if (Database.get(requireActivity()).getWallpapersCount() > 0) {
- Database.get(requireActivity()).deleteWallpapers();
- }
-
- Database.get(requireActivity()).addWallpapers(null, list);
- wallpapers = Database.get(requireActivity()).getWallpapers(null);
-
- return true;
- }
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- mProgress.setVisibility(View.GONE);
- mSwipe.setRefreshing(false);
-
- if (ok) {
- setHasOptionsMenu(true);
-
- mRecyclerView.setAdapter(new WallpapersAdapter(getActivity(), wallpapers));
-
- ((WallpapersListener) getActivity())
- .onWallpapersChecked(Database.get(getActivity()).getWallpapersCount());
-
- try {
- if (getActivity().getResources().getBoolean(R.bool.show_intro)) {
- TapIntroHelper.showWallpapersIntro(getActivity(), mRecyclerView);
- }
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- } else {
- Toast.makeText(getActivity(), R.string.connection_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ChangelogFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ChangelogFragment.java
deleted file mode 100644
index 26613e1..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ChangelogFragment.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.ChangelogAdapter;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.utils.listeners.HomeListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ChangelogFragment extends DialogFragment {
-
- private static final String TAG = "candybar.dialog.changelog";
-
- private static ChangelogFragment newInstance() {
- return new ChangelogFragment();
- }
-
- public static void showChangelog(FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = ChangelogFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .customView(R.layout.fragment_changelog, false)
- .positiveText(R.string.close)
- .build();
- dialog.show();
-
- ListView changelogList = (ListView) dialog.findViewById(R.id.changelog_list);
- TextView changelogDate = (TextView) dialog.findViewById(R.id.changelog_date);
- TextView changelogVersion = (TextView) dialog.findViewById(R.id.changelog_version);
-
- Activity activity = requireActivity();
- try {
- String version = activity.getPackageManager().getPackageInfo(
- activity.getPackageName(), 0).versionName;
- if (version != null && version.length() > 0) {
- changelogVersion.setText(activity.getResources().getString(
- R.string.changelog_version));
- changelogVersion.append(" " + version);
- }
- } catch (Exception ignored) {
- }
-
- String date = activity.getResources().getString(R.string.changelog_date);
- if (date.length() > 0) changelogDate.setText(date);
- else changelogDate.setVisibility(View.GONE);
-
- String[] changelog = activity.getResources().getStringArray(R.array.changelog);
- changelogList.setAdapter(new ChangelogAdapter(requireActivity(), changelog));
-
- return dialog;
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- super.onDismiss(dialog);
-
- FragmentManager fm = requireActivity().getSupportFragmentManager();
- if (fm != null) {
- Fragment fragment = fm.findFragmentByTag("home");
- if (fragment != null) {
- HomeListener listener = (HomeListener) fragment;
- listener.onHomeIntroInit();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/CreditsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/CreditsFragment.java
deleted file mode 100644
index a5f59d5..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/CreditsFragment.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.CreditsAdapter;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Credit;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CreditsFragment extends DialogFragment {
-
- private ListView mListView;
- private AsyncTaskBase mAsyncTask;
- private int mType;
-
- private static final String TAG = "candybar.dialog.credits";
- private static final String TYPE = "type";
-
- public static final int TYPE_ICON_PACK_CONTRIBUTORS = 0;
- public static final int TYPE_DASHBOARD_CONTRIBUTORS = 1;
- public static final int TYPE_DASHBOARD_TRANSLATOR = 2;
-
- private static CreditsFragment newInstance(int type) {
- CreditsFragment fragment = new CreditsFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(TYPE, type);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- public static void showCreditsDialog(FragmentManager fm, int type) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = CreditsFragment.newInstance(type);
- dialog.show(ft, TAG);
- } catch (IllegalStateException | IllegalArgumentException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_credits, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(getTitle(mType))
- .positiveText(R.string.close)
- .build();
- dialog.show();
- mListView = (ListView) dialog.findViewById(R.id.listview);
- mAsyncTask = new CreditsLoader().executeOnThreadPool();
-
- return dialog;
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mType = getArguments().getInt(TYPE);
- }
- }
-
- @Override
- public void onDestroyView() {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- super.onDestroyView();
- }
-
- @NonNull
- private String getTitle(int type) {
- if (getActivity() == null) return "";
- switch (type) {
- case TYPE_ICON_PACK_CONTRIBUTORS:
- return getActivity().getResources().getString(R.string.about_contributors_title);
- case TYPE_DASHBOARD_CONTRIBUTORS:
- return getActivity().getResources().getString(R.string.about_dashboard_contributors);
- case TYPE_DASHBOARD_TRANSLATOR:
- return getActivity().getResources().getString(R.string.about_dashboard_translator);
- default:
- return "";
- }
- }
-
- private int getResource(int type) {
- switch (type) {
- case TYPE_ICON_PACK_CONTRIBUTORS:
- return R.xml.contributors;
- case TYPE_DASHBOARD_CONTRIBUTORS:
- return R.xml.dashboard_contributors;
- case TYPE_DASHBOARD_TRANSLATOR:
- return R.xml.dashboard_translator;
- default:
- return -1;
- }
- }
-
- private class CreditsLoader extends AsyncTaskBase {
-
- private List credits;
-
- @Override
- protected void preRun() {
- credits = new ArrayList<>();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- int res = getResource(mType);
-
- XmlPullParser xpp = getResources().getXml(res);
-
- while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
- if (xpp.getEventType() == XmlPullParser.START_TAG) {
- if (xpp.getName().equals("contributor")) {
- Credit credit = new Credit(
- xpp.getAttributeValue(null, "name"),
- xpp.getAttributeValue(null, "contribution"),
- xpp.getAttributeValue(null, "image"),
- xpp.getAttributeValue(null, "link"));
- credits.add(credit);
- }
- }
- xpp.next();
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- if (ok) {
- mListView.setAdapter(new CreditsAdapter(getActivity(), credits));
- } else {
- dismiss();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/DonationLinksFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/DonationLinksFragment.java
deleted file mode 100644
index 43a4a8b..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/DonationLinksFragment.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.os.Bundle;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.OtherAppsAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.TypefaceHelper;
-
-public class DonationLinksFragment extends DialogFragment {
-
- private static final String TAG = "candybar.dialog.donationlinks";
-
- private static DonationLinksFragment newInstance() {
- return new DonationLinksFragment();
- }
-
- public static void showDonationLinksDialog(@NonNull FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = DonationLinksFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalStateException | IllegalArgumentException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_other_apps, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(R.string.donate)
- .positiveText(R.string.close)
- .build();
- dialog.show();
-
- ListView listView = (ListView) dialog.findViewById(R.id.listview);
- List donationLinks = CandyBarApplication.getConfiguration().getDonationLinks();
- if (donationLinks != null) {
- listView.setAdapter(new OtherAppsAdapter(requireActivity(), donationLinks));
- } else {
- dismiss();
- }
-
- return dialog;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconPreviewFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconPreviewFragment.java
deleted file mode 100644
index 765f118..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconPreviewFragment.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.AttrRes;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.DrawableHelper;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import candybar.lib.R;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.IconsFragment;
-import candybar.lib.helpers.TypefaceHelper;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconPreviewFragment extends DialogFragment {
-
- private String mIconTitle;
- private String mDrawableName;
- private int mIconId;
-
- private boolean prevIsBookmarked, currentIsBookmarked;
-
- private static final String TITLE = "title";
- private static final String DRAWABLE_NAME = "drawable_name";
- private static final String ID = "id";
-
- private static final String TAG = "candybar.dialog.icon.preview";
-
- private static IconPreviewFragment newInstance(String title, int id, String drawableName) {
- IconPreviewFragment fragment = new IconPreviewFragment();
- Bundle bundle = new Bundle();
- bundle.putString(TITLE, title);
- bundle.putString(DRAWABLE_NAME, drawableName);
- bundle.putInt(ID, id);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- public static void showIconPreview(@NonNull FragmentManager fm, @NonNull String title, int id, @Nullable String drawableName) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = IconPreviewFragment.newInstance(title, id, drawableName);
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mIconTitle = requireArguments().getString(TITLE);
- mDrawableName = requireArguments().getString(DRAWABLE_NAME);
- mIconId = requireArguments().getInt(ID);
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_icon_preview, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .positiveText(R.string.close)
- .build();
-
- dialog.show();
-
- if (savedInstanceState != null) {
- mIconTitle = savedInstanceState.getString(TITLE);
- mDrawableName = savedInstanceState.getString(DRAWABLE_NAME);
- mIconId = savedInstanceState.getInt(ID);
- }
-
- TextView name = (TextView) dialog.findViewById(R.id.name);
- ImageView icon = (ImageView) dialog.findViewById(R.id.icon);
- ImageView bookmark = (ImageView) dialog.findViewById(R.id.bookmark_button);
-
- name.setText(mIconTitle);
-
- Glide.with(this)
- .load("drawable://" + mIconId)
- .transition(DrawableTransitionOptions.withCrossFade(300))
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .into(icon);
-
- if (mDrawableName == null) {
- bookmark.setVisibility(View.INVISIBLE);
- } else {
- AtomicBoolean isBookmarked = new AtomicBoolean(Database.get(requireActivity()).isIconBookmarked(mDrawableName));
- prevIsBookmarked = currentIsBookmarked = isBookmarked.get();
-
- final Runnable updateBookmark = () -> {
- @DrawableRes int drawableRes;
- @AttrRes int colorAttr;
- if (isBookmarked.get()) {
- drawableRes = R.drawable.ic_bookmark_filled;
- colorAttr = R.attr.colorSecondary;
- } else {
- drawableRes = R.drawable.ic_bookmark;
- colorAttr = android.R.attr.textColorSecondary;
- }
- bookmark.setImageDrawable(DrawableHelper.getTintedDrawable(requireActivity(),
- drawableRes, ColorHelper.getAttributeColor(requireActivity(), colorAttr)));
- };
-
- updateBookmark.run();
-
- bookmark.setOnClickListener(view -> {
- if (isBookmarked.get()) {
- Database.get(requireActivity()).deleteBookmarkedIcon(mDrawableName);
- } else {
- Database.get(requireActivity()).addBookmarkedIcon(mDrawableName, mIconTitle);
- }
- isBookmarked.set(!isBookmarked.get());
- updateBookmark.run();
- currentIsBookmarked = isBookmarked.get();
- });
- }
-
- return dialog;
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- outState.putString(TITLE, mIconTitle);
- outState.putInt(ID, mIconId);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- super.onDismiss(dialog);
- if (prevIsBookmarked != currentIsBookmarked) {
- IconsFragment.reloadBookmarks();
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconShapeChooserFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconShapeChooserFragment.java
deleted file mode 100644
index 6de4f57..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IconShapeChooserFragment.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.IconShapeAdapter;
-import candybar.lib.fragments.IconsFragment;
-import candybar.lib.fragments.IconsSearchFragment;
-import candybar.lib.helpers.IconShapeHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.IconShape;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconShapeChooserFragment extends DialogFragment {
-
- private int mShape;
-
- public static final String TAG = "candybar.dialog.iconshapes";
-
- private static IconShapeChooserFragment newInstance() {
- return new IconShapeChooserFragment();
- }
-
- public static void showIconShapeChooser(@NonNull FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = IconShapeChooserFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_languages, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(R.string.icon_shape)
- .negativeText(R.string.close)
- .build();
- dialog.show();
-
- ListView listView = (ListView) dialog.findViewById(R.id.listview);
- List iconShapes = IconShapeHelper.getShapes();
- int currentShape = mShape = Preferences.get(requireActivity()).getIconShape();
- int currentShapeIndex = 0;
-
- for (int i = 0; i < iconShapes.size(); i++) {
- int shape = iconShapes.get(i).getShape();
- if (shape == currentShape) {
- currentShapeIndex = i;
- break;
- }
- }
-
- listView.setAdapter(new IconShapeAdapter(requireActivity(), iconShapes, currentShapeIndex));
-
- return dialog;
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- int prevShape = Preferences.get(requireActivity()).getIconShape();
- if (prevShape != mShape) {
- Preferences.get(requireActivity()).setIconShape(mShape);
- IconsFragment.reloadIcons();
- IconsSearchFragment.reloadIcons();
- }
- super.onDismiss(dialog);
- }
-
- public void setShape(int shape) {
- mShape = shape;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IntentChooserFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IntentChooserFragment.java
deleted file mode 100644
index 734d8a4..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/IntentChooserFragment.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.DialogAction;
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.IntentAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.RequestFragment;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.IntentChooser;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IntentChooserFragment extends DialogFragment {
-
- private ListView mIntentList;
- private TextView mNoApp;
-
- private int mType;
- private IntentAdapter mAdapter;
- private AsyncTaskBase mAsyncTask;
-
- public static final int ICON_REQUEST = 0;
- public static final int REBUILD_ICON_REQUEST = 1;
-
- public static final String TAG = "candybar.dialog.intent.chooser";
- private static final String TYPE = "type";
-
- private static IntentChooserFragment newInstance(int type) {
- IntentChooserFragment fragment = new IntentChooserFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(TYPE, type);
- fragment.setArguments(bundle);
- return fragment;
- }
-
- public static void showIntentChooserDialog(@NonNull FragmentManager fm, int type) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = IntentChooserFragment.newInstance(type);
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mType = getArguments().getInt(TYPE);
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_intent_chooser, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .positiveText(android.R.string.cancel)
- .build();
-
- dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
- if (mAdapter == null || mAdapter.isAsyncTaskRunning()) return;
-
- if (CandyBarApplication.sZipPath != null) {
- File file = new File(CandyBarApplication.sZipPath);
- if (file.exists()) {
- if (file.delete()) {
- LogUtil.e(String.format("Intent chooser cancel: %s deleted", file.getName()));
- }
- }
- }
-
- RequestFragment.sSelectedRequests = null;
- CandyBarApplication.sRequestProperty = null;
- CandyBarApplication.sZipPath = null;
- dialog.dismiss();
- });
- dialog.setCancelable(false);
- dialog.setCanceledOnTouchOutside(false);
- dialog.show();
- setCancelable(false);
-
- mIntentList = (ListView) dialog.findViewById(R.id.intent_list);
- mNoApp = (TextView) dialog.findViewById(R.id.intent_noapp);
- mAsyncTask = new IntentChooserLoader().execute();
-
- return dialog;
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- super.onDismiss(dialog);
- }
-
- private class IntentChooserLoader extends AsyncTaskBase {
-
- private List apps;
-
- @Override
- protected void preRun() {
- apps = new ArrayList<>();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
-
- boolean nonMailingAppSend = getResources().getBoolean(R.bool.enable_non_mail_app_request);
- Intent intent;
-
- if (!nonMailingAppSend) {
- intent = new Intent(Intent.ACTION_SENDTO);
- intent.setData(Uri.parse("mailto:"));
- } else {
- intent = new Intent(Intent.ACTION_SEND);
- intent.setType("application/zip");
- }
-
- List resolveInfos = requireActivity().getPackageManager()
- .queryIntentActivities(intent, 0);
- try {
- Collections.sort(resolveInfos, new ResolveInfo.DisplayNameComparator(
- requireActivity().getPackageManager()));
- } catch (Exception ignored) {
- }
-
- for (ResolveInfo resolveInfo : resolveInfos) {
- switch (resolveInfo.activityInfo.packageName) {
- case "com.google.android.gm":
- apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_RECOMMENDED));
- break;
- case "com.google.android.apps.inbox":
- try {
- ComponentName componentName = new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
- "com.google.android.apps.bigtop.activities.MainActivity");
- Intent inbox = new Intent(Intent.ACTION_SEND);
- inbox.setComponent(componentName);
-
- List list = requireActivity().getPackageManager().queryIntentActivities(
- inbox, PackageManager.MATCH_DEFAULT_ONLY);
- if (list.size() > 0) {
- apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_SUPPORTED));
- break;
- }
- } catch (ActivityNotFoundException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
-
- apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_NOT_SUPPORTED));
- break;
- case "com.android.fallback":
- case "com.paypal.android.p2pmobile":
- case "com.lonelycatgames.Xplore":
- break;
- default:
- apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_SUPPORTED));
- break;
- }
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
- if (ok && apps != null) {
- mAdapter = new IntentAdapter(getActivity(), apps, mType);
- mIntentList.setAdapter(mAdapter);
-
- if (apps.size() == 0) {
- mNoApp.setVisibility(View.VISIBLE);
- setCancelable(true);
- }
- } else {
- dismiss();
- Toast.makeText(getActivity(), R.string.intent_email_failed,
- Toast.LENGTH_LONG).show();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/LanguagesFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/LanguagesFragment.java
deleted file mode 100644
index 04eb22e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/LanguagesFragment.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.LanguagesAdapter;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Language;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class LanguagesFragment extends DialogFragment {
-
- private ListView mListView;
- private Locale mLocale;
- private AsyncTaskBase mAsyncTask;
-
- public static final String TAG = "candybar.dialog.languages";
-
- private static LanguagesFragment newInstance() {
- return new LanguagesFragment();
- }
-
- public static void showLanguageChooser(@NonNull FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = LanguagesFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_languages, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(R.string.pref_language_header)
- .negativeText(R.string.close)
- .build();
- dialog.show();
-
- mListView = (ListView) dialog.findViewById(R.id.listview);
- mAsyncTask = new LanguagesLoader().executeOnThreadPool();
-
- return dialog;
- }
-
- @Override
- public void onDestroy() {
- if (mAsyncTask != null) {
- mAsyncTask.cancel(true);
- }
- super.onDestroy();
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- if (mLocale != null) {
- Preferences.get(requireActivity()).setCurrentLocale(mLocale.toString());
- LocaleHelper.setLocale(requireActivity());
- requireActivity().recreate();
- }
- super.onDismiss(dialog);
- }
-
- public void setLanguage(@NonNull Locale locale) {
- mLocale = locale;
- dismiss();
- }
-
- private class LanguagesLoader extends AsyncTaskBase {
-
- private List languages;
- private int index = 0;
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- languages = LocaleHelper.getAvailableLanguages(requireActivity());
- Locale locale = Preferences.get(requireActivity()).getCurrentLocale();
- for (int i = 0; i < languages.size(); i++) {
- Locale l = languages.get(i).getLocale();
- if (l.toString().equals(locale.toString())) {
- index = i;
- break;
- }
- }
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (getActivity() == null) return;
- if (getActivity().isFinishing()) return;
-
- mAsyncTask = null;
-
- if (ok) {
- mListView.setAdapter(new LanguagesAdapter(getActivity(), languages, index));
- } else {
- dismiss();
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/OtherAppsFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/OtherAppsFragment.java
deleted file mode 100644
index 0528ff9..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/OtherAppsFragment.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.os.Bundle;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.OtherAppsAdapter;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.TypefaceHelper;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class OtherAppsFragment extends DialogFragment {
-
- private static final String TAG = "candybar.dialog.otherapps";
-
- private static OtherAppsFragment newInstance() {
- return new OtherAppsFragment();
- }
-
- public static void showOtherAppsDialog(@NonNull FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = OtherAppsFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalStateException | IllegalArgumentException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_other_apps, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(R.string.home_more_apps_header)
- .positiveText(R.string.close)
- .build();
- dialog.show();
-
- ListView listView = (ListView) dialog.findViewById(R.id.listview);
- List otherApps = CandyBarApplication.getConfiguration().getOtherApps();
- if (otherApps != null) {
- listView.setAdapter(new OtherAppsAdapter(requireActivity(), otherApps));
- } else {
- dismiss();
- }
-
- return dialog;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ThemeChooserFragment.java b/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ThemeChooserFragment.java
deleted file mode 100644
index 964d83c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/fragments/dialog/ThemeChooserFragment.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package candybar.lib.fragments.dialog;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.widget.ListView;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import java.util.Arrays;
-
-import candybar.lib.R;
-import candybar.lib.adapters.dialog.ThemeAdapter;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.items.Theme;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ThemeChooserFragment extends DialogFragment {
-
- private Theme mChosenTheme;
- private Theme mCurrentTheme;
-
- public static final String TAG = "candybar.dialog.theme";
-
- private static ThemeChooserFragment newInstance() {
- return new ThemeChooserFragment();
- }
-
- public static void showThemeChooser(@NonNull FragmentManager fm) {
- FragmentTransaction ft = fm.beginTransaction();
- Fragment prev = fm.findFragmentByTag(TAG);
- if (prev != null) {
- ft.remove(prev);
- }
-
- try {
- DialogFragment dialog = ThemeChooserFragment.newInstance();
- dialog.show(ft, TAG);
- } catch (IllegalArgumentException | IllegalStateException ignored) {
- }
- }
-
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- MaterialDialog dialog = new MaterialDialog.Builder(requireActivity())
- .customView(R.layout.fragment_languages, false)
- .typeface(TypefaceHelper.getMedium(requireActivity()), TypefaceHelper.getRegular(requireActivity()))
- .title(R.string.pref_theme_header)
- .negativeText(R.string.close)
- .build();
- dialog.show();
-
- ListView listView = (ListView) dialog.findViewById(R.id.listview);
- mChosenTheme = mCurrentTheme = Preferences.get(requireActivity()).getTheme();
-
- listView.setAdapter(new ThemeAdapter(requireActivity(), Arrays.asList(Theme.values()), mCurrentTheme.ordinal()));
-
- return dialog;
- }
-
- @Override
- public void onDismiss(@NonNull DialogInterface dialog) {
- if (mChosenTheme != mCurrentTheme) {
- Preferences.get(requireActivity()).setTheme(mChosenTheme);
- requireActivity().recreate();
- }
- super.onDismiss(dialog);
- }
-
- public void setTheme(Theme theme) {
- mChosenTheme = theme;
- dismiss();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/ConfigurationHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/ConfigurationHelper.java
deleted file mode 100644
index ed7a46b..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/ConfigurationHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-
-import static com.danimahardhika.android.helpers.core.DrawableHelper.get;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ConfigurationHelper {
-
- public static Drawable getNavigationIcon(@NonNull Context context, @NonNull CandyBarApplication.NavigationIcon navigationIcon) {
- switch (navigationIcon) {
- case DEFAULT:
- return new DrawerArrowDrawable(context);
- case STYLE_1:
- return get(context, R.drawable.ic_toolbar_navigation);
- case STYLE_2:
- return get(context, R.drawable.ic_toolbar_navigation_2);
- case STYLE_3:
- return get(context, R.drawable.ic_toolbar_navigation_3);
- case STYLE_4:
- return get(context, R.drawable.ic_toolbar_navigation_4);
- default:
- return get(context, R.drawable.ic_toolbar_navigation);
- }
- }
-
- public static int getSocialIconColor(@NonNull Context context, @NonNull CandyBarApplication.IconColor iconColor) {
- if (iconColor == CandyBarApplication.IconColor.ACCENT) {
- return ColorHelper.getAttributeColor(context, R.attr.colorSecondary);
- }
- return ColorHelper.getAttributeColor(context, android.R.attr.textColorPrimary);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/ContextHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/ContextHelper.java
deleted file mode 100644
index 5760d84..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/ContextHelper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.view.ContextThemeWrapper;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-class ContextHelper {
-
- @NonNull
- static Context getBaseContext(@NonNull View view) {
- Context context = view.getContext();
- if (context instanceof ContextThemeWrapper) {
- context = ((ContextThemeWrapper) view.getContext()).getBaseContext();
- }
- return context;
- }
-}
\ No newline at end of file
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/DeviceHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/DeviceHelper.java
deleted file mode 100644
index 0c091e6..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/DeviceHelper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.util.DisplayMetrics;
-
-import androidx.annotation.NonNull;
-
-import candybar.lib.BuildConfig;
-import candybar.lib.R;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class DeviceHelper {
-
- @NonNull
- public static String getDeviceInfo(@NonNull Context context) {
- DisplayMetrics displaymetrics = context.getResources().getDisplayMetrics();
- StringBuilder sb = new StringBuilder();
- final int height = displaymetrics.heightPixels;
- final int width = displaymetrics.widthPixels;
- PackageManager pm = context.getPackageManager();
- String installerPackage = pm.getInstallerPackageName(context.getPackageName());
-
- String appVersion = "";
- try {
- appVersion = context.getPackageManager().getPackageInfo(
- context.getPackageName(), 0).versionName;
- } catch (PackageManager.NameNotFoundException ignored) {
- }
-
- if (installerPackage == null || !installerPackage.contentEquals("com.android.vending")) {
- appVersion = context.getResources().getString(R.string.version_outside_playstore).replaceAll("\\{\\{appVersion\\}\\}", appVersion);
- } else {
- appVersion = context.getResources().getString(R.string.version_from_playstore).replaceAll("\\{\\{appVersion\\}\\}", appVersion);
- }
-
- sb.append("Manufacturer : ").append(Build.MANUFACTURER)
- .append("\r\nModel : ").append(Build.MODEL)
- .append("\r\nProduct : ").append(Build.PRODUCT)
- .append("\r\nScreen Resolution : ")
- .append(width).append(" x ").append(height).append(" pixels")
- .append("\r\nAndroid Version : ").append(Build.VERSION.RELEASE)
- .append("\r\nApp Version : ").append(appVersion)
- .append("\r\nCandyBar Version : ").append(BuildConfig.VERSION_NAME)
- .append("\r\n");
- return sb.toString();
- }
-
- @NonNull
- public static String getDeviceInfoForCrashReport(@NonNull Context context) {
- return "Icon Pack Name : " + context.getResources().getString(R.string.app_name)
- + "\r\n" + getDeviceInfo(context);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/DrawableHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/DrawableHelper.java
deleted file mode 100644
index 019f71c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/DrawableHelper.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.AdaptiveIconDrawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.util.DisplayMetrics;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
-import androidx.core.content.res.ResourcesCompat;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import candybar.lib.R;
-import sarsamurmu.adaptiveicon.AdaptiveIcon;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class DrawableHelper {
-
- public static Drawable getAppIcon(@NonNull Context context, ResolveInfo info) {
- try {
- return info.activityInfo.loadIcon(context.getPackageManager());
- } catch (OutOfMemoryError | Exception e) {
- return ContextCompat.getDrawable(context, R.drawable.ic_app_default);
- }
- }
-
- @Nullable
- public static Drawable getReqIcon(@NonNull Context context, String componentNameStr) {
- PackageManager packageManager = context.getPackageManager();
-
- int slashIndex = componentNameStr.indexOf("/");
- String packageName = componentNameStr.substring(0, slashIndex);
- String activityName = componentNameStr.substring(slashIndex + 1);
- ComponentName componentName = new ComponentName(packageName, activityName);
-
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
- // Load Adaptive icon if possible
- Intent intent = new Intent();
- intent.setComponent(componentName);
- ResolveInfo resolveInfo = packageManager.resolveActivity(intent, 0);
- if (resolveInfo != null) {
- Drawable adaptiveDrawable = resolveInfo.loadIcon(packageManager);
- if (adaptiveDrawable instanceof AdaptiveIconDrawable) return adaptiveDrawable;
- }
- }
-
- // Fallback to legacy icon if AdaptiveIcon is not found
- try {
- ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
- Resources appResources = packageManager.getResourcesForApplication(appInfo);
-
- int density = DisplayMetrics.DENSITY_XHIGH;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- density = DisplayMetrics.DENSITY_XXHIGH;
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- density = DisplayMetrics.DENSITY_XXXHIGH;
- }
- Drawable drawable = ResourcesCompat.getDrawableForDensity(appResources, appInfo.icon,
- density, null);
-
- if (drawable != null) return drawable;
- LogUtil.e("DrawableHelper - drawable is null");
- } catch (Exception | OutOfMemoryError e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return null;
- }
-
- public static Bitmap getRightIcon(Drawable drawable) {
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
- return ((BitmapDrawable) drawable).getBitmap();
- } else {
- if (drawable instanceof BitmapDrawable) {
- return ((BitmapDrawable) drawable).getBitmap();
- } else if (drawable instanceof AdaptiveIconDrawable) {
- return new AdaptiveIcon()
- .setDrawable((AdaptiveIconDrawable) drawable)
- .render();
- }
- }
- return null;
- }
-}
-
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/IconShapeHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/IconShapeHelper.java
deleted file mode 100644
index f1c419a..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/IconShapeHelper.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package candybar.lib.helpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.items.IconShape;
-import sarsamurmu.adaptiveicon.AdaptiveIcon;
-
-public class IconShapeHelper {
- public static List getShapes() {
- List shapes = new ArrayList<>();
- shapes.add(new IconShape("System default", -1));
- shapes.add(new IconShape("Circle", AdaptiveIcon.PATH_CIRCLE));
- shapes.add(new IconShape("Square", AdaptiveIcon.PATH_SQUARE));
- shapes.add(new IconShape("Rounded Square", AdaptiveIcon.PATH_ROUNDED_SQUARE));
- shapes.add(new IconShape("Squircle", AdaptiveIcon.PATH_SQUIRCLE));
- shapes.add(new IconShape("Teardrop", AdaptiveIcon.PATH_TEARDROP));
- return shapes;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/IconsHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/IconsHelper.java
deleted file mode 100644
index 9faf814..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/IconsHelper.java
+++ /dev/null
@@ -1,285 +0,0 @@
-package candybar.lib.helpers;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.XmlResourceParser;
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.DataSource;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.load.engine.GlideException;
-import com.bumptech.glide.request.RequestListener;
-import com.bumptech.glide.request.target.Target;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.fragments.dialog.IconPreviewFragment;
-import candybar.lib.items.Icon;
-
-import static candybar.lib.helpers.DrawableHelper.getRightIcon;
-import static com.danimahardhika.android.helpers.core.DrawableHelper.getResourceId;
-import static com.danimahardhika.android.helpers.core.FileHelper.getUriFromFile;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsHelper {
-
- @NonNull
- public static List getIconsList(@NonNull Context context) throws Exception {
- XmlResourceParser parser = context.getResources().getXml(R.xml.drawable);
- int eventType = parser.getEventType();
- String sectionTitle = "";
- List icons = new ArrayList<>();
- List sections = new ArrayList<>();
-
- int count = 0;
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- if (parser.getName().equals("category")) {
- String title = parser.getAttributeValue(null, "title");
- if (!sectionTitle.equals(title)) {
- if (sectionTitle.length() > 0 && icons.size() > 0) {
- count += icons.size();
- sections.add(new Icon(sectionTitle, icons));
- }
- }
- sectionTitle = title;
- icons = new ArrayList<>();
- } else if (parser.getName().equals("item")) {
- String drawableName = parser.getAttributeValue(null, "drawable");
- String customName = parser.getAttributeValue(null, "name");
- int id = getResourceId(context, drawableName);
- if (id > 0) {
- icons.add(new Icon(drawableName, customName, id));
- }
- }
- }
-
- eventType = parser.next();
- }
- count += icons.size();
- CandyBarMainActivity.sIconsCount = count;
- if (!CandyBarApplication.getConfiguration().isAutomaticIconsCountEnabled() &&
- CandyBarApplication.getConfiguration().getCustomIconsCount() == 0) {
- CandyBarApplication.getConfiguration().setCustomIconsCount(count);
- }
- if (icons.size() > 0) {
- sections.add(new Icon(sectionTitle, icons));
- }
- parser.close();
- return sections;
- }
-
- public static List getTabAllIcons() {
- List icons = new ArrayList<>();
- String[] categories = CandyBarApplication.getConfiguration().getCategoryForTabAllIcons();
-
- if (categories != null && categories.length > 0) {
- for (String category : categories) {
- for (Icon section : CandyBarMainActivity.sSections) {
- if (section.getTitle().equals(category)) {
- icons.addAll(section.getIcons());
- break;
- }
- }
- }
- } else {
- for (Icon section : CandyBarMainActivity.sSections) {
- icons.addAll(section.getIcons());
- }
- }
-
- Collections.sort(icons, Icon.TitleComparator);
- return icons;
- }
-
- public static void computeTitles(@NonNull Context context, List icons) {
- final boolean iconReplacer = context.getResources().getBoolean(R.bool.enable_icon_name_replacer);
- for (Icon icon : icons) {
- if (icon.getTitle() != null) {
- // Title is already computed, so continue
- continue;
- }
- if (icon.getCustomName() != null && !icon.getCustomName().equals("")) {
- icon.setTitle(icon.getCustomName());
- } else {
- icon.setTitle(replaceName(context, iconReplacer, icon.getDrawableName()));
- }
- }
- }
-
- public static String replaceName(@NonNull Context context, boolean iconReplacer, String name) {
- if (iconReplacer) {
- String[] replacer = context.getResources().getStringArray(R.array.icon_name_replacer);
- for (String replace : replacer) {
- String[] strings = replace.split(",");
- if (strings.length > 0)
- name = name.replace(strings[0], strings.length > 1 ? strings[1] : "");
- }
- }
- name = name.replaceAll("_", " ");
- name = name.trim().replaceAll("\\s+", " ");
- return capitalizeWord(name);
- }
-
- public static String capitalizeWord(String str) {
- String[] words = str.split("\\s");
- StringBuilder capitalizeWord = new StringBuilder();
- for (String w : words) {
- String first = w.substring(0, 1);
- String afterfirst = w.substring(1);
- capitalizeWord.append(first.toUpperCase()).append(afterfirst).append(" ");
- }
- return capitalizeWord.toString().trim();
- }
-
- public static void selectIcon(@NonNull Context context, int action, Icon icon) {
- if (action == IntentHelper.ICON_PICKER) {
- Glide.with(context)
- .asBitmap()
- .load("drawable://" + icon.getRes())
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .listener(new RequestListener() {
- public void handleResult(Bitmap resource) {
- Intent intent = new Intent();
- intent.putExtra("icon", resource);
- ((AppCompatActivity) context).setResult(resource != null ?
- Activity.RESULT_OK : Activity.RESULT_CANCELED, intent);
- ((AppCompatActivity) context).finish();
- }
-
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
- handleResult(null);
- return true;
- }
-
- @Override
- public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
- handleResult(resource);
- return true;
- }
- })
- .submit();
- } else if (action == IntentHelper.IMAGE_PICKER) {
-
- Glide.with(context)
- .asBitmap()
- .load("drawable://" + icon.getRes())
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .listener(new RequestListener() {
- private void handleResult(Bitmap bitmap) {
- Intent intent = new Intent();
- if (bitmap != null) {
- File file = new File(context.getCacheDir(), icon.getTitle() + ".png");
- FileOutputStream outStream;
- try {
- outStream = new FileOutputStream(file);
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
- outStream.flush();
- outStream.close();
-
- Uri uri = getUriFromFile(context, context.getPackageName(), file);
- if (uri == null) uri = Uri.fromFile(file);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setData(uri);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- } catch (Exception | OutOfMemoryError e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- intent.putExtra("return-data", false);
- }
- ((AppCompatActivity) context).setResult(bitmap != null ?
- Activity.RESULT_OK : Activity.RESULT_CANCELED, intent);
- ((AppCompatActivity) context).finish();
- }
-
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
- handleResult(null);
- return false;
- }
-
- @Override
- public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
- handleResult(resource);
- return true;
- }
- })
- .submit();
- } else {
- if (!context.getResources().getBoolean(R.bool.show_icon_name)) {
- // It means the title of icon is not yet computed, so compute it
- IconsHelper.computeTitles(context, Collections.singletonList(icon));
- }
-
- IconPreviewFragment.showIconPreview(((AppCompatActivity) context)
- .getSupportFragmentManager(),
- icon.getTitle(), icon.getRes(), icon.getDrawableName());
- }
- }
-
- @Nullable
- public static String saveIcon(List files, File directory, Drawable drawable, String name) {
- String fileName = name + ".png";
- File file = new File(directory, fileName);
- try {
- Thread.sleep(2);
- Bitmap bitmap = getRightIcon(drawable);
-
- if (files.contains(file.toString())) {
- fileName = fileName.replace(".png", "_" + System.currentTimeMillis() + ".png");
- file = new File(directory, fileName);
-
- LogUtil.e("Duplicate File name, Renamed: " + fileName);
- }
-
- FileOutputStream outStream = new FileOutputStream(file);
- assert bitmap != null;
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
- outStream.flush();
- outStream.close();
- return directory.toString() + "/" + fileName;
- } catch (Exception | OutOfMemoryError e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return null;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/IntentHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/IntentHelper.java
deleted file mode 100644
index 91fe6b9..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/IntentHelper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Intent;
-
-import androidx.annotation.Nullable;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IntentHelper {
-
- public static final int ACTION_DEFAULT = 0;
- public static final int ICON_PICKER = 1;
- public static final int IMAGE_PICKER = 2;
- public static final int WALLPAPER_PICKER = 3;
-
- public static int sAction = ACTION_DEFAULT;
-
- private static final String ACTION_ADW_PICK_ICON = "org.adw.launcher.icons.ACTION_PICK_ICON";
- private static final String ACTION_TURBO_PICK_ICON = "com.phonemetra.turbo.launcher.icons.ACTION_PICK_ICON";
- private static final String ACTION_LAWNCHAIR_ICONPACK = "ch.deletescape.lawnchair.ICONPACK";
- private static final String ACTION_NOVA_LAUNCHER = "com.novalauncher.THEME";
- private static final String ACTION_ONEPLUS_PICK_ICON = "net.oneplus.launcher.icons.ACTION_PICK_ICON";
- private static final String ACTION_PLUS_HOME = "jp.co.a_tm.android.launcher.icons.ACTION_PICK_ICON";
-
- public static int getAction(@Nullable Intent intent) {
- if (intent == null) return ACTION_DEFAULT;
- String action = intent.getAction();
- if (action != null) {
- switch (action) {
- case ACTION_ADW_PICK_ICON:
- case ACTION_TURBO_PICK_ICON:
- case ACTION_LAWNCHAIR_ICONPACK:
- case ACTION_NOVA_LAUNCHER:
- case ACTION_ONEPLUS_PICK_ICON:
- case ACTION_PLUS_HOME:
- return ICON_PICKER;
- case Intent.ACTION_PICK:
- case Intent.ACTION_GET_CONTENT:
- return IMAGE_PICKER;
- case Intent.ACTION_SET_WALLPAPER:
- return WALLPAPER_PICKER;
- default:
- return ACTION_DEFAULT;
- }
- }
-
- return ACTION_DEFAULT;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/JsonHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/JsonHelper.java
deleted file mode 100644
index aa11894..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/JsonHelper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package candybar.lib.helpers;
-
-import android.annotation.SuppressLint;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.bluelinelabs.logansquare.LoganSquare;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.utils.JsonStructure;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class JsonHelper {
-
- @SuppressLint("Raw")
- @Nullable
- public static List> parseList(@NonNull InputStream stream) {
- List> list = null;
- JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();
-
- try {
- if (jsonStructure.getArrayName() == null) {
- list = LoganSquare.parseList(stream, Map.class);
- } else {
- Map map = LoganSquare.parseMap(stream, List.class);
- list = map.get(jsonStructure.getArrayName());
- }
- } catch (IOException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return list;
- }
-
- @Nullable
- public static Wallpaper getWallpaper(@NonNull Object object) {
- if (object instanceof Map) {
- JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();
- Map, ?> map = (Map, ?>) object;
- return Wallpaper.Builder()
- .name((String) map.get(jsonStructure.getName()))
- .author(getAuthor(map))
- .url((String) map.get(jsonStructure.getUrl()))
- .thumbUrl(getThumbUrl(map))
- .build();
- }
- return null;
- }
-
- public static String getThumbUrl(@NonNull Map, ?> map) {
- JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();
- String url = (String) map.get(jsonStructure.getUrl());
- if (jsonStructure.getThumbUrl() == null) return url;
- String[] thumbUrlSelectors = {"thumb", "thumbnail", "thumbUrl", "url-thumb", "urlThumb"};
-
- String thumbUrl = (String) map.get(jsonStructure.getThumbUrl());
- for (String selector : thumbUrlSelectors) {
- if (thumbUrl == null) thumbUrl = (String) map.get(selector);
- }
- if (thumbUrl == null) return url;
- return thumbUrl;
- }
-
- private static String getAuthor(@NonNull Map, ?> map) {
- JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();
- String defaultAuthorName = "";
-
- String authorName = (String) map.get(jsonStructure.getAuthor());
- if (authorName == null) return defaultAuthorName;
- return authorName;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/LauncherHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/LauncherHelper.java
deleted file mode 100644
index cf40827..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/LauncherHelper.java
+++ /dev/null
@@ -1,620 +0,0 @@
-package candybar.lib.helpers;
-
-import android.annotation.SuppressLint;
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import candybar.lib.R;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class LauncherHelper {
-
- private static final String thirdPartyHelperURL = "https://play.google.com/store/apps/details?id=rk.android.app.shortcutmaker";
-
- private enum Launcher {
- UNKNOWN, ACTION, ADW, APEX, ATOM, AVIATE, CMTHEME, GO, HOLO, HOLOHD, LAWNCHAIR,
- LGHOME, LGHOME3, LUCID, MINI, NEXT, NOVA, PIXEL, SMART, SOLO, ZENUI, NOUGAT, M,
- ZERO, V, ABC, EVIE, POCO, POSIDON, MICROSOFT, FLICK, BLACKBERRY, SQUARE, NIAGARA,
- HYPERION, OMEGA
- }
-
- private static Launcher getLauncher(String packageName) {
- if (packageName == null) return Launcher.UNKNOWN;
- switch (packageName) {
- case "com.actionlauncher.playstore":
- case "com.chrislacy.actionlauncher.pro":
- return Launcher.ACTION;
- case "org.adw.launcher":
- case "org.adwfreak.launcher":
- return Launcher.ADW;
- case "com.anddoes.launcher":
- case "com.anddoes.launcher.pro":
- return Launcher.APEX;
- case "com.dlto.atom.launcher":
- return Launcher.ATOM;
- case "com.tul.aviate":
- return Launcher.AVIATE;
- case "org.cyanogenmod.theme.chooser":
- return Launcher.CMTHEME;
- case "com.gau.go.launcherex":
- return Launcher.GO;
- case "com.mobint.hololauncher":
- return Launcher.HOLO;
- case "com.mobint.hololauncher.hd":
- return Launcher.HOLOHD;
- case "com.lge.launcher2":
- return Launcher.LGHOME;
- case "com.lge.launcher3":
- return Launcher.LGHOME3;
- case "ch.deletescape.lawnchair.ci":
- case "ch.deletescape.lawnchair.plah":
- return Launcher.LAWNCHAIR;
- case "com.powerpoint45.launcher":
- return Launcher.LUCID;
- case "com.jiubang.go.mini.launcher":
- return Launcher.MINI;
- case "bitpit.launcher":
- return Launcher.NIAGARA;
- case "com.gtp.nextlauncher":
- case "com.gtp.nextlauncher.trial":
- return Launcher.NEXT;
- case "com.teslacoilsw.launcher":
- case "com.teslacoilsw.launcher.prime":
- return Launcher.NOVA;
- case "com.google.android.apps.nexuslauncher":
- return Launcher.PIXEL;
- case "ginlemon.flowerfree":
- case "ginlemon.flowerpro":
- case "ginlemon.flowerpro.special":
- return Launcher.SMART;
- case "home.solo.launcher.free":
- return Launcher.SOLO;
- case "com.ss.squarehome2":
- return Launcher.SQUARE;
- case "com.asus.launcher":
- return Launcher.ZENUI;
- case "me.craftsapp.nlauncher":
- return Launcher.NOUGAT;
- case "com.uprui.launcher.marshmallow":
- return Launcher.M;
- case "com.zeroteam.zerolauncher":
- return Launcher.ZERO;
- case "com.vivid.launcher":
- return Launcher.V;
- case "com.abclauncher.launcher":
- return Launcher.ABC;
- case "is.shortcut":
- return Launcher.EVIE;
- case "com.mi.android.globallauncher":
- return Launcher.POCO;
- case "posidon.launcher":
- return Launcher.POSIDON;
- case "com.microsoft.launcher":
- return Launcher.MICROSOFT;
- case "com.universallauncher.universallauncher":
- return Launcher.FLICK;
- case "com.blackberry.blackberrylauncher":
- return Launcher.BLACKBERRY;
- case "projekt.launcher":
- return Launcher.HYPERION;
- case "com.saggitt.omega":
- case "com.saggitt.omega.OmegaLauncher":
- return Launcher.OMEGA;
- default:
- return Launcher.UNKNOWN;
- }
- }
-
- public static void apply(@NonNull Context context, String packageName, String launcherName) {
- applyLauncher(context, packageName, launcherName, getLauncher(packageName));
- }
-
- private static void applyLauncher(@NonNull Context context, String launcherPackage, String launcherName, Launcher launcher) {
- switch (launcher) {
- case ABC:
- try {
- /*
- * Just want to let anyone who is going to copy
- * It's not easy searching for this
- * I will be grateful if you take this with a proper credit
- * Thank you
- */
- final Intent abc = context.getPackageManager().getLaunchIntentForPackage(
- "com.abclauncher.launcher");
- final Intent abc1 = new Intent("com.abclauncher.launcher.themes.themeaction");
- abc1.putExtra("theme_package_name", context.getPackageName());
- abc.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(abc1);
- context.startActivity(abc);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case ACTION:
- try {
- final Intent action = context.getPackageManager().getLaunchIntentForPackage(
- launcherPackage);
- action.putExtra("apply_icon_pack", context.getPackageName());
- action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(action);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case ADW:
- try {
- final Intent adw = new Intent("org.adw.launcher.SET_THEME");
- adw.putExtra("org.adw.launcher.theme.NAME", context.getPackageName());
- adw.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(adw);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case APEX:
- try {
- final Intent apex = new Intent("com.anddoes.launcher.SET_THEME");
- apex.putExtra("com.anddoes.launcher.THEME_PACKAGE_NAME", context.getPackageName());
- apex.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(apex);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case ATOM:
- try {
- final Intent atom = new Intent("com.dlto.atom.launcher.intent.action.ACTION_VIEW_THEME_SETTINGS");
- atom.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- atom.putExtra("packageName", context.getPackageName());
- context.startActivity(atom);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case AVIATE:
- try {
- final Intent aviate = new Intent("com.tul.aviate.SET_THEME");
- aviate.putExtra("THEME_PACKAGE", context.getPackageName());
- aviate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(aviate);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case BLACKBERRY:
- applyManual(context, launcherPackage, launcherName, "com.blackberry.blackberrylauncher.MainActivity");
- break;
- case CMTHEME:
- try {
- final Intent cmtheme = new Intent("android.intent.action.MAIN");
- cmtheme.setComponent(new ComponentName(launcherPackage,
- "org.cyanogenmod.theme.chooser.ChooserActivity"));
- cmtheme.putExtra("pkgName", context.getPackageName());
- context.startActivity(cmtheme);
- } catch (ActivityNotFoundException | NullPointerException e) {
- Toast.makeText(context, R.string.apply_cmtheme_not_available,
- Toast.LENGTH_LONG).show();
- } catch (SecurityException | IllegalArgumentException e) {
- Toast.makeText(context, R.string.apply_cmtheme_failed,
- Toast.LENGTH_LONG).show();
- }
- break;
- case EVIE:
- applyEvie(context, launcherPackage, launcherName);
- break;
- case FLICK:
- try {
- final Intent flick = context.getPackageManager().getLaunchIntentForPackage("com.universallauncher.universallauncher");
- final Intent flickAction = new Intent("com.universallauncher.universallauncher.FLICK_ICON_PACK_APPLIER");
- flickAction.putExtra("com.universallauncher.universallauncher.ICON_THEME_PACKAGE", context.getPackageName());
- flickAction.setComponent(new ComponentName("com.universallauncher.universallauncher", "com.android.launcher3.icon.ApplyIconPack"));
- flick.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(flickAction);
- context.startActivity(flick);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case GO:
- try {
- final Intent goex = context.getPackageManager().getLaunchIntentForPackage(
- "com.gau.go.launcherex");
- final Intent go = new Intent("com.gau.go.launcherex.MyThemes.mythemeaction");
- go.putExtra("type", 1);
- go.putExtra("pkgname", context.getPackageName());
- goex.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(go);
- context.startActivity(goex);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case HOLO:
- case HOLOHD:
- applyManual(context, launcherPackage, launcherName, "com.mobint.hololauncher.SettingsActivity");
- break;
- case HYPERION:
- applyManual(context, launcherPackage, launcherName, "projekt.launcher.activities.SettingsActivity");
- break;
- case LAWNCHAIR:
- try {
- final Intent lawnchair = new Intent("ch.deletescape.lawnchair.APPLY_ICONS", null);
- lawnchair.putExtra("packageName", context.getPackageName());
- context.startActivity(lawnchair);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case LGHOME:
- case LGHOME3:
- launcherIncompatible(context, launcherName);
- break;
- case LUCID:
- try {
- final Intent lucid = new Intent("com.powerpoint45.action.APPLY_THEME", null);
- lucid.putExtra("icontheme", context.getPackageName());
- context.startActivity(lucid);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case MICROSOFT:
- applyManual(context, launcherPackage, launcherName, null);
- break;
- case MINI:
- applyManual(context, launcherPackage, launcherName,
- "com.jiubang.go.mini.launcher.setting.MiniLauncherSettingActivity");
- break;
- case NIAGARA:
- try {
- final Intent niagara = new Intent("bitpit.launcher.APPLY_ICONS");
- niagara.putExtra("packageName", context.getPackageName());
- context.startActivity(niagara);
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case NEXT:
- try {
- Intent next = context.getPackageManager().getLaunchIntentForPackage("com.gtp.nextlauncher");
- if (next == null) {
- next = context.getPackageManager().getLaunchIntentForPackage("com.gtp.nextlauncher.trial");
- }
- final Intent next2 = new Intent("com.gau.go.launcherex.MyThemes.mythemeaction");
- next2.putExtra("type", 1);
- next2.putExtra("pkgname", context.getPackageName());
- next.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(next2);
- context.startActivity(next);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case NOVA:
- try {
- final Intent nova = new Intent("com.teslacoilsw.launcher.APPLY_ICON_THEME");
- nova.setPackage("com.teslacoilsw.launcher");
- nova.putExtra("com.teslacoilsw.launcher.extra.ICON_THEME_TYPE", "GO");
- nova.putExtra("com.teslacoilsw.launcher.extra.ICON_THEME_PACKAGE", context.getPackageName());
- nova.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(nova);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case PIXEL:
- launcherIncompatible(context, launcherName);
- break;
- case POCO:
- applyManual(context, launcherPackage, launcherName, "com.miui.home.settings.HomeSettingsActivity");
- break;
- case POSIDON:
- try {
- Intent posidon = new Intent(Intent.ACTION_MAIN);
- posidon.setComponent(new ComponentName("posidon.launcher", "posidon.launcher.external.ApplyIcons"));
- posidon.putExtra("iconpack", context.getPackageName());
- posidon.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(posidon);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case SMART:
- try {
- final Intent smart = new Intent("ginlemon.smartlauncher.setGSLTHEME");
- smart.putExtra("package", context.getPackageName());
- smart.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(smart);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case SOLO:
- try {
- final Intent solo = context.getPackageManager().getLaunchIntentForPackage(
- "home.solo.launcher.free");
- final Intent soloAction = new Intent("home.solo.launcher.free.APPLY_THEME");
- soloAction.putExtra("EXTRA_THEMENAME", context.getResources().getString(
- R.string.app_name));
- soloAction.putExtra("EXTRA_PACKAGENAME", context.getPackageName());
- solo.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(soloAction);
- context.startActivity(solo);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case SQUARE:
- try {
- final Intent square = new Intent("com.ss.squarehome2.ACTION_APPLY_ICONPACK");
- square.setComponent(ComponentName.unflattenFromString("com.ss.squarehome2/.ApplyThemeActivity"));
- square.putExtra("com.ss.squarehome2.EXTRA_ICONPACK", context.getPackageName());
- context.startActivity(square);
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case OMEGA:
- try {
- final Intent omega = new Intent("com.saggitt.omega.APPLY_ICONS", null);
- omega.putExtra("packageName", context.getPackageName());
- context.startActivity(omega);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case NOUGAT:
- try {
- /*
- * Just want to let anyone who is going to copy
- * It's not easy searching for this
- * I will be grateful if you take this with a proper credit
- * Thank you
- */
- final Intent nougat = new Intent("me.craftsapp.nlauncher");
- nougat.setAction("me.craftsapp.nlauncher.SET_THEME");
- nougat.putExtra("me.craftsapp.nlauncher.theme.NAME", context.getPackageName());
- nougat.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(nougat);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case M:
- try {
- /*
- * Just want to let anyone who is going to copy
- * It's not easy searching for this
- * I will be grateful if you take this with a proper credit
- * Thank you
- */
- final Intent m = new Intent("com.uprui.launcher.marshmallow");
- m.setAction("com.uprui.launcher.marshmallow.SET_THEME");
- m.putExtra("com.uprui.launcher.marshmallow.theme.NAME", context.getPackageName());
- m.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(m);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case ZENUI:
- try {
- final Intent asus = new Intent("com.asus.launcher");
- asus.setAction("com.asus.launcher.intent.action.APPLY_ICONPACK");
- asus.addCategory(Intent.CATEGORY_DEFAULT);
- asus.putExtra("com.asus.launcher.iconpack.PACKAGE_NAME", context.getPackageName());
- asus.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(asus);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case ZERO:
- try {
- /*
- * Just want to let anyone who is going to copy
- * It's not easy searching for this
- * I will be grateful if you take this with a proper credit
- * Thank you
- */
- final Intent zero = context.getPackageManager().getLaunchIntentForPackage(
- "com.zeroteam.zerolauncher");
- final Intent zero1 = new Intent("com.zeroteam.zerolauncher.MyThemes.mythemeaction");
- zero1.putExtra("type", 1);
- zero1.putExtra("pkgname", context.getPackageName());
- zero.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(zero1);
- context.startActivity(zero);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- case V:
- try {
- /*
- * Just want to let anyone who is going to copy
- * It's not easy searching for this
- * I will be grateful if you take this with a proper credit
- * Thank you
- */
- final Intent v = context.getPackageManager().getLaunchIntentForPackage(
- "com.vivid.launcher");
- final Intent v1 = new Intent("com.vivid.launcher.MyThemes.mythemeaction");
- v1.putExtra("type", 1);
- v1.putExtra("pkgname", context.getPackageName());
- v.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.sendBroadcast(v1);
- context.startActivity(v);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- break;
- }
- }
-
- @SuppressLint("StringFormatInvalid")
- private static void applyManual(Context context, String launcherPackage, String launcherName, String activity) {
- if (isInstalled(context, launcherPackage)) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(launcherName)
- .content(context.getResources().getString(R.string.apply_manual,
- launcherName,
- context.getResources().getString(R.string.app_name)))
- .positiveText(android.R.string.ok)
- .onPositive((dialog, which) -> {
- if (activity == null) return;
- try {
- final Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setComponent(new ComponentName(launcherPackage,
- activity));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- } catch (SecurityException | IllegalArgumentException e) {
- Toast.makeText(context, context.getResources().getString(
- R.string.apply_launch_failed, launcherName),
- Toast.LENGTH_LONG).show();
- }
- })
- .negativeText(android.R.string.cancel)
- .show();
- } else {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- }
-
- private static boolean isInstalled(Context context, String packageName) {
- PackageManager packageManager = context.getPackageManager();
- boolean found = true;
- try {
- packageManager.getPackageInfo(packageName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- found = false;
- }
- return found;
- }
-
- @SuppressLint("StringFormatInvalid")
- private static void applyEvie(Context context, String launcherPackage, String launcherName) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(launcherName)
- .content(context.getResources().getString(R.string.apply_manual,
- launcherName,
- context.getResources().getString(R.string.app_name)) + "\n\n" +
- context.getResources().getString(R.string.apply_manual_evie,
- context.getResources().getString(R.string.app_name)))
- .positiveText(android.R.string.ok)
- .onPositive((dialog, which) -> {
- try {
- final Intent intent = context.getPackageManager().getLaunchIntentForPackage(launcherPackage);
- intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- context.startActivity(intent);
- ((AppCompatActivity) context).finish();
- } catch (ActivityNotFoundException | NullPointerException e) {
- openGooglePlay(context, launcherPackage, launcherName);
- }
- })
- .negativeText(android.R.string.cancel)
- .show();
- }
-
- private static void launcherIncompatible(Context context, String launcherName) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(launcherName)
- .content(R.string.apply_launcher_incompatible, launcherName, launcherName)
- .positiveText(android.R.string.yes)
- .onPositive((dialog, which) -> {
- try {
- Intent store = new Intent(Intent.ACTION_VIEW, Uri.parse(thirdPartyHelperURL));
- context.startActivity(store);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(context, context.getResources().getString(
- R.string.no_browser), Toast.LENGTH_LONG).show();
- }
- })
- .negativeText(android.R.string.cancel)
- .show();
- }
-
- private static void notInstalledError(Context context, String launcherName) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(launcherName)
- .content(R.string.apply_launcher_not_installable, launcherName)
- .positiveText(context.getResources().getString(R.string.close))
- .show();
- }
-
- private static void openGooglePlay(Context context, String packageName, String launcherName) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(launcherName)
- .content(R.string.apply_launcher_not_installed, launcherName)
- .positiveText(context.getResources().getString(R.string.install))
- .onPositive((dialog, which) -> {
- try {
- Intent store = new Intent(Intent.ACTION_VIEW, Uri.parse(
- "https://play.google.com/store/apps/details?id=" + packageName));
- context.startActivity(store);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(context, context.getResources().getString(
- R.string.no_browser), Toast.LENGTH_LONG).show();
- }
- })
- .negativeText(android.R.string.cancel)
- .show();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/LocaleHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/LocaleHelper.java
deleted file mode 100644
index 600d7e6..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/LocaleHelper.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.os.Build;
-import android.os.LocaleList;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.items.Language;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class LocaleHelper {
-
- public static void setLocale(@NonNull Context context) {
- Locale locale = Preferences.get(context).getCurrentLocale();
- Locale.setDefault(locale);
-
- Configuration configuration = context.getResources().getConfiguration();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- LocaleList.setDefault(new LocaleList(locale));
- configuration.setLocales(new LocaleList(locale));
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- configuration.setLocale(locale);
- } else {
- configuration.locale = locale;
- }
-
- //Todo:
- // Find out a solution to use context.createConfigurationContext(configuration);
- // It breaks onConfigurationChanged()
- // Still can't find a way to fix that
- // No other options, better use deprecated code for now
- context.getResources().updateConfiguration(configuration, context.getResources().getDisplayMetrics());
- }
-
- public static List getAvailableLanguages(@NonNull Context context) {
- List languages = new ArrayList<>();
- String[] names = context.getResources().getStringArray(R.array.languages_name);
- String[] codes = context.getResources().getStringArray(R.array.languages_code);
-
- for (int i = 0; i < names.length; i++) {
- Language language = new Language(names[i], getLocale(codes[i]));
- languages.add(language);
- }
- return languages;
- }
-
- public static Language getCurrentLanguage(@NonNull Context context) {
- List languages = getAvailableLanguages(context);
- Locale locale = Preferences.get(context).getCurrentLocale();
-
- for (Language language : languages) {
- Locale l = language.getLocale();
- if (locale.toString().equals(l.toString())) {
- return language;
- }
- }
- return new Language("English", new Locale("en", "US"));
- }
-
- public static Locale getLocale(String language) {
- String[] codes = language.split("_");
- if (codes.length == 2) {
- return new Locale(codes[0], codes[1]);
- }
- return Locale.getDefault();
- }
-
- @Nullable
- public static String getOtherAppLocaleName(@NonNull Context context, @NonNull Locale locale, @NonNull String componentNameStr) {
- try {
- int slashIndex = componentNameStr.indexOf("/");
- String packageName = componentNameStr.substring(0, slashIndex);
- String activityName = componentNameStr.substring(slashIndex + 1);
- ComponentName componentName = new ComponentName(packageName, activityName);
-
- PackageManager packageManager = context.getPackageManager();
- ActivityInfo info = packageManager.getActivityInfo(componentName, PackageManager.GET_META_DATA);
-
- Resources res = packageManager.getResourcesForActivity(componentName);
- Configuration configuration = new Configuration();
-
- configuration.locale = locale;
- res.updateConfiguration(configuration, context.getResources().getDisplayMetrics());
- return info.loadLabel(packageManager).toString();
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return null;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/MuzeiHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/MuzeiHelper.java
deleted file mode 100644
index d15e25f..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/MuzeiHelper.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.Random;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.utils.JsonStructure;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class MuzeiHelper {
-
- @Nullable
- public static Wallpaper getRandomWallpaper(@NonNull Context context) throws Exception {
- if (Database.get(context).getWallpapersCount() == 0) {
- URL url = new URL(context.getString(R.string.wallpaper_json));
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setConnectTimeout(15000);
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- InputStream stream = new BufferedInputStream(connection.getInputStream());
- List> list = JsonHelper.parseList(stream);
- if (list == null) {
- JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();
- LogUtil.e("Muzei: Json error: wallpaper array with name "
- + jsonStructure.getArrayName() + " not found");
- return null;
- }
-
- if (list.size() > 0) {
- int position = getRandomInt(list.size());
- Wallpaper wallpaper = JsonHelper.getWallpaper(list.get(position));
- if (wallpaper != null) {
- if (wallpaper.getName() == null) {
- wallpaper.setName("Wallpaper");
- }
- }
- return wallpaper;
- }
- }
- return null;
- } else {
- return Database.get(context).getRandomWallpaper();
- }
- }
-
-
- private static int getRandomInt(int size) {
- try {
- Random random = new Random();
- return random.nextInt(size);
- } catch (Exception e) {
- return 0;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/NavigationViewHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/NavigationViewHelper.java
deleted file mode 100644
index 3fcb309..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/NavigationViewHelper.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.view.MenuItem;
-
-import com.google.android.material.navigation.NavigationView;
-
-import candybar.lib.R;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class NavigationViewHelper {
-
- public static void initApply(NavigationView navigationView) {
- Context context = ContextHelper.getBaseContext(navigationView);
-
- MenuItem menuItem = navigationView.getMenu().findItem(R.id.navigation_view_apply);
- if (menuItem == null) return;
-
- menuItem.setVisible(context.getResources().getBoolean(R.bool.enable_apply));
- }
-
- public static void initIconRequest(NavigationView navigationView) {
- Context context = ContextHelper.getBaseContext(navigationView);
-
- MenuItem menuItem = navigationView.getMenu().findItem(R.id.navigation_view_request);
- if (menuItem == null) return;
-
- menuItem.setVisible(context.getResources().getBoolean(R.bool.enable_icon_request) ||
- Preferences.get(context).isPremiumRequestEnabled());
- }
-
- public static void initWallpapers(NavigationView navigationView) {
- Context context = ContextHelper.getBaseContext(navigationView);
-
- MenuItem menuItem = navigationView.getMenu().findItem(R.id.navigation_view_wallpapers);
- if (menuItem == null) return;
-
- if (WallpaperHelper.getWallpaperType(context) == WallpaperHelper.UNKNOWN)
- menuItem.setVisible(false);
- }
-
- public static void initPresets(NavigationView navigationView) {
- Context context = ContextHelper.getBaseContext(navigationView);
-
- MenuItem menuItem = navigationView.getMenu().findItem(R.id.navigation_view_presets);
- if (menuItem == null) return;
-
- if (PresetsHelper.getPresetsCount(context) == 0) {
- menuItem.setVisible(false);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/PlayStoreCheckHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/PlayStoreCheckHelper.java
deleted file mode 100644
index ed9314b..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/PlayStoreCheckHelper.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import candybar.lib.R;
-
-public class PlayStoreCheckHelper {
-
- private final Context mContext;
- private final Runnable mCallback;
-
- public PlayStoreCheckHelper(Context context, Runnable callback) {
- mContext = context;
- mCallback = callback;
- }
-
- public void run() {
- PackageManager pm = mContext.getPackageManager();
- String installerPackage = pm.getInstallerPackageName(mContext.getPackageName());
- boolean fromPlayStore = installerPackage != null && installerPackage.contentEquals("com.android.vending");
-
- MaterialDialog.Builder dialog = new MaterialDialog.Builder(mContext)
- .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
- .title(R.string.playstore_check)
- .content(fromPlayStore ? R.string.playstore_check_success : R.string.playstore_check_failed)
- .positiveText(R.string.close)
- .cancelable(false)
- .canceledOnTouchOutside(false);
-
- if (fromPlayStore) {
- dialog.onPositive((dialog1, which) -> {
- dialog1.dismiss();
- mCallback.run();
- });
- } else {
- dialog.onPositive((dial, which) -> ((AppCompatActivity) mContext).finish());
- }
-
- dialog.show();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/PresetsHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/PresetsHelper.java
deleted file mode 100644
index 5fabf09..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/PresetsHelper.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.util.Log;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-public class PresetsHelper {
-
- public static int getPresetsCount(Context context) {
- try {
- String[] komponents = context.getAssets().list("komponents");
- String[] lockscreens = context.getAssets().list("lockscreens");
- String[] wallpapers = context.getAssets().list("wallpapers");
- String[] widgets = context.getAssets().list("widgets");
-
- return komponents.length + lockscreens.length + wallpapers.length + widgets.length;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return 0;
- }
- }
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/ReportBugsHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/ReportBugsHelper.java
deleted file mode 100644
index 0f427ef..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/ReportBugsHelper.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.util.Log;
-import android.widget.EditText;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.afollestad.materialdialogs.DialogAction;
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.material.textfield.TextInputLayout;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.items.Icon;
-import candybar.lib.tasks.ReportBugsTask;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ReportBugsHelper {
-
- public static final String REPORT_BUGS = "reportbugs.zip";
- private static final String BROKEN_APPFILTER = "broken_appfilter.xml";
- private static final String BROKEN_DRAWABLES = "broken_drawables.xml";
- private static final String ACTIVITY_LIST = "activity_list.xml";
- private static final String CRASHLOG = "crashlog.txt";
- private static String UTF8 = "UTF8";
-
- public static void prepareReportBugs(@NonNull Context context) {
- MaterialDialog dialog = new MaterialDialog.Builder(context)
- .customView(R.layout.dialog_report_bugs, true)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .positiveText(R.string.report_bugs_send)
- .negativeText(R.string.close)
- .build();
-
- EditText editText = (EditText) dialog.findViewById(R.id.input_desc);
- TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout);
-
- dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
- if (editText.getText().length() > 0) {
- inputLayout.setErrorEnabled(false);
- new ReportBugsTask(context, editText.getText().toString()).executeOnThreadPool();
- dialog.dismiss();
- return;
- }
-
- inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty));
- });
- dialog.show();
- }
-
- @Nullable
- public static File buildBrokenAppFilter(@NonNull Context context) {
- try {
- HashMap activities = RequestHelper.getAppFilter(context, RequestHelper.Key.ACTIVITY);
- File brokenAppFilter = new File(context.getCacheDir(), BROKEN_APPFILTER);
- Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(brokenAppFilter), UTF8));
-
- boolean first = true;
- for (Map.Entry entry : activities.entrySet()) {
- if (first) {
- first = false;
- writer.append("")
- .append("\r\n").append("")
- .append("\r\n\r\n\r\n");
- }
-
- int drawable = context.getResources().getIdentifier(
- entry.getValue(), "drawable", context.getPackageName());
- if (drawable == 0) {
- writer.append("Activity: ").append(entry.getKey())
- .append("\r\n")
- .append("Drawable: ").append(entry.getValue()).append(".png")
- .append("\r\n\r\n");
- }
- }
-
- writer.flush();
- writer.close();
- return brokenAppFilter;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return null;
- }
- }
-
- @Nullable
- public static File buildBrokenDrawables(@NonNull Context context) {
- try {
- HashMap drawables = RequestHelper.getAppFilter(context, RequestHelper.Key.DRAWABLE);
- List iconList = IconsHelper.getIconsList(context);
- List icons = new ArrayList<>();
-
- File brokenDrawables = new File(context.getCacheDir(), BROKEN_DRAWABLES);
- Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(brokenDrawables), UTF8));
-
- for (Icon icon : iconList) {
- if (CandyBarApplication.getConfiguration().isShowTabAllIcons()) {
- if (!icon.getTitle().equals(CandyBarApplication.getConfiguration().getTabAllIconsTitle())) {
- icons.addAll(icon.getIcons());
- }
- } else {
- icons.addAll(icon.getIcons());
- }
- }
-
- IconsHelper.computeTitles(context, icons);
-
- boolean first = true;
- for (Icon icon : icons) {
- if (first) {
- first = false;
- writer.append("")
- .append("\r\n").append("")
- .append("\r\n\r\n\r\n");
- }
-
- String drawable = drawables.get(icon.getTitle());
- if (drawable == null || drawable.length() == 0) {
- writer.append("Drawable: ").append(icon.getTitle()).append(".png")
- .append("\r\n\r\n");
- }
- }
-
- writer.flush();
- writer.close();
- return brokenDrawables;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return null;
- }
- }
-
- @Nullable
- public static File buildActivityList(@NonNull Context context) {
- try {
- File activityList = new File(context.getCacheDir(), ACTIVITY_LIST);
- Writer out = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(activityList), UTF8));
-
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
-
- List appList = context.getPackageManager().queryIntentActivities(
- intent, PackageManager.GET_RESOLVED_FILTER);
- try {
- Collections.sort(appList, new ResolveInfo.DisplayNameComparator(context.getPackageManager()));
- } catch (Exception ignored) {
- }
-
- boolean first = true;
- for (ResolveInfo app : appList) {
-
- if (first) {
- first = false;
- out.append("")
- .append("\r\n").append("")
- .append("\r\n\r\n\r\n");
- }
-
- String name = app.activityInfo.loadLabel(context.getPackageManager()).toString();
- String activity = app.activityInfo.packageName + "/" + app.activityInfo.name;
- out.append("");
- out.append("\r\n").append(activity);
- out.append("\r\n\r\n");
- }
-
- out.flush();
- out.close();
- return activityList;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return null;
- }
- }
-
- @Nullable
- public static File buildCrashLog(@NonNull Context context, @NonNull String stackTrace) {
- try {
- if (stackTrace.length() == 0) return null;
-
- File crashLog = new File(context.getCacheDir(), CRASHLOG);
- String deviceInfo = DeviceHelper.getDeviceInfoForCrashReport(context);
- Writer out = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(crashLog), UTF8));
- out.append(deviceInfo).append(stackTrace);
- out.flush();
- out.close();
- return crashLog;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return null;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/RequestHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/RequestHelper.java
deleted file mode 100644
index 56e803d..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/RequestHelper.java
+++ /dev/null
@@ -1,568 +0,0 @@
-package candybar.lib.helpers;
-
-import static candybar.lib.helpers.DrawableHelper.getReqIcon;
-import static candybar.lib.helpers.DrawableHelper.getRightIcon;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.graphics.Bitmap;
-import android.util.Base64;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.TimeHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.text.Normalizer;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.items.Request;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.listeners.RequestListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class RequestHelper {
-
- public static final String APPFILTER = "appfilter.xml";
- public static final String APPMAP = "appmap.xml";
- public static final String THEME_RESOURCES = "theme_resources.xml";
- public static final String ZIP = "icon_request.zip";
- public static final String REBUILD_ZIP = "rebuild_icon_request.zip";
-
- public static String getGeneratedZipName(@NonNull String baseName) {
- return baseName.substring(0, baseName.lastIndexOf(".")) + "_" + TimeHelper.getDateTime(
- new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss", Locale.ENGLISH)) + ".zip";
- }
-
- public static String fixNameForRequest(String name) {
- String normalized = Normalizer.normalize(name.toLowerCase(), Normalizer.Form.NFD);
-
- try {
- // This code causes crash on some android devices
- normalized = normalized.replaceAll("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+", "");
- } catch (Exception ignored) {
- }
-
- normalized = normalized
- .replaceAll("[.\"']", "")
- .replaceAll("[ \\[\\]{}()=!/\\\\,?°|<>;:#~+*-]", "_")
- .replaceAll("&", "_and_");
-
- if (Character.isDigit(normalized.charAt(0))) normalized = "_" + normalized;
- normalized = normalized.replaceAll("_+", "_");
-
- return normalized;
- }
-
- @Nullable
- public static File buildXml(@NonNull Context context, @NonNull List requests, @NonNull XmlType xmlType) {
- try {
- if (xmlType == XmlType.APPFILTER && !CandyBarApplication.getConfiguration().isGenerateAppFilter()) {
- return null;
- } else if (xmlType == XmlType.APPMAP && !CandyBarApplication.getConfiguration().isGenerateAppMap()) {
- return null;
- } else if (xmlType == XmlType.THEME_RESOURCES & !CandyBarApplication.getConfiguration().isGenerateThemeResources()) {
- return null;
- }
-
- File file = new File(context.getCacheDir().toString(), xmlType.getFileName());
- String UTF8 = "UTF8";
- Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(file), UTF8));
- writer.append(xmlType.getHeader()).append("\n\n");
-
- for (Request request : requests) {
- writer.append(xmlType.getContent(context, request));
- }
- writer.append(xmlType.getFooter());
- writer.flush();
- writer.close();
- return file;
- } catch (IOException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return null;
- }
-
- public static String buildJsonForArctic(@NonNull List requests) {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
-
- sb.append("{ \"components\": [\n");
- for (Request request : requests) {
- if (!isFirst) sb.append(",\n");
- sb.append(String.format("{ \"name\": \"%s\", \"pkg\": \"%s\", \"componentInfo\": \"%s\", \"drawable\": \"%s\" }",
- request.getName(),
- request.getPackageName(),
- request.getActivity(),
- fixNameForRequest(request.getName())));
- isFirst = false;
- }
- sb.append("]}");
-
- return sb.toString();
- }
-
- public static String buildJsonForMyAP(@NonNull Context context, @NonNull List requests) {
- StringBuilder sb = new StringBuilder();
- boolean isFirst = true;
-
- sb.append("{ \"projectUID\": \"ENTER UID\",");
- sb.append("\"icons\" : [");
- for (Request request : requests) {
- Bitmap appBitmap = getRightIcon(getReqIcon(context, request.getActivity()));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- assert appBitmap != null;
- appBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
- String base64Icon = Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
-
- if (!isFirst) sb.append(",\n");
- sb
- .append("\"name\": \"").append(request.getName()).append("\",")
- .append("\"packageName\": \"").append(request.getPackageName()).append("\",")
- .append("\"imageStr\": \"").append(base64Icon).append("\",")
- .append("\"activities\": [\"").append(request.getActivity()).append("\"]");
- isFirst = false;
- }
- sb.append("]}");
-
- return sb.toString();
- }
-
- public static String getRegularArcticApiKey(Context context) {
- String arcticApiKey = context.getResources().getString(R.string.regular_request_arctic_api_key);
- // Fallback to arctic_manager_api_key
- if (arcticApiKey.length() == 0)
- arcticApiKey = context.getResources().getString(R.string.arctic_manager_api_key);
-
- return arcticApiKey;
- }
-
- public static boolean isRegularArcticEnabled(Context context) {
- return context.getResources().getString(R.string.regular_request_method).length() > 0
- ? context.getResources().getString(R.string.regular_request_method).contentEquals("arctic")
- // Use fallback method to check if arctic is enabled
- : getRegularArcticApiKey(context).length() > 0;
- }
-
- public static String getPremiumArcticApiKey(Context context) {
- String arcticApiKey = context.getResources().getString(R.string.premium_request_arctic_api_key);
- // Fallback to regular request's api key
- if (arcticApiKey.length() == 0) arcticApiKey = getRegularArcticApiKey(context);
-
- return arcticApiKey;
- }
-
- public static boolean isPremiumArcticEnabled(Context context) {
- return context.getResources().getString(R.string.premium_request_method).length() > 0
- ? context.getResources().getString(R.string.premium_request_method).contentEquals("arctic")
- // Fallback to regular request's method
- : context.getResources().getString(R.string.regular_request_method).length() > 0
- ? context.getResources().getString(R.string.regular_request_method).contentEquals("arctic")
- // Use fallback method to check if arctic is enabled
- : getRegularArcticApiKey(context).length() > 0;
- }
-
- public static String sendArcticRequest(List requests, List iconFiles, File directory, String apiKey) {
- okhttp3.RequestBody okRequestBody = new okhttp3.MultipartBody.Builder()
- .setType(okhttp3.MultipartBody.FORM)
- .addFormDataPart("apps", buildJsonForArctic(requests))
- .addFormDataPart("archive", "icons.zip", okhttp3.RequestBody.create(
- Objects.requireNonNull(getZipFile(iconFiles, directory.toString(), "icons.zip")),
- okhttp3.MediaType.parse("application/zip")))
- .build();
-
- okhttp3.Request okRequest = new okhttp3.Request.Builder()
- .url("https://arcticmanager.com/v1/request")
- .addHeader("TokenID", apiKey)
- .addHeader("Accept", "application/json")
- .addHeader("User-Agent", "afollestad/icon-request")
- .post(okRequestBody)
- .build();
-
- okhttp3.OkHttpClient okHttpClient = new okhttp3.OkHttpClient();
-
- try {
- okhttp3.Response response = okHttpClient.newCall(okRequest).execute();
- boolean success = response.code() > 199 && response.code() < 300;
- if (!success) {
- JSONObject responseJson = new JSONObject(Objects.requireNonNull(response.body()).string());
- return responseJson.getString("error");
- }
- } catch (IOException | JSONException ignoredException) {
- LogUtil.d("ARCTIC_MANAGER: Error");
- return "";
- }
- return null;
- }
-
- public static File getZipFile(List files, String filepath, String filename) {
- // Modified from https://github.com/danimahardhika/android-helpers/blob/master/core/src/main/java/com/danimahardhika/android/helpers/core/FileHelper.java
- try {
- final int BUFFER = 2048;
- final File file = new File(filepath, filename);
- BufferedInputStream origin;
- FileOutputStream dest = new FileOutputStream(file);
- ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
- dest));
-
- byte[] data = new byte[BUFFER];
- for (int i = 0; i < files.size(); i++) {
- FileInputStream fi = new FileInputStream(files.get(i));
- origin = new BufferedInputStream(fi, BUFFER);
-
- ZipEntry entry = new ZipEntry(files.get(i).substring(
- files.get(i).lastIndexOf("/") + 1));
- out.putNextEntry(entry);
- int count;
-
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- origin.close();
- }
-
- out.close();
- return file;
- } catch (Exception ignored) {
- }
- return null;
- }
-
- @NonNull
- public static HashMap getAppFilter(@NonNull Context context, @NonNull Key key) {
- try {
- HashMap activities = new HashMap<>();
- XmlPullParser xpp = context.getResources().getXml(R.xml.appfilter);
-
- while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
- if (xpp.getEventType() == XmlPullParser.START_TAG) {
- if (xpp.getName().equals("item")) {
- String sKey = xpp.getAttributeValue(null, key.getKey());
- String sValue = xpp.getAttributeValue(null, key.getValue());
-
- if (sKey != null && sValue != null) {
- activities.put(
- sKey.replace("ComponentInfo{", "").replace("}", ""),
- sValue.replace("ComponentInfo{", "").replace("}", ""));
- } else {
- LogUtil.e("Appfilter Error\nKey: " + sKey + "\nValue: " + sValue);
- }
- }
- }
- xpp.next();
- }
- return activities;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- return new HashMap<>();
- }
-
- @NonNull
- public static List getMissingApps(@NonNull Context context) {
- List requests = new ArrayList<>();
- HashMap appFilter = getAppFilter(context, Key.ACTIVITY);
- PackageManager packageManager = context.getPackageManager();
-
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- List installedApps = packageManager.queryIntentActivities(
- intent, PackageManager.GET_RESOLVED_FILTER);
- CandyBarMainActivity.sInstalledAppsCount = installedApps.size();
-
- try {
- Collections.sort(installedApps,
- new ResolveInfo.DisplayNameComparator(packageManager));
- } catch (Exception ignored) {
- }
-
- for (ResolveInfo app : installedApps) {
- String packageName = app.activityInfo.packageName;
- String activity = packageName + "/" + app.activityInfo.name;
-
- String value = appFilter.get(activity);
-
- if (value == null) {
- String name = LocaleHelper.getOtherAppLocaleName(context, new Locale("en"), activity);
- if (name == null) {
- name = app.activityInfo.loadLabel(packageManager).toString();
- }
-
- boolean requested = Database.get(context).isRequested(activity);
- Request request = Request.Builder()
- .name(name)
- .packageName(app.activityInfo.packageName)
- .activity(activity)
- .requested(requested)
- .build();
-
- requests.add(request);
- }
- }
- return requests;
- }
-
- public static void showAlreadyRequestedDialog(@NonNull Context context) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.request_title)
- .content(R.string.request_requested)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void showIconRequestLimitDialog(@NonNull Context context) {
- boolean reset = context.getResources().getBoolean(R.bool.reset_icon_request_limit);
- int limit = context.getResources().getInteger(R.integer.icon_request_limit);
- String message = context.getResources().getString(R.string.request_limit, limit);
- message += " " + context.getResources().getString(R.string.request_used,
- Preferences.get(context).getRegularRequestUsed());
-
- if (Preferences.get(context).isPremiumRequestEnabled())
- message += " " + context.getResources().getString(R.string.request_limit_buy);
-
- if (reset)
- message += "\n\n" + context.getResources().getString(R.string.request_limit_reset);
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.request_title)
- .content(message)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void showPremiumRequestRequired(@NonNull Context context) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.request_title)
- .content(R.string.premium_request_required)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void showPremiumRequestLimitDialog(@NonNull Context context, int selected) {
- String message = context.getResources().getString(R.string.premium_request_limit,
- Preferences.get(context).getPremiumRequestCount());
- message += " " + context.getResources().getString(R.string.premium_request_limit1, selected);
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.premium_request)
- .content(message)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void showPremiumRequestStillAvailable(@NonNull Context context) {
- String message = context.getResources().getString(
- R.string.premium_request_already_purchased,
- Preferences.get(context).getPremiumRequestCount());
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.premium_request)
- .content(message)
- .positiveText(R.string.close)
- .show();
- }
-
- public static boolean isReadyToSendPremiumRequest(@NonNull Context context) {
- boolean isReady = Preferences.get(context).isConnectedToNetwork();
- if (!isReady) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.premium_request)
- .content(R.string.premium_request_no_internet)
- .positiveText(R.string.close)
- .show();
- }
- return isReady;
- }
-
- public static void showPremiumRequestConsumeFailed(@NonNull Context context) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.premium_request)
- .content(R.string.premium_request_consume_failed)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void showPremiumRequestExist(@NonNull Context context) {
- new MaterialDialog.Builder(context)
- .typeface(TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context))
- .title(R.string.premium_request)
- .content(R.string.premium_request_exist)
- .positiveText(R.string.close)
- .show();
- }
-
- public static void checkPiracyApp(@NonNull Context context) {
- boolean premiumRequest = context.getResources().getBoolean(R.bool.enable_premium_request);
- //Dashboard don't need to check piracy app if premium request is disabled
- if (!premiumRequest) {
- Preferences.get(context).setPremiumRequestEnabled(false);
- RequestListener listener = (RequestListener) context;
- return;
- }
-
- // Lucky Patcher and Freedom package name
- String[] strings = new String[]{
- "com.chelpus.lackypatch",
- "com.dimonvideo.luckypatcher",
- "com.forpda.lp",
- //"com.android.protips", This is not lucky patcher or freedom
- "com.android.vending.billing.InAppBillingService.LUCK",
- "com.android.vending.billing.InAppBillingService.LOCK",
- "cc.madkite.freedom",
- "com.android.vending.billing.InAppBillingService.LACK",
- "com.android.vending.billing.InAppBillingService.CLON",
- "com.android.vending.billing.InAppBillingService.CRAC",
- "com.android.vending.billing.InAppBillingService.COIN"
- };
-
- boolean isPiracyAppInstalled = false;
- for (String string : strings) {
- try {
- PackageInfo packageInfo = context.getPackageManager().getPackageInfo(
- string, PackageManager.GET_ACTIVITIES);
- if (packageInfo != null) {
- isPiracyAppInstalled = true;
- break;
- }
- } catch (Exception ignored) {
- }
- }
-
- Preferences.get(context).setPremiumRequestEnabled(!isPiracyAppInstalled);
-
- RequestListener listener = (RequestListener) context;
- }
-
- public enum XmlType {
- APPFILTER(RequestHelper.APPFILTER, "", ""),
- APPMAP(RequestHelper.APPMAP, "", ""),
- THEME_RESOURCES(RequestHelper.THEME_RESOURCES, "", "");
-
- private final String fileName;
- private final String header;
- private final String footer;
-
- XmlType(String fileName, String header, String footer) {
- this.fileName = fileName;
- this.header = header;
- this.footer = footer;
- }
-
- private String getFileName() {
- return fileName;
- }
-
- private String getHeader() {
- return header;
- }
-
- private String getFooter() {
- return footer;
- }
-
- private String getContent(@NonNull Context context, @NonNull Request request) {
- switch (this) {
- case APPFILTER:
- return "\t" +
- "\n" +
- "\t" + context.getString(R.string.appfilter_item)
- .replaceAll("\\{\\{component\\}\\}", request.getActivity())
- .replaceAll("\\{\\{drawable\\}\\}", fixNameForRequest(request.getName())) +
- "\n\n";
- case APPMAP:
- String packageName = "" + request.getPackageName() + "/";
- String className = request.getActivity().replaceFirst(packageName, "");
- return "\t" +
- "\n" +
- "\t" +
- "\n\n";
- case THEME_RESOURCES:
- return "\t" +
- "\n" +
- "\t" +
- "\n\n";
- default:
- return "";
- }
- }
- }
-
- public enum Key {
- ACTIVITY("component", "drawable"),
- DRAWABLE("drawable", "component");
-
- private final String key;
- private final String value;
-
- Key(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- private String getKey() {
- return key;
- }
-
- private String getValue() {
- return value;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/TapIntroHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/TapIntroHelper.java
deleted file mode 100644
index 2338633..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/TapIntroHelper.java
+++ /dev/null
@@ -1,553 +0,0 @@
-package candybar.lib.helpers;
-
-import static com.danimahardhika.android.helpers.core.UnitHelper.toDp;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
-import android.graphics.Typeface;
-import android.os.Build;
-import android.os.Handler;
-import android.util.Log;
-import android.view.View;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
-import androidx.core.content.ContextCompat;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.getkeepsafe.taptargetview.TapTarget;
-import com.getkeepsafe.taptargetview.TapTargetSequence;
-import com.getkeepsafe.taptargetview.TapTargetView;
-
-import candybar.lib.R;
-import candybar.lib.adapters.HomeAdapter;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class TapIntroHelper {
-
- @SuppressLint("StringFormatInvalid")
- public static void showHomeIntros(@NonNull Context context, @Nullable RecyclerView recyclerView,
- @Nullable StaggeredGridLayoutManager manager, int position) {
- if (Preferences.get(context).isTimeToShowHomeIntro()) {
- AppCompatActivity activity = (AppCompatActivity) context;
-
- Toolbar toolbar = activity.findViewById(R.id.toolbar);
-
- new Handler().postDelayed(() -> {
- try {
- int primary = ContextCompat.getColor(context, R.color.toolbarIcon);
- int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
-
- TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
- tapTargetSequence.continueOnCancel(true);
-
- Typeface title = TypefaceHelper.getMedium(context);
- //Todo:
- //Typeface description = TypefaceHelper.getRegular(context);
-
- if (toolbar != null) {
- TapTarget tapTarget = TapTarget.forToolbarNavigationIcon(toolbar,
- context.getResources().getString(R.string.tap_intro_home_navigation),
- context.getResources().getString(R.string.tap_intro_home_navigation_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //Todo:
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
-
- if (recyclerView != null) {
- HomeAdapter adapter = (HomeAdapter) recyclerView.getAdapter();
- if (adapter != null) {
- if (context.getResources().getBoolean(R.bool.enable_apply)) {
- if (position >= 0 && position < adapter.getItemCount()) {
- RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
- if (holder != null) {
- View view = holder.itemView;
- float targetRadius = toDp(context, view.getMeasuredWidth()) - 20f;
-
- String desc = context.getResources().getString(R.string.tap_intro_home_apply_desc,
- context.getResources().getString(R.string.app_name));
- TapTarget tapTarget = TapTarget.forView(view,
- context.getResources().getString(R.string.tap_intro_home_apply),
- desc)
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .targetRadius((int) targetRadius)
- .tintTarget(false)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
- }
- }
- }
- }
-
- tapTargetSequence.listener(new TapTargetSequence.Listener() {
- @Override
- public void onSequenceFinish() {
- Preferences.get(context).setTimeToShowHomeIntro(false);
- }
-
- @Override
- public void onSequenceStep(TapTarget tapTarget, boolean b) {
- if (manager != null) {
- if (position >= 0)
- manager.scrollToPosition(position);
- }
- }
-
- @Override
- public void onSequenceCanceled(TapTarget tapTarget) {
-
- }
- });
- tapTargetSequence.start();
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }, 100);
- }
- }
-
- public static void showIconsIntro(@NonNull Context context) {
- if (Preferences.get(context).isTimeToShowIconsIntro()) {
- AppCompatActivity activity = (AppCompatActivity) context;
-
- Toolbar toolbar = activity.findViewById(R.id.toolbar);
- if (toolbar == null) return;
-
- new Handler().postDelayed(() -> {
- try {
- int primary = ContextCompat.getColor(context, R.color.toolbarIcon);
- int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
-
- Typeface title = TypefaceHelper.getMedium(context);
-
- TapTarget tapTarget = TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search,
- context.getResources().getString(R.string.tap_intro_icons_search),
- context.getResources().getString(R.string.tap_intro_icons_search_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- TapTargetView.showFor(activity, tapTarget,
- new TapTargetView.Listener() {
-
- @Override
- public void onTargetDismissed(TapTargetView view, boolean userInitiated) {
- super.onTargetDismissed(view, userInitiated);
- Preferences.get(context).setTimeToShowIconsIntro(false);
- }
- });
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }, 100);
- }
- }
-
- public static void showRequestIntro(@NonNull Context context, @Nullable RecyclerView recyclerView) {
- if (Preferences.get(context).isTimeToShowRequestIntro()) {
- AppCompatActivity activity = (AppCompatActivity) context;
-
- int requestOrientation = context.getResources().getConfiguration().orientation ==
- Configuration.ORIENTATION_PORTRAIT ?
- ActivityInfo.SCREEN_ORIENTATION_PORTRAIT :
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
- activity.setRequestedOrientation(requestOrientation);
-
- Toolbar toolbar = activity.findViewById(R.id.toolbar);
-
- new Handler().postDelayed(() -> {
- try {
- int primary = ContextCompat.getColor(context, R.color.toolbarIcon);
- int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
-
- TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
- tapTargetSequence.continueOnCancel(true);
-
- Typeface title = TypefaceHelper.getMedium(context);
-
- if (recyclerView != null) {
- int position = 0;
- if (Preferences.get(context).isPremiumRequestEnabled())
- position += 1;
-
- if (recyclerView.getAdapter() != null) {
- if (position < recyclerView.getAdapter().getItemCount()) {
- RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
-
- if (holder != null) {
- View view = holder.itemView.findViewById(R.id.checkbox);
- if (view != null) {
- TapTarget tapTarget = TapTarget.forView(view,
- context.getResources().getString(R.string.tap_intro_request_select),
- context.getResources().getString(R.string.tap_intro_request_select_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
- }
- }
- }
- }
-
- if (toolbar != null) {
- TapTarget tapTarget = TapTarget.forToolbarMenuItem(toolbar, R.id.menu_select_all,
- context.getResources().getString(R.string.tap_intro_request_select_all),
- context.getResources().getString(R.string.tap_intro_request_select_all_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
-
- View fab = activity.findViewById(R.id.fab);
- if (fab != null) {
- TapTarget tapTarget = TapTarget.forView(fab,
- context.getResources().getString(R.string.tap_intro_request_send),
- context.getResources().getString(R.string.tap_intro_request_send_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .tintTarget(false)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
-
- if (Preferences.get(context).isPremiumRequestEnabled()) {
- if (!Preferences.get(context).isPremiumRequest()) {
- if (recyclerView != null) {
- int position = 0;
-
- if (recyclerView.getAdapter() != null) {
- if (position < recyclerView.getAdapter().getItemCount()) {
- RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
-
- if (holder != null) {
- View view = holder.itemView.findViewById(R.id.buy);
- if (view != null) {
- float targetRadius = toDp(context, view.getMeasuredWidth()) - 10f;
-
- TapTarget tapTarget = TapTarget.forView(view,
- context.getResources().getString(R.string.tap_intro_request_premium),
- context.getResources().getString(R.string.tap_intro_request_premium_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .targetRadius((int) targetRadius)
- .tintTarget(false)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- }
- }
- }
- }
- }
- }
- }
-
- tapTargetSequence.listener(new TapTargetSequence.Listener() {
- @Override
- public void onSequenceFinish() {
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- Preferences.get(context).setTimeToShowRequestIntro(false);
- }
-
- @Override
- public void onSequenceStep(TapTarget tapTarget, boolean b) {
-
- }
-
- @Override
- public void onSequenceCanceled(TapTarget tapTarget) {
-
- }
- });
- tapTargetSequence.start();
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }, 100);
- }
- }
-
- @SuppressLint("StringFormatInvalid")
- public static void showWallpapersIntro(@NonNull Context context, @Nullable RecyclerView recyclerView) {
- if (Preferences.get(context).isTimeToShowWallpapersIntro()) {
- AppCompatActivity activity = (AppCompatActivity) context;
-
- if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
-
- new Handler().postDelayed(() -> {
- int primary = ContextCompat.getColor(context, R.color.toolbarIcon);
- int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
-
- if (recyclerView != null) {
- TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
- tapTargetSequence.continueOnCancel(true);
-
- int position = 0;
-
- if (recyclerView.getAdapter() == null)
- return;
-
- if (position < recyclerView.getAdapter().getItemCount()) {
- RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(position);
- if (holder == null) return;
-
- View view = holder.itemView.findViewById(R.id.image);
- if (view != null) {
- float targetRadius = toDp(context, view.getMeasuredWidth()) - 10f;
-
- Typeface title = TypefaceHelper.getMedium(context);
-
- String desc = context.getResources().getString(R.string.tap_intro_wallpapers_option_desc,
- context.getResources().getBoolean(R.bool.enable_wallpaper_download) ?
- context.getResources().getString(R.string.tap_intro_wallpapers_option_desc_download) : "");
-
- TapTarget tapTarget = TapTarget.forView(view,
- context.getResources().getString(R.string.tap_intro_wallpapers_option),
- desc)
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .targetRadius((int) targetRadius)
- .tintTarget(false)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- TapTarget tapTarget1 = TapTarget.forView(view,
- context.getResources().getString(R.string.tap_intro_wallpapers_preview),
- context.getResources().getString(R.string.tap_intro_wallpapers_preview_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .targetRadius((int) targetRadius)
- .tintTarget(false)
- .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());
-
- if (title != null) {
- tapTarget.textTypeface(title);
- tapTarget1.textTypeface(title);
- }
-
- //if (description != null) {
- //tapTarget.descriptionTypeface(description);
- //tapTarget1.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- tapTargetSequence.target(tapTarget1);
-
- tapTargetSequence.listener(new TapTargetSequence.Listener() {
- @Override
- public void onSequenceFinish() {
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- Preferences.get(context).setTimeToShowWallpapersIntro(false);
- }
-
- @Override
- public void onSequenceStep(TapTarget tapTarget, boolean b) {
-
- }
-
- @Override
- public void onSequenceCanceled(TapTarget tapTarget) {
-
- }
- });
- tapTargetSequence.start();
- }
- }
- }
- }, 200);
- }
- }
-
- public static void showWallpaperPreviewIntro(@NonNull Context context, @ColorInt int color) {
- if (Preferences.get(context).isTimeToShowWallpaperPreviewIntro()) {
- AppCompatActivity activity = (AppCompatActivity) context;
-
- View rootView = activity.findViewById(R.id.rootview);
- if (rootView == null) return;
-
- new Handler().postDelayed(() -> {
- try {
- int baseColor = color;
- if (baseColor == 0) {
- baseColor = ColorHelper.getAttributeColor(context, R.attr.colorSecondary);
- }
-
- int primary = ColorHelper.getTitleTextColor(baseColor);
- int secondary = ColorHelper.setColorAlpha(primary, 0.7f);
-
- TapTargetSequence tapTargetSequence = new TapTargetSequence(activity);
- tapTargetSequence.continueOnCancel(true);
-
- Typeface title = TypefaceHelper.getMedium(context);
- //Todo:
- //Typeface description = TypefaceHelper.getRegular(context);
-
- View apply = rootView.findViewById(R.id.menu_apply);
- View save = rootView.findViewById(R.id.menu_save);
-
- TapTarget tapTarget = TapTarget.forView(apply,
- context.getResources().getString(R.string.tap_intro_wallpaper_preview_apply),
- context.getResources().getString(R.string.tap_intro_wallpaper_preview_apply_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .outerCircleColorInt(baseColor)
- .drawShadow(true);
-
- TapTarget tapTarget1 = TapTarget.forView(save,
- context.getResources().getString(R.string.tap_intro_wallpaper_preview_save),
- context.getResources().getString(R.string.tap_intro_wallpaper_preview_save_desc))
- .titleTextColorInt(primary)
- .descriptionTextColorInt(secondary)
- .targetCircleColorInt(primary)
- .outerCircleColorInt(baseColor)
- .drawShadow(true);
-
- if (title != null) {
- //Todo:
- //tapTarget.titleTypeface(title);
- //tapTarget1.titleTypeface(title);
- //tapTarget2.titleTypeface(title);
- tapTarget.textTypeface(title);
- tapTarget1.textTypeface(title);
- }
-
- //if (description != null) {
- //Todo:
- //tapTarget.descriptionTypeface(description);
- //tapTarget1.descriptionTypeface(description);
- //tapTarget2.descriptionTypeface(description);
- //}
-
- tapTargetSequence.target(tapTarget);
- if (context.getResources().getBoolean(R.bool.enable_wallpaper_download)) {
- tapTargetSequence.target(tapTarget1);
- }
-
- tapTargetSequence.listener(new TapTargetSequence.Listener() {
- @Override
- public void onSequenceFinish() {
- Preferences.get(context).setTimeToShowWallpaperPreviewIntro(false);
- }
-
- @Override
- public void onSequenceStep(TapTarget tapTarget, boolean b) {
-
- }
-
- @Override
- public void onSequenceCanceled(TapTarget tapTarget) {
-
- }
- });
- tapTargetSequence.start();
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }, 100);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/ThemeHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/ThemeHelper.java
deleted file mode 100644
index f3fcdea..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/ThemeHelper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.content.res.Configuration;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.items.Theme;
-import candybar.lib.preferences.Preferences;
-
-public class ThemeHelper {
- public static Theme getDefaultTheme(Context context) {
- try {
- return Theme.valueOf(context.getResources().getString(R.string.default_theme).toUpperCase());
- } catch (Exception e) {
- return Theme.AUTO;
- }
- }
-
- public static boolean isDarkTheme(Context context) {
- boolean isThemingEnabled = CandyBarApplication.getConfiguration().isDashboardThemingEnabled();
- if (!isThemingEnabled) return getDefaultTheme(context) == Theme.DARK;
-
- Theme currentTheme = Preferences.get(context).getTheme();
- if (currentTheme == Theme.AUTO) {
- switch (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
- case Configuration.UI_MODE_NIGHT_YES:
- return true;
- case Configuration.UI_MODE_NIGHT_NO:
- return false;
- }
- }
-
- return currentTheme == Theme.DARK;
- }
-}
\ No newline at end of file
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/TypefaceHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/TypefaceHelper.java
deleted file mode 100644
index 24086b8..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/TypefaceHelper.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.graphics.Typeface;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.res.ResourcesCompat;
-
-import candybar.lib.R;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class TypefaceHelper {
-
- @Nullable
- public static Typeface getRegular(@NonNull Context context) {
- return ResourcesCompat.getFont(context, R.font.regular);
- }
-
- @Nullable
- public static Typeface getMedium(@NonNull Context context) {
- return ResourcesCompat.getFont(context, R.font.medium);
- }
-
- @Nullable
- public static Typeface getBold(@NonNull Context context) {
- return ResourcesCompat.getFont(context, R.font.bold);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/UrlHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/UrlHelper.java
deleted file mode 100644
index a91768c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/UrlHelper.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.util.Patterns;
-import android.webkit.URLUtil;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-
-import static com.danimahardhika.android.helpers.core.DrawableHelper.getTintedDrawable;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class UrlHelper {
-
- @Nullable
- public static Drawable getSocialIcon(@NonNull Context context, @NonNull Type type) {
- int color = ConfigurationHelper.getSocialIconColor(context, CandyBarApplication.getConfiguration().getSocialIconColor());
- switch (type) {
- case EMAIL:
- return getTintedDrawable(context, R.drawable.ic_toolbar_email, color);
- case BEHANCE:
- return getTintedDrawable(context, R.drawable.ic_toolbar_behance, color);
- case DRIBBBLE:
- return getTintedDrawable(context, R.drawable.ic_toolbar_dribbble, color);
- case FACEBOOK:
- return getTintedDrawable(context, R.drawable.ic_toolbar_facebook, color);
- case GITHUB:
- return getTintedDrawable(context, R.drawable.ic_toolbar_github, color);
- case INSTAGRAM:
- return getTintedDrawable(context, R.drawable.ic_toolbar_instagram, color);
- case PINTEREST:
- return getTintedDrawable(context, R.drawable.ic_toolbar_pinterest, color);
- case TWITTER:
- return getTintedDrawable(context, R.drawable.ic_toolbar_twitter, color);
- case TELEGRAM:
- return getTintedDrawable(context, R.drawable.ic_toolbar_telegram, color);
- default:
- return getTintedDrawable(context, R.drawable.ic_toolbar_website, color);
- }
- }
-
- public static Type getType(String url) {
- if (url == null) return Type.INVALID;
- if (!URLUtil.isValidUrl(url)) {
- if (Patterns.EMAIL_ADDRESS.matcher(url).matches()) {
- return Type.EMAIL;
- }
- return Type.INVALID;
- }
-
- if (url.contains("behance.")) {
- return Type.BEHANCE;
- } else if (url.contains("dribbble.")) {
- return Type.DRIBBBLE;
- } else if (url.contains("facebook.")) {
- return Type.FACEBOOK;
- } else if (url.contains("github.")) {
- return Type.GITHUB;
- } else if (url.contains("instagram.")) {
- return Type.INSTAGRAM;
- } else if (url.contains("pinterest.")) {
- return Type.PINTEREST;
- } else if (url.contains("twitter.")) {
- return Type.TWITTER;
- } else if (url.contains("t.me/") || url.contains("telegram.me/")) {
- return Type.TELEGRAM;
- } else {
- return Type.UNKNOWN;
- }
- }
-
- public enum Type {
- EMAIL,
- BEHANCE,
- DRIBBBLE,
- FACEBOOK,
- GITHUB,
- INSTAGRAM,
- PINTEREST,
- TWITTER,
- TELEGRAM,
- UNKNOWN,
- INVALID
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/ViewHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/ViewHelper.java
deleted file mode 100644
index 51e2d09..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/ViewHelper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package candybar.lib.helpers;
-
-import android.graphics.Point;
-
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
-
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.items.Home;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ViewHelper {
-
- public static void setFastScrollColor(@Nullable RecyclerFastScroller fastScroll) {
- if (fastScroll == null) return;
-
- int accent = ColorHelper.getAttributeColor(fastScroll.getContext(), R.attr.colorSecondary);
- fastScroll.setBarColor(ColorHelper.setColorAlpha(accent, 0.8f));
- fastScroll.setHandleNormalColor(accent);
- fastScroll.setHandlePressedColor(ColorHelper.getDarkerColor(accent, 0.7f));
- }
-
- public static Point getWallpaperViewRatio(String viewStyle) {
- switch (viewStyle.toLowerCase(Locale.getDefault())) {
- default:
- case "square":
- return new Point(1, 1);
- case "landscape":
- return new Point(16, 9);
- case "portrait":
- return new Point(4, 5);
- }
- }
-
- public static Home.Style getHomeImageViewStyle(String viewStyle) {
- switch (viewStyle.toLowerCase(Locale.getDefault())) {
- case "card_square":
- return new Home.Style(new Point(1, 1), Home.Style.Type.CARD_SQUARE);
- default:
- case "card_landscape":
- return new Home.Style(new Point(16, 9), Home.Style.Type.CARD_LANDSCAPE);
- case "square":
- return new Home.Style(new Point(1, 1), Home.Style.Type.SQUARE);
- case "landscape":
- return new Home.Style(new Point(16, 9), Home.Style.Type.LANDSCAPE);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/helpers/WallpaperHelper.java b/libs/candybar/src/main/java/candybar/lib/helpers/WallpaperHelper.java
deleted file mode 100644
index d01f947..0000000
--- a/libs/candybar/src/main/java/candybar/lib/helpers/WallpaperHelper.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package candybar.lib.helpers;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.graphics.Point;
-import android.graphics.RectF;
-import android.net.Uri;
-import android.os.Build;
-import android.webkit.URLUtil;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.WindowHelper;
-
-import candybar.lib.R;
-import candybar.lib.items.ImageSize;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class WallpaperHelper {
-
- public static final int UNKNOWN = 0;
- public static final int CLOUD_WALLPAPERS = 1;
- public static final int EXTERNAL_APP = 2;
-
- public static int getWallpaperType(@NonNull Context context) {
- String url = context.getResources().getString(R.string.wallpaper_json);
- if (URLUtil.isValidUrl(url)) {
- return CLOUD_WALLPAPERS;
- } else if (url.length() > 0) {
- return EXTERNAL_APP;
- }
- return UNKNOWN;
- }
-
- public static void launchExternalApp(@NonNull Context context) {
- String packageName = context.getResources().getString(R.string.wallpaper_json);
-
- PackageManager pm = context.getPackageManager();
- Intent intent = pm.getLaunchIntentForPackage(packageName);
- if (intent != null) {
- try {
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- return;
- } catch (Exception ignored) {
- }
- }
-
- try {
- Intent store = new Intent(Intent.ACTION_VIEW, Uri.parse(
- "https://play.google.com/store/apps/details?id=" + packageName));
- context.startActivity(store);
- } catch (ActivityNotFoundException ignored) {
- }
- }
-
- public static String getFormat(String mimeType) {
- if (mimeType == null) return "jpg";
- if ("image/png".equals(mimeType)) {
- return "png";
- }
- return "jpg";
- }
-
- public static ImageSize getTargetSize(@NonNull Context context) {
- Point point = WindowHelper.getScreenSize(context);
- int targetHeight = point.y;
- int targetWidth = point.x;
-
- if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
- targetHeight = point.x;
- targetWidth = point.y;
- }
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
- int statusBarHeight = WindowHelper.getStatusBarHeight(context);
- int navBarHeight = WindowHelper.getNavigationBarHeight(context);
- targetHeight += (statusBarHeight + navBarHeight);
- }
-
- return new ImageSize(targetWidth, targetHeight);
- }
-
- @Nullable
- public static RectF getScaledRectF(@Nullable RectF rectF, float heightFactor, float widthFactor) {
- if (rectF == null) return null;
-
- RectF scaledRectF = new RectF(rectF);
- scaledRectF.top *= heightFactor;
- scaledRectF.bottom *= heightFactor;
- scaledRectF.left *= widthFactor;
- scaledRectF.right *= widthFactor;
- return scaledRectF;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Credit.java b/libs/candybar/src/main/java/candybar/lib/items/Credit.java
deleted file mode 100644
index 2cff81e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Credit.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package candybar.lib.items;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Credit {
-
- private final String mName;
- private final String mContribution;
- private final String mImage;
- private final String mLink;
-
- public Credit(String name, String contribution, String image, String link) {
- mName = name;
- mContribution = contribution;
- mImage = image;
- mLink = link;
- }
-
- public String getName() {
- return mName;
- }
-
- public String getContribution() {
- return mContribution;
- }
-
- public String getImage() {
- return mImage;
- }
-
- public String getLink() {
- return mLink;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/FAQs.java b/libs/candybar/src/main/java/candybar/lib/items/FAQs.java
deleted file mode 100644
index 4da8e56..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/FAQs.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package candybar.lib.items;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class FAQs {
-
- private final String mQuestion;
- private final String mAnswer;
-
- public FAQs(String question, String answer) {
- mQuestion = question;
- mAnswer = answer;
- }
-
- public String getQuestion() {
- return mQuestion;
- }
-
- public String getAnswer() {
- return mAnswer;
- }
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Home.java b/libs/candybar/src/main/java/candybar/lib/items/Home.java
deleted file mode 100644
index 0e095a7..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Home.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package candybar.lib.items;
-
-import android.graphics.Point;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Home {
-
- private final int mIcon;
- private String mTitle;
- private final String mSubtitle;
- private final Home.Type mType;
- private boolean mLoading;
-
- public Home(@DrawableRes int icon, String title, String subtitle, @NonNull Home.Type type, boolean loading) {
- mIcon = icon;
- mTitle = title;
- mSubtitle = subtitle;
- mType = type;
- mLoading = loading;
- }
-
- @DrawableRes
- public int getIcon() {
- return mIcon;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public String getSubtitle() {
- return mSubtitle;
- }
-
- public Home.Type getType() {
- return mType;
- }
-
- public boolean isLoading() {
- return mLoading;
- }
-
- public void setTitle(String title) {
- mTitle = title;
- }
-
- public void setLoading(boolean loading) {
- mLoading = loading;
- }
-
- public enum Type {
- APPLY,
- DONATE,
- ICONS,
- DIMENSION
- }
-
- public static class Style {
-
- private final Point mPoint;
- private final Home.Style.Type mType;
-
- public Style(@NonNull Point point, @NonNull Home.Style.Type type) {
- mPoint = point;
- mType = type;
- }
-
- public Point getPoint() {
- return mPoint;
- }
-
- public Type getType() {
- return mType;
- }
-
- public enum Type {
- CARD_SQUARE,
- CARD_LANDSCAPE,
- SQUARE,
- LANDSCAPE
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Icon.java b/libs/candybar/src/main/java/candybar/lib/items/Icon.java
deleted file mode 100644
index 2192cc5..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Icon.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package candybar.lib.items;
-
-import androidx.annotation.NonNull;
-
-import java.util.List;
-
-import candybar.lib.utils.AlphanumComparator;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Icon {
-
- private String mDrawableName;
- private String mCustomName;
- private String mTitle;
- private int mRes;
- private String mPackageName;
- private List mIcons;
-
- public Icon(String drawableName, String customName, int res) {
- mDrawableName = drawableName;
- mCustomName = customName;
- mRes = res;
- }
-
- public Icon(String title, int res, String packageName) {
- mTitle = title;
- mRes = res;
- mPackageName = packageName;
- }
-
- public Icon(String title, @NonNull List icons) {
- mTitle = title;
- mIcons = icons;
- }
-
- public String getDrawableName() {
- return mDrawableName;
- }
-
- public String getCustomName() {
- return mCustomName;
- }
-
- public Icon setTitle(String title) {
- mTitle = title;
- return this;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public int getRes() {
- return mRes;
- }
-
- public String getPackageName() {
- return mPackageName;
- }
-
- @NonNull
- public List getIcons() {
- return mIcons;
- }
-
- public void setIcons(List icons) {
- mIcons = icons;
- }
-
- @Override
- public boolean equals(Object object) {
- boolean res = false;
- boolean title = false;
- if (object instanceof Icon) {
- res = mRes == ((Icon) object).getRes();
- title = mTitle.equals(((Icon) object).getTitle());
- }
- return res && title;
- }
-
- public static final AlphanumComparator TitleComparator = new AlphanumComparator() {
- @Override
- public int compare(Object o1, Object o2) {
- String s1 = ((Icon) o1).getTitle();
- String s2 = ((Icon) o2).getTitle();
- return super.compare(s1, s2);
- }
- };
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/IconShape.java b/libs/candybar/src/main/java/candybar/lib/items/IconShape.java
deleted file mode 100644
index 8fc57f0..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/IconShape.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package candybar.lib.items;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconShape {
-
- private final String mName;
- private final int mShape;
-
- public IconShape(String name, int shape) {
- mName = name;
- mShape = shape;
- }
-
- public String getName() {
- return mName;
- }
-
- public int getShape() {
- return mShape;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/ImageSize.java b/libs/candybar/src/main/java/candybar/lib/items/ImageSize.java
deleted file mode 100644
index 94778aa..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/ImageSize.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package candybar.lib.items;
-
-public class ImageSize {
- public final int width;
- public final int height;
-
- public ImageSize(int width, int height) {
- this.width = width;
- this.height = height;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/InAppBilling.java b/libs/candybar/src/main/java/candybar/lib/items/InAppBilling.java
deleted file mode 100644
index 4c16954..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/InAppBilling.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package candybar.lib.items;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import androidx.annotation.NonNull;
-
-
-public class InAppBilling {
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/IntentChooser.java b/libs/candybar/src/main/java/candybar/lib/items/IntentChooser.java
deleted file mode 100644
index a45eeb2..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/IntentChooser.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package candybar.lib.items;
-
-import android.content.pm.ResolveInfo;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IntentChooser {
-
- private final ResolveInfo mApp;
- private final int mType;
-
- public static final int TYPE_SUPPORTED = 0;
- public static final int TYPE_RECOMMENDED = 1;
- public static final int TYPE_NOT_SUPPORTED = 2;
-
- public IntentChooser(ResolveInfo app, int type) {
- mApp = app;
- mType = type;
- }
-
- public ResolveInfo getApp() {
- return mApp;
- }
-
- public int getType() {
- return mType;
- }
-
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Language.java b/libs/candybar/src/main/java/candybar/lib/items/Language.java
deleted file mode 100644
index 59e1b84..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Language.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package candybar.lib.items;
-
-import java.util.Locale;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Language {
-
- private final String mName;
- private final Locale mLocale;
-
- public Language(String name, Locale locale) {
- mName = name;
- mLocale = locale;
- }
-
- public String getName() {
- return mName;
- }
-
- public Locale getLocale() {
- return mLocale;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/PopupItem.java b/libs/candybar/src/main/java/candybar/lib/items/PopupItem.java
deleted file mode 100644
index 258a95e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/PopupItem.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package candybar.lib.items;
-
-import android.content.Context;
-import android.os.Build;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.preferences.Preferences;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class PopupItem {
-
- private final String mTitle;
- private int mIcon;
- private boolean mShowCheckbox;
- private boolean mCheckboxValue;
- private boolean mIsSelected;
- private Type mType;
-
- public PopupItem(String title) {
- mTitle = title;
- mShowCheckbox = false;
- mCheckboxValue = false;
- mIsSelected = false;
- }
-
- public PopupItem setIcon(@DrawableRes int icon) {
- mIcon = icon;
- return this;
- }
-
- public PopupItem setShowCheckbox(boolean showCheckbox) {
- mShowCheckbox = showCheckbox;
- return this;
- }
-
- public PopupItem setCheckboxValue(boolean checkboxValue) {
- mCheckboxValue = checkboxValue;
- return this;
- }
-
- public PopupItem setSelected(boolean selected) {
- mIsSelected = selected;
- return this;
- }
-
- public PopupItem setType(Type type) {
- mType = type;
- return this;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- @DrawableRes
- public int getIcon() {
- return mIcon;
- }
-
- public boolean isShowCheckbox() {
- return mShowCheckbox;
- }
-
- public boolean getCheckboxValue() {
- return mCheckboxValue;
- }
-
- public boolean isSelected() {
- return mIsSelected;
- }
-
- public Type getType() {
- return mType;
- }
-
- public enum Type {
- WALLPAPER_CROP,
- HOMESCREEN,
- LOCKSCREEN,
- HOMESCREEN_LOCKSCREEN,
- DOWNLOAD
- }
-
- public static List getApplyItems(@NonNull Context context) {
- List items = new ArrayList<>();
-
- //Todo: wait until google fix the issue, then enable wallpaper crop again on API 26+
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- items.add(new PopupItem(context.getResources().getString(R.string.menu_wallpaper_crop))
- .setType(Type.WALLPAPER_CROP)
- .setCheckboxValue(Preferences.get(context).isCropWallpaper())
- .setShowCheckbox(true));
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- items.add(new PopupItem(context.getResources().getString(R.string.menu_apply_lockscreen))
- .setType(Type.LOCKSCREEN)
- .setIcon(R.drawable.ic_toolbar_lockscreen));
- }
-
- items.add(new PopupItem(context.getResources().getString(R.string.menu_apply_homescreen))
- .setType(Type.HOMESCREEN)
- .setIcon(R.drawable.ic_toolbar_homescreen));
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- items.add(new PopupItem(context.getResources().getString(R.string.menu_apply_homescreen_lockscreen))
- .setType(Type.HOMESCREEN_LOCKSCREEN)
- .setIcon(R.drawable.ic_toolbar_homescreen_lockscreen));
- }
-
- if (context.getResources().getBoolean(R.bool.enable_wallpaper_download)) {
- items.add(new PopupItem(context.getResources().getString(R.string.menu_save))
- .setType(Type.DOWNLOAD)
- .setIcon(R.drawable.ic_toolbar_download));
- }
- return items;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Preset.java b/libs/candybar/src/main/java/candybar/lib/items/Preset.java
deleted file mode 100644
index eb8cbce..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Preset.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package candybar.lib.items;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Preset {
- private final String mPath;
- private final String mHeaderText;
-
- public Preset(String path, String headerText) {
- mPath = path;
- mHeaderText = headerText;
- }
-
- public String getPath() {
- return mPath;
- }
-
- public String getHeaderText() {
- return mHeaderText;
- }
-
- public boolean isHeader() {
- return mHeaderText != null;
- }
-
- public static List sectioned(String sectionName, String[] paths) {
- List presets = new ArrayList<>();
- presets.add(new Preset(null, sectionName));
-
- for (String path : paths) {
- presets.add(new Preset(path, null));
- }
-
- return presets;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Request.java b/libs/candybar/src/main/java/candybar/lib/items/Request.java
deleted file mode 100644
index 01ac9fd..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Request.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package candybar.lib.items;
-
-import android.content.ComponentName;
-
-import androidx.annotation.Nullable;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Request {
-
- private final String mName;
- private final String mActivity;
- private String mPackageName;
- private String mOrderId;
- private String mProductId;
- private String mRequestedOn;
- private boolean mRequested;
-
- private Request(String name, String activity) {
- mName = name;
- mActivity = activity;
- }
-
- public String getName() {
- return mName;
- }
-
- @Nullable
- public String getPackageName() {
- if (mPackageName == null) {
- if (mActivity.length() > 0) {
- return mActivity.substring(0, mActivity.lastIndexOf("/"));
- }
- }
- return mPackageName;
- }
-
- public String getActivity() {
- return mActivity;
- }
-
- public boolean isRequested() {
- return mRequested;
- }
-
- public String getOrderId() {
- return mOrderId;
- }
-
- public String getProductId() {
- return mProductId;
- }
-
- public String getRequestedOn() {
- return mRequestedOn;
- }
-
- public void setPackageName(String packageName) {
- mPackageName = packageName;
- }
-
- public void setOrderId(String orderId) {
- mOrderId = orderId;
- }
-
- public void setProductId(String productId) {
- mProductId = productId;
- }
-
- public void setRequestedOn(String requestedOn) {
- mRequestedOn = requestedOn;
- }
-
- public void setRequested(boolean requested) {
- mRequested = requested;
- }
-
- public static Builder Builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String mName;
- private String mActivity;
- private String mPackageName;
- private String mOrderId;
- private String mProductId;
- private String mRequestedOn;
- private boolean mRequested;
-
- private Builder() {
- mName = "";
- mActivity = "";
- mRequested = false;
- }
-
- public Builder name(String name) {
- mName = name;
- return this;
- }
-
- public Builder activity(String activity) {
- mActivity = activity;
- return this;
- }
-
- public Builder packageName(String packageName) {
- mPackageName = packageName;
- return this;
- }
-
- public Builder orderId(String orderId) {
- mOrderId = orderId;
- return this;
- }
-
- public Builder productId(String productId) {
- mProductId = productId;
- return this;
- }
-
- public Builder requestedOn(String requestedOn) {
- mRequestedOn = requestedOn;
- return this;
- }
-
- public Builder requested(boolean requested) {
- mRequested = requested;
- return this;
- }
-
- public Request build() {
- Request request = new Request(mName, mActivity);
- request.setPackageName(mPackageName);
- request.setRequestedOn(mRequestedOn);
- request.setRequested(mRequested);
- request.setOrderId(mOrderId);
- request.setProductId(mProductId);
- return request;
- }
- }
-
- public static class Property {
-
- private ComponentName componentName;
- private final String orderId;
- private final String productId;
-
- public Property(ComponentName componentName, String orderId, String productId) {
- this.componentName = componentName;
- this.orderId = orderId;
- this.productId = productId;
- }
-
- @Nullable
- public ComponentName getComponentName() {
- return componentName;
- }
-
- public String getOrderId() {
- return orderId;
- }
-
- public String getProductId() {
- return productId;
- }
-
- public void setComponentName(ComponentName componentName) {
- this.componentName = componentName;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Setting.java b/libs/candybar/src/main/java/candybar/lib/items/Setting.java
deleted file mode 100644
index 360089b..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Setting.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package candybar.lib.items;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Setting {
-
- private final int mIcon;
- private final String mTitle;
- private final String mSubtitle;
- private final String mContent;
- private String mFooter;
- private final Setting.Type mType;
-
- public Setting(@DrawableRes int icon, String title, String subtitle, String content, String footer,
- @NonNull Setting.Type type) {
- mIcon = icon;
- mTitle = title;
- mSubtitle = subtitle;
- mContent = content;
- mFooter = footer;
- mType = type;
- }
-
- @DrawableRes
- public int getIcon() {
- return mIcon;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public String getSubtitle() {
- return mSubtitle;
- }
-
- public String getContent() {
- return mContent;
- }
-
- public String getFooter() {
- return mFooter;
- }
-
- public Setting.Type getType() {
- return mType;
- }
-
- public void setFooter(String footer) {
- mFooter = footer;
- }
-
- public enum Type {
- HEADER,
- CACHE,
- ICON_REQUEST,
- RESTORE,
- PREMIUM_REQUEST,
- THEME,
- LANGUAGE,
- REPORT_BUGS,
- CHANGELOG,
- RESET_TUTORIAL
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Theme.java b/libs/candybar/src/main/java/candybar/lib/items/Theme.java
deleted file mode 100644
index bf42085..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Theme.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package candybar.lib.items;
-
-import android.content.Context;
-
-import androidx.annotation.StringRes;
-
-import candybar.lib.R;
-
-public enum Theme {
- AUTO(R.string.theme_name_auto),
- LIGHT(R.string.theme_name_light),
- DARK(R.string.theme_name_dark);
-
- private final int nameStringRes;
-
- Theme(@StringRes int nameRes) {
- nameStringRes = nameRes;
- }
-
- public String displayName(Context context) {
- return context.getResources().getString(nameStringRes);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/items/Wallpaper.java b/libs/candybar/src/main/java/candybar/lib/items/Wallpaper.java
deleted file mode 100644
index 74a2a25..0000000
--- a/libs/candybar/src/main/java/candybar/lib/items/Wallpaper.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package candybar.lib.items;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Wallpaper {
-
- private final String mUrl;
- private final String mThumbUrl;
- private final String mAuthor;
- private String mName;
- private int mColor;
- private int mSize;
- private String mMimeType;
- private ImageSize mDimensions;
-
- private Wallpaper(String name, String author, String url, String thumbUrl) {
- mName = name;
- mAuthor = author;
- mUrl = url;
- mThumbUrl = thumbUrl;
- }
-
- public String getName() {
- return mName;
- }
-
- public String getAuthor() {
- return mAuthor;
- }
-
- public String getThumbUrl() {
- return mThumbUrl;
- }
-
- public String getURL() {
- return mUrl;
- }
-
- public int getColor() {
- return mColor;
- }
-
- public String getMimeType() {
- return mMimeType;
- }
-
- public ImageSize getDimensions() {
- return mDimensions;
- }
-
- public int getSize() {
- return mSize;
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public void setColor(int color) {
- mColor = color;
- }
-
- public void setMimeType(String mimeType) {
- mMimeType = mimeType;
- }
-
- public void setDimensions(ImageSize dimensions) {
- mDimensions = dimensions;
- }
-
- public void setSize(int size) {
- mSize = size;
- }
-
- @Override
- public boolean equals(Object object) {
- boolean equals = false;
- if (object instanceof Wallpaper) {
- equals = mAuthor.equals(((Wallpaper) object).getAuthor()) &&
- mUrl.equals(((Wallpaper) object).getURL()) &&
- mThumbUrl.equals(((Wallpaper) object).getThumbUrl());
- }
- return equals;
- }
-
- public static Builder Builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String mName;
- private String mAuthor;
- private String mThumbUrl;
- private String mUrl;
- private int mColor;
- private int mSize;
- private String mMimeType;
- private ImageSize mDimensions;
-
- private Builder() {
- mColor = 0;
- mSize = 0;
- }
-
- public Builder name(String name) {
- mName = name;
- return this;
- }
-
- public Builder author(String author) {
- mAuthor = author;
- return this;
- }
-
- public Builder url(String url) {
- mUrl = url;
- return this;
- }
-
- public Builder thumbUrl(String thumbUrl) {
- mThumbUrl = thumbUrl;
- return this;
- }
-
- public Builder dimensions(ImageSize dimensions) {
- mDimensions = dimensions;
- return this;
- }
-
- public Builder mimeType(String mimeType) {
- mMimeType = mimeType;
- return this;
- }
-
- public Builder color(int color) {
- mColor = color;
- return this;
- }
-
- public Builder size(int size) {
- mSize = size;
- return this;
- }
-
- public Wallpaper build() {
- Wallpaper wallpaper = new Wallpaper(mName, mAuthor, mUrl, mThumbUrl);
- wallpaper.setDimensions(mDimensions);
- wallpaper.setMimeType(mMimeType);
- wallpaper.setColor(mColor);
- wallpaper.setSize(mSize);
- return wallpaper;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/preferences/Preferences.java b/libs/candybar/src/main/java/candybar/lib/preferences/Preferences.java
deleted file mode 100644
index a32e440..0000000
--- a/libs/candybar/src/main/java/candybar/lib/preferences/Preferences.java
+++ /dev/null
@@ -1,385 +0,0 @@
-package candybar.lib.preferences;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-
-import androidx.annotation.NonNull;
-
-import java.lang.ref.WeakReference;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.ThemeHelper;
-import candybar.lib.items.Language;
-import candybar.lib.items.Theme;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Preferences {
-
- private final Context mContext;
-
- private static final String PREFERENCES_NAME = "candybar_preferences";
-
- private static final String KEY_FIRST_RUN = "first_run";
- private static final String KEY_THEME = "theme";
- private static final String KEY_ICON_SHAPE = "icon_shape";
- private static final String KEY_APP_VERSION = "app_version";
- private static final String KEY_WIFI_ONLY = "wifi_only";
- private static final String KEY_WALLS_DIRECTORY = "wallpaper_directory";
- private static final String KEY_PREMIUM_REQUEST = "premium_request";
- private static final String KEY_PREMIUM_REQUEST_PRODUCT = "premium_request_product";
- private static final String KEY_PREMIUM_REQUEST_COUNT = "premium_request_count";
- private static final String KEY_PREMIUM_REQUEST_TOTAL = "premium_request_total";
- private static final String KEY_REGULAR_REQUEST_USED = "regular_request_used";
- private static final String KEY_INAPP_BILLING_TYPE = "inapp_billing_type";
- private static final String KEY_LICENSED = "licensed";
- private static final String KEY_LATEST_CRASHLOG = "last_crashlog";
- private static final String KEY_PREMIUM_REQUEST_ENABLED = "premium_request_enabled";
- private static final String KEY_AVAILABLE_WALLPAPERS_COUNT = "available_wallpapers_count";
- private static final String KEY_CROP_WALLPAPER = "crop_wallpaper";
- private static final String KEY_HOME_INTRO = "home_intro";
- private static final String KEY_ICONS_INTRO = "icons_intro";
- private static final String KEY_REQUEST_INTRO = "request_intro";
- private static final String KEY_WALLPAPERS_INTRO = "wallpapers_intro";
- private static final String KEY_WALLPAPER_PREVIEW_INTRO = "wallpaper_preview_intro";
-
- private static final String KEY_LANGUAGE_PREFERENCE = "language_preference";
- private static final String KEY_CURRENT_LOCALE = "current_locale";
-
- private static WeakReference mPreferences;
-
- @NonNull
- public static Preferences get(@NonNull Context context) {
- if (mPreferences == null || mPreferences.get() == null) {
- mPreferences = new WeakReference<>(new Preferences(context));
- }
- return mPreferences.get();
- }
-
- private Preferences(Context context) {
- mContext = context;
- }
-
- private SharedPreferences getSharedPreferences() {
- return mContext.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
- }
-
- public void clearPreferences() {
- boolean isLicensed = isLicensed();
- getSharedPreferences().edit().clear().apply();
-
- if (isLicensed) {
- setFirstRun(false);
- setLicensed(true);
- }
- }
-
- public boolean isFirstRun() {
- return getSharedPreferences().getBoolean(KEY_FIRST_RUN, true);
- }
-
- public void setFirstRun(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_FIRST_RUN, bool).apply();
- }
-
- public void setIconShape(int shape) {
- getSharedPreferences().edit().putInt(KEY_ICON_SHAPE, shape).apply();
- }
-
- public int getIconShape() {
- return getSharedPreferences().getInt(KEY_ICON_SHAPE, -1); // -1 is System default
- }
-
- public boolean isTimeToShowHomeIntro() {
- return getSharedPreferences().getBoolean(KEY_HOME_INTRO, true);
- }
-
- public void setTimeToShowHomeIntro(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_HOME_INTRO, bool).apply();
- }
-
- public boolean isTimeToShowIconsIntro() {
- return getSharedPreferences().getBoolean(KEY_ICONS_INTRO, true);
- }
-
- public void setTimeToShowIconsIntro(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_ICONS_INTRO, bool).apply();
- }
-
- public boolean isTimeToShowRequestIntro() {
- return getSharedPreferences().getBoolean(KEY_REQUEST_INTRO, true);
- }
-
- public void setTimeToShowRequestIntro(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_REQUEST_INTRO, bool).apply();
- }
-
- public boolean isTimeToShowWallpapersIntro() {
- return getSharedPreferences().getBoolean(KEY_WALLPAPERS_INTRO, true);
- }
-
- public void setTimeToShowWallpapersIntro(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_WALLPAPERS_INTRO, bool).apply();
- }
-
- public boolean isTimeToShowWallpaperPreviewIntro() {
- return getSharedPreferences().getBoolean(KEY_WALLPAPER_PREVIEW_INTRO, true);
- }
-
- public void setTimeToShowWallpaperPreviewIntro(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_WALLPAPER_PREVIEW_INTRO, bool).apply();
- }
-
- public Theme getTheme() {
- return Theme.values()[getSharedPreferences().getInt(KEY_THEME, ThemeHelper.getDefaultTheme(mContext).ordinal())];
- }
-
- public void setTheme(Theme theme) {
- getSharedPreferences().edit().putInt(KEY_THEME, theme.ordinal()).apply();
- }
-
- public boolean isToolbarShadowEnabled() {
- return CandyBarApplication.getConfiguration().getShadowOptions().isToolbarEnabled();
- }
-
- public boolean isCardShadowEnabled() {
- return CandyBarApplication.getConfiguration().getShadowOptions().isCardEnabled();
- }
-
- public boolean isFabShadowEnabled() {
- return CandyBarApplication.getConfiguration().getShadowOptions().isFabEnabled();
- }
-
- public boolean isTapIntroShadowEnabled() {
- return CandyBarApplication.getConfiguration().getShadowOptions().isTapIntroEnabled();
- }
-
- public boolean isWifiOnly() {
- return getSharedPreferences().getBoolean(KEY_WIFI_ONLY, false);
- }
-
- public String getWallsDirectory() {
- return getSharedPreferences().getString(KEY_WALLS_DIRECTORY, "");
- }
-
- public boolean isPremiumRequestEnabled() {
- return getSharedPreferences().getBoolean(KEY_PREMIUM_REQUEST_ENABLED,
- mContext.getResources().getBoolean(R.bool.enable_premium_request));
- }
-
- public void setPremiumRequestEnabled(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_PREMIUM_REQUEST_ENABLED, bool).apply();
- }
-
- public boolean isPremiumRequest() {
- return getSharedPreferences().getBoolean(KEY_PREMIUM_REQUEST, false);
- }
-
- public void setPremiumRequest(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_PREMIUM_REQUEST, bool).apply();
- }
-
- public String getPremiumRequestProductId() {
- return getSharedPreferences().getString(KEY_PREMIUM_REQUEST_PRODUCT, "");
- }
-
- public void setPremiumRequestProductId(String productId) {
- getSharedPreferences().edit().putString(KEY_PREMIUM_REQUEST_PRODUCT, productId).apply();
- }
-
- public int getPremiumRequestCount() {
- return getSharedPreferences().getInt(KEY_PREMIUM_REQUEST_COUNT, 0);
- }
-
- public void setPremiumRequestCount(int count) {
- getSharedPreferences().edit().putInt(KEY_PREMIUM_REQUEST_COUNT, count).apply();
- }
-
- public int getPremiumRequestTotal() {
- int count = getPremiumRequestCount();
- return getSharedPreferences().getInt(KEY_PREMIUM_REQUEST_TOTAL, count);
- }
-
- public void setPremiumRequestTotal(int count) {
- getSharedPreferences().edit().putInt(KEY_PREMIUM_REQUEST_TOTAL, count).apply();
- }
-
- public int getRegularRequestUsed() {
- return getSharedPreferences().getInt(KEY_REGULAR_REQUEST_USED, 0);
- }
-
- public boolean isRegularRequestLimit() {
- return mContext.getResources().getBoolean(R.bool.enable_icon_request_limit);
- }
-
- public void setRegularRequestUsed(int used) {
- getSharedPreferences().edit().putInt(KEY_REGULAR_REQUEST_USED, used).apply();
- }
-
- public int getInAppBillingType() {
- return getSharedPreferences().getInt(KEY_INAPP_BILLING_TYPE, -1);
- }
-
- public void setInAppBillingType(int type) {
- getSharedPreferences().edit().putInt(KEY_INAPP_BILLING_TYPE, type).apply();
- }
-
- public boolean isLicensed() {
- return getSharedPreferences().getBoolean(KEY_LICENSED, false);
- }
-
- public void setLicensed(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_LICENSED, bool).apply();
- }
-
- public boolean isCropWallpaper() {
- return getSharedPreferences().getBoolean(KEY_CROP_WALLPAPER, false);
- }
-
- public void setCropWallpaper(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_CROP_WALLPAPER, bool).apply();
- }
-
- public String getLatestCrashLog() {
- return getSharedPreferences().getString(KEY_LATEST_CRASHLOG, "");
- }
-
- public void setLatestCrashLog(String string) {
- getSharedPreferences().edit().putString(KEY_LATEST_CRASHLOG, string).apply();
- }
-
- public int getAvailableWallpapersCount() {
- return getSharedPreferences().getInt(KEY_AVAILABLE_WALLPAPERS_COUNT, 0);
- }
-
- public void setAvailableWallpapersCount(int count) {
- getSharedPreferences().edit().putInt(KEY_AVAILABLE_WALLPAPERS_COUNT, count).apply();
- }
-
- public boolean isPlayStoreCheckEnabled() {
- return mContext.getResources().getBoolean(R.bool.playstore_check_enabled);
- }
-
- private int getVersion() {
- return getSharedPreferences().getInt(KEY_APP_VERSION, 0);
- }
-
- private void setVersion(int version) {
- getSharedPreferences().edit().putInt(KEY_APP_VERSION, version).apply();
- }
-
- public boolean isNewVersion() {
- int version = 0;
- try {
- version = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode;
- } catch (PackageManager.NameNotFoundException ignored) {
- }
- if (version > getVersion()) {
- boolean resetLimit = mContext.getResources().getBoolean(R.bool.reset_icon_request_limit);
- if (resetLimit) setRegularRequestUsed(0);
- setVersion(version);
- return true;
- } else {
- return false;
- }
- }
-
- public Locale getCurrentLocale() {
- String code = getSharedPreferences().getString(KEY_CURRENT_LOCALE, "en_US");
- return LocaleHelper.getLocale(code);
- }
-
- public void setCurrentLocale(String code) {
- getSharedPreferences().edit().putString(KEY_CURRENT_LOCALE, code).apply();
- }
-
- public boolean isTimeToSetLanguagePreference() {
- return getSharedPreferences().getBoolean(KEY_LANGUAGE_PREFERENCE, true);
- }
-
- private void setTimeToSetLanguagePreference(boolean bool) {
- getSharedPreferences().edit().putBoolean(KEY_LANGUAGE_PREFERENCE, bool).apply();
- }
-
- public void setLanguagePreference() {
- Locale locale = Locale.getDefault();
- List languages = LocaleHelper.getAvailableLanguages(mContext);
-
- Locale currentLocale = null;
- for (Language language : languages) {
- Locale l = language.getLocale();
- if (locale.toString().equals(l.toString())) {
- currentLocale = l;
- break;
- }
- }
-
- if (currentLocale == null) {
- for (Language language : languages) {
- Locale l = language.getLocale();
- if (locale.getLanguage().equals(l.getLanguage())) {
- currentLocale = l;
- break;
- }
- }
- }
-
- if (currentLocale != null) {
- setCurrentLocale(currentLocale.toString());
- LocaleHelper.setLocale(mContext);
- setTimeToSetLanguagePreference(false);
- }
- }
-
- public boolean isConnectedToNetwork() {
- try {
- ConnectivityManager connectivityManager = (ConnectivityManager)
- mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- assert connectivityManager != null;
- NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
- return activeNetworkInfo != null && activeNetworkInfo.isConnected();
- } catch (Exception e) {
- return false;
- }
- }
-
- public boolean isConnectedAsPreferred() {
- try {
- if (isWifiOnly()) {
- ConnectivityManager connectivityManager = (ConnectivityManager)
- mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- assert connectivityManager != null;
- NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
- assert activeNetworkInfo != null;
- return activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI &&
- activeNetworkInfo.isConnected();
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/services/CandyBarArtWorker.java b/libs/candybar/src/main/java/candybar/lib/services/CandyBarArtWorker.java
deleted file mode 100644
index 2d937c6..0000000
--- a/libs/candybar/src/main/java/candybar/lib/services/CandyBarArtWorker.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package candybar.lib.services;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.net.Uri;
-import android.webkit.URLUtil;
-
-import androidx.annotation.NonNull;
-import androidx.work.Constraints;
-import androidx.work.NetworkType;
-import androidx.work.OneTimeWorkRequest;
-import androidx.work.WorkManager;
-import androidx.work.WorkRequest;
-import androidx.work.Worker;
-import androidx.work.WorkerParameters;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.google.android.apps.muzei.api.provider.Artwork;
-import com.google.android.apps.muzei.api.provider.ProviderClient;
-import com.google.android.apps.muzei.api.provider.ProviderContract;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.databases.Database;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-
-@SuppressLint("NewApi")
-public class CandyBarArtWorker extends Worker {
- private final String WORKER_TAG = this.getApplicationContext().getPackageName() + ".ArtProvider";
- private final Context mContext = getApplicationContext();
-
- public CandyBarArtWorker(@NonNull Context context, @NonNull WorkerParameters params) {
- super(context, params);
- }
-
- public static void enqueueLoad(Context context) {
- WorkManager manager = WorkManager.getInstance(context);
- Constraints constraints = new Constraints.Builder()
- .setRequiredNetworkType(NetworkType.CONNECTED)
- .build();
- WorkRequest request = new OneTimeWorkRequest.Builder(CandyBarArtWorker.class)
- .setConstraints(constraints)
- .build();
- manager.enqueue(request);
- }
-
-
- @Override
- @NonNull
- public Result doWork() {
- LogUtil.d("Executing doWork() for Muzei");
- if (!URLUtil.isValidUrl(mContext.getString(R.string.wallpaper_json))) {
- LogUtil.e("Not a valid Wallpaper JSON URL");
- return Result.failure();
- }
-
- List wallpapers = Database.get(mContext).getWallpapers(null);
-
- ProviderClient providerClient = ProviderContract.getProviderClient(getApplicationContext(), WORKER_TAG);
-
- if (Preferences.get(getApplicationContext()).isConnectedAsPreferred()) {
- ArrayList artworks = new ArrayList<>();
-
- for (Wallpaper wallpaper : wallpapers) {
- if (wallpaper != null) {
- Uri uri = Uri.parse(wallpaper.getURL());
-
- Artwork artwork = new Artwork.Builder()
- .title(wallpaper.getName())
- .byline(wallpaper.getAuthor())
- .persistentUri(uri)
- .build();
-
- if (!artworks.contains(artwork)) {
- artworks.add(artwork);
- } else {
- LogUtil.d("Already Contains Artwork" + wallpaper.getName());
- }
- } else {
- LogUtil.d("Wallpaper is Null");
- }
- }
-
- LogUtil.d("Closing Database - Muzei");
- Database.get(mContext).closeDatabase();
-
- providerClient.setArtwork(artworks);
- return Result.success();
- }
-
- return Result.failure();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/services/CandyBarMuzeiService.java b/libs/candybar/src/main/java/candybar/lib/services/CandyBarMuzeiService.java
deleted file mode 100644
index ae73ae9..0000000
--- a/libs/candybar/src/main/java/candybar/lib/services/CandyBarMuzeiService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package candybar.lib.services;
-
-import com.google.android.apps.muzei.api.provider.MuzeiArtProvider;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CandyBarMuzeiService extends MuzeiArtProvider {
-
- public CandyBarMuzeiService() {
- }
-
- @Override
- public void onLoadRequested(boolean initial) {
- CandyBarArtWorker.enqueueLoad(getContext());
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/services/CandyBarService.java b/libs/candybar/src/main/java/candybar/lib/services/CandyBarService.java
deleted file mode 100644
index a4d349c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/services/CandyBarService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package candybar.lib.services;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import candybar.lib.databases.Database;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class CandyBarService extends Service {
-
- @Nullable
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public void onTaskRemoved(Intent rootIntent) {
- LogUtil.d("App removed from recent task, database connection closed");
- Database.get(this).closeDatabase();
-
- stopSelf();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/services/CandyBarWidgetService.java b/libs/candybar/src/main/java/candybar/lib/services/CandyBarWidgetService.java
deleted file mode 100644
index 9afd4d3..0000000
--- a/libs/candybar/src/main/java/candybar/lib/services/CandyBarWidgetService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package candybar.lib.services;
-
-import android.app.PendingIntent;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-import android.provider.AlarmClock;
-import android.widget.RemoteViews;
-
-import candybar.lib.R;
-
-public class CandyBarWidgetService extends AppWidgetProvider {
-
- public void onReceive(Context context, Intent intent) {
- String act = intent.getAction();
- if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(act)) {
- RemoteViews clockView = new RemoteViews(context.getPackageName(), R.layout.analog_clock);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- Intent clockIntent = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
- clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- clockView.setOnClickPendingIntent(R.id.analog_clock, PendingIntent.getActivity(context, 0, clockIntent, 0));
- }
-
- AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), clockView);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestBuilderTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestBuilderTask.java
deleted file mode 100644
index ccd03d1..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestBuilderTask.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package candybar.lib.tasks;
-
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.applications.CandyBarApplication.Configuration.EmailBodyGenerator;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.RequestFragment;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.DeviceHelper;
-import candybar.lib.items.Request;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.listeners.RequestListener;
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconRequestBuilderTask extends AsyncTaskBase {
-
- private final WeakReference mContext;
- private final WeakReference mCallback;
- private String mEmailBody;
- private Extras.Error mError;
-
- public IconRequestBuilderTask(@NonNull Context context, IconRequestBuilderCallback callback) {
- mContext = new WeakReference<>(context);
- mCallback = new WeakReference<>(callback);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (RequestFragment.sSelectedRequests == null) {
- mError = Extras.Error.ICON_REQUEST_NULL;
- return false;
- }
-
- if (CandyBarApplication.sRequestProperty == null) {
- mError = Extras.Error.ICON_REQUEST_PROPERTY_NULL;
- return false;
- }
-
- if (CandyBarApplication.sRequestProperty.getComponentName() == null) {
- mError = Extras.Error.ICON_REQUEST_PROPERTY_COMPONENT_NULL;
- return false;
- }
-
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(DeviceHelper.getDeviceInfo(mContext.get()));
-
- if (Preferences.get(mContext.get()).isPremiumRequest()) {
- if (CandyBarApplication.sRequestProperty.getOrderId() != null) {
- stringBuilder.append("Order Id: ")
- .append(CandyBarApplication.sRequestProperty.getOrderId());
- }
-
- if (CandyBarApplication.sRequestProperty.getProductId() != null) {
- stringBuilder.append("\r\nProduct Id: ")
- .append(CandyBarApplication.sRequestProperty.getProductId());
- }
- }
-
- List requestsForGenerator = new ArrayList<>();
- EmailBodyGenerator emailBodyGenerator = CandyBarApplication.getConfiguration().getEmailBodyGenerator();
- boolean emailBodyGeneratorEnabled = emailBodyGenerator != null;
- for (int i = 0; i < RequestFragment.sSelectedRequests.size(); i++) {
- Request request = CandyBarMainActivity.sMissedApps.get(RequestFragment.sSelectedRequests.get(i));
- Database.get(mContext.get()).addRequest(null, request);
-
- if (Preferences.get(mContext.get()).isPremiumRequest()) {
- Request premiumRequest = Request.Builder()
- .name(request.getName())
- .activity(request.getActivity())
- .productId(CandyBarApplication.sRequestProperty.getProductId())
- .orderId(CandyBarApplication.sRequestProperty.getOrderId())
- .build();
- Database.get(mContext.get()).addPremiumRequest(null, premiumRequest);
- }
-
- if (CandyBarApplication.getConfiguration().isIncludeIconRequestToEmailBody()) {
- if (emailBodyGeneratorEnabled) {
- requestsForGenerator.add(request);
- } else {
- stringBuilder.append("\r\n\r\n")
- .append(request.getName())
- .append("\r\n")
- .append(request.getActivity())
- .append("\r\n")
- .append("https://play.google.com/store/apps/details?id=")
- .append(request.getPackageName());
- }
- }
- }
-
- mEmailBody = stringBuilder.toString();
- if (emailBodyGeneratorEnabled) {
- mEmailBody += "\r\n\r\n" + emailBodyGenerator.generate(requestsForGenerator);
- }
- return true;
- } catch (Exception e) {
- CandyBarApplication.sRequestProperty = null;
- RequestFragment.sSelectedRequests = null;
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (ok) {
- try {
- if (mCallback.get() != null)
- mCallback.get().onFinished();
-
- RequestListener listener = (RequestListener) mContext.get();
- listener.onRequestBuilt(getIntent(CandyBarApplication.sRequestProperty
- .getComponentName(), mEmailBody),
- IntentChooserFragment.ICON_REQUEST);
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- } else {
- if (mError != null) {
- LogUtil.e(mError.getMessage());
- mError.showToast(mContext.get());
- }
- }
- }
-
- @Nullable
- private Intent getIntent(ComponentName name, String emailBody) {
- try {
- Intent intent = new Intent(Intent.ACTION_SEND);
- addIntentExtra(intent, emailBody);
- intent.setComponent(name);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- return intent;
- } catch (IllegalArgumentException e) {
- try {
- Intent intent = new Intent(Intent.ACTION_SEND);
- addIntentExtra(intent, emailBody);
- return intent;
- } catch (ActivityNotFoundException e1) {
- LogUtil.e(Log.getStackTraceString(e1));
- }
- }
- return null;
- }
-
- private void addIntentExtra(@NonNull Intent intent, String emailBody) {
- intent.setType("application/zip");
-
- if (CandyBarApplication.sZipPath != null) {
- File zip = new File(CandyBarApplication.sZipPath);
- if (zip.exists()) {
- Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
- if (uri == null) uri = Uri.fromFile(zip);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- }
- }
-
- String appName = mContext.get().getResources().getString(R.string.app_name);
-
- String regularRequestSubject = mContext.get().getResources().getString(R.string.regular_request_email_subject);
- // Fallback to request_email_subject
- if (regularRequestSubject.length() == 0)
- regularRequestSubject = mContext.get().getResources().getString(R.string.request_email_subject);
- if (regularRequestSubject.length() == 0) regularRequestSubject = appName + " Icon Request";
-
- String premiumRequestSubject = mContext.get().getResources().getString(R.string.premium_request_email_subject);
- if (premiumRequestSubject.length() == 0)
- premiumRequestSubject = appName + " Premium Icon Request";
-
- String regularRequestEmail = mContext.get().getResources().getString(R.string.regular_request_email);
- String premiumRequestEmail = mContext.get().getResources().getString(R.string.premium_request_email);
- // Fallback to regular request email
- if (premiumRequestEmail.length() == 0) premiumRequestEmail = regularRequestEmail;
-
- String subject = Preferences.get(mContext.get()).isPremiumRequest() ? premiumRequestSubject : regularRequestSubject;
- String emailAddress = Preferences.get(mContext.get()).isPremiumRequest() ? premiumRequestEmail : regularRequestEmail;
- // Fallback to dev_email
- if (emailAddress.length() == 0)
- emailAddress = mContext.get().getResources().getString(R.string.dev_email);
-
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddress});
- intent.putExtra(Intent.EXTRA_SUBJECT, subject);
- intent.putExtra(Intent.EXTRA_TEXT, emailBody);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
- }
-
- public interface IconRequestBuilderCallback {
- void onFinished();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestTask.java
deleted file mode 100644
index 1088a20..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/IconRequestTask.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package candybar.lib.tasks;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.util.Log;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.databases.Database;
-import candybar.lib.helpers.LocaleHelper;
-import candybar.lib.helpers.RequestHelper;
-import candybar.lib.items.Request;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.listeners.HomeListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconRequestTask extends AsyncTaskBase {
-
- private final WeakReference mContext;
- private Extras.Error mError;
-
- public IconRequestTask(Context context) {
- mContext = new WeakReference<>(context);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (mContext.get().getResources().getBoolean(R.bool.enable_icon_request) ||
- mContext.get().getResources().getBoolean(R.bool.enable_premium_request)) {
- List requests = new ArrayList<>();
- HashMap appFilter = RequestHelper.getAppFilter(mContext.get(), RequestHelper.Key.ACTIVITY);
- if (appFilter.size() == 0) {
- mError = Extras.Error.APPFILTER_NULL;
- return false;
- }
-
- PackageManager packageManager = mContext.get().getPackageManager();
-
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- List installedApps = packageManager.queryIntentActivities(
- intent, PackageManager.GET_RESOLVED_FILTER);
- if (installedApps.size() == 0) {
- mError = Extras.Error.INSTALLED_APPS_NULL;
- return false;
- }
-
- CandyBarMainActivity.sInstalledAppsCount = installedApps.size();
-
- try {
- Collections.sort(installedApps,
- new ResolveInfo.DisplayNameComparator(packageManager));
- } catch (Exception ignored) {
- }
-
- for (ResolveInfo app : installedApps) {
- String packageName = app.activityInfo.packageName;
- String activity = packageName + "/" + app.activityInfo.name;
-
- String value = appFilter.get(activity);
-
- if (value == null) {
- String name = LocaleHelper.getOtherAppLocaleName(mContext.get(), new Locale("en"), activity);
- if (name == null) {
- name = app.activityInfo.loadLabel(packageManager).toString();
- }
-
- boolean requested = Database.get(mContext.get()).isRequested(activity);
- Request request = Request.Builder()
- .name(name)
- .packageName(app.activityInfo.packageName)
- .activity(activity)
- .requested(requested)
- .build();
-
- requests.add(request);
- }
- }
-
- CandyBarMainActivity.sMissedApps = requests;
- }
- return true;
- } catch (Exception e) {
- CandyBarMainActivity.sMissedApps = null;
- mError = Extras.Error.DATABASE_ERROR;
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (mContext.get() == null) return;
- if (((AppCompatActivity) mContext.get()).isFinishing()) return;
-
- if (ok) {
- FragmentManager fm = ((AppCompatActivity) mContext.get()).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag("home");
- if (fragment == null) return;
-
- HomeListener listener = (HomeListener) fragment;
- listener.onHomeDataUpdated(null);
- } else {
- if (mError != null) {
- mError.showToast(mContext.get());
- }
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/IconsLoaderTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/IconsLoaderTask.java
deleted file mode 100644
index 05ed831..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/IconsLoaderTask.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package candybar.lib.tasks;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-
-import candybar.lib.R;
-import candybar.lib.activities.CandyBarMainActivity;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.helpers.IconsHelper;
-import candybar.lib.items.Home;
-import candybar.lib.items.Icon;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.listeners.HomeListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class IconsLoaderTask extends AsyncTaskBase {
-
- private final WeakReference mContext;
- private Home mHome;
-
- public IconsLoaderTask(Context context) {
- mContext = new WeakReference<>(context);
- }
-
- @Override
- @SuppressLint("StringFormatInvalid")
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (CandyBarMainActivity.sSections == null) {
- CandyBarMainActivity.sSections = IconsHelper.getIconsList(mContext.get());
-
- for (int i = 0; i < CandyBarMainActivity.sSections.size(); i++) {
- List icons = CandyBarMainActivity.sSections.get(i).getIcons();
-
- if (mContext.get().getResources().getBoolean(R.bool.show_icon_name) ||
- mContext.get().getResources().getBoolean(R.bool.enable_icon_name_replacer)) {
- IconsHelper.computeTitles(mContext.get(), icons);
- }
-
- if (mContext.get().getResources().getBoolean(R.bool.enable_icons_sort) ||
- mContext.get().getResources().getBoolean(R.bool.enable_icon_name_replacer)) {
- Collections.sort(icons, Icon.TitleComparator);
- CandyBarMainActivity.sSections.get(i).setIcons(icons);
- }
- }
-
- if (CandyBarApplication.getConfiguration().isShowTabAllIcons()) {
- List icons = IconsHelper.getTabAllIcons();
- CandyBarMainActivity.sSections.add(new Icon(
- CandyBarApplication.getConfiguration().getTabAllIconsTitle(), icons));
- }
- }
-
- if (CandyBarMainActivity.sHomeIcon != null) return true;
-
- Random random = new Random();
- int index = random.nextInt(CandyBarMainActivity.sSections.size());
- List icons = CandyBarMainActivity.sSections.get(index).getIcons();
- index = random.nextInt(icons.size());
- Icon icon = icons.get(index);
-
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeResource(mContext.get().getResources(),
- icon.getRes(), options);
-
- if (!mContext.get().getResources().getBoolean(R.bool.show_icon_name)) {
- // It means the title of icon is not yet computed, so compute it
- IconsHelper.computeTitles(mContext.get(), Collections.singletonList(icon));
- }
-
- String iconDimension = "";
-
- if (options.outWidth > 0 && options.outHeight > 0) {
- iconDimension = mContext.get().getResources().getString(R.string.home_icon_dimension,
- options.outWidth + " x " + options.outHeight);
- }
-
- mHome = new Home(
- icon.getRes(),
- icon.getTitle(),
- iconDimension,
- Home.Type.DIMENSION,
- false);
- CandyBarMainActivity.sHomeIcon = mHome;
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (ok) {
- if (mHome == null) return;
- if (mContext.get() == null) return;
-
- FragmentManager fm = ((AppCompatActivity) mContext.get()).getSupportFragmentManager();
- if (fm == null) return;
-
- Fragment fragment = fm.findFragmentByTag("home");
- if (fragment == null) return;
-
- HomeListener listener = (HomeListener) fragment;
- listener.onHomeDataUpdated(mHome);
- }
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/PremiumRequestBuilderTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/PremiumRequestBuilderTask.java
deleted file mode 100644
index 3acc63e..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/PremiumRequestBuilderTask.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package candybar.lib.tasks;
-
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.applications.CandyBarApplication;
-import candybar.lib.databases.Database;
-import candybar.lib.fragments.dialog.IntentChooserFragment;
-import candybar.lib.helpers.DeviceHelper;
-import candybar.lib.items.Request;
-import candybar.lib.utils.AsyncTaskBase;
-import candybar.lib.utils.Extras;
-import candybar.lib.utils.listeners.RequestListener;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class PremiumRequestBuilderTask extends AsyncTaskBase {
-
- private final WeakReference mContext;
- private final WeakReference mCallback;
- private String mEmailBody;
- private Extras.Error mError;
-
- public PremiumRequestBuilderTask(Context context, PremiumRequestBuilderCallback callback) {
- mContext = new WeakReference<>(context);
- mCallback = new WeakReference<>(callback);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (CandyBarApplication.sRequestProperty == null) {
- mError = Extras.Error.ICON_REQUEST_PROPERTY_NULL;
- return false;
- }
-
- if (CandyBarApplication.sRequestProperty.getComponentName() == null) {
- mError = Extras.Error.ICON_REQUEST_PROPERTY_COMPONENT_NULL;
- return false;
- }
-
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(DeviceHelper.getDeviceInfo(mContext.get()));
-
- List requests = Database.get(mContext.get()).getPremiumRequest(null);
-
- for (int i = 0; i < requests.size(); i++) {
- stringBuilder.append("\r\n\r\n")
- .append(requests.get(i).getName())
- .append("\r\n")
- .append(requests.get(i).getActivity())
- .append("\r\n")
- .append("https://play.google.com/store/apps/details?id=")
- .append(requests.get(i).getPackageName())
- .append("\r\n")
- .append("Order Id: ")
- .append(requests.get(i).getOrderId())
- .append("\r\n")
- .append("Product Id: ")
- .append(requests.get(i).getProductId());
- }
-
- mEmailBody = stringBuilder.toString();
- return true;
- } catch (Exception e) {
- CandyBarApplication.sRequestProperty = null;
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (mContext.get() == null) return;
- if (((AppCompatActivity) mContext.get()).isFinishing()) return;
-
- if (ok) {
- try {
- if (mCallback.get() != null) {
- mCallback.get().onFinished();
- }
-
- RequestListener listener = (RequestListener) mContext.get();
- listener.onRequestBuilt(getIntent(CandyBarApplication.sRequestProperty.getComponentName(), mEmailBody),
- IntentChooserFragment.REBUILD_ICON_REQUEST);
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- } else {
- if (mError != null) {
- LogUtil.e(mError.getMessage());
- mError.showToast(mContext.get());
- }
- }
- }
-
- @Nullable
- private Intent getIntent(ComponentName name, String emailBody) {
- try {
- Intent intent = new Intent(Intent.ACTION_SEND);
- addIntentExtra(intent, emailBody);
- intent.setComponent(name);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- return intent;
- } catch (IllegalArgumentException e) {
- try {
- Intent intent = new Intent(Intent.ACTION_SEND);
- addIntentExtra(intent, emailBody);
- return intent;
- } catch (ActivityNotFoundException e1) {
- LogUtil.e(Log.getStackTraceString(e1));
- }
- }
- return null;
- }
-
- private void addIntentExtra(@NonNull Intent intent, String emailBody) {
- intent.setType("application/zip");
-
- if (CandyBarApplication.sZipPath != null) {
- File zip = new File(CandyBarApplication.sZipPath);
- if (zip.exists()) {
- Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
- if (uri == null) uri = Uri.fromFile(zip);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- }
- }
-
- String subject = mContext.get().getResources().getString(R.string.premium_request_email_subject);
- if (subject.length() == 0)
- subject = mContext.get().getResources().getString(R.string.app_name) + " Premium Icon Request";
- subject = "Rebuilt: " + subject;
-
- String emailAddress = mContext.get().getResources().getString(R.string.premium_request_email);
- // Fallback to regular request email
- if (emailAddress.length() == 0)
- emailAddress = mContext.get().getResources().getString(R.string.regular_request_email);
- // Fallback to dev_email
- if (emailAddress.length() == 0)
- emailAddress = mContext.get().getResources().getString(R.string.dev_email);
-
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddress});
- intent.putExtra(Intent.EXTRA_SUBJECT, subject);
- intent.putExtra(Intent.EXTRA_TEXT, emailBody);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
- }
-
- public interface PremiumRequestBuilderCallback {
- void onFinished();
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/ReportBugsTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/ReportBugsTask.java
deleted file mode 100644
index 60a8401..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/ReportBugsTask.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package candybar.lib.tasks;
-
-import static com.danimahardhika.android.helpers.core.FileHelper.getUriFromFile;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.util.Log;
-import android.widget.Toast;
-
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.danimahardhika.android.helpers.core.FileHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.List;
-
-import candybar.lib.R;
-import candybar.lib.helpers.DeviceHelper;
-import candybar.lib.helpers.ReportBugsHelper;
-import candybar.lib.helpers.RequestHelper;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ReportBugsTask extends AsyncTaskBase {
-
- private final WeakReference mContext;
- private final String mDescription;
- private String mZipPath = null;
- private StringBuilder mStringBuilder;
- private MaterialDialog mDialog;
-
- public ReportBugsTask(Context context, String description) {
- mContext = new WeakReference<>(context);
- mDescription = description;
- }
-
- @Override
- protected void preRun() {
- mDialog = new MaterialDialog.Builder(mContext.get())
- .typeface(TypefaceHelper.getMedium(mContext.get()), TypefaceHelper.getRegular(mContext.get()))
- .content(R.string.report_bugs_building)
- .progress(true, 0)
- .progressIndeterminateStyle(true)
- .cancelable(false)
- .canceledOnTouchOutside(false)
- .build();
- mDialog.show();
- mStringBuilder = new StringBuilder();
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- List files = new ArrayList<>();
-
- mStringBuilder.append(DeviceHelper.getDeviceInfo(mContext.get()))
- .append("\r\n").append(mDescription).append("\r\n");
-
- File brokenAppFilter = ReportBugsHelper.buildBrokenAppFilter(mContext.get());
- if (brokenAppFilter != null) files.add(brokenAppFilter.toString());
-
- File brokenDrawables = ReportBugsHelper.buildBrokenDrawables(mContext.get());
- if (brokenDrawables != null) files.add(brokenDrawables.toString());
-
- File activityList = ReportBugsHelper.buildActivityList(mContext.get());
- if (activityList != null) files.add(activityList.toString());
-
- String stackTrace = Preferences.get(mContext.get()).getLatestCrashLog();
- File crashLog = ReportBugsHelper.buildCrashLog(mContext.get(), stackTrace);
- if (crashLog != null) files.add(crashLog.toString());
-
- mZipPath = FileHelper.createZip(files, new File(mContext.get().getCacheDir(),
- RequestHelper.getGeneratedZipName(ReportBugsHelper.REPORT_BUGS)));
- return true;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (mContext.get() == null) return;
- if (((AppCompatActivity) mContext.get()).isFinishing()) return;
-
- mDialog.dismiss();
- if (ok) {
- String emailAddress = mContext.get().getString(R.string.regular_request_email);
- // Fallback to dev_email
- if (emailAddress.length() == 0)
- emailAddress = mContext.get().getString(R.string.dev_email);
-
- final Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("application/zip");
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddress});
- intent.putExtra(Intent.EXTRA_SUBJECT,
- "Report Bugs " + (mContext.get().getString(
- R.string.app_name)));
- intent.putExtra(Intent.EXTRA_TEXT, mStringBuilder.toString());
-
- if (mZipPath != null) {
- File zip = new File(mZipPath);
- if (zip.exists()) {
- Uri uri = getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
- if (uri == null) uri = Uri.fromFile(zip);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- }
- }
-
- mContext.get().startActivity(Intent.createChooser(intent,
- mContext.get().getResources().getString(R.string.app_client)));
- } else {
- Toast.makeText(mContext.get(), R.string.report_bugs_failed,
- Toast.LENGTH_LONG).show();
- }
-
- mZipPath = null;
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperApplyTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperApplyTask.java
deleted file mode 100644
index f7c2a4c..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperApplyTask.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package candybar.lib.tasks;
-
-import android.app.Activity;
-import android.app.WallpaperManager;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Point;
-import android.graphics.RectF;
-import android.os.Build;
-import android.util.Log;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.content.ContextCompat;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.danimahardhika.android.helpers.core.ColorHelper;
-import com.danimahardhika.android.helpers.core.WindowHelper;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-import com.danimahardhika.cafebar.CafeBar;
-import com.danimahardhika.cafebar.CafeBarTheme;
-
-import java.lang.ref.WeakReference;
-import java.util.Locale;
-import java.util.concurrent.ExecutorService;
-
-import candybar.lib.R;
-import candybar.lib.helpers.TypefaceHelper;
-import candybar.lib.helpers.WallpaperHelper;
-import candybar.lib.items.ImageSize;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.preferences.Preferences;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class WallpaperApplyTask extends AsyncTaskBase implements WallpaperPropertiesLoaderTask.Callback {
-
- private final WeakReference mContext;
- private Apply mApply;
- private RectF mRectF;
- private Wallpaper mWallpaper;
- private MaterialDialog mDialog;
-
- public WallpaperApplyTask(@NonNull Context context, @NonNull Wallpaper wallpaper) {
- mContext = new WeakReference<>(context);
- mWallpaper = wallpaper;
- mApply = Apply.HOMESCREEN;
- }
-
- public WallpaperApplyTask to(Apply apply) {
- mApply = apply;
- return this;
- }
-
- public WallpaperApplyTask crop(@Nullable RectF rectF) {
- mRectF = rectF;
- return this;
- }
-
- @Override
- protected AsyncTaskBase execute(ExecutorService executorService) {
- if (mDialog == null) {
- int color = mWallpaper.getColor();
- if (color == 0) {
- color = ColorHelper.getAttributeColor(mContext.get(), R.attr.colorSecondary);
- }
-
- final MaterialDialog.Builder builder = new MaterialDialog.Builder(mContext.get());
- builder.widgetColor(color)
- .typeface(TypefaceHelper.getMedium(mContext.get()), TypefaceHelper.getRegular(mContext.get()))
- .progress(true, 0)
- .cancelable(false)
- .progressIndeterminateStyle(true)
- .content(R.string.wallpaper_loading)
- .positiveColor(color)
- .positiveText(android.R.string.cancel)
- .onPositive((dialog, which) -> cancel(true));
-
- mDialog = builder.build();
- }
-
- if (!mDialog.isShowing()) mDialog.show();
-
- if (mWallpaper == null) {
- LogUtil.e("WallpaperApply cancelled, wallpaper is null");
- return null;
- }
-
- if (mWallpaper.getDimensions() == null) {
- return new WallpaperPropertiesLoaderTask(mContext.get(), mWallpaper, this)
- .executeOnThreadPool();
- }
-
- return super.execute(executorService);
- }
-
- @Override
- public void onPropertiesReceived(Wallpaper wallpaper) {
- mWallpaper = wallpaper;
- if (mWallpaper.getDimensions() == null) {
- LogUtil.e("WallpaperApply cancelled, unable to retrieve wallpaper dimensions");
-
- if (mContext.get() == null) return;
- if (mContext.get() instanceof Activity) {
- if (((Activity) mContext.get()).isFinishing())
- return;
- }
-
- if (mDialog != null && mDialog.isShowing()) {
- mDialog.dismiss();
- }
-
- Toast.makeText(mContext.get(), R.string.wallpaper_apply_failed,
- Toast.LENGTH_LONG).show();
- return;
- }
-
- try {
- executeOnThreadPool();
- } catch (IllegalStateException e) {
- LogUtil.e(Log.getStackTraceString(e));
- }
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- ImageSize imageSize = WallpaperHelper.getTargetSize(mContext.get());
-
- LogUtil.d("original rectF: " + mRectF);
-
- if (mRectF != null && Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
- Point point = WindowHelper.getScreenSize(mContext.get());
- int height = point.y - WindowHelper.getStatusBarHeight(mContext.get()) - WindowHelper.getNavigationBarHeight(mContext.get());
- float heightFactor = (float) imageSize.height / (float) height;
- mRectF = WallpaperHelper.getScaledRectF(mRectF, heightFactor, 1f);
- }
-
- if (mRectF == null && Preferences.get(mContext.get()).isCropWallpaper()) {
- /*
- * Create a center crop rectF if wallpaper applied from grid, not opening the preview first
- */
- float widthScaleFactor = (float) imageSize.height / (float) mWallpaper.getDimensions().height;
-
- float side = ((float) mWallpaper.getDimensions().width * widthScaleFactor - (float) imageSize.width) / 2f;
- float leftRectF = 0f - side;
- float rightRectF = (float) mWallpaper.getDimensions().width * widthScaleFactor - side;
- float topRectF = 0f;
- float bottomRectF = (float) imageSize.height;
- mRectF = new RectF(leftRectF, topRectF, rightRectF, bottomRectF);
- LogUtil.d("created center crop rectF: " + mRectF);
- }
-
- ImageSize adjustedSize = imageSize;
- RectF adjustedRectF = mRectF;
-
- float scaleFactor = (float) mWallpaper.getDimensions().height / (float) imageSize.height;
- if (scaleFactor > 1f) {
- /*
- * Applying original wallpaper size caused a problem (wallpaper zoomed in)
- * if wallpaper dimension bigger than device screen resolution
- *
- * Solution: Resize wallpaper to match screen resolution
- */
-
- /*
- * Use original wallpaper size:
- * adjustedSize = new ImageSize(width, height);
- */
-
- /*
- * Adjust wallpaper size to match screen resolution:
- */
- float widthScaleFactor = (float) imageSize.height / (float) mWallpaper.getDimensions().height;
- int adjustedWidth = Float.valueOf((float) mWallpaper.getDimensions().width * widthScaleFactor).intValue();
- adjustedSize = new ImageSize(adjustedWidth, imageSize.height);
-
- if (adjustedRectF != null) {
- /*
- * If wallpaper crop enabled, original wallpaper size should be loaded first
- */
- adjustedSize = new ImageSize(mWallpaper.getDimensions().width, mWallpaper.getDimensions().height);
- adjustedRectF = WallpaperHelper.getScaledRectF(mRectF, scaleFactor, scaleFactor);
- LogUtil.d("adjusted rectF: " + adjustedRectF);
- }
-
- LogUtil.d(String.format(Locale.getDefault(), "adjusted bitmap: %d x %d",
- adjustedSize.width, adjustedSize.height));
- }
-
- int call = 1;
- do {
- /*
- * Load the bitmap first
- */
- Bitmap loadedBitmap = Glide.with(mContext.get())
- .asBitmap()
- .load(mWallpaper.getURL())
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
- .submit()
- .get();
-
- if (loadedBitmap != null) {
- try {
- /*
- * Checking if loaded bitmap resolution supported by the device
- * If texture size too big then resize it
- */
- Bitmap bitmapTemp = Bitmap.createBitmap(
- loadedBitmap.getWidth(),
- loadedBitmap.getHeight(),
- loadedBitmap.getConfig());
- bitmapTemp.recycle();
-
- /*
- * Texture size is ok
- */
- LogUtil.d(String.format(Locale.getDefault(), "loaded bitmap: %d x %d",
- loadedBitmap.getWidth(), loadedBitmap.getHeight()));
- runOnUiThread(() -> mDialog.setContent(R.string.wallpaper_applying));
-
- Bitmap bitmap = loadedBitmap;
- if (Preferences.get(mContext.get()).isCropWallpaper() && adjustedRectF != null) {
- LogUtil.d("rectF: " + adjustedRectF);
- /*
- * Cropping bitmap
- */
- ImageSize targetSize = WallpaperHelper.getTargetSize(mContext.get());
-
- int targetWidth = Double.valueOf(
- ((double) loadedBitmap.getHeight() / (double) targetSize.height)
- * (double) targetSize.width).intValue();
-
- bitmap = Bitmap.createBitmap(
- targetWidth,
- loadedBitmap.getHeight(),
- loadedBitmap.getConfig());
- Paint paint = new Paint();
- paint.setFilterBitmap(true);
- paint.setAntiAlias(true);
- paint.setDither(true);
-
- Canvas canvas = new Canvas(bitmap);
- canvas.drawBitmap(loadedBitmap, null, adjustedRectF, paint);
-
- float scale = (float) targetSize.height / (float) bitmap.getHeight();
- if (scale < 1f) {
- LogUtil.d("bitmap size is bigger than screen resolution, resizing bitmap");
- int resizedWidth = Float.valueOf((float) bitmap.getWidth() * scale).intValue();
- bitmap = Bitmap.createScaledBitmap(bitmap, resizedWidth, targetSize.height, true);
- }
- }
-
- /*
- * Final bitmap generated
- */
- LogUtil.d(String.format(Locale.getDefault(), "generated bitmap: %d x %d ",
- bitmap.getWidth(), bitmap.getHeight()));
-
- if (mApply == Apply.HOMESCREEN_LOCKSCREEN) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- WallpaperManager.getInstance(mContext.get().getApplicationContext()).setBitmap(
- bitmap, null, true, WallpaperManager.FLAG_LOCK | WallpaperManager.FLAG_SYSTEM);
- return true;
- }
- }
-
- if (mApply == Apply.HOMESCREEN) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- WallpaperManager.getInstance(mContext.get().getApplicationContext()).setBitmap(
- bitmap, null, true, WallpaperManager.FLAG_SYSTEM);
- return true;
- }
-
- WallpaperManager.getInstance(mContext.get().getApplicationContext()).setBitmap(bitmap);
- return true;
- }
-
- if (mApply == Apply.LOCKSCREEN) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- WallpaperManager.getInstance(mContext.get().getApplicationContext()).setBitmap(
- bitmap, null, true, WallpaperManager.FLAG_LOCK);
- return true;
- }
- }
- } catch (OutOfMemoryError e) {
- LogUtil.e("loaded bitmap is too big, resizing it ...");
- /*
- * Texture size is too big
- * Resizing bitmap
- */
-
- double scale = 1 - (0.1 * call);
- int scaledWidth = Double.valueOf(adjustedSize.width * scale).intValue();
- int scaledHeight = Double.valueOf(adjustedSize.height * scale).intValue();
-
- adjustedRectF = WallpaperHelper.getScaledRectF(adjustedRectF,
- (float) scale, (float) scale);
- adjustedSize = new ImageSize(scaledWidth, scaledHeight);
- }
- }
-
- /*
- * Continue to next iteration
- */
- call++;
- } while (call <= 5 && !isCancelled());
- return false;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- public void cancel(boolean mayInterruptIfRunning) {
- super.cancel(mayInterruptIfRunning);
- Toast.makeText(mContext.get(), R.string.wallpaper_apply_cancelled,
- Toast.LENGTH_LONG).show();
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (mContext.get() == null) {
- return;
- }
-
- if (((AppCompatActivity) mContext.get()).isFinishing()) {
- return;
- }
-
- if (mDialog != null && mDialog.isShowing()) {
- mDialog.dismiss();
- }
-
- if (ok) {
- CafeBar.builder(mContext.get())
- .theme(CafeBarTheme.Custom(ContextCompat.getColor(
- mContext.get(), R.color.cardBackground)))
- .contentTypeface(TypefaceHelper.getRegular(mContext.get()))
- .floating(true)
- .fitSystemWindow()
- .content(R.string.wallpaper_applied)
- .show();
- } else {
- Toast.makeText(mContext.get(), R.string.wallpaper_apply_failed,
- Toast.LENGTH_LONG).show();
- }
- }
-
- public enum Apply {
- LOCKSCREEN,
- HOMESCREEN,
- HOMESCREEN_LOCKSCREEN
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperPropertiesLoaderTask.java b/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperPropertiesLoaderTask.java
deleted file mode 100644
index f9897b3..0000000
--- a/libs/candybar/src/main/java/candybar/lib/tasks/WallpaperPropertiesLoaderTask.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package candybar.lib.tasks;
-
-import android.content.Context;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.bumptech.glide.Glide;
-import com.danimahardhika.android.helpers.core.utils.LogUtil;
-
-import java.io.File;
-import java.io.InputStream;
-import java.lang.ref.WeakReference;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import candybar.lib.databases.Database;
-import candybar.lib.items.ImageSize;
-import candybar.lib.items.Wallpaper;
-import candybar.lib.utils.AsyncTaskBase;
-
-/*
- * CandyBar - Material Dashboard
- *
- * Copyright (c) 2014-2016 Dani Mahardhika
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class WallpaperPropertiesLoaderTask extends AsyncTaskBase {
-
- private final Wallpaper mWallpaper;
- private final WeakReference mCallback;
- private final WeakReference mContext;
-
- public WallpaperPropertiesLoaderTask(Context context, Wallpaper wallpaper, @Nullable Callback callback) {
- mContext = new WeakReference<>(context);
- mWallpaper = wallpaper;
- mCallback = new WeakReference<>(callback);
- }
-
- @Override
- protected boolean run() {
- if (!isCancelled()) {
- try {
- Thread.sleep(1);
- if (mWallpaper == null) return false;
-
- if (mWallpaper.getDimensions() != null &&
- mWallpaper.getMimeType() != null &&
- mWallpaper.getSize() > 0) {
- return false;
- }
-
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
-
- URL url = new URL(mWallpaper.getURL());
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setConnectTimeout(15000);
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- InputStream stream = connection.getInputStream();
- BitmapFactory.decodeStream(stream, null, options);
-
- ImageSize imageSize = new ImageSize(options.outWidth, options.outHeight);
- mWallpaper.setDimensions(imageSize);
- mWallpaper.setMimeType(options.outMimeType);
-
- int contentLength = connection.getContentLength();
- if (contentLength > 0) {
- mWallpaper.setSize(contentLength);
- }
-
- Database.get(mContext.get()).updateWallpaper(mWallpaper);
- stream.close();
- return true;
- }
- return false;
- } catch (Exception e) {
- LogUtil.e(Log.getStackTraceString(e));
- return false;
- }
- }
- return false;
- }
-
- @Override
- protected void postRun(boolean ok) {
- if (ok && mContext.get() != null && !((AppCompatActivity) mContext.get()).isFinishing()) {
- if (mWallpaper.getSize() <= 0) {
- try {
- File target = Glide.with(mContext.get())
- .asFile()
- .load(mWallpaper.getURL())
- .onlyRetrieveFromCache(true)
- .submit()
- .get();
- if (target != null && target.exists()) {
- mWallpaper.setSize((int) target.length());
- }
- } catch (Exception ignored) {
- }
- }
- }
-
- if (mCallback.get() != null) {
- mCallback.get().onPropertiesReceived(mWallpaper);
- }
- }
-
- public interface Callback {
- void onPropertiesReceived(Wallpaper wallpaper);
- }
-}
diff --git a/libs/candybar/src/main/java/candybar/lib/utils/AlphanumComparator.java b/libs/candybar/src/main/java/candybar/lib/utils/AlphanumComparator.java
deleted file mode 100644
index f360006..0000000
--- a/libs/candybar/src/main/java/candybar/lib/utils/AlphanumComparator.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package candybar.lib.utils;
-
-/*
- * The Alphanum Algorithm is an improved sorting algorithm for strings
- * containing numbers. Instead of sorting numbers in ASCII order like
- * a standard sort, this algorithm sorts numbers in numeric order.
- *
- * The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-import java.util.Comparator;
-import java.util.Locale;
-
-/**
- * This is an updated version with enhancements made by Daniel Migowski,
- * Andre Bogus, and David Koelle
- *
- * To convert to use Templates (Java 1.5+):
- * - Change "implements Comparator" to "implements Comparator"
- * - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)"
- * - Remove the type checking and casting in compare().
- *
- * To use this class:
- * Use the static "sort" method from the java.util.Collections class:
- * Collections.sort(your list, new AlphanumComparator());
- */
-public class AlphanumComparator implements Comparator