Merge pull request #534 from h4h13/homesection

Homesection
This commit is contained in:
Hemanth S 2019-10-12 14:09:02 +05:30 committed by GitHub
commit 5ff9d5bcd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 101 additions and 61 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 379 versionCode 380
versionName '3.4.400-beta05' versionName '3.4.400-beta06'
multiDexEnabled true multiDexEnabled true

View file

@ -244,6 +244,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.ALBUM_COVER_STYLE ||
key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE ||
key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.ALBUM_COVER_TRANSFORM ||
key == PreferenceUtil.DESATURATED_COLOR ||
key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.TAB_TEXT_MODE ||
key == PreferenceUtil.LIBRARY_CATEGORIES) key == PreferenceUtil.LIBRARY_CATEGORIES)
postRecreate() postRecreate()

View file

@ -12,6 +12,7 @@ import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.appcompat.widget.AppCompatImageView
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView 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.R
import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.activities.base.AbsBaseActivity
import code.name.monkey.retromusic.extensions.applyToolbar 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.BillingProcessor
import com.anjlab.android.iab.v3.SkuDetails import com.anjlab.android.iab.v3.SkuDetails
import com.anjlab.android.iab.v3.TransactionDetails 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<SkuDetails>) : RecyclerView.Adapter<SkuDetailsAdapter.ViewHolder>() { class SkuDetailsAdapter(
private var donationsDialog: SupportDevelopmentActivity,
objects: List<SkuDetails>
) : RecyclerView.Adapter<SkuDetailsAdapter.ViewHolder>() {
private var skuDetailsList: List<SkuDetails> = ArrayList() private var skuDetailsList: List<SkuDetails> = ArrayList()
init { init {
@ -218,7 +221,7 @@ class SkuDetailsAdapter(private var donationsDialog: SupportDevelopmentActivity,
var title: TextView = view.findViewById(R.id.itemTitle) var title: TextView = view.findViewById(R.id.itemTitle)
var text: TextView = view.findViewById(R.id.itemText) var text: TextView = view.findViewById(R.id.itemText)
var price: TextView = view.findViewById(R.id.itemPrice) 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 { companion object {

View file

@ -15,20 +15,27 @@ import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Home
import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
class HomeAdapter( class HomeAdapter(
private val activity: AppCompatActivity, private val activity: AppCompatActivity,
private var homes: List<Home>, private val displayMetrics: DisplayMetrics,
private val displayMetrics: DisplayMetrics private val repository: Repository
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { ) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
return homes[position].homeSection return when (position) {
0 -> TOP_ARTISTS
1 -> TOP_ALBUMS
2 -> RECENT_ARTISTS
3 -> RECENT_ALBUMS
4 -> PLAYLISTS
else -> -1
}
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
@ -43,87 +50,92 @@ class HomeAdapter(
} }
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val home = homes[position] println(getItemViewType(position))
when (getItemViewType(position)) { when (getItemViewType(position)) {
RECENT_ALBUMS -> {
RECENT_ALBUMS, TOP_ALBUMS -> {
val viewHolder = holder as AlbumViewHolder val viewHolder = holder as AlbumViewHolder
viewHolder.bindView(home) viewHolder.bindView(repository.recentAlbums(), R.string.recent_albums, R.string.recent_added_albums)
} }
RECENT_ARTISTS, TOP_ARTISTS -> { TOP_ALBUMS -> {
val viewHolder = holder as AlbumViewHolder
viewHolder.bindView(repository.topAlbums(), R.string.top_albums, R.string.most_played_albums)
}
RECENT_ARTISTS -> {
val viewHolder = holder as ArtistViewHolder val viewHolder = holder as ArtistViewHolder
viewHolder.bindView(home) viewHolder.bindView(repository.recentArtists(), R.string.recent_artists, R.string.recent_added_artists)
}
TOP_ARTISTS -> {
val viewHolder = holder as ArtistViewHolder
viewHolder.bindView(repository.recentArtists(), R.string.top_artists, R.string.most_played_artists)
} }
PLAYLISTS -> { PLAYLISTS -> {
val viewHolder = holder as PlaylistViewHolder val viewHolder = holder as PlaylistViewHolder
viewHolder.bindView(home) viewHolder.bindView(repository.favoritePlaylist, R.string.favorites, R.string.favorites_songs)
} }
} }
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return homes.size return 5
}
fun swapData(finalList: List<Home>) {
homes = finalList
notifyDataSetChanged()
} }
companion object { companion object {
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, GENRES, PLAYLISTS) @IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, PLAYLISTS)
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
annotation class HomeSection annotation class HomeSection
const val RECENT_ALBUMS = 0 const val RECENT_ALBUMS = 3
const val TOP_ALBUMS = 1 const val TOP_ALBUMS = 1
const val RECENT_ARTISTS = 2 const val RECENT_ARTISTS = 2
const val TOP_ARTISTS = 3 const val TOP_ARTISTS = 0
const val GENRES = 4 const val PLAYLISTS = 4
const val PLAYLISTS = 5
} }
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) { private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(list: ArrayList<Album>, titleRes: Int, subtitleRes: Int) {
recyclerView.apply { recyclerView.apply {
adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList<Album>, displayMetrics) adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
} }
title.text = activity.getString(home.title) title.text = activity.getString(titleRes)
text.text = activity.getString(home.subTitle) text.text = activity.getString(subtitleRes)
} }
} }
private inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) { inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(list: ArrayList<Artist>, titleRes: Int, subtitleRes: Int) {
recyclerView.apply { recyclerView.apply {
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, val artistAdapter = ArtistAdapter(activity, list,
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), false, null) PreferenceUtil.getInstance(activity).getHomeGridStyle(activity), false, null)
adapter = artistAdapter adapter = artistAdapter
} }
title.text = activity.getString(home.title) title.text = activity.getString(titleRes)
text.text = activity.getString(home.subTitle) text.text = activity.getString(subtitleRes)
} }
} }
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) { private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(arrayList: ArrayList<Playlist>, titleRes: Int, subtitleRes: Int) {
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist) if (arrayList.isNotEmpty()) {
recyclerView.apply { val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0])
val songAdapter = SongAdapter(activity, songs, R.layout.item_album_card, false, null) recyclerView.apply {
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) val songAdapter = SongAdapter(activity, songs, R.layout.item_album_card, false, null)
adapter = songAdapter layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
adapter = songAdapter
}
title.text = activity.getString(titleRes)
text.text = activity.getString(subtitleRes)
} }
title.text = activity.getString(home.title)
text.text = activity.getString(home.subTitle)
} }
} }
private open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) { open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView) val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
val title: MaterialTextView = itemView.findViewById(R.id.title) val title: MaterialTextView = itemView.findViewById(R.id.title)
val text: MaterialTextView = itemView.findViewById(R.id.text) val text: MaterialTextView = itemView.findViewById(R.id.text)

