mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
style: make audio player align with status bar color
This commit is contained in:
parent
94ef6a00f4
commit
30d8de4d08
@ -3,6 +3,7 @@ package com.github.libretube.ui.activities
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
@ -13,6 +14,7 @@ import android.view.ViewTreeObserver
|
|||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import androidx.activity.addCallback
|
import androidx.activity.addCallback
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
@ -112,13 +114,7 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sets the color if the navigation bar is visible
|
// sets the color if the navigation bar is visible
|
||||||
val bottomNavColor = if (binding.bottomNav.menu.size() == 0) {
|
val bottomNavColor = getBottomNavColor()
|
||||||
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)
|
|
||||||
}
|
|
||||||
ThemeHelper.setSystemBarColors(this, window, bottomNavColor)
|
ThemeHelper.setSystemBarColors(this, window, bottomNavColor)
|
||||||
|
|
||||||
// set default tab as start fragment
|
// set default tab as start fragment
|
||||||
@ -200,6 +196,17 @@ class MainActivity : BaseActivity() {
|
|||||||
loadIntentData()
|
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
|
* Deselect all bottom bar items
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +52,6 @@ import com.github.libretube.ui.sheets.SleepTimerSheet
|
|||||||
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
|
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
|
||||||
import com.github.libretube.util.DataSaverMode
|
import com.github.libretube.util.DataSaverMode
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
import com.google.android.material.elevation.SurfaceColors
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
@ -108,6 +107,10 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
(activity as? MainActivity)?.getBottomNavColor()?.let { color ->
|
||||||
|
binding.audioPlayerContainer.setBackgroundColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
initializeTransitionLayout()
|
initializeTransitionLayout()
|
||||||
|
|
||||||
// select the title TV in order for it to automatically scroll
|
// select the title TV in order for it to automatically scroll
|
||||||
@ -238,9 +241,6 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
||||||
mainMotionLayout.progress = 0F
|
mainMotionLayout.progress = 0F
|
||||||
|
|
||||||
val surfaceColor = SurfaceColors.getColorForElevation(requireContext(), 3f)
|
|
||||||
binding.audioPlayerContainer.setBackgroundColor(surfaceColor)
|
|
||||||
|
|
||||||
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
||||||
override fun onTransitionChange(
|
override fun onTransitionChange(
|
||||||
motionLayout: MotionLayout?,
|
motionLayout: MotionLayout?,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
android:id="@+id/audio_player_container"
|
android:id="@+id/audio_player_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?android:attr/colorBackground"
|
android:background="?attr/colorSurfaceContainer"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@ -265,19 +265,12 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
style="@style/Widget.Material3.CardView.Elevated"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
app:shapeAppearanceOverlay="@style/CardOnlyBottomCorners">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:padding="15dp">
|
android:paddingVertical="15dp"
|
||||||
|
android:paddingHorizontal="30dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -343,8 +336,6 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -189,14 +189,6 @@
|
|||||||
<item name="android:drawableTint" tools:targetApi="m">?android:attr/textColorPrimary</item>
|
<item name="android:drawableTint" tools:targetApi="m">?android:attr/textColorPrimary</item>
|
||||||
</style>
|
</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">
|
<style name="HomeCategoryTitle">
|
||||||
|
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user