Removed use of theme engine for colorPrimary

This commit is contained in:
h4h13 2019-10-09 19:16:25 +05:30
parent 8d8149839a
commit 3f50a118f7
32 changed files with 102 additions and 205 deletions

View file

@ -82,7 +82,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
setLightNavigationBar(true)
setNavigationbarColorAuto()
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ThemeStore.primaryColor(this)))
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
postponeEnterTransition()
@ -124,10 +124,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
private fun setupToolbarMarginHeight() {
setSupportActionBar(toolbar)
supportActionBar!!.title = null
val primaryColor = ThemeStore.primaryColor(this)
supportActionBar?.title = null
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
collapsingToolbarLayout?.let {
it.setContentScrimColor(primaryColor)
it.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
@ -147,8 +145,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
override fun onStateChanged(appBarLayout: AppBarLayout, state: State) {
val color: Int = when (state) {
State.COLLAPSED -> {
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this@AlbumDetailsActivity)))
ThemeStore.primaryColor(this@AlbumDetailsActivity)
setLightStatusbar(ColorUtil.isColorLight(primaryColor))
primaryColor
}
State.EXPANDED, State.IDLE -> {
setLightStatusbar(false)

View file

@ -72,7 +72,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
setDrawUnderStatusBar()
setupWindowTransitions()
super.onCreate(savedInstanceState)
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ThemeStore.primaryColor(this)))
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
toggleBottomNavigationView(true)
setNavigationbarColorAuto()
setLightNavigationBar(true)
@ -128,8 +128,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
}
private fun setupToolbarMarginHeight() {
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
collapsingToolbarLayout?.let {
it.setContentScrimColor(primaryColor)
it.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
@ -150,8 +149,8 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
override fun onStateChanged(appBarLayout: AppBarLayout, state: State) {
val color: Int = when (state) {
State.COLLAPSED -> {
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(appBarLayout.context)))
ThemeStore.primaryColor(appBarLayout.context)
setLightStatusbar(ColorUtil.isColorLight(primaryColor))
primaryColor
}
State.EXPANDED, State.IDLE -> {
setLightStatusbar(false)

View file

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.App
import code.name.monkey.retromusic.R
@ -53,7 +54,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
setNavigationbarColorAuto()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this)))
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
toggleBottomNavigationView(true)
if (intent.extras != null) {
@ -65,13 +66,13 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
setUpToolBar()
setupRecyclerView()
App.musicComponent?.inject(this)
App.musicComponent.inject(this)
genreDetailsPresenter.attachView(this)
}
private fun setUpToolBar() {
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
appBarLayout.setBackgroundColor(primaryColor)
applyToolbar(toolbar)
title = genre.name
@ -132,7 +133,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(this)))
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
.start(callback)
return cab!!
}

View file

@ -7,11 +7,10 @@ import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.core.view.ViewCompat
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.fragments.player.lockscreen.LockScreenPlayerControlsFragment
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -84,7 +83,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
.start()
}
findViewById<View>(R.id.root_layout).setBackgroundColor(ThemeStore.primaryColor(this))
findViewById<View>(R.id.root_layout).setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
}
override fun onPlayingMetaChanged() {

View file

@ -15,10 +15,7 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.ThemeStore
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.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.*
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
@ -51,10 +48,10 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
override fun onPageScrollStateChanged(state: Int) {
when (state) {
ViewPager.SCROLL_STATE_IDLE ->
fab.show( )
fab.show()
ViewPager.SCROLL_STATE_DRAGGING,
ViewPager.SCROLL_STATE_SETTLING ->
fab.hide( )
fab.hide()
}
}
@ -94,9 +91,10 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
setTaskDescriptionColorAuto()
setNavigationBarColorPrimary()
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
appBarLayout.setBackgroundColor(primaryColor)
toolbar.apply {
setBackgroundColor(ThemeStore.primaryColor(this@LyricsActivity))
setBackgroundColor(primaryColor)
navigationIcon = TintHelper.createTintedDrawable(ContextCompat.getDrawable(this@LyricsActivity, R.drawable.ic_keyboard_backspace_black_24dp), ThemeStore.textColorSecondary(this@LyricsActivity))
setSupportActionBar(toolbar)
}

View file

@ -6,6 +6,7 @@ import android.view.MenuItem
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.MaterialValueHelper
import code.name.monkey.retromusic.R
@ -164,7 +165,7 @@ class PlayingQueueActivity : AbsMusicServiceActivity() {
playerQueueSubHeader.setTextColor(ThemeStore.accentColor(this))
applyToolbar(toolbar)
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
clearQueue.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))).apply {

View file

@ -8,6 +8,7 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.App
import code.name.monkey.retromusic.R
@ -54,7 +55,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
setNavigationbarColorAuto()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this)))
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
toggleBottomNavigationView(true)
@ -143,7 +144,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(this)))
RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
.start(callback)
return cab!!
}

