From c49584d003d2620bc95b59ffbf96a607165672c2 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 3 May 2021 16:18:09 -0400 Subject: [PATCH] Fix background color of browse/recents' bottom sheet --- .../tachiyomi/ui/recents/RecentsController.kt | 22 +++++++++++++++++++ .../main/res/layout/download_bottom_sheet.xml | 2 +- .../res/layout/extensions_bottom_sheet.xml | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 6bf0d6ad39..972fada593 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.recents import android.Manifest.permission.WRITE_EXTERNAL_STORAGE import android.app.Activity +import android.content.res.ColorStateList import android.os.Bundle import android.view.LayoutInflater import android.view.Menu @@ -10,6 +11,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView +import androidx.core.graphics.ColorUtils import androidx.core.view.isVisible import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager @@ -40,7 +42,9 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.recents.options.TabbedRecentsOptionsSheet import eu.kanade.tachiyomi.ui.source.browse.ProgressItem import eu.kanade.tachiyomi.util.system.dpToPx +import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.spToPx +import eu.kanade.tachiyomi.util.system.toInt import eu.kanade.tachiyomi.util.view.activityBinding import eu.kanade.tachiyomi.util.view.expand import eu.kanade.tachiyomi.util.view.isCollapsed @@ -191,6 +195,15 @@ class RecentsController(bundle: Bundle? = null) : binding.shadow2.alpha = if (isCollapsed) 0.25f else 0f binding.shadow.alpha = if (isCollapsed) 0.5f else 0f binding.fakeAppBar.alpha = if (isExpanded) 1f else 0f + binding.downloadBottomSheet.dlRecycler.alpha = isExpanded.toInt().toFloat() + binding.downloadBottomSheet.sheetLayout.backgroundTintList = ColorStateList.valueOf( + ColorUtils.blendARGB( + view.context.getResourceColor(R.attr.colorPrimaryVariant), + view.context.getResourceColor(android.R.attr.colorBackground), + isExpanded.toInt().toFloat() + ) + ) + binding.downloadBottomSheet.root.backgroundTintList = binding.downloadBottomSheet.sheetLayout.backgroundTintList updateTitleAndMenu() } @@ -224,6 +237,15 @@ class RecentsController(bundle: Bundle? = null) : ).coerceIn(0f, 15f) binding.fakeAppBar.alpha = max(0f, (progress - cap) / (1f - cap)) binding.downloadBottomSheet.sheetLayout.alpha = 1 - max(0f, progress / cap) + binding.downloadBottomSheet.dlRecycler.alpha = progress * 10 + binding.downloadBottomSheet.sheetLayout.backgroundTintList = ColorStateList.valueOf( + ColorUtils.blendARGB( + view.context.getResourceColor(R.attr.colorPrimaryVariant), + view.context.getResourceColor(android.R.attr.colorBackground), + (progress * 2f).coerceIn(0f, 1f) + ) + ) + binding.downloadBottomSheet.root.backgroundTintList = binding.downloadBottomSheet.sheetLayout.backgroundTintList activityBinding?.appBar?.y = max( activityBinding!!.appBar.y, -headerHeight * (1 - progress) diff --git a/app/src/main/res/layout/download_bottom_sheet.xml b/app/src/main/res/layout/download_bottom_sheet.xml index ef719aba8c..b5b0996b84 100644 --- a/app/src/main/res/layout/download_bottom_sheet.xml +++ b/app/src/main/res/layout/download_bottom_sheet.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bottom_sheet_rounded_background" - android:backgroundTint="?android:attr/colorBackground" + android:backgroundTint="?colorPrimaryVariant" android:orientation="vertical" app:behavior_peekHeight="48sp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> diff --git a/app/src/main/res/layout/extensions_bottom_sheet.xml b/app/src/main/res/layout/extensions_bottom_sheet.xml index 570d2df3cb..3aac0ba676 100644 --- a/app/src/main/res/layout/extensions_bottom_sheet.xml +++ b/app/src/main/res/layout/extensions_bottom_sheet.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bottom_sheet_rounded_background" - android:backgroundTint="?android:attr/colorBackground" + android:backgroundTint="?attr/colorPrimaryVariant" android:orientation="vertical" app:behavior_peekHeight="60sp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">