From 3f50a118f7086abe144fa43baaffe11fee9fc6fd Mon Sep 17 00:00:00 2001 From: h4h13 Date: Wed, 9 Oct 2019 19:16:25 +0530 Subject: [PATCH] Removed use of theme engine for colorPrimary --- .../activities/AlbumDetailsActivity.kt | 12 +-- .../activities/ArtistDetailActivity.kt | 9 +- .../activities/GenreDetailsActivity.kt | 9 +- .../activities/LockScreenActivity.kt | 5 +- .../retromusic/activities/LyricsActivity.kt | 14 ++- .../activities/PlayingQueueActivity.kt | 3 +- .../activities/PlaylistDetailActivity.kt | 5 +- .../retromusic/activities/PurchaseActivity.kt | 4 +- .../retromusic/activities/SearchActivity.kt | 3 +- .../retromusic/activities/SettingsActivity.kt | 10 +- .../activities/SupportDevelopmentActivity.kt | 2 +- .../retromusic/activities/UserInfoActivity.kt | 3 +- .../activities/WhatsNewActivity.java | 8 +- .../base/AbsSlidingMusicPanelActivity.kt | 4 +- .../activities/base/AbsThemeActivity.kt | 2 +- .../activities/bugreport/BugReportActivity.kt | 3 +- .../tageditor/AbsTagEditorActivity.kt | 4 +- .../tageditor/AlbumTagEditorActivity.kt | 40 ++++--- .../tageditor/SongTagEditorActivity.kt | 5 +- .../retromusic/adapter/SongFileAdapter.kt | 12 +-- .../adapter/base/MediaEntryViewHolder.java | 4 +- .../adapter/playlist/PlaylistAdapter.kt | 2 +- .../retromusic/extensions/ActivityEx.kt | 3 +- .../fragments/base/AbsMainActivityFragment.kt | 7 +- .../mainactivity/LibraryFragment.java | 5 +- .../mainactivity/folders/FoldersFragment.java | 4 +- .../mainactivity/home/BannerHomeFragment.kt | 5 +- .../player/adaptive/AdaptiveFragment.kt | 7 +- .../player/classic/ClassicPlayerFragment.kt | 4 +- .../settings/MainSettingsFragment.kt | 4 +- .../name/monkey/retromusic/util/ViewUtil.kt | 4 +- .../RoundedBottomSheetDialogFragment.java | 101 ------------------ 32 files changed, 102 insertions(+), 205 deletions(-) delete mode 100644 app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java 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 72a59f47..9be1bf63 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 @@ -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) 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 75a3ed47..7cd2efb4 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 @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt index 0851a793..9148b9b7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt @@ -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!! } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt index 2b7d90d0..b065af76 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt @@ -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(R.id.root_layout).setBackgroundColor(ThemeStore.primaryColor(this)) + findViewById(R.id.root_layout).setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary)) } override fun onPlayingMetaChanged() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index a696bfd4..c1385224 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -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) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt index d7231aba..f5c1fecd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt @@ -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 { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt index 0a28f42d..e2d9c8d4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt @@ -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!! } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt index d752fee3..90a2f6d1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt @@ -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) 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 2433f0a1..0fb0e5bc 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 @@ -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)) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt index 2ba2e63e..272e8533 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt @@ -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)) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt index 4ffb8bac..0692f740 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt @@ -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) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt index 0745c17f..a4117541 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt @@ -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) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java index 3ded7aae..4a5be75b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java @@ -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(); diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index 37d677a2..68c4fe57 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -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) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt index 1ed11b20..022198c5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt @@ -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) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt index 4fa1b25d..aeb482ad 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt index e0971bd7..1fb9f53c 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt @@ -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() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt index 47d5bd13..94117c2a 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt @@ -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() { - 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() { + 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?) { - 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?) { + 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) { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt index 474d163f..30a0ecb3 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/SongFileAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/SongFileAdapter.kt index 1e92801d..f76c5d28 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/SongFileAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/SongFileAdapter.kt @@ -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(activity, cabHolder, code.name.monkey.retromusic.R.menu.menu_media_selection), FastScrollRecyclerView.SectionedAdapter { +) : AbsMultiSelectAdapter(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) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java index 3d2b231e..17786888 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java @@ -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); diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt index 72ab249c..885170c0 100755 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt @@ -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)) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityEx.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityEx.kt index d6d68272..764a5908 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityEx.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityEx.kt @@ -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) } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt index ab32f3c3..fa0d0538 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt @@ -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)) } } 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 13533edd..bdce1b0a 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 @@ -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; } 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 be2413e8..f4e36e6c 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 @@ -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; } 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 4fb3d1a7..4345512f 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 @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt index c469b5b6..2077eead 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt @@ -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!!)) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index cee3e46c..572bfbbf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -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 { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt index 1b58c346..186b6f5f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt index 0ce0f246..fb2edc4b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java b/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java deleted file mode 100644 index bca21dd8..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/views/RoundedBottomSheetDialogFragment.java +++ /dev/null @@ -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); - } - } -} \ No newline at end of file