View file

@ -6,7 +6,7 @@ import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import android.widget.Toast
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.BuildConfig
@ -35,7 +35,7 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
setTaskDescriptionColorAuto()
setLightNavigationBar(true)
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
toolbar.setBackgroundColor(primaryColor)
appBarLayout.setBackgroundColor(primaryColor)

View file

@ -19,6 +19,7 @@ import androidx.appcompat.widget.SearchView.OnQueryTextListener
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.MaterialValueHelper
import code.name.monkey.retromusic.App
@ -129,7 +130,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
private fun setUpToolBar() {
title = null
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
}

View file

@ -5,7 +5,7 @@ import android.view.MenuItem
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.transition.TransitionManager
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
@ -36,12 +36,12 @@ class SettingsActivity : AbsBaseActivity() {
setSupportActionBar(toolbar)
setTitle(R.string.action_settings)
toolbar.apply {
setTitleTextColor(ThemeStore.textColorPrimary(context))
setBackgroundColor(ThemeStore.primaryColor(context))
setTitleTextColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorOnPrimary))
setBackgroundColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorPrimary))
setNavigationOnClickListener { onBackPressed() }
ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.textColorSecondary(context))
ToolbarContentTintHelper.colorBackButton(toolbar, ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorOnSecondary))
}
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorPrimary))
}

View file

@ -71,7 +71,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
}
private fun setupToolbar() {
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
appBarLayout.setBackgroundColor(primaryColor)
applyToolbar(toolbar)
}

View file

@ -16,6 +16,7 @@ import android.text.TextUtils
import android.view.MenuItem
import android.widget.Toast
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
@ -109,7 +110,7 @@ class UserInfoActivity : AbsBaseActivity() {
}
private fun setupToolbar() {
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
applyToolbar(toolbar)
appBarLayout.setBackgroundColor(primaryColor)
}

View file

@ -19,6 +19,7 @@ import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
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.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
@ -60,12 +61,13 @@ public class WhatsNewActivity extends AbsBaseActivity {
toolbar = findViewById(R.id.toolbar);
appBarLayout = findViewById(R.id.appBarLayout);
toolbar.setBackgroundColor(ThemeStore.Companion.primaryColor(this));
appBarLayout.setBackgroundColor(ThemeStore.Companion.primaryColor(this));
int primaryColor = INSTANCE.resolveColor(this, R.attr.colorPrimary);
toolbar.setBackgroundColor(primaryColor);
appBarLayout.setBackgroundColor(primaryColor);
//setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> onBackPressed());
ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.Companion.textColorSecondary(this));
ToolbarContentTintHelper.colorBackButton(toolbar, ATHUtil.INSTANCE.resolveColor(this, R.attr.colorOnSecondary));
try {
StringBuilder buf = new StringBuilder();

View file

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
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
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
@ -310,7 +310,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(isColorLight)
} else {
super.setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this)))
super.setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
super.setLightNavigationBar(true)
}
}

View file

@ -73,7 +73,7 @@ abstract class AbsThemeActivity : ATHActivity(), Runnable {
ContextCompat.getDrawable(this, R.drawable.round_window)
else
ContextCompat.getDrawable(this, R.drawable.square_window)
background = TintHelper.createTintedDrawable(background, ThemeStore.primaryColor(this))
background = TintHelper.createTintedDrawable(background, ATHUtil.resolveColor(this, R.attr.colorPrimary))
window.setBackgroundDrawable(background)
}

View file

@ -16,6 +16,7 @@ import androidx.annotation.StringDef
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R
@ -74,7 +75,7 @@ open class BugReportActivity : AbsThemeActivity() {
private fun initViews() {
val accentColor = ThemeStore.accentColor(this)
val primaryColor = ThemeStore.primaryColor(this)
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
toolbar!!.setBackgroundColor(primaryColor)
setSupportActionBar(toolbar)

View file

@ -14,6 +14,7 @@ import android.view.MenuItem
import android.view.View
import android.view.animation.OvershootInterpolator
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.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
@ -25,7 +26,6 @@ import code.name.monkey.retromusic.util.SAFUtil
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItems
import com.google.android.material.button.MaterialButton
import com.google.android.material.floatingactionbutton.FloatingActionButton
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
import org.jaudiotagger.audio.AudioFile
import org.jaudiotagger.audio.AudioFileIO
@ -289,7 +289,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
editorImage.visibility = View.GONE
editorImage.isEnabled = false
setColors(intent.getIntExtra(EXTRA_PALETTE, ThemeStore.primaryColor(this)))
setColors(intent.getIntExtra(EXTRA_PALETTE, ATHUtil.resolveColor(this, R.attr.colorPrimary)))
}
protected fun dataChanged() {

View file

@ -12,8 +12,6 @@ import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.widget.Toast
import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.TintHelper
@ -106,7 +104,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(this, toolbar, Color.TRANSPARENT)
title = null
setSupportActionBar(toolbar)
TintHelper.setTintAuto(content, ThemeStore.primaryColor(this), true)
TintHelper.setTintAuto(content, ATHUtil.resolveColor(this, R.attr.colorPrimary), true)
}
override fun onCreate(savedInstanceState: Bundle?) {
@ -173,25 +171,25 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
if (!TextUtils.isEmpty(url) && url.trim { it <= ' ' }.isNotEmpty()) {
Glide.with(this@AlbumTagEditorActivity)
.load(url)
.asBitmap()
.transcode( BitmapPaletteTranscoder(this), BitmapPaletteWrapper::class.java)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.error(R.drawable.default_album_art)
.into( object: SimpleTarget<BitmapPaletteWrapper>() {
override fun onLoadFailed(e: java.lang.Exception?, errorDrawable: Drawable?) {
super.onLoadFailed(e, errorDrawable)
Toast.makeText(this@AlbumTagEditorActivity, e.toString(), Toast.LENGTH_LONG).show()
}
.load(url)
.asBitmap()
.transcode(BitmapPaletteTranscoder(this), BitmapPaletteWrapper::class.java)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.error(R.drawable.default_album_art)
.into(object : SimpleTarget<BitmapPaletteWrapper>() {
override fun onLoadFailed(e: java.lang.Exception?, errorDrawable: Drawable?) {
super.onLoadFailed(e, errorDrawable)
Toast.makeText(this@AlbumTagEditorActivity, e.toString(), Toast.LENGTH_LONG).show()
}
override fun onResourceReady(resource: BitmapPaletteWrapper?, glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?) {
albumArtBitmap = resource?.bitmap?.let { ImageUtil.resizeBitmap(it, 2048) }
setImageBitmap(albumArtBitmap, RetroColorUtil.getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor)))
deleteAlbumArt = false
dataChanged()
setResult(RESULT_OK)
}
});
override fun onResourceReady(resource: BitmapPaletteWrapper?, glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?) {
albumArtBitmap = resource?.bitmap?.let { ImageUtil.resizeBitmap(it, 2048) }
setImageBitmap(albumArtBitmap, RetroColorUtil.getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor)))
deleteAlbumArt = false
dataChanged()
setResult(RESULT_OK)
}
});
return
}
if (lastFmAlbum.album.tags.tag.size > 0) {

View file

@ -6,6 +6,7 @@ import android.text.Editable
import android.text.TextWatcher
import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R
@ -22,9 +23,9 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
get() = R.layout.activity_song_tag_editor
private fun setupToolbar() {
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
toolbar.apply {
setBackgroundColor(ThemeStore.primaryColor(context))
setBackgroundColor(ATHUtil.resolveColor(this@SongTagEditorActivity, R.attr.colorPrimary))
navigationIcon = TintHelper.createTintedDrawable(ContextCompat.getDrawable(context, R.drawable.ic_keyboard_backspace_black_24dp), ThemeStore.textColorPrimary(context))
setNavigationOnClickListener { onBackPressed() }
setSupportActionBar(toolbar)

View file

@ -6,8 +6,8 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover
@ -30,7 +30,7 @@ class SongFileAdapter(
private val itemLayoutRes: Int,
private val callbacks: Callbacks?,
cabHolder: CabHolder?
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(activity, cabHolder, code.name.monkey.retromusic.R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter {
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(activity, cabHolder, R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter {
init {
this.setHasStableIds(true)
@ -83,16 +83,16 @@ class SongFileAdapter(
}
private fun loadFileImage(file: File, holder: ViewHolder) {
val iconColor = ATHUtil.resolveColor(activity, code.name.monkey.retromusic.R.attr.iconColor)
val iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor)
if (file.isDirectory) {
holder.image?.let {
it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
it.setImageResource(code.name.monkey.retromusic.R.drawable.ic_folder_white_24dp)
it.setImageResource(R.drawable.ic_folder_white_24dp)
}
holder.imageTextContainer?.setCardBackgroundColor(ThemeStore.primaryColor(activity))
holder.imageTextContainer?.setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorPrimary))
} else {
val error = RetroUtil.getTintedVectorDrawable(activity, code.name.monkey.retromusic.R.drawable.ic_file_music_white_24dp, iconColor)
val error = RetroUtil.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor)
Glide.with(activity)
.load(AudioFileCover(file.path))
.diskCacheStrategy(DiskCacheStrategy.NONE)

View file

@ -27,7 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.card.MaterialCardView;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.retromusic.R;
public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
@ -94,7 +94,7 @@ public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements Vie
playSongs = itemView.findViewById(R.id.playSongs);
if (imageContainerCard != null) {
imageContainerCard.setCardBackgroundColor(ThemeStore.Companion.primaryColor(itemView.getContext()));
imageContainerCard.setCardBackgroundColor(ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorPrimary));
}
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);

View file

@ -195,7 +195,7 @@ class PlaylistAdapter(protected val activity: AppCompatActivity, dataSet: ArrayL
imageTextContainer?.apply {
cardElevation = 0f
setCardBackgroundColor(ThemeStore.primaryColor(itemView.context))
setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorPrimary))
}
}

View file

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.extensions
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
@ -25,7 +26,7 @@ fun AppCompatActivity.applyToolbar(toolbar: Toolbar) {
setNavigationOnClickListener { onBackPressed() }
setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.textColorSecondary(this@applyToolbar))
setBackgroundColor(ThemeStore.primaryColor(this@applyToolbar))
setBackgroundColor(ATHUtil.resolveColor(this@applyToolbar, R.attr.colorPrimary))
}
setSupportActionBar(toolbar)
}

View file

@ -3,7 +3,7 @@ package code.name.monkey.retromusic.fragments.base
import android.os.Build
import android.os.Bundle
import android.view.View
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.VersionUtils
import code.name.monkey.retromusic.R
@ -39,11 +39,12 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
}
fun setStatusbarColorAuto(view: View) {
val colorPrimary = ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary)
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
if (VersionUtils.hasMarshmallow()) {
setStatusbarColor(view, ThemeStore.primaryColor(context!!))
setStatusbarColor(view, colorPrimary)
} else {
setStatusbarColor(view, ColorUtil.darkenColor(ThemeStore.primaryColor(context!!)))
setStatusbarColor(view, ColorUtil.darkenColor(colorPrimary))
}
}

