Fix colors in classic

main
Hemanth S 2020-05-09 11:25:42 +05:30
parent d74ad32a38
commit 6e7d945fb1
11 changed files with 90 additions and 113 deletions

View File

@ -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<FrameLayout>
private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<MaterialCardView>
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 {

View File

@ -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<MaterialCardView> {
playerQueueSheet as MaterialCardView
return RetroBottomSheetBehavior.from(playerQueueSheet) as RetroBottomSheetBehavior<MaterialCardView>
}
@ -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)
}
}

View File

@ -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);
}

View File

@ -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

View File

@ -1,24 +1,5 @@
<!--
~ 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6.34 7.93c-3.12 3.12-3.12 8.19 0 11.31C7.9 20.8 9.95 21.58 12 21.58s4.1-0.78 5.66-2.34c3.12-3.12 3.12-8.19 0-11.31l-4.95-4.95c-0.39-0.39-1.02-0.39-1.41 0L6.34 7.93zM12 19.59c-1.6 0-3.11-0.62-4.24-1.76C6.62 16.69 6 15.19 6 13.59s0.62-3.11 1.76-4.24L12 5.1v14.49z" />
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M17.66,7.93L12,2.27 6.34,7.93c-3.12,3.12 -3.12,8.19 0,11.31C7.9,20.8 9.95,21.58 12,21.58c2.05,0 4.1,-0.78 5.66,-2.34 3.12,-3.12 3.12,-8.19 0,-11.31zM12,19.59c-1.6,0 -3.11,-0.62 -4.24,-1.76C6.62,16.69 6,15.19 6,13.59s0.62,-3.11 1.76,-4.24L12,5.1v14.49z"/>
</vector>

View File

@ -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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
<include
android:id="@+id/playerControlsContainer"
layout="@layout/fragment_classic_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="0dp">
<include
android:id="@+id/playerControlsContainer"
layout="@layout/fragment_classic_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.card.MaterialCardView>
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@ -95,6 +89,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:overScrollMode="never"
tools:listitem="@layout/item_list" />
</LinearLayout>
</LinearLayout>

View File

@ -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"

View File

@ -19,14 +19,17 @@
android:focusable="true"
android:visibility="gone" />
<FrameLayout
<com.google.android.material.card.MaterialCardView
android:id="@+id/slidingPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:gravity="bottom"
app:behavior_hideable="false"
app:behavior_peekHeight="0dp"
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
app:cardCornerRadius="0dp"
app:cardElevation="12dp"
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior"
app:shapeAppearance="@style/ClassicThemeOverLay">
<FrameLayout
android:id="@+id/playerFragmentContainer"
@ -40,7 +43,7 @@
android:layout_height="48dp"
tools:layout="@layout/fragment_mini_player" />
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
<code.name.monkey.retromusic.views.BottomNavigationBarTinted
android:id="@+id/bottomNavigationView"

View File

@ -52,7 +52,7 @@
<dimen name="pref_title_padding">72dp</dimen>
<dimen name="slider_thumb_radius">6dp</dimen>
<dimen name="slider_track_height">3dp</dimen>
<dimen name="adaptive_icon_size">48dp</dimen>
<dimen name="adaptive_icon_size">46dp</dimen>
<dimen name="adaptive_icon_padding">12dp</dimen>
<dimen name="about_card_radius">16dp</dimen>
<dimen name="about_card_elevation">2dp</dimen>

View File

@ -62,7 +62,7 @@
</style>
<style name="ToolbarTextAppearanceNormal.Library" parent="ToolbarTextAppearanceNormal">
<item name="android:textSize">24sp</item>
<item name="android:textAppearance">@style/TextAppearance.MaterialComponents.Headline6</item>
</style>
<style name="BigTitleTextAppearanceToolbar">
@ -175,9 +175,11 @@
<item name="cornerSizeTopRight">16dp</item>
</style>
<style name="ToolbarCornerCardView">
<style name="ClassicThemeOverLay">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item>
<item name="cornerSize">0dp</item>
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeTopLeft">16dp</item>
</style>
<style name="TopCornerCardViewStyle" parent="@style/Widget.MaterialComponents.CardView">
@ -219,4 +221,5 @@
<item name="android:background">@color/md_white_1000</item>
<item name="android:textColor">@color/md_red_400</item>
</style>
</resources>

View File

@ -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" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="dominant_color"
android:layout="@layout/list_item_view_switch"
android:summary="@string/pref_summary_dominant_color"
android:title="@string/pref_title_toggle_dominant_color" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
</androidx.preference.PreferenceScreen>