From df8a9c447ebb4b4c54dd568d40ce11beea05f14d Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sat, 12 Oct 2019 12:11:48 +0530 Subject: [PATCH] Added desatuated color --- .../name/monkey/retromusic/activities/MainActivity.kt | 1 + .../activities/SupportDevelopmentActivity.kt | 9 ++++++--- .../fragments/settings/ThemeSettingsFragment.kt | 10 ++++++++++ .../name/monkey/retromusic/util/PreferenceUtil.java | 11 +++++++++++ .../monkey/retromusic/views/ColorIconsImageView.kt | 4 ++-- app/src/main/res/xml/pref_general.xml | 8 ++++++++ .../code/name/monkey/appthemehelper/ThemeStore.kt | 3 ++- 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt index 9aad95d3..eb740960 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt @@ -244,6 +244,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.ALBUM_COVER_TRANSFORM || + key == PreferenceUtil.DESATURATED_COLOR || key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES) postRecreate() diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt index 0692f740..902ad982 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt @@ -12,6 +12,7 @@ import android.view.ViewGroup import android.widget.TextView import android.widget.Toast import androidx.annotation.LayoutRes +import androidx.appcompat.widget.AppCompatImageView import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -22,7 +23,6 @@ import code.name.monkey.retromusic.BuildConfig import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.extensions.applyToolbar -import code.name.monkey.retromusic.views.IconImageView import com.anjlab.android.iab.v3.BillingProcessor import com.anjlab.android.iab.v3.SkuDetails import com.anjlab.android.iab.v3.TransactionDetails @@ -161,7 +161,10 @@ private class SkuDetailsLoadAsyncTask internal constructor(supportDevelopmentAct } } -class SkuDetailsAdapter(private var donationsDialog: SupportDevelopmentActivity, objects: List) : RecyclerView.Adapter() { +class SkuDetailsAdapter( + private var donationsDialog: SupportDevelopmentActivity, + objects: List +) : RecyclerView.Adapter() { private var skuDetailsList: List = ArrayList() init { @@ -218,7 +221,7 @@ class SkuDetailsAdapter(private var donationsDialog: SupportDevelopmentActivity, var title: TextView = view.findViewById(R.id.itemTitle) var text: TextView = view.findViewById(R.id.itemText) var price: TextView = view.findViewById(R.id.itemPrice) - var image: IconImageView = view.findViewById(R.id.itemImage) + var image: AppCompatImageView = view.findViewById(R.id.itemImage) } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt index 4adff377..67185f8c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt @@ -86,6 +86,16 @@ class ThemeSettingsFragment : AbsSettingsFragment() { true } + val desaturatedColor: ATESwitchPreference? = findPreference(PreferenceUtil.DESATURATED_COLOR) + desaturatedColor?.setOnPreferenceChangeListener { _, value -> + val desaturated = value as Boolean + ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated).apply() + PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated) + requireActivity().recreate() + true + } + + val colorAppShortcuts: TwoStatePreference = findPreference("should_color_app_shortcuts")!! if (!VersionUtils.hasNougatMR()) { colorAppShortcuts.isVisible = false diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index 5017139f..49ad9f1e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -59,6 +59,7 @@ import code.name.monkey.retromusic.transform.VerticalStackTransformer; public final class PreferenceUtil { public static final String LIBRARY_CATEGORIES = "library_categories"; + public static final String DESATURATED_COLOR = "desaturated_color"; public static final String BLACK_THEME = "black_theme"; public static final String DIALOG_CORNER = "dialog_corner"; public static final String KEEP_SCREEN_ON = "keep_screen_on"; @@ -181,6 +182,16 @@ public final class PreferenceUtil { } } + public boolean desaturatedColor() { + return mPreferences.getBoolean(DESATURATED_COLOR, false); + } + + public void setDesaturatedColor(boolean value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(DESATURATED_COLOR, value); + editor.apply(); + } + public boolean getSleepTimerFinishMusic() { return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false); } diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt b/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt index 7f16a611..8663e3ba 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt +++ b/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt @@ -22,6 +22,7 @@ import androidx.appcompat.widget.AppCompatImageView import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroColorUtil @@ -49,7 +50,7 @@ class ColorIconsImageView : AppCompatImageView { private fun setIconBackgroundColor(color: Int) { setBackgroundResource(R.drawable.color_circle_gradient) - if (ATHUtil.isWindowBackgroundDark(context)) { + if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtil.getInstance(context).desaturatedColor()) { val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f) backgroundTintList = ColorStateList.valueOf(desaturatedColor) imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary)) @@ -61,5 +62,4 @@ class ColorIconsImageView : AppCompatImageView { invalidate() } - } diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 4a498530..6da39af5 100755 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -23,6 +23,7 @@ android:key="category_color" android:layout="@layout/preference_category_title" android:title="@string/colors"> + + +