View file

@ -28,8 +28,8 @@ import code.name.monkey.retromusic.model.Home
import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
import code.name.monkey.retromusic.mvp.presenter.HomePresenter
import code.name.monkey.retromusic.mvp.presenter.HomeView import code.name.monkey.retromusic.mvp.presenter.HomeView
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.util.Compressor import code.name.monkey.retromusic.util.Compressor
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
@ -48,17 +48,14 @@ import javax.inject.Inject
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeView { class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeView {
private lateinit var homeAdapter: HomeAdapter private lateinit var homeAdapter: HomeAdapter
@Inject @Inject
lateinit var homePresenter: HomePresenter lateinit var repository: Repository
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
private lateinit var toolbar: Toolbar private lateinit var toolbar: Toolbar
override fun sections(sections: ArrayList<Home>) { override fun sections(sections: ArrayList<Home>) {
val finalList = sections.sortedWith(compareBy { it.priority }) val finalList = sections.sortedWith(compareBy { it.priority })
homeAdapter.swapData(finalList)
if (sections.isEmpty()) { if (sections.isEmpty()) {
showEmptyView() showEmptyView()
@ -67,7 +64,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
} }
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false) return inflater.inflate(if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false)
} }
@ -137,10 +133,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
titleWelcome.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName) titleWelcome.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
App.musicComponent.inject(this) App.musicComponent.inject(this)
homePresenter.attachView(this) homeAdapter = HomeAdapter(mainActivity, displayMetrics, repository)
homePresenter.loadSections()
homeAdapter = HomeAdapter(mainActivity, ArrayList(), displayMetrics)
recyclerView.apply { recyclerView.apply {
layoutManager = LinearLayoutManager(mainActivity) layoutManager = LinearLayoutManager(mainActivity)
@ -183,7 +176,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
disposable.dispose() disposable.dispose()
homePresenter.detachView()
} }
override fun showEmptyView() { override fun showEmptyView() {

View file

@ -86,6 +86,16 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
true 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")!! val colorAppShortcuts: TwoStatePreference = findPreference("should_color_app_shortcuts")!!
if (!VersionUtils.hasNougatMR()) { if (!VersionUtils.hasNougatMR()) {
colorAppShortcuts.isVisible = false colorAppShortcuts.isVisible = false

View file

@ -59,6 +59,7 @@ import code.name.monkey.retromusic.transform.VerticalStackTransformer;
public final class PreferenceUtil { public final class PreferenceUtil {
public static final String LIBRARY_CATEGORIES = "library_categories"; 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 BLACK_THEME = "black_theme";
public static final String DIALOG_CORNER = "dialog_corner"; public static final String DIALOG_CORNER = "dialog_corner";
public static final String KEEP_SCREEN_ON = "keep_screen_on"; 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() { public boolean getSleepTimerFinishMusic() {
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false); return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
} }

View file

@ -22,6 +22,7 @@ import androidx.appcompat.widget.AppCompatImageView
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroColorUtil
@ -49,7 +50,7 @@ class ColorIconsImageView : AppCompatImageView {
private fun setIconBackgroundColor(color: Int) { private fun setIconBackgroundColor(color: Int) {
setBackgroundResource(R.drawable.color_circle_gradient) 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) val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
backgroundTintList = ColorStateList.valueOf(desaturatedColor) backgroundTintList = ColorStateList.valueOf(desaturatedColor)
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary)) imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary))
@ -61,5 +62,4 @@ class ColorIconsImageView : AppCompatImageView {
invalidate() invalidate()
} }
} }

