diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 82ce65c28..8143f454f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -13,7 +13,7 @@ import android.graphics.Color import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter import android.graphics.Paint -import android.graphics.PorterDuff +import android.graphics.drawable.RippleDrawable import android.os.Build import android.os.Bundle import android.view.Gravity @@ -76,6 +76,7 @@ import eu.kanade.tachiyomi.util.system.hasDisplayCutout import eu.kanade.tachiyomi.util.system.isNightMode import eu.kanade.tachiyomi.util.system.logcat import eu.kanade.tachiyomi.util.system.toast +import eu.kanade.tachiyomi.util.view.copy import eu.kanade.tachiyomi.util.view.popupMenu import eu.kanade.tachiyomi.util.view.setTooltip import eu.kanade.tachiyomi.widget.listener.SimpleAnimationListener @@ -389,23 +390,32 @@ class ReaderActivity : BaseRxActivity() initBottomShortcuts() - val alpha = if (isNightMode()) 230 else 242 // 90% dark 95% light - val toolbarColor = ColorUtils.setAlphaComponent(getThemeColor(R.attr.colorToolbar), alpha) - listOf( - binding.toolbarBottom, - binding.leftChapter, - binding.readerSeekbar, - binding.rightChapter - ).forEach { - it.backgroundTintMode = PorterDuff.Mode.DST_IN - it.backgroundTintList = ColorStateList.valueOf(toolbarColor) + val toolbarBackground = (binding.toolbar.background as MaterialShapeDrawable).apply { + elevation = resources.getDimension(R.dimen.m3_sys_elevation_level2) + alpha = if (isNightMode()) 230 else 242 // 90% dark 95% light + } + binding.toolbarBottom.background = toolbarBackground.copy(this@ReaderActivity) + + binding.readerSeekbar.background = toolbarBackground.copy(this@ReaderActivity)?.apply { + setCornerSize(999F) + } + listOf(binding.leftChapter, binding.rightChapter).forEach { + it.background = binding.readerSeekbar.background.copy(this) + it.foreground = RippleDrawable( + ColorStateList.valueOf(getThemeColor(android.R.attr.colorControlHighlight)), + null, + it.background + ) } + val toolbarColor = ColorUtils.setAlphaComponent( + toolbarBackground.resolvedTintColor, + toolbarBackground.alpha + ) window.statusBarColor = toolbarColor if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { window.navigationBarColor = toolbarColor } - (binding.toolbar.background as MaterialShapeDrawable).fillColor = ColorStateList.valueOf(toolbarColor) // Set initial visibility setMenuVisibility(menuVisible) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index f7a43f5c8..947e5239f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -3,7 +3,9 @@ package eu.kanade.tachiyomi.util.view import android.annotation.SuppressLint +import android.content.Context import android.graphics.Point +import android.graphics.drawable.Drawable import android.text.TextUtils import android.view.Gravity import android.view.Menu @@ -25,6 +27,7 @@ import androidx.viewpager.widget.ViewPager import com.google.android.material.chip.Chip import com.google.android.material.chip.ChipGroup import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton +import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.snackbar.Snackbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.getResourceColor @@ -245,3 +248,14 @@ fun ViewPager.getActivePageView(): View? { false } } + +/** + * Returns a deep copy of the provided [Drawable] + */ +inline fun T.copy(context: Context): T? { + return (constantState?.newDrawable()?.mutate() as? T).apply { + if (this is MaterialShapeDrawable) { + initializeElevationOverlay(context) + } + } +} diff --git a/app/src/main/res/drawable/reader_seekbar_background.xml b/app/src/main/res/drawable/reader_seekbar_background.xml deleted file mode 100644 index ecb8171f0..000000000 --- a/app/src/main/res/drawable/reader_seekbar_background.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/reader_seekbar_button.xml b/app/src/main/res/drawable/reader_seekbar_button.xml deleted file mode 100644 index cbe9ef163..000000000 --- a/app/src/main/res/drawable/reader_seekbar_button.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/drawable/reader_seekbar_ripple.xml b/app/src/main/res/drawable/reader_seekbar_ripple.xml deleted file mode 100644 index 982f2361e..000000000 --- a/app/src/main/res/drawable/reader_seekbar_ripple.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index ad2b72c49..75e43fed9 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -78,7 +78,6 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_marginEnd="8dp" - android:background="@drawable/reader_seekbar_button" android:contentDescription="@string/action_previous_chapter" android:padding="@dimen/screen_edge_margin" app:srcCompat="@drawable/ic_skip_previous_24dp" @@ -89,7 +88,6 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@drawable/reader_seekbar_background" android:clickable="true" android:paddingStart="8dp" android:paddingEnd="8dp" @@ -132,7 +130,6 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_marginStart="8dp" - android:background="@drawable/reader_seekbar_button" android:contentDescription="@string/action_next_chapter" android:padding="@dimen/screen_edge_margin" app:srcCompat="@drawable/ic_skip_next_24dp" @@ -145,7 +142,6 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_gravity="bottom" - android:background="?attr/colorToolbar" android:clickable="true" tools:ignore="KeyboardInaccessibleWidget">