style: make audio player align with status bar color

This commit is contained in:
Bnyro 2024-06-21 16:52:12 +02:00
parent 94ef6a00f4
commit 30d8de4d08
4 changed files with 75 additions and 85 deletions

View File

@ -3,6 +3,7 @@ package com.github.libretube.ui.activities
import android.annotation.SuppressLint
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.KeyEvent
@ -13,6 +14,7 @@ import android.view.ViewTreeObserver
import android.widget.ScrollView
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.annotation.ColorInt
import androidx.appcompat.widget.SearchView
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.os.bundleOf
@ -112,13 +114,7 @@ class MainActivity : BaseActivity() {
}
// sets the color if the navigation bar is visible
val bottomNavColor = if (binding.bottomNav.menu.size() == 0) {
null
} else if (PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false)) {
SurfaceColors.getColorForElevation(this, binding.bottomNav.elevation)
} else {
ThemeHelper.getThemeColor(this, com.google.android.material.R.attr.colorSurfaceContainer)
}
val bottomNavColor = getBottomNavColor()
ThemeHelper.setSystemBarColors(this, window, bottomNavColor)
// set default tab as start fragment
@ -200,6 +196,17 @@ class MainActivity : BaseActivity() {
loadIntentData()
}
@ColorInt
fun getBottomNavColor(): Int? {
return if (binding.bottomNav.menu.size() == 0) {
null
} else if (PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false)) {
SurfaceColors.getColorForElevation(this, binding.bottomNav.elevation)
} else {
ThemeHelper.getThemeColor(this, com.google.android.material.R.attr.colorSurfaceContainer)
}
}
/**
* Deselect all bottom bar items
*/

View File

@ -52,7 +52,6 @@ import com.github.libretube.ui.sheets.SleepTimerSheet
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
import com.github.libretube.util.DataSaverMode
import com.github.libretube.util.PlayingQueue
import com.google.android.material.elevation.SurfaceColors
import kotlinx.coroutines.launch
import kotlin.math.abs
@ -108,6 +107,10 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as? MainActivity)?.getBottomNavColor()?.let { color ->
binding.audioPlayerContainer.setBackgroundColor(color)
}
initializeTransitionLayout()
// select the title TV in order for it to automatically scroll
@ -238,9 +241,6 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
val mainMotionLayout = mainActivity.binding.mainMotionLayout
mainMotionLayout.progress = 0F
val surfaceColor = SurfaceColors.getColorForElevation(requireContext(), 3f)
binding.audioPlayerContainer.setBackgroundColor(surfaceColor)
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
override fun onTransitionChange(
motionLayout: MotionLayout?,

View File

@ -11,7 +11,7 @@
android:id="@+id/audio_player_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
android:background="?attr/colorSurfaceContainer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -265,85 +265,76 @@
</LinearLayout>
<com.google.android.material.card.MaterialCardView
style="@style/Widget.Material3.CardView.Elevated"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
app:shapeAppearanceOverlay="@style/CardOnlyBottomCorners">
android:paddingVertical="15dp"
android:paddingHorizontal="30dp">
<FrameLayout
android:layout_width="match_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="15dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/playback_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_speed" />
<ImageView
android:id="@+id/sleep_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_sleep" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/open_chapters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_frame" />
<ImageView
android:id="@+id/open_queue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_queue" />
</LinearLayout>
android:layout_gravity="start|center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/show_more"
android:id="@+id/playback_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="10dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_three_dots" />
android:src="@drawable/ic_speed" />
</FrameLayout>
<ImageView
android:id="@+id/sleep_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_sleep" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/open_chapters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_frame" />
<ImageView
android:id="@+id/open_queue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_queue" />
</LinearLayout>
<ImageView
android:id="@+id/show_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleX="0.9"
android:scaleY="0.9"
android:src="@drawable/ic_three_dots" />
</FrameLayout>
</LinearLayout>

View File

@ -189,14 +189,6 @@
<item name="android:drawableTint" tools:targetApi="m">?android:attr/textColorPrimary</item>
</style>
<style name="CardOnlyBottomCorners">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopRight">0dp</item>
<item name="cornerSizeTopLeft">0dp</item>
<item name="cornerSizeBottomRight">18dp</item>
<item name="cornerSizeBottomLeft">18dp</item>
</style>
<style name="HomeCategoryTitle">
<item name="android:layout_width">match_parent</item>