Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: make audio player align with status bar color #6170

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?,
Expand Down
113 changes: 52 additions & 61 deletions app/src/main/res/layout/fragment_audio_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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">
android:layout_gravity="start|center_vertical"
android:orientation="horizontal">

<LinearLayout
<ImageView
android:id="@+id/playback_options"
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_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: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: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/show_more"
android:id="@+id/open_chapters"
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_frame" />

</FrameLayout>
<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>

</com.google.android.material.card.MaterialCardView>
<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>

Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/values/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading