Fix buttons color

This commit is contained in:
h4h13 2019-06-08 19:12:57 +05:30
parent a96e682e2b
commit 933bf70068
13 changed files with 47 additions and 90 deletions

View file

@ -31,7 +31,7 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 333 versionCode 334
versionName '3.1.900' versionName '3.1.900'
multiDexEnabled true multiDexEnabled true

View file

@ -1,7 +1,6 @@
package code.name.monkey.retromusic.activities package code.name.monkey.retromusic.activities
import android.content.Intent import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.transition.Slide import android.transition.Slide
@ -14,10 +13,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.*
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.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
@ -245,19 +241,17 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
} }
private fun setColors(color: Int) { 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) songTitle.setTextColor(themeColor)
moreTitle.setTextColor(themeColor) moreTitle.setTextColor(themeColor)
playAction.backgroundTintList = ColorStateList.valueOf(themeColor) val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color
shuffleAction.backgroundTintList = ColorStateList.valueOf(themeColor) else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(themeColor))).apply {
playAction.setTextColor(this)
playAction.iconTint = this
shuffleAction.setTextColor(this) MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
shuffleAction.iconTint = this MaterialUtil.setTint(button = playAction, color = buttonColor)
}
} }

View file

@ -18,10 +18,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.*
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.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.album.AlbumAdapter 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.rest.model.LastFmArtist
import code.name.monkey.retromusic.util.* import code.name.monkey.retromusic.util.*
import com.google.android.material.appbar.AppBarLayout 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.*
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 kotlinx.android.synthetic.main.activity_artist_details.*
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -291,17 +293,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
songTitle.setTextColor(textColor) songTitle.setTextColor(textColor)
biographyTitle.setTextColor(textColor) biographyTitle.setTextColor(textColor)
playAction.backgroundTintList = ColorStateList.valueOf(textColor) val buttonColor = if (PreferenceUtil.getInstance().adaptiveColor) color
shuffleAction.backgroundTintList = ColorStateList.valueOf(textColor) else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(textColor))).apply {
playAction.setTextColor(this)
playAction.iconTint = this
shuffleAction.setTextColor(this) MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
shuffleAction.iconTint = this MaterialUtil.setTint(button = playAction, color = buttonColor)
}
findViewById<View>(R.id.root).setBackgroundColor(ThemeStore.primaryColor(this))
} }

View file

@ -26,6 +26,7 @@ import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.adapter.SearchAdapter import code.name.monkey.retromusic.adapter.SearchAdapter
import code.name.monkey.retromusic.mvp.contract.SearchContract import code.name.monkey.retromusic.mvp.contract.SearchContract
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import kotlinx.android.synthetic.main.activity_search.* import kotlinx.android.synthetic.main.activity_search.*
import java.util.* import java.util.*
@ -59,7 +60,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon
back.setOnClickListener { onBackPressed() } back.setOnClickListener { onBackPressed() }
voiceSearch.setOnClickListener { startMicSearch() } voiceSearch.setOnClickListener { startMicSearch() }
searchContainer.setCardBackgroundColor(RetroUtil.toolbarColor(this)) searchContainer.setCardBackgroundColor(RetroColorUtil.toolbarColor(this))
keyboardPopup.setOnClickListener { keyboardPopup.setOnClickListener {
val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager

View file

@ -13,7 +13,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.NavigationUtil 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 com.google.android.material.button.MaterialButton
import java.util.* import java.util.*
@ -37,7 +37,7 @@ open class PlaylistSongAdapter(activity: AppCompatActivity,
if (holder.itemViewType == OFFSET_ITEM) { if (holder.itemViewType == OFFSET_ITEM) {
val buttonColor = RetroUtil.toolbarColor(activity) val buttonColor = RetroColorUtil.toolbarColor(activity)
val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor)) val textColor = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(buttonColor))
val viewHolder = holder as ViewHolder val viewHolder = holder as ViewHolder

View file

@ -1,17 +1,14 @@
package code.name.monkey.retromusic.adapter.song package code.name.monkey.retromusic.adapter.song
import android.content.res.ColorStateList
import android.view.View import android.view.View
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.RetroUtil
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import java.util.* import java.util.*
@ -28,51 +25,19 @@ class ShuffleButtonSongAdapter(activity: AppCompatActivity,
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) { override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
if (holder.itemViewType == OFFSET_ITEM) { 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 val viewHolder = holder as ViewHolder
viewHolder.playAction?.let { viewHolder.playAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor) MaterialUtil.setTint(it, color = ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor))
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener { it.setOnClickListener {
MusicPlayerRemote.openQueue(dataSet, 0, true) MusicPlayerRemote.openQueue(dataSet, 0, true)
} }
} }
viewHolder.shuffleAction?.let { viewHolder.shuffleAction?.let {
it.backgroundTintList = ColorStateList.valueOf(buttonColor) MaterialUtil.setTint(button = it, color = ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor))
it.setTextColor(textColor)
it.iconTint = ColorStateList.valueOf(textColor)
it.setOnClickListener { it.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(dataSet, true) 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 { } else {
super.onBindViewHolder(holder, position - 1) super.onBindViewHolder(holder, position - 1)
} }

View file

@ -144,7 +144,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
private void setupToolbar() { private void setupToolbar() {
int primaryColor = ThemeStore.Companion.primaryColor(getContext()); int primaryColor = ThemeStore.Companion.primaryColor(getContext());
TintHelper.setTintAuto(contentContainer, primaryColor, true); TintHelper.setTintAuto(contentContainer, primaryColor, true);
toolbar.setBackgroundColor(RetroUtil.toolbarColor(getMainActivity())); toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.setOnClickListener(v -> { toolbar.setOnClickListener(v -> {
Pair<View, String> pair = new Pair<>(toolbarContainer, getString(R.string.transition_toolbar)); Pair<View, String> pair = new Pair<>(toolbarContainer, getString(R.string.transition_toolbar));

View file

@ -229,7 +229,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
getMainActivity().setSupportActionBar(toolbar); getMainActivity().setSupportActionBar(toolbar);
TintHelper.setTintAuto(container, primaryColor, true); TintHelper.setTintAuto(container, primaryColor, true);
appBarLayout.setBackgroundColor(primaryColor); appBarLayout.setBackgroundColor(primaryColor);
toolbar.setBackgroundColor(RetroUtil.toolbarColor(getMainActivity())); toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp); toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.setOnClickListener(v -> { toolbar.setOnClickListener(v -> {
showMainMenu(); showMainMenu();

View file

@ -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.model.smartplaylist.MyTopTracksPlaylist
import code.name.monkey.retromusic.mvp.contract.HomeContract import code.name.monkey.retromusic.mvp.contract.HomeContract
import code.name.monkey.retromusic.mvp.presenter.HomePresenter import code.name.monkey.retromusic.mvp.presenter.HomePresenter
import code.name.monkey.retromusic.util.Compressor import code.name.monkey.retromusic.util.*
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
@ -155,9 +152,9 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
private fun toolbarColor(): Int { private fun toolbarColor(): Int {
return if (PreferenceUtil.getInstance().isHomeBanner) { return if (PreferenceUtil.getInstance().isHomeBanner) {
toolbarContainer.setBackgroundColor(Color.TRANSPARENT) toolbarContainer.setBackgroundColor(Color.TRANSPARENT)
ColorUtil.withAlpha(RetroUtil.toolbarColor(mainActivity), 0.85f) ColorUtil.withAlpha(RetroColorUtil.toolbarColor(mainActivity), 0.85f)
} else { } else {
RetroUtil.toolbarColor(mainActivity) RetroColorUtil.toolbarColor(mainActivity)
} }
} }

View file

@ -18,6 +18,7 @@ import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -28,12 +29,23 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; 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.appthemehelper.util.ColorUtil;
import code.name.monkey.retromusic.R;
public class RetroColorUtil { 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 @Nullable
public static Palette generatePalette(Bitmap bitmap) { public static Palette generatePalette(@Nullable Bitmap bitmap) {
return bitmap == null ? null : Palette.from(bitmap).clearFilters().generate(); return bitmap == null ? null : Palette.from(bitmap).clearFilters().generate();
} }

View file

@ -71,14 +71,6 @@ public class RetroUtil {
private static final int[] TEMP_ARRAY = new int[1]; private static final int[] TEMP_ARRAY = new int[1];
private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar"; 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) { public static int calculateNoOfColumns(@NonNull Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();

View file

@ -6,5 +6,5 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="@color/md_white_1000" android:fillColor="@color/md_white_1000"
android:pathData="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> 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" />
</vector> </vector>

View file

@ -6,5 +6,5 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="@color/md_white_1000" android:fillColor="@color/md_white_1000"
android:pathData="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" /> 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" />
</vector> </vector>