Improved full theme color and lyrics alignment

This commit is contained in:
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 var miniPlayerFragment: MiniPlayerFragment? = null
private var playerFragment: AbsPlayerFragment? = null
private var currentNowPlayingScreen: NowPlayingScreen? = null
private var cps: NowPlayingScreen? = null
private var navigationBarColor: Int = 0
private var taskColor: Int = 0
private var lightStatusBar: Boolean = false
@ -117,7 +117,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
override fun onResume() {
super.onResume()
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) {
if (cps != PreferenceUtil.getInstance(this).nowPlayingScreen) {
postRecreate()
}
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
@ -190,7 +190,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (currentNowPlayingScreen != PEAK) {
if (cps != PEAK) {
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
params.height = ViewGroup.LayoutParams.MATCH_PARENT
slidingPanel.layoutParams = params
@ -239,9 +239,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}
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()
ADAPTIVE -> AdaptiveFragment()
NORMAL -> PlayerFragment()
@ -309,20 +309,24 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
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.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.setLightNavigationBar(true)
super.setNavigationbarColor(Color.BLACK)
} else if (currentNowPlayingScreen == COLOR || currentNowPlayingScreen == TINY) {
} else if (cps == COLOR || cps == TINY) {
super.setNavigationbarColor(paletteColor)
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(isColorLight)
} else if (currentNowPlayingScreen == CLASSIC) {
} else if (cps == FULL) {
super.setNavigationbarColor(paletteColor)
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(false)
} else if (currentNowPlayingScreen == FIT) {
} else if (cps == CLASSIC) {
super.setLightStatusbar(false)
} else if (cps == FIT) {
super.setLightStatusbar(false)
} else {
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.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
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) {
lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor =
@ -319,4 +343,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
}

View file

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

View file

@ -1,9 +1,6 @@
package code.name.monkey.retromusic.util.theme
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.appcompat.app.AppCompatDelegate
import code.name.monkey.retromusic.R
@ -30,17 +27,6 @@ object ThemeManager {
BLACK -> AppCompatDelegate.MODE_NIGHT_YES
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

View file

@ -1,5 +1,5 @@
<?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:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -7,63 +7,67 @@
android:clickable="true"
android:focusable="true">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface" />
<fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
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" />
<View
android:id="@+id/mask"
android:layout_width="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
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<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"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout="@layout/fragment_full_player_controls" />
</LinearLayout>
<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_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/statusBarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include layout="@layout/status_bar" />
</FrameLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app: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"
@ -77,14 +81,14 @@
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingHorizontal="8dp"
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" />
app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/nextSong"
@ -93,8 +97,7 @@
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingHorizontal="8dp"
android:singleLine="true"
android:textAppearance="@style/TextViewSubtitle1"
android:textColor="@color/md_white_1000"
@ -123,14 +126,18 @@
</com.google.android.material.appbar.MaterialToolbar>
<FrameLayout
android:id="@+id/player_lyrics"
android:id="@+id/playerLyrics"
android:layout_width="match_parent"
android:layout_height="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
@ -138,9 +145,9 @@
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:textAlignment="center"
android:textAppearance="@style/TextViewHeadline6"
android:textColor="@color/md_white_1000"
android:visibility="gone" />
@ -150,12 +157,11 @@
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:textAlignment="center"
android:textAppearance="@style/TextViewHeadline6"
android:textColor="@color/md_white_1000" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

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