From 933bf7006803ac8ef907756351d9a9ec9328cccd Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sat, 8 Jun 2019 19:12:57 +0530 Subject: [PATCH] Fix buttons color --- app/build.gradle | 2 +- .../activities/AlbumDetailsActivity.kt | 22 ++++------ .../activities/ArtistDetailActivity.kt | 24 +++++------ .../retromusic/activities/SearchActivity.kt | 3 +- .../adapter/song/PlaylistSongAdapter.kt | 4 +- .../adapter/song/ShuffleButtonSongAdapter.kt | 43 ++----------------- .../mainactivity/LibraryFragment.java | 2 +- .../mainactivity/folders/FoldersFragment.java | 2 +- .../mainactivity/home/BannerHomeFragment.kt | 9 ++-- .../retromusic/util/RetroColorUtil.java | 14 +++++- .../monkey/retromusic/util/RetroUtil.java | 8 ---- .../drawable/ic_home_selected_white_24dp.xml | 2 +- .../main/res/drawable/ic_home_white_24dp.xml | 2 +- 13 files changed, 47 insertions(+), 90 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 016c7ca0..f992d319 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,7 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 333 + versionCode 334 versionName '3.1.900' multiDexEnabled true diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt index 37a7f0d9..1835f39f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt @@ -1,7 +1,6 @@ package code.name.monkey.retromusic.activities import android.content.Intent -import android.content.res.ColorStateList import android.graphics.Color import android.os.Bundle import android.transition.Slide @@ -14,10 +13,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.appthemehelper.util.MaterialValueHelper -import code.name.monkey.appthemehelper.util.TintHelper -import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper +import code.name.monkey.appthemehelper.util.* import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity @@ -245,19 +241,17 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac } private fun setColors(color: Int) { - val themeColor = if (PreferenceUtil.getInstance().adaptiveColor) color else ThemeStore.accentColor(this) + val themeColor = if (PreferenceUtil.getInstance().adaptiveColor) color + else ThemeStore.accentColor(this) + songTitle.setTextColor(themeColor) moreTitle.setTextColor(themeColor) - playAction.backgroundTintList = ColorStateList.valueOf(themeColor) - shuffleAction.backgroundTintList = ColorStateList.valueOf(themeColor) - ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(themeColor))).apply { - playAction.setTextColor(this) - playAction.iconTint = this + val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color + else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor) - shuffleAction.setTextColor(this) - shuffleAction.iconTint = this - } + MaterialUtil.setTint(button = shuffleAction, color = buttonColor) + MaterialUtil.setTint(button = playAction, color = buttonColor) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt index 9c0dc629..91fe80f0 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt @@ -18,10 +18,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.appthemehelper.util.MaterialValueHelper -import code.name.monkey.appthemehelper.util.TintHelper -import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper +import code.name.monkey.appthemehelper.util.* import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.adapter.album.AlbumAdapter @@ -40,7 +37,12 @@ import code.name.monkey.retromusic.rest.LastFMRestClient import code.name.monkey.retromusic.rest.model.LastFmArtist import code.name.monkey.retromusic.util.* import com.google.android.material.appbar.AppBarLayout +import kotlinx.android.synthetic.main.activity_album_content.* import kotlinx.android.synthetic.main.activity_artist_content.* +import kotlinx.android.synthetic.main.activity_artist_content.playAction +import kotlinx.android.synthetic.main.activity_artist_content.recyclerView +import kotlinx.android.synthetic.main.activity_artist_content.shuffleAction +import kotlinx.android.synthetic.main.activity_artist_content.songTitle import kotlinx.android.synthetic.main.activity_artist_details.* import retrofit2.Call import retrofit2.Callback @@ -291,17 +293,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac songTitle.setTextColor(textColor) biographyTitle.setTextColor(textColor) - playAction.backgroundTintList = ColorStateList.valueOf(textColor) - shuffleAction.backgroundTintList = ColorStateList.valueOf(textColor) - ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(textColor))).apply { - playAction.setTextColor(this) - playAction.iconTint = this + val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color + else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor) - shuffleAction.setTextColor(this) - shuffleAction.iconTint = this - } - - findViewById(R.id.root).setBackgroundColor(ThemeStore.primaryColor(this)) + MaterialUtil.setTint(button = shuffleAction, color = buttonColor) + MaterialUtil.setTint(button = playAction, color = buttonColor) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt index 066e1146..967ff329 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt @@ -26,6 +26,7 @@ import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.adapter.SearchAdapter import code.name.monkey.retromusic.mvp.contract.SearchContract import code.name.monkey.retromusic.mvp.presenter.SearchPresenter +import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroUtil import kotlinx.android.synthetic.main.activity_search.* import java.util.* @@ -59,7 +60,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon back.setOnClickListener { onBackPressed() } voiceSearch.setOnClickListener { startMicSearch() } - searchContainer.setCardBackgroundColor(RetroUtil.toolbarColor(this)) + searchContainer.setCardBackgroundColor(RetroColorUtil.toolbarColor(this)) keyboardPopup.setOnClickListener { val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt index 7f8d5355..f2dcc2d5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt @@ -13,7 +13,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.NavigationUtil -import code.name.monkey.retromusic.util.RetroUtil +import code.name.monkey.retromusic.util.RetroColorUtil import com.google.android.material.button.MaterialButton import java.util.* @@ -37,7 +37,7 @@ open class PlaylistSongAdapter(activity: AppCompatActivity, if (holder.itemViewType == OFFSET_ITEM) { - val buttonColor = RetroUtil.toolbarColor(activity) + val buttonColor = RetroColorUtil.toolbarColor(activity) val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor)) val viewHolder = holder as ViewHolder diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt index f99642a6..ec066c10 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt @@ -1,17 +1,14 @@ package code.name.monkey.retromusic.adapter.song -import android.content.res.ColorStateList import android.view.View import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatActivity -import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.appthemehelper.util.MaterialValueHelper +import code.name.monkey.appthemehelper.util.ATHUtil +import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.retromusic.R import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.model.Song -import code.name.monkey.retromusic.util.RetroUtil import com.google.android.material.button.MaterialButton import java.util.* @@ -28,51 +25,19 @@ class ShuffleButtonSongAdapter(activity: AppCompatActivity, override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) { if (holder.itemViewType == OFFSET_ITEM) { - val accentColor = ThemeStore.accentColor(activity.applicationContext) - val buttonColor = RetroUtil.toolbarColor(activity) - val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor)) val viewHolder = holder as ViewHolder - viewHolder.playAction?.let { - it.backgroundTintList = ColorStateList.valueOf(buttonColor) - it.setTextColor(textColor) - it.iconTint = ColorStateList.valueOf(textColor) + MaterialUtil.setTint(it, color = ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor)) it.setOnClickListener { MusicPlayerRemote.openQueue(dataSet, 0, true) } } viewHolder.shuffleAction?.let { - it.backgroundTintList = ColorStateList.valueOf(buttonColor) - it.setTextColor(textColor) - it.iconTint = ColorStateList.valueOf(textColor) + MaterialUtil.setTint(button = it, color = ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor)) it.setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(dataSet, true) } } - - - if (holder.title != null) { - holder.title!!.text = activity.resources.getString(R.string.action_shuffle_all) - holder.title!!.setTextColor(accentColor) - } - if (holder.text != null) { - holder.text!!.visibility = View.GONE - } - if (holder.menu != null) { - holder.menu!!.visibility = View.GONE - } - if (holder.image != null) { - val padding = activity.resources.getDimensionPixelSize(R.dimen.default_item_margin) / 2 - holder.image!!.setPadding(padding, padding, padding, padding) - holder.image!!.setColorFilter(accentColor) - holder.image!!.setImageResource(R.drawable.ic_shuffle_white_24dp) - } - if (holder.separator != null) { - holder.separator!!.visibility = View.GONE - } - if (holder.shortSeparator != null) { - holder.shortSeparator!!.visibility = View.GONE - } } else { super.onBindViewHolder(holder, position - 1) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java index f422220d..c92d7260 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java @@ -144,7 +144,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde private void setupToolbar() { int primaryColor = ThemeStore.Companion.primaryColor(getContext()); TintHelper.setTintAuto(contentContainer, primaryColor, true); - toolbar.setBackgroundColor(RetroUtil.toolbarColor(getMainActivity())); + toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity())); toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); toolbar.setOnClickListener(v -> { Pair pair = new Pair<>(toolbarContainer, getString(R.string.transition_toolbar)); diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java index d2123907..884caf4d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java @@ -229,7 +229,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements getMainActivity().setSupportActionBar(toolbar); TintHelper.setTintAuto(container, primaryColor, true); appBarLayout.setBackgroundColor(primaryColor); - toolbar.setBackgroundColor(RetroUtil.toolbarColor(getMainActivity())); + toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity())); toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); toolbar.setOnClickListener(v -> { showMainMenu(); diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt index a583a67e..c0ee28b3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt @@ -28,10 +28,7 @@ import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist import code.name.monkey.retromusic.mvp.contract.HomeContract import code.name.monkey.retromusic.mvp.presenter.HomePresenter -import code.name.monkey.retromusic.util.Compressor -import code.name.monkey.retromusic.util.NavigationUtil -import code.name.monkey.retromusic.util.PreferenceUtil -import code.name.monkey.retromusic.util.RetroUtil +import code.name.monkey.retromusic.util.* import com.bumptech.glide.load.engine.DiskCacheStrategy import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable @@ -155,9 +152,9 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba private fun toolbarColor(): Int { return if (PreferenceUtil.getInstance().isHomeBanner) { toolbarContainer.setBackgroundColor(Color.TRANSPARENT) - ColorUtil.withAlpha(RetroUtil.toolbarColor(mainActivity), 0.85f) + ColorUtil.withAlpha(RetroColorUtil.toolbarColor(mainActivity), 0.85f) } else { - RetroUtil.toolbarColor(mainActivity) + RetroColorUtil.toolbarColor(mainActivity) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java index e54effe0..b961ae67 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Color; + import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -28,12 +29,23 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import code.name.monkey.appthemehelper.ThemeStore; +import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ColorUtil; +import code.name.monkey.retromusic.R; public class RetroColorUtil { + public static int toolbarColor(@NonNull Context context) { + int color = ThemeStore.Companion.primaryColor(context); + if (ATHUtil.INSTANCE.isWindowBackgroundDark(context)) { + return ATHUtil.INSTANCE.resolveColor(context, R.attr.cardBackgroundColor); + } else { + return color; + } + } @Nullable - public static Palette generatePalette(Bitmap bitmap) { + public static Palette generatePalette(@Nullable Bitmap bitmap) { return bitmap == null ? null : Palette.from(bitmap).clearFilters().generate(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java index c06c41a1..c499ef4a 100755 --- a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java @@ -71,14 +71,6 @@ public class RetroUtil { private static final int[] TEMP_ARRAY = new int[1]; private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar"; - public static int toolbarColor(@NonNull Context context) { - int color = ThemeStore.Companion.primaryColor(context); - if (ATHUtil.INSTANCE.isWindowBackgroundDark(context)) { - return ATHUtil.INSTANCE.resolveColor(context, R.attr.cardBackgroundColor); - } else { - return color; - } - } public static int calculateNoOfColumns(@NonNull Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); diff --git a/app/src/main/res/drawable/ic_home_selected_white_24dp.xml b/app/src/main/res/drawable/ic_home_selected_white_24dp.xml index 6f6136f0..37beaa0c 100644 --- a/app/src/main/res/drawable/ic_home_selected_white_24dp.xml +++ b/app/src/main/res/drawable/ic_home_selected_white_24dp.xml @@ -6,5 +6,5 @@ android:viewportHeight="24"> + android:pathData="M9 11.75c-0.69 0-1.25 0.56 -1.25 1.25s0.56 1.25 1.25 1.25 1.25-0.56 1.25-1.25-0.56-1.25-1.25-1.25zm6 0c-0.69 0-1.25 0.56 -1.25 1.25s0.56 1.25 1.25 1.25 1.25-0.56 1.25-1.25-0.56-1.25-1.25-1.25zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-0.29 0.02 -0.58 0.05 -0.86 2.36-1.05 4.23-2.98 5.21-5.37C11.07 8.33 14.05 10 17.42 10c0.78 0 1.53-0.09 2.25-0.26 0.21 0.71 0.33 1.47 0.33 2.26 0 4.41-3.59 8-8 8z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_home_white_24dp.xml b/app/src/main/res/drawable/ic_home_white_24dp.xml index 76f069b7..b78bab9d 100644 --- a/app/src/main/res/drawable/ic_home_white_24dp.xml +++ b/app/src/main/res/drawable/ic_home_white_24dp.xml @@ -6,5 +6,5 @@ android:viewportHeight="24"> + android:pathData="M10.25 13c0 0.69-0.56 1.25-1.25 1.25S7.75 13.69 7.75 13s0.56-1.25 1.25-1.25 1.25 0.56 1.25 1.25zM15 11.75c-0.69 0-1.25 0.56 -1.25 1.25s0.56 1.25 1.25 1.25 1.25-0.56 1.25-1.25-0.56-1.25-1.25-1.25zm7 0.25c0 5.52-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2s10 4.48 10 10zM10.66 4.12C12.06 6.44 14.6 8 17.5 8c0.46 0 0.91-0.05 1.34-0.12C17.44 5.56 14.9 4 12 4c-0.46 0-0.91 0.05 -1.34 0.12 zM4.42 9.47c1.71-0.97 3.03-2.55 3.66-4.44C6.37 6 5.05 7.58 4.42 9.47zM20 12c0-0.78-0.12-1.53-0.33-2.24-0.7 0.15 -1.42 0.24 -2.17 0.24 -3.13 0-5.92-1.44-7.76-3.69C8.69 8.87 6.6 10.88 4 11.86c0.01 0.04 0 0.09 0 0.14 0 4.41 3.59 8 8 8s8-3.59 8-8z" /> \ No newline at end of file