View file

@ -115,6 +115,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:cardElevation="8dp" app:cardElevation="8dp"
app:cardBackgroundColor="?colorPrimary"
app:shapeAppearanceOverlay="@style/TopCornerCardView"> app:shapeAppearanceOverlay="@style/TopCornerCardView">
<include layout="@layout/home_content" /> <include layout="@layout/home_content" />

View file

@ -111,6 +111,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/toolbar_margin_horizontal" android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal" android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:cardBackgroundColor="?colorPrimary"
app:cardElevation="8dp" app:cardElevation="8dp"
app:shapeAppearanceOverlay="@style/TopCornerCardView"> app:shapeAppearanceOverlay="@style/TopCornerCardView">

View file

@ -112,6 +112,7 @@
android:layout_marginStart="@dimen/toolbar_margin_horizontal" android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal" android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:cardElevation="8dp" app:cardElevation="8dp"
app:cardBackgroundColor="?colorPrimary"
app:shapeAppearanceOverlay="@style/TopCornerCardView"> app:shapeAppearanceOverlay="@style/TopCornerCardView">
<include layout="@layout/home_content" /> <include layout="@layout/home_content" />

View file

@ -104,6 +104,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardElevation="8dp" app:cardElevation="8dp"
app:cardBackgroundColor="?colorPrimary"
app:shapeAppearanceOverlay="@style/TopCornerCardView"> app:shapeAppearanceOverlay="@style/TopCornerCardView">
<include layout="@layout/home_content" /> <include layout="@layout/home_content" />

View file

@ -20,7 +20,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?colorPrimary"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"

View file

@ -60,7 +60,6 @@
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:nestedScrollingEnabled="false" android:nestedScrollingEnabled="false"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View file

@ -23,6 +23,7 @@
android:key="category_color" android:key="category_color"
android:layout="@layout/preference_category_title" android:layout="@layout/preference_category_title"
android:title="@string/colors"> android:title="@string/colors">
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference <code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color" android:key="accent_color"
android:persistent="false" android:persistent="false"
@ -31,6 +32,13 @@
app:enableCopying="true" app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" /> app:icon="@drawable/ic_colorize_white_24dp" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="desaturated_color"
android:summary="As per Material Design guide lines in dark mode colors should be desaturated"
android:title="Desaturated color"
app:enableCopying="true" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference <code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="adaptive_color_app" android:key="adaptive_color_app"

View file

@ -206,8 +206,9 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
@CheckResult @CheckResult
@ColorInt @ColorInt
fun accentColor(context: Context): Int { fun accentColor(context: Context): Int {
val desaturatedColor = prefs(context).getBoolean("desaturated_color", false)
val color = prefs(context).getInt(ThemeStorePrefKeys.KEY_ACCENT_COLOR, ATHUtil.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238"))) val color = prefs(context).getInt(ThemeStorePrefKeys.KEY_ACCENT_COLOR, ATHUtil.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")))
return if (ATHUtil.isWindowBackgroundDark(context)) ColorUtil.desaturateColor(color, 0.4f) else color return if (ATHUtil.isWindowBackgroundDark(context) && desaturatedColor) ColorUtil.desaturateColor(color, 0.4f) else color
} }
@CheckResult @CheckResult