From 6e7d945fb1d0b310256086de5521d43c822fd02b Mon Sep 17 00:00:00 2001 From: Hemanth S Date: Sat, 9 May 2020 11:25:42 +0530 Subject: [PATCH] Fix colors in classic --- .../base/AbsSlidingMusicPanelActivity.kt | 25 ++++-- .../player/classic/ClassicPlayerFragment.kt | 84 +++++++++---------- .../retromusic/util/PreferenceUtil.java | 6 +- .../retromusic/util/theme/ThemeManager.kt | 3 - .../drawable/ic_invert_colors_white_24dp.xml | 27 +----- .../res/layout/fragment_clasic_player.xml | 21 ++--- .../res/layout/fragment_classic_controls.xml | 6 +- .../res/layout/sliding_music_panel_layout.xml | 11 ++- app/src/main/res/values/dimens.xml | 2 +- app/src/main/res/values/styles.xml | 9 +- app/src/main/res/xml/pref_general.xml | 9 +- 11 files changed, 90 insertions(+), 113 deletions(-) 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 9974ce5f..b219ecc9 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 @@ -6,25 +6,24 @@ import android.os.Bundle import android.view.View import android.view.ViewGroup import android.view.ViewTreeObserver -import android.widget.FrameLayout import androidx.annotation.LayoutRes import androidx.fragment.app.Fragment import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.fragments.MiniPlayerFragment import code.name.monkey.retromusic.fragments.NowPlayingScreen import code.name.monkey.retromusic.fragments.NowPlayingScreen.* import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment -import code.name.monkey.retromusic.fragments.player.classic.ClassicPlayerFragment import code.name.monkey.retromusic.fragments.player.adaptive.AdaptiveFragment import code.name.monkey.retromusic.fragments.player.blur.BlurPlayerFragment import code.name.monkey.retromusic.fragments.player.card.CardFragment import code.name.monkey.retromusic.fragments.player.cardblur.CardBlurFragment import code.name.monkey.retromusic.fragments.player.circle.CirclePlayerFragment +import code.name.monkey.retromusic.fragments.player.classic.ClassicPlayerFragment import code.name.monkey.retromusic.fragments.player.color.ColorFragment import code.name.monkey.retromusic.fragments.player.fit.FitFragment import code.name.monkey.retromusic.fragments.player.flat.FlatPlayerFragment @@ -41,6 +40,9 @@ import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.views.BottomNavigationBarTinted import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.card.MaterialCardView +import com.google.android.material.shape.MaterialShapeDrawable +import com.google.android.material.shape.ShapeAppearanceModel import kotlinx.android.synthetic.main.sliding_music_panel_layout.* abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), @@ -49,7 +51,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName } - private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior + private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior private var miniPlayerFragment: MiniPlayerFragment? = null private var playerFragment: AbsPlayerFragment? = null private var currentNowPlayingScreen: NowPlayingScreen? = null @@ -59,6 +61,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), private var lightNavigationBar: Boolean = false private var navigationBarColorAnimator: ValueAnimator? = null protected abstract fun createContentView(): View + private lateinit var shapeDrawable: MaterialShapeDrawable private val panelState: Int get() = bottomSheetBehavior.state @@ -68,6 +71,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), setMiniPlayerAlphaProgress(slideOffset) dimBackground.show() dimBackground.alpha = slideOffset + shapeDrawable.interpolation = 1 - slideOffset } override fun onStateChanged(bottomSheet: View, newState: Int) { @@ -97,11 +101,18 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), updateTabs() - bottomSheetBehavior = - BottomSheetBehavior.from(slidingPanel) as RetroBottomSheetBehavior + bottomSheetBehavior = BottomSheetBehavior.from(slidingPanel) as RetroBottomSheetBehavior val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY) dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f)) + shapeDrawable = MaterialShapeDrawable( + ShapeAppearanceModel.builder( + this, + R.style.ClassicThemeOverLay, + 0 + ).build() + ) + slidingPanel.background = shapeDrawable } override fun onResume() { @@ -309,6 +320,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), super.setNavigationbarColor(paletteColor) super.setLightNavigationBar(isColorLight) super.setLightStatusbar(isColorLight) + } else if (currentNowPlayingScreen == CLASSIC) { + super.setLightStatusbar(false) } else if (currentNowPlayingScreen == FIT) { super.setLightStatusbar(false) } else { 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 bfdc8b76..30e0c8cb 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 @@ -1,23 +1,26 @@ package code.name.monkey.retromusic.fragments.player.classic +import android.content.res.ColorStateList import android.graphics.Color import android.graphics.PorterDuff import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.LinearLayout import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.view.ViewCompat import androidx.recyclerview.widget.LinearLayoutManager -import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.* -import code.name.monkey.retromusic.RetroBottomSheetBehavior +import code.name.monkey.appthemehelper.util.ATHUtil +import code.name.monkey.appthemehelper.util.ColorUtil +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.RetroBottomSheetBehavior import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter import code.name.monkey.retromusic.extensions.hide -import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.fragments.VolumeFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment @@ -27,16 +30,20 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.service.MusicService +import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.card.MaterialCardView +import com.google.android.material.shape.MaterialShapeDrawable +import com.google.android.material.shape.ShapeAppearanceModel import kotlinx.android.synthetic.main.fragment_clasic_player.* import kotlinx.android.synthetic.main.fragment_classic_controls.* import kotlinx.android.synthetic.main.status_bar.* + class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, MusicProgressViewUpdateHelper.Callback { @@ -46,7 +53,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var queueAdapter: PlayingQueueAdapter private var volumeFragment: VolumeFragment? = null - + private lateinit var shapeDrawable: MaterialShapeDrawable private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(bottomSheet: View, slideOffset: Float) { @@ -59,6 +66,8 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, playerQueueSheet.contentPaddingRight, playerQueueSheet.contentPaddingBottom ) + val corner = (1 - slideOffset) * DensityUtil.dip2px(requireContext(), 16f) + shapeDrawable.interpolation = 1 - slideOffset } override fun onStateChanged(bottomSheet: View, newState: Int) { @@ -97,13 +106,20 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList) - playerQueueSheet.setOnTouchListener { _, _ -> (requireActivity() as AbsSlidingMusicPanelActivity).getBottomSheetBehavior() .setAllowDragging(false) getQueuePanel().setAllowDragging(true) return@setOnTouchListener false } + + shapeDrawable = MaterialShapeDrawable( + ShapeAppearanceModel.builder( + requireContext(), + R.style.ClassicThemeOverLay, + 0 + ).build() + ) } private fun hideVolumeIfAvailable() { @@ -146,7 +162,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, } private fun getQueuePanel(): RetroBottomSheetBehavior { - playerQueueSheet as MaterialCardView return RetroBottomSheetBehavior.from(playerQueueSheet) as RetroBottomSheetBehavior } @@ -233,48 +248,25 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, override fun onColorChanged(color: MediaNotificationProcessor) { lastColor = color.backgroundColor - ToolbarContentTintHelper.colorizeToolbar( - playerToolbar, - Color.WHITE, - requireActivity() - ) + lastPlaybackControlsColor = color.primaryTextColor + lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f) + shapeDrawable.fillColor = ColorStateList.valueOf(color.backgroundColor) + playerQueueSheet.background = shapeDrawable - if (!ATHUtil.isWindowBackgroundDark(requireContext())) { - lastPlaybackControlsColor = - MaterialValueHelper.getSecondaryTextColor(requireContext(), true) - lastDisabledPlaybackControlsColor = - MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) - } else { - lastPlaybackControlsColor = - MaterialValueHelper.getPrimaryTextColor(requireContext(), false) - lastDisabledPlaybackControlsColor = - MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) - } + title.setTextColor(color.primaryTextColor) + text.setTextColor(color.secondaryTextColor) + songInfo.setTextColor(color.secondaryTextColor) - val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { - color.backgroundColor - } else { - ThemeStore.accentColor(requireContext()) - }.ripAlpha() - - TintHelper.setTintAuto( - playPauseButton, - MaterialValueHelper.getPrimaryTextColor( - requireContext(), - ColorUtil.isColorLight(colorFinal) - ), - false - ) - title.setTextColor(lastPlaybackControlsColor) - text.setTextColor(lastDisabledPlaybackControlsColor) - songInfo.setTextColor(lastDisabledPlaybackControlsColor) songCurrentProgress.setTextColor(lastPlaybackControlsColor) songTotalTime.setTextColor(lastPlaybackControlsColor) - ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) - player_queue_sub_header.setTextColor(colorFinal) - volumeFragment?.setTintable(colorFinal) - TintHelper.setTintAuto(playPauseButton, colorFinal, true) - ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) + + ViewUtil.setProgressDrawable(progressSlider, color.primaryTextColor, true) + volumeFragment?.setTintableColor(color.primaryTextColor) + + player_queue_sub_header.setTextColor(color.secondaryTextColor) + + TintHelper.setTintAuto(playPauseButton, color.primaryTextColor, true) + TintHelper.setTintAuto(playPauseButton, color.backgroundColor, false) updateRepeatState() updateShuffleState() updatePrevNextColor() @@ -410,6 +402,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, val width = playerContainer.width val finalHeight = height - width val panel = getQueuePanel() - panel.peekHeight = finalHeight + panel.peekHeight = finalHeight + DensityUtil.dip2px(requireContext(), 16f) } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index d0a0a380..4f0a04a1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -499,10 +499,10 @@ public final class PreferenceUtil { @NonNull public ThemeMode getGeneralThemeValue() { - if (isBlackMode()) { + String themeMode = mPreferences.getString(GENERAL_THEME, "dark"); + if (isBlackMode() && themeMode.equals("dark")) { return ThemeMode.BLACK; } else { - String themeMode = mPreferences.getString(GENERAL_THEME, "dark"); switch (themeMode) { case "light": return ThemeMode.LIGHT; @@ -764,7 +764,7 @@ public final class PreferenceUtil { return mPreferences.getBoolean(INTRO_SHOWN, false); } - public boolean isBlackMode() { + private boolean isBlackMode() { return mPreferences.getBoolean(BLACK_THEME, false); } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt index 542fdbe5..17003488 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/theme/ThemeManager.kt @@ -10,9 +10,6 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.theme.ThemeMode.* -/** - * @author Paolo Valerdi - */ object ThemeManager { @StyleRes diff --git a/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml b/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml index a0670e6b..e4002361 100644 --- a/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml +++ b/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml @@ -1,24 +1,5 @@ - - - - + + diff --git a/app/src/main/res/layout/fragment_clasic_player.xml b/app/src/main/res/layout/fragment_clasic_player.xml index bf6bc457..1c24548c 100644 --- a/app/src/main/res/layout/fragment_clasic_player.xml +++ b/app/src/main/res/layout/fragment_clasic_player.xml @@ -50,28 +50,22 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="bottom" - android:orientation="vertical" app:behavior_hideable="false" app:cardCornerRadius="0dp" - app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior"> + app:cardElevation="12dp" + app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior" + app:shapeAppearance="@style/ClassicThemeOverLay"> - - - - + android:layout_height="wrap_content" /> diff --git a/app/src/main/res/layout/fragment_classic_controls.xml b/app/src/main/res/layout/fragment_classic_controls.xml index ffac3d5c..279d51c5 100644 --- a/app/src/main/res/layout/fragment_classic_controls.xml +++ b/app/src/main/res/layout/fragment_classic_controls.xml @@ -77,7 +77,7 @@ android:paddingStart="16dp" android:paddingTop="8dp" android:paddingEnd="16dp" - android:paddingBottom="8dp" + android:paddingBottom="4dp" android:scrollHorizontally="true" android:singleLine="true" android:textAppearance="@style/TextViewHeadline6" @@ -95,9 +95,9 @@ android:gravity="center" android:maxLines="1" android:paddingStart="16dp" - android:paddingTop="8dp" + android:paddingTop="4dp" android:paddingEnd="16dp" - android:paddingBottom="8dp" + android:paddingBottom="12dp" android:textAppearance="@style/TextViewBody1" android:textColor="?android:attr/textColorSecondary" app:layout_constrainedWidth="true" diff --git a/app/src/main/res/layout/sliding_music_panel_layout.xml b/app/src/main/res/layout/sliding_music_panel_layout.xml index 73f82ad0..b7dfdfda 100644 --- a/app/src/main/res/layout/sliding_music_panel_layout.xml +++ b/app/src/main/res/layout/sliding_music_panel_layout.xml @@ -19,14 +19,17 @@ android:focusable="true" android:visibility="gone" /> - + app:cardCornerRadius="0dp" + app:cardElevation="12dp" + app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior" + app:shapeAppearance="@style/ClassicThemeOverLay"> - + 72dp 6dp 3dp - 48dp + 46dp 12dp 16dp 2dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d25052d8..6ec32bad 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -62,7 +62,7 @@ - + diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 4de7ba2c..3bce2330 100755 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -53,13 +53,6 @@ android:layout="@layout/list_item_view_switch" android:summary="@string/pref_summary_colored_app_shortcuts" android:title="@string/pref_title_app_shortcuts" /> - - - + \ No newline at end of file