Improved full theme color and lyrics alignment

main
Hemanth S 2020-05-09 20:15:07 +05:30
parent 2f42ce1638
commit 1291666451
6 changed files with 177 additions and 155 deletions

View File

@ -54,7 +54,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<MaterialCardView> private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<MaterialCardView>
private var miniPlayerFragment: MiniPlayerFragment? = null private var miniPlayerFragment: MiniPlayerFragment? = null
private var playerFragment: AbsPlayerFragment? = null private var playerFragment: AbsPlayerFragment? = null
private var currentNowPlayingScreen: NowPlayingScreen? = null private var cps: NowPlayingScreen? = null
private var navigationBarColor: Int = 0 private var navigationBarColor: Int = 0
private var taskColor: Int = 0 private var taskColor: Int = 0
private var lightStatusBar: Boolean = false private var lightStatusBar: Boolean = false
@ -117,7 +117,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) { if (cps != PreferenceUtil.getInstance(this).nowPlayingScreen) {
postRecreate() postRecreate()
} }
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList) bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
@ -190,7 +190,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
ViewTreeObserver.OnGlobalLayoutListener { ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() { override fun onGlobalLayout() {
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this) slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (currentNowPlayingScreen != PEAK) { if (cps != PEAK) {
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
params.height = ViewGroup.LayoutParams.MATCH_PARENT params.height = ViewGroup.LayoutParams.MATCH_PARENT
slidingPanel.layoutParams = params slidingPanel.layoutParams = params
@ -239,9 +239,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
} }
private fun chooseFragmentForTheme() { private fun chooseFragmentForTheme() {
currentNowPlayingScreen = PreferenceUtil.getInstance(this).nowPlayingScreen cps = PreferenceUtil.getInstance(this).nowPlayingScreen
val fragment: Fragment = when (currentNowPlayingScreen) { val fragment: Fragment = when (cps) {
BLUR -> BlurPlayerFragment() BLUR -> BlurPlayerFragment()
ADAPTIVE -> AdaptiveFragment() ADAPTIVE -> AdaptiveFragment()
NORMAL -> PlayerFragment() NORMAL -> PlayerFragment()
@ -309,20 +309,24 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
val isColorLight = ColorUtil.isColorLight(paletteColor) val isColorLight = ColorUtil.isColorLight(paletteColor)
if (PreferenceUtil.getInstance(this).adaptiveColor && (currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) { if (PreferenceUtil.getInstance(this).adaptiveColor && (cps == NORMAL || cps == FLAT)) {
super.setLightNavigationBar(true) super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight) super.setLightStatusbar(isColorLight)
} else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) { } else if (cps == CARD || cps == BLUR || cps == BLUR_CARD) {
super.setLightStatusbar(false) super.setLightStatusbar(false)
super.setLightNavigationBar(true) super.setLightNavigationBar(true)
super.setNavigationbarColor(Color.BLACK) super.setNavigationbarColor(Color.BLACK)
} else if (currentNowPlayingScreen == COLOR || currentNowPlayingScreen == TINY) { } else if (cps == COLOR || cps == TINY) {
super.setNavigationbarColor(paletteColor) super.setNavigationbarColor(paletteColor)
super.setLightNavigationBar(isColorLight) super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(isColorLight) super.setLightStatusbar(isColorLight)
} else if (currentNowPlayingScreen == CLASSIC) { } else if (cps == FULL) {
super.setNavigationbarColor(paletteColor)
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(false) super.setLightStatusbar(false)
} else if (currentNowPlayingScreen == FIT) { } else if (cps == CLASSIC) {
super.setLightStatusbar(false)
} else if (cps == FIT) {
super.setLightStatusbar(false) super.setLightStatusbar(false)
} else { } else {
super.setLightStatusbar( super.setLightStatusbar(

View File

@ -30,6 +30,7 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_full_player_controls.* import kotlinx.android.synthetic.main.fragment_full_player_controls.*
/** /**
@ -92,6 +93,29 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
} }
} }
fun setDark(color: MediaNotificationProcessor) {
lastPlaybackControlsColor = color.primaryTextColor
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f)
val tintList=ColorStateList.valueOf(color.primaryTextColor)
playerMenu.imageTintList = tintList
songFavourite.imageTintList = tintList
volumeFragment?.setTintableColor(color.primaryTextColor)
ViewUtil.setProgressDrawable(progressSlider, color.primaryTextColor, true)
title.setTextColor(color.primaryTextColor)
text.setTextColor(color.secondaryTextColor)
songInfo.setTextColor(color.secondaryTextColor)
songCurrentProgress.setTextColor(color.secondaryTextColor)
songTotalTime.setTextColor(color.secondaryTextColor)
playPauseButton.backgroundTintList = tintList
playPauseButton.imageTintList = ColorStateList.valueOf(color.backgroundColor)
updateRepeatState()
updateShuffleState()
updatePrevNextColor()
}
override fun setDark(color: Int) { override fun setDark(color: Int) {
lastPlaybackControlsColor = Color.WHITE lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor = lastDisabledPlaybackControlsColor =
@ -319,4 +343,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
fun onFavoriteToggled() { fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
} }

View File

@ -1,6 +1,7 @@
package code.name.monkey.retromusic.fragments.player.full package code.name.monkey.retromusic.fragments.player.full
import android.app.ActivityOptions import android.app.ActivityOptions
import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -142,7 +143,7 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
lyricsLayout = view.findViewById(R.id.player_lyrics) lyricsLayout = view.findViewById(R.id.playerLyrics)
lyricsLine1 = view.findViewById(R.id.player_lyrics_line1) lyricsLine1 = view.findViewById(R.id.player_lyrics_line1)
lyricsLine2 = view.findViewById(R.id.player_lyrics_line2) lyricsLine2 = view.findViewById(R.id.player_lyrics_line2)
@ -199,7 +200,8 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onColorChanged(color: MediaNotificationProcessor) { override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor lastColor = color.backgroundColor
controlsFragment.setDark(color.primaryTextColor) mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor)
controlsFragment.setDark(color)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
} }

View File

@ -1,9 +1,6 @@
package code.name.monkey.retromusic.util.theme package code.name.monkey.retromusic.util.theme
import android.content.Context import android.content.Context
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.os.PowerManager
import androidx.annotation.StyleRes import androidx.annotation.StyleRes
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -30,17 +27,6 @@ object ThemeManager {
BLACK -> AppCompatDelegate.MODE_NIGHT_YES BLACK -> AppCompatDelegate.MODE_NIGHT_YES
AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
} }
private fun isSystemDarkModeEnabled(context: Context): Boolean {
val isBatterySaverEnabled =
(context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
?: false
val isDarkModeEnabled =
(context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
return isBatterySaverEnabled or isDarkModeEnabled
}
} }
val Context.generalThemeValue: ThemeMode val Context.generalThemeValue: ThemeMode

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -7,155 +7,161 @@
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface" />
<fragment <fragment
android:id="@+id/playerAlbumCoverFragment" android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment" android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout="@layout/fragment_album_full_cover" /> tools:layout="@layout/fragment_album_full_cover" />
<View <View
android:id="@+id/mask"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/shadow_up_full_theme" /> android:background="@drawable/shadow_up_full_theme"
android:backgroundTint="@color/md_red_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.full.FullPlaybackControlsFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="vertical"> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout="@layout/fragment_full_player_controls" />
<fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.full.FullPlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:layout="@layout/fragment_full_player_controls" />
</LinearLayout> <FrameLayout
android:id="@+id/statusBarContainer"
<View
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@drawable/shadow_down" />
<LinearLayout
android:id="@+id/toolbar_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout <include layout="@layout/status_bar" />
</FrameLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:contentInsetEndWithActions="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/statusBarContainer"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:titleMargin="0dp"
app:titleMargins="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
</FrameLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nextSongLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:alpha="0.75"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/next_song"
android:textAppearance="@style/TextViewSubtitle2"
android:textColor="@color/md_white_1000"
app:layout_constraintEnd_toStartOf="@+id/artistImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nextSong"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:singleLine="true"
android:textAppearance="@style/TextViewSubtitle1"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/artistImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nextSongLabel"
tools:text="@tools:sample/lorem/random" />
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/artistImage"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="end"
android:layout_marginEnd="8dp"
android:elevation="10dp"
app:civ_border="false"
app:civ_shadow="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/default_artist_art" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.MaterialToolbar>
<FrameLayout
android:id="@+id/player_lyrics"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:clipToPadding="false"
android:elevation="20dp"
android:padding="16dp"
android:visibility="gone"
tools:visibility="visible">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/player_lyrics_line1" android:id="@+id/nextSongLabel"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:alpha="0.75"
android:shadowColor="@color/md_black_1000" android:ellipsize="end"
android:shadowRadius="4" android:gravity="center"
android:textAlignment="center" android:maxLines="1"
android:textAppearance="@style/TextViewHeadline6" android:paddingHorizontal="8dp"
android:text="@string/next_song"
android:textAppearance="@style/TextViewSubtitle2"
android:textColor="@color/md_white_1000" android:textColor="@color/md_white_1000"
android:visibility="gone" /> app:layout_constraintEnd_toStartOf="@+id/artistImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/player_lyrics_line2" android:id="@+id/nextSong"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_marginTop="4dp"
android:shadowColor="@color/md_black_1000" android:ellipsize="end"
android:shadowRadius="4" android:gravity="center"
android:textAlignment="center" android:paddingHorizontal="8dp"
android:textAppearance="@style/TextViewHeadline6" android:singleLine="true"
android:textColor="@color/md_white_1000" /> android:textAppearance="@style/TextViewSubtitle1"
android:textColor="@color/md_white_1000"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/artistImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nextSongLabel"
tools:text="@tools:sample/lorem/random" />
</FrameLayout> <code.name.monkey.retromusic.views.CircularImageView
</LinearLayout> android:id="@+id/artistImage"
</FrameLayout> android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="end"
android:layout_marginEnd="8dp"
android:elevation="10dp"
app:civ_border="false"
app:civ_shadow="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/default_artist_art" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.MaterialToolbar>
<FrameLayout
android:id="@+id/playerLyrics"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0"
android:clipToPadding="false"
android:elevation="20dp"
android:padding="16dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/playbackControlsFragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/playerToolbar"
tools:visibility="visible">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/player_lyrics_line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:shadowColor="@color/md_black_1000"
android:shadowRadius="4"
android:textAppearance="@style/TextViewHeadline6"
android:textColor="@color/md_white_1000"
android:visibility="gone" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/player_lyrics_line2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:shadowColor="@color/md_black_1000"
android:shadowRadius="4"
android:textAppearance="@style/TextViewHeadline6"
android:textColor="@color/md_white_1000" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -13,8 +13,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
android:paddingHorizontal="16dp" android:padding="16dp"
android:paddingVertical="12dp"
app:layout_constraintBottom_toBottomOf="@+id/titleContainer" app:layout_constraintBottom_toBottomOf="@+id/titleContainer"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/titleContainer" app:layout_constraintTop_toTopOf="@id/titleContainer"
@ -67,8 +66,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
android:paddingHorizontal="16dp" android:padding="16dp"
android:paddingVertical="12dp"
app:layout_constraintBottom_toBottomOf="@+id/titleContainer" app:layout_constraintBottom_toBottomOf="@+id/titleContainer"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/titleContainer" app:layout_constraintTop_toTopOf="@+id/titleContainer"
@ -162,7 +160,7 @@
android:id="@+id/playPauseButton" android:id="@+id/playPauseButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
app:fabCustomSize="64dp" app:fabCustomSize="64dp"