View file

@ -26,9 +26,6 @@ import com.google.android.material.card.MaterialCardView;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
@ -193,7 +190,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.Companion.primaryColor(Objects.requireNonNull(getActivity()))))
RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary)))
.start(callback);
return cab;
}

View file

@ -230,7 +230,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
}
private void setUpAppbarColor() {
int primaryColor = ThemeStore.Companion.primaryColor(requireContext());
int primaryColor = ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary);
getMainActivity().setSupportActionBar(toolbar);
TintHelper.setTintAuto(container, primaryColor, true);
appBarLayout.setBackgroundColor(primaryColor);
@ -309,7 +309,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ThemeStore.Companion.primaryColor(getActivity())))
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary)))
.start(callback);
return cab;
}

View file

@ -9,8 +9,8 @@ import android.view.*
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.App
@ -127,7 +127,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToPlaylistNew(requireActivity(), HistoryPlaylist(requireActivity()))
}
contentContainer.setBackgroundColor(ThemeStore.primaryColor(requireContext()))
contentContainer.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary))
setupToolbar()
checkPadding()
@ -136,7 +136,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, userImage, getString(R.string.transition_user_image))
NavigationUtil.goToUserInfo(requireActivity(), options)
}
titleWelcome.setTextColor(ThemeStore.textColorPrimary(requireContext()))
titleWelcome.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
App.musicComponent.inject(this)

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics
import kotlinx.android.synthetic.main.fragment_adaptive_player.*
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
private lateinit var lyricsLayout: FrameLayout
private lateinit var lyricsLine1: TextView
@ -139,11 +139,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Cal
}
private fun setUpPlayerToolbar() {
ATHUtil.resolveColor(context, R.attr.iconColor)
val primaryColor = ThemeStore.primaryColor(context!!)
val primaryColor = ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary)
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { activity!!.onBackPressed() }
setNavigationOnClickListener { requireActivity().onBackPressed() }
ToolbarContentTintHelper.colorizeToolbar(this, primaryColor, activity)
setTitleTextColor(primaryColor)
setSubtitleTextColor(ThemeStore.textColorSecondary(context!!))

View file

@ -144,7 +144,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), SlidingUpPanelLayout.PanelSli
})
// for some reason the xml attribute doesn't get applied here.
playingQueueCard.setCardBackgroundColor(ThemeStore.primaryColor(requireContext()))
playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary))
}
private fun setUpPlayerToolbar() {
@ -308,7 +308,7 @@ class PortraitImpl(private val fragment: ClassicPlayerFragment) : BaseImpl(fragm
}
imageTextContainer?.let {
it.cardElevation = 0f
it.setCardBackgroundColor(ThemeStore.primaryColor(fragment.activity!!))
it.setCardBackgroundColor(ATHUtil.resolveColor(fragment.requireContext(), R.attr.colorPrimary))
}
itemView.setOnClickListener {

View file

@ -21,7 +21,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
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
@ -75,7 +75,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
NavigationUtil.goToProVersion(requireContext())
}
MaterialUtil.setTint(buyPremium)
val primaryColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(ThemeStore.primaryColor(requireContext())))
val primaryColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary)))
text.setTextColor(ColorUtil.withAlpha(primaryColor, 0.75f))
text2.setTextColor(primaryColor)
text3.imageTintList = ColorStateList.valueOf(primaryColor)

View file

@ -31,7 +31,6 @@ import android.widget.SeekBar
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.core.view.ViewCompat
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.MaterialValueHelper
@ -67,7 +66,8 @@ object ViewUtil {
progress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
val background = ld.findDrawableByLayerId(android.R.id.background)
background.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(progressSlider.context, ColorUtil.isColorLight(ThemeStore.primaryColor(progressSlider.context))), PorterDuff.Mode.SRC_IN)
val primaryColor = ATHUtil.resolveColor(progressSlider.context, R.attr.colorPrimary);
background.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(progressSlider.context, ColorUtil.isColorLight(primaryColor)), PorterDuff.Mode.SRC_IN)
val secondaryProgress = ld.findDrawableByLayerId(android.R.id.secondaryProgress)
secondaryProgress.setColorFilter(ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN)

View file

@ -1,101 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software 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 General Public License for more details.
*/
package code.name.monkey.retromusic.views;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import java.util.Objects;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatDialogFragment;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.VersionUtils;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.util.RetroUtil;
/**
* Created by yu on 2016/11/10.
*/
@SuppressLint("RestrictedApi")
public class RoundedBottomSheetDialogFragment extends AppCompatDialogFragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
if (bottomSheet != null) {
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
bottomSheet.setBackground(RetroUtil.getTintedDrawable(getContext(), R.drawable.bg_bottom_sheet_dialog_fragment, ThemeStore.Companion.primaryColor(getContext())));
}
});
if (getActivity() != null) {
if (VersionUtils.INSTANCE.hasNougat()) {
((AbsBaseActivity) getActivity()).setNavigationbarColor(ThemeStore.Companion.primaryColor(getContext()));
} else {
((AbsBaseActivity) getActivity()).setNavigationbarColorAuto();
}
}
}
@NonNull
@Override
public Dialog onCreateDialog(@NonNull Bundle savedInstanceState) {
//noinspection ConstantConditions
return new CustomWidthBottomSheetDialog(getContext(), getTheme());
}
@Override
public void onStart() {
super.onStart();
if (getDialog() != null && getDialog().getWindow() != null) {
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setNavigationBarColor(ThemeStore.Companion.primaryColor(getContext()));
window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(true);
}
}
static class CustomWidthBottomSheetDialog extends BottomSheetDialog {
CustomWidthBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int width = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_width);
Objects.requireNonNull(getWindow()).setLayout(width > 0 ? width : ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
}
}
}