Black theme switching possible only when dark or system dark theme is enabled
App dark theme -> Black System dark -> Black
This commit is contained in:
parent
54e6a8fb81
commit
82a19b5462
6 changed files with 32 additions and 18 deletions
|
@ -11,11 +11,11 @@ enum class AlbumCoverStyle(
|
||||||
@param:DrawableRes @field:DrawableRes
|
@param:DrawableRes @field:DrawableRes
|
||||||
val drawableResId: Int, val id: Int
|
val drawableResId: Int, val id: Int
|
||||||
) {
|
) {
|
||||||
NORMAL(R.string.normal, R.drawable.np_normal, 0),
|
|
||||||
FLAT(R.string.flat, R.drawable.np_flat, 1),
|
|
||||||
CIRCLE(R.string.circular, R.drawable.np_circle, 2),
|
|
||||||
MATERIAL(R.string.material, R.drawable.np_material, 3),
|
|
||||||
CARD(R.string.card, R.drawable.np_blur_card, 4),
|
CARD(R.string.card, R.drawable.np_blur_card, 4),
|
||||||
|
CIRCLE(R.string.circular, R.drawable.np_circle, 2),
|
||||||
|
FLAT(R.string.flat, R.drawable.np_flat, 1),
|
||||||
|
FULL_CARD(R.string.full_card, R.drawable.np_adaptive, 6),
|
||||||
FULL(R.string.full, R.drawable.np_full, 5),
|
FULL(R.string.full, R.drawable.np_full, 5),
|
||||||
FULL_CARD(R.string.full_card, R.drawable.np_adaptive, 6)
|
MATERIAL(R.string.material, R.drawable.np_material, 3),
|
||||||
|
NORMAL(R.string.normal, R.drawable.np_normal, 0),
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,8 +495,8 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
||||||
) {
|
) {
|
||||||
val height = playerContainer.height
|
val height = playerContainer.height
|
||||||
val width = playerContainer.width
|
val width = playerContainer.width
|
||||||
val finalHeight = height - width
|
val finalHeight = height - (playerControlsContainer.height + width)
|
||||||
val panel = getQueuePanel()
|
val panel = getQueuePanel()
|
||||||
panel.peekHeight = finalHeight + DensityUtil.dip2px(requireContext(), 16f)
|
panel.peekHeight = finalHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -496,9 +496,11 @@ public final class PreferenceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public ThemeMode getGeneralThemeValue() {
|
public ThemeMode getGeneralThemeValue(boolean isSystemDark) {
|
||||||
String themeMode = mPreferences.getString(GENERAL_THEME, "dark");
|
String themeMode = mPreferences.getString(GENERAL_THEME, "dark");
|
||||||
if (isBlackMode() && themeMode.equals("dark")) {
|
if (isBlackMode() && isSystemDark) {
|
||||||
|
return ThemeMode.BLACK;
|
||||||
|
} else if (isBlackMode() && themeMode.equals("dark")) {
|
||||||
return ThemeMode.BLACK;
|
return ThemeMode.BLACK;
|
||||||
} else {
|
} else {
|
||||||
switch (themeMode) {
|
switch (themeMode) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ object ViewUtil {
|
||||||
}
|
}
|
||||||
val colorWithAlpha = ColorUtil.withAlpha(color, 0.25f)
|
val colorWithAlpha = ColorUtil.withAlpha(color, 0.25f)
|
||||||
progressSlider.haloColor = ColorStateList.valueOf(colorWithAlpha)
|
progressSlider.haloColor = ColorStateList.valueOf(colorWithAlpha)
|
||||||
|
progressSlider.haloRadius = 0
|
||||||
progressSlider.trackColorActive = ColorStateList.valueOf(color)
|
progressSlider.trackColorActive = ColorStateList.valueOf(color)
|
||||||
progressSlider.trackColorInactive = ColorStateList.valueOf(colorWithAlpha)
|
progressSlider.trackColorInactive = ColorStateList.valueOf(colorWithAlpha)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
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
|
||||||
|
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
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.theme.ThemeManager.isSystemDarkModeEnabled
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeMode.*
|
import code.name.monkey.retromusic.util.theme.ThemeMode.*
|
||||||
|
|
||||||
object ThemeManager {
|
object ThemeManager {
|
||||||
|
@ -27,7 +30,19 @@ object ThemeManager {
|
||||||
BLACK -> AppCompatDelegate.MODE_NIGHT_YES
|
BLACK -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
AUTO -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||||
|
val isBatterySaverEnabled =
|
||||||
|
(context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
|
||||||
|
?: false
|
||||||
|
val isDarkModeEnabled =
|
||||||
|
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
|
||||||
|
return isBatterySaverEnabled or isDarkModeEnabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.generalThemeValue: ThemeMode
|
val Context.generalThemeValue: ThemeMode
|
||||||
get() = PreferenceUtil.getInstance(this).generalThemeValue
|
get() {
|
||||||
|
return PreferenceUtil.getInstance(this).getGeneralThemeValue(isSystemDarkModeEnabled(this))
|
||||||
|
}
|
|
@ -28,11 +28,10 @@
|
||||||
android:id="@+id/progressSlider"
|
android:id="@+id/progressSlider"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
app:haloRadius="0dp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/songTotalTime"
|
app:layout_constraintEnd_toStartOf="@id/songTotalTime"
|
||||||
app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
|
app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:haloRadius="0dp"
|
|
||||||
app:thumbRadius="@dimen/slider_thumb_radius"
|
app:thumbRadius="@dimen/slider_thumb_radius"
|
||||||
app:trackHeight="@dimen/slider_track_height" />
|
app:trackHeight="@dimen/slider_track_height" />
|
||||||
|
|
||||||
|
@ -86,7 +85,6 @@
|
||||||
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="8dp"
|
|
||||||
android:background="?attr/roundSelector"
|
android:background="?attr/roundSelector"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
||||||
|
@ -132,8 +130,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:paddingStart="8dp"
|
android:paddingHorizontal="8dp"
|
||||||
android:paddingEnd="8dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/songInfo"
|
app:layout_constraintBottom_toTopOf="@id/songInfo"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -149,9 +146,8 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingStart="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingVertical="8dp"
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue