Targeting SDK 34 (Android 14)

Its a much easier target than 13, first time ive gotten to change compile and target at the same time

Also updating a bunch of libraries while i'm at it

One of them is material and using it have back button progress on bottom sheet for now
This commit is contained in:
Jays2Kings 2023-08-02 20:27:41 -04:00
parent 211068d79a
commit 19db2ebee5
16 changed files with 242 additions and 79 deletions

View file

@ -127,18 +127,18 @@ android {
dependencies {
// Compose
implementation("androidx.activity:activity-compose:1.6.1")
implementation("androidx.compose.foundation:foundation:1.3.1")
implementation("androidx.compose.animation:animation:1.3.3")
implementation("androidx.compose.ui:ui:1.3.3")
implementation("androidx.compose.material:material:1.3.1")
implementation("androidx.compose.material3:material3:1.0.1")
implementation("androidx.activity:activity-compose:1.7.2")
implementation("androidx.compose.foundation:foundation:1.4.3")
implementation("androidx.compose.animation:animation:1.4.3")
implementation("androidx.compose.ui:ui:1.4.3")
implementation("androidx.compose.material:material:1.4.3")
implementation("androidx.compose.material3:material3:1.1.1")
implementation("com.google.android.material:compose-theme-adapter-3:1.1.1")
implementation("androidx.compose.material:material-icons-extended:1.3.1")
implementation("androidx.compose.ui:ui-tooling-preview:1.3.3")
debugImplementation("androidx.compose.ui:ui-tooling:1.3.3")
implementation("androidx.compose.material:material-icons-extended:1.4.3")
implementation("androidx.compose.ui:ui-tooling-preview:1.4.3")
debugImplementation("androidx.compose.ui:ui-tooling:1.4.3")
implementation("com.google.accompanist:accompanist-webview:0.28.0")
implementation("androidx.glance:glance-appwidget:1.0.0-alpha03")
implementation("androidx.glance:glance-appwidget:1.0.0-rc01")
// Modified dependencies
implementation("com.github.jays2kings:subsampling-scale-image-view:756849e") {
@ -149,18 +149,18 @@ dependencies {
// Android X libraries
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.cardview:cardview:1.0.0")
implementation("com.google.android.material:material:1.8.0")
implementation("androidx.webkit:webkit:1.6.1")
implementation("androidx.recyclerview:recyclerview:1.3.0")
implementation("androidx.preference:preference:1.2.0")
implementation("com.google.android.material:material:1.10.0-alpha05")
implementation("androidx.webkit:webkit:1.7.0")
implementation("androidx.recyclerview:recyclerview:1.3.1")
implementation("androidx.preference:preference:1.2.1")
implementation("androidx.annotation:annotation:1.6.0")
implementation("androidx.browser:browser:1.5.0")
implementation("androidx.biometric:biometric:1.1.0")
implementation("androidx.palette:palette:1.0.0")
implementation("androidx.activity:activity-ktx:1.7.0")
implementation("androidx.core:core-ktx:1.10.0")
implementation("androidx.activity:activity-ktx:1.8.0-alpha06")
implementation("androidx.core:core-ktx:1.10.1")
implementation("com.google.android.flexbox:flexbox:3.0.0")
implementation("androidx.window:window:1.0.0")
implementation("androidx.window:window:1.1.0")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

View file

@ -1,16 +1,18 @@
package eu.kanade.tachiyomi.appwidget
import android.app.Application
import android.content.Context
import android.graphics.Bitmap
import android.os.Build
import androidx.compose.runtime.Composable
import androidx.core.graphics.drawable.toBitmap
import androidx.glance.GlanceId
import androidx.glance.GlanceModifier
import androidx.glance.ImageProvider
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.GlanceAppWidgetManager
import androidx.glance.appwidget.SizeMode
import androidx.glance.appwidget.appWidgetBackground
import androidx.glance.appwidget.provideContent
import androidx.glance.appwidget.updateAll
import androidx.glance.background
import androidx.glance.layout.fillMaxSize
@ -47,15 +49,15 @@ class UpdatesGridGlanceWidget : GlanceAppWidget() {
private var data: List<Pair<Long, Bitmap?>>? = null
override val sizeMode = SizeMode.Exact
@Composable
override fun Content() {
// If app lock enabled, don't do anything
if (preferences.useBiometrics().get()) {
LockedWidget()
return
override suspend fun provideGlance(context: Context, id: GlanceId) {
provideContent {
// If app lock enabled, don't do anything
if (preferences.useBiometrics().get()) {
LockedWidget()
} else {
UpdatesWidget(data)
}
}
UpdatesWidget(data)
}
fun loadData(list: List<Pair<Manga, Long>>? = null) {

View file

@ -8,6 +8,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.activity.BackEventCompat
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.forEach
import androidx.core.view.isVisible
@ -94,6 +95,12 @@ abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
open fun canStillGoBack(): Boolean { return false }
open fun handleOnBackStarted(backEvent: BackEventCompat) {}
open fun handleOnBackProgressed(backEvent: BackEventCompat) {}
open fun handleOnBackCancelled() {}
open val mainRecycler: RecyclerView?
get() = null

View file

@ -371,16 +371,21 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
updateExtUpdateAllButton()
}
fun canStillGoBack(): Boolean {
return (binding.tabs.selectedTabPosition == 1 && migAdapter is MangaAdapter) ||
(binding.tabs.selectedTabPosition == 0 && binding.sheetToolbar.hasExpandedActionView())
}
fun canGoBack(): Boolean {
if (binding.tabs.selectedTabPosition == 1 && migAdapter is MangaAdapter) {
return if (binding.tabs.selectedTabPosition == 1 && migAdapter is MangaAdapter) {
presenter.deselectSource()
return false
}
if (binding.sheetToolbar.hasExpandedActionView()) {
false
} else if (binding.sheetToolbar.hasExpandedActionView()) {
binding.sheetToolbar.collapseActionView()
return false
false
} else {
true
}
return true
}
fun downloadUpdate(item: ExtensionItem) {

View file

@ -14,9 +14,13 @@ class LibraryCategoryGestureDetector(private val controller: LibraryController?)
var locked = false
var cancelled = false
private val poa = 1.7f
private var startingX = 0f
private var startingY = 0f
override fun onDown(e: MotionEvent): Boolean {
locked = false
startingX = e.x
startingY = e.y
controller ?: return false
val startingOnLibraryView = listOf(
controller.activityBinding?.bottomNav,
@ -35,14 +39,14 @@ class LibraryCategoryGestureDetector(private val controller: LibraryController?)
}
override fun onScroll(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
distanceX: Float,
distanceY: Float,
): Boolean {
val controller = controller ?: return false
val distance = e1.rawX - e2.rawX
val totalDistanceY = e1.rawY - e2.rawY
val distance = startingX - e2.x
val totalDistanceY = startingY - e2.y
controller.binding.libraryGridRecycler.recycler.translationX =
if (!cancelled) abs(distance / 50).pow(poa) * -sign(distance / 50) else 0f
if (!locked && abs(distance) > 50 && !cancelled) {
@ -59,7 +63,7 @@ class LibraryCategoryGestureDetector(private val controller: LibraryController?)
}
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,
@ -72,8 +76,8 @@ class LibraryCategoryGestureDetector(private val controller: LibraryController?)
cancelled = false
val controller = controller ?: return false
var result = false
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
val diffY = e2.y - startingY
val diffX = e2.x - startingX
val recycler = controller.binding.libraryGridRecycler.recycler
var moved = false
if (abs(diffX) >= abs(diffY) &&

View file

@ -13,17 +13,22 @@ import kotlin.math.sign
class LibraryGestureDetector(private val controller: LibraryController) : GestureDetector
.SimpleOnGestureListener() {
private var startingX = 0f
private var startingY = 0f
override fun onDown(e: MotionEvent): Boolean {
startingX = e.x
startingY = e.y
return false
}
override fun onScroll(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
distanceX: Float,
distanceY: Float,
): Boolean {
val distance = (e1.rawX - e2.rawX) / 50
val distance = (startingX - e2.x) / 50
val poa = 1.7f
controller.binding.categoryHopperFrame.translationX = abs(distance).pow(poa) * -sign(distance)
return super.onScroll(e1, e2, distanceX, distanceY)
@ -31,14 +36,14 @@ class LibraryGestureDetector(private val controller: LibraryController) : Gestur
@SuppressLint("RtlHardcoded")
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,
): Boolean {
var result = false
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
val diffY = e2.y - startingY
val diffX = e2.x - startingX
val hopperFrame = controller.binding.categoryHopperFrame
val animator = controller.binding.categoryHopperFrame.animate().setDuration(150L)
animator.translationX(0f)

View file

@ -17,20 +17,24 @@ class LibraryHeaderGestureDetector(
private val binding: LibraryCategoryHeaderItemBinding?,
) : GestureDetector.SimpleOnGestureListener() {
private var startingX = 0f
private var startingY = 0f
var vibrated = false
override fun onDown(e: MotionEvent): Boolean {
vibrated = false
startingX = e.x
startingY = e.y
return super.onDown(e)
}
override fun onScroll(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
distanceX: Float,
distanceY: Float,
): Boolean {
if (binding == null || header == null) return false
val distance = (e1.rawX - e2.rawX)
val distance = (startingX - e2.x)
val poa = 0.75f
binding.categoryHeaderLayout.translationX = abs(distance).pow(poa) * -sign(distance)
binding.rearView.isVisible = distance != 0f
@ -58,14 +62,14 @@ class LibraryHeaderGestureDetector(
}
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,
): Boolean {
var result = false
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
val diffY = e2.y - startingY
val diffX = e2.x - startingX
val mainLayout = binding?.categoryHeaderLayout ?: return false
val animator = binding.categoryHeaderLayout.animate().setDuration(200L)
header?.itemView?.parent?.requestDisallowInterceptTouchEvent(false)

View file

@ -25,6 +25,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import androidx.activity.BackEventCompat
import androidx.activity.OnBackPressedCallback
import androidx.activity.addCallback
import androidx.activity.result.contract.ActivityResultContracts
@ -249,8 +250,27 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
window.sharedElementsUseOverlay = false
super.onCreate(savedInstanceState)
backPressedCallback = onBackPressedDispatcher.addCallback { backCallback() }
backPressedCallback = object : OnBackPressedCallback(enabled = true) {
override fun handleOnBackPressed() {
backCallback()
}
override fun handleOnBackStarted(backEvent: BackEventCompat) {
val controller = router.backstack.lastOrNull()?.controller as? BaseController<*>
controller?.handleOnBackStarted(backEvent)
}
override fun handleOnBackProgressed(backEvent: BackEventCompat) {
val controller = router.backstack.lastOrNull()?.controller as? BaseController<*>
controller?.handleOnBackProgressed(backEvent)
}
override fun handleOnBackCancelled() {
val controller = router.backstack.lastOrNull()?.controller as? BaseController<*>
controller?.handleOnBackCancelled()
}
}
onBackPressedDispatcher.addCallback(backPressedCallback!!)
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
if (!isTaskRoot && this !is SearchActivity) {
finish()
@ -1378,23 +1398,27 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
)
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
private var startingX = 0f
private var startingY = 0f
override fun onDown(e: MotionEvent): Boolean {
startingX = e.x
startingY = e.y
return true
}
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,
): Boolean {
var result = false
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
val diffY = e2.y - startingY
val diffX = e2.x - startingX
if (abs(diffX) <= abs(diffY)) {
val sheetRect = Rect()
nav.getGlobalVisibleRect(sheetRect)
if (sheetRect.contains(e1.x.toInt(), e1.y.toInt()) &&
if (sheetRect.contains(startingX.toInt(), startingY.toInt()) &&
abs(diffY) > Companion.SWIPE_THRESHOLD &&
abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD &&
diffY <= 0
@ -1403,7 +1427,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
router.backstack.lastOrNull()?.controller as? BottomSheetController
bottomSheetController?.showSheet()
} else if (nav == binding.sideNav &&
sheetRect.contains(e1.x.toInt(), e1.y.toInt()) &&
sheetRect.contains(startingX.toInt(), startingY.toInt()) &&
abs(diffY) > Companion.SWIPE_THRESHOLD &&
abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD &&
diffY > 0

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader
import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityOptions
import android.app.assist.AssistContent
import android.content.ClipData
import android.content.Context
@ -38,7 +39,6 @@ import androidx.activity.OnBackPressedCallback
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.text.buildSpannedString
@ -260,7 +260,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
MainActivity.chapterIdToExitTo = 0L
val intent = newIntent(activity, manga, chapter)
intent.putExtra(TRANSITION_NAME, sharedElement.transitionName)
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
sharedElement,
sharedElement.transitionName,
@ -933,7 +933,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
firstPass = false
lastVis = vis
}
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
if (!fullscreen && sheetManageNavColor) {
window.navigationBarColor = getResourceColor(R.attr.colorSurface)
}
@ -1132,7 +1132,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
} else {
if (preferences.fullscreen().get()) {
wic.hide(systemBars())
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
}
if (animate && binding.appBar.isVisible) {
@ -1929,7 +1929,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
*/
private fun setFullscreen(enabled: Boolean) {
WindowCompat.setDecorFitsSystemWindows(window, !enabled || isSplitScreen)
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
wic.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
binding.root.rootWindowInsetsCompat?.let { setNavColor(it) }
}

View file

@ -11,21 +11,25 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
var hasScrollHorizontal = false
var lockVertical = false
private var startingX = 0f
private var startingY = 0f
override fun onDown(e: MotionEvent): Boolean {
lockVertical = false
hasScrollHorizontal = false
startingX = e.x
startingY = e.y
return false
}
override fun onScroll(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
distanceX: Float,
distanceY: Float,
): Boolean {
val newDistanceX = e1.rawX - e2.rawX
val newDistanceY = e1.rawY - e2.rawY
val newDistanceX = startingX - e2.x
val newDistanceY = startingY - e2.y
if ((!hasScrollHorizontal || lockVertical)) {
hasScrollHorizontal = abs(newDistanceX) > abs(newDistanceY) && abs(newDistanceX) > 40
if (!lockVertical) {
@ -36,14 +40,14 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
}
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,
): Boolean {
var result = false
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
val diffY = e2.y - startingY
val diffX = e2.x - startingX
val sheetBehavior = activity.binding.chaptersSheet.root.sheetBehavior
if (!hasScrollHorizontal && abs(diffX) < abs(diffY) &&
(abs(diffY) > SWIPE_THRESHOLD || abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) &&

View file

@ -68,27 +68,27 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
strokeWidth = 8f
}
override fun onDraw(canvas: Canvas?) {
override fun onDraw(canvas: Canvas) {
if (navigation == null) return
navigation?.regions?.forEach {
val region = it.invert(navigation!!.invertMode)
val rect = region.rectF
canvas?.save()
canvas.save()
// Scale rect from 1f,1f to screen width and height
canvas?.scale(width.toFloat(), height.toFloat())
canvas.scale(width.toFloat(), height.toFloat())
val directionalRegion = region.type.directionalRegion(isLTR)
regionPaint.color = ContextCompat.getColor(context, directionalRegion.colorRes)
canvas?.drawRect(rect, regionPaint)
canvas.drawRect(rect, regionPaint)
canvas?.restore()
canvas.restore()
// Don't want scale anymore because it messes with drawText
canvas?.save()
canvas.save()
// Translate origin to rect start (left, top)
canvas?.translate((width * rect.left), (height * rect.top))
canvas.translate((width * rect.left), (height * rect.top))
// Calculate center of rect width on screen
val x = width * (abs(rect.left - rect.right) / 2)
@ -96,10 +96,10 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
// Calculate center of rect height on screen
val y = height * (abs(rect.top - rect.bottom) / 2)
canvas?.drawText(context.getString(directionalRegion.nameRes), x, y, textBorderPaint)
canvas?.drawText(context.getString(directionalRegion.nameRes), x, y, textPaint)
canvas.drawText(context.getString(directionalRegion.nameRes), x, y, textBorderPaint)
canvas.drawText(context.getString(directionalRegion.nameRes), x, y, textPaint)
canvas?.restore()
canvas.restore()
}
}

View file

@ -74,7 +74,7 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
}
override fun onFling(
e1: MotionEvent,
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float,

View file

@ -11,6 +11,7 @@ import android.view.MenuItem
import android.view.RoundedCorner
import android.view.View
import android.view.ViewGroup
import androidx.activity.BackEventCompat
import androidx.core.view.WindowInsetsCompat.Type.systemBars
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
@ -120,6 +121,7 @@ class RecentsController(bundle: Bundle? = null) :
private var headerHeight = 0
private var ogRadius = 0f
private var deviceRadius = 0f to 0f
private var lastScale = 1f
private var query = ""
set(value) {
@ -278,6 +280,17 @@ class RecentsController(bundle: Bundle? = null) :
if (!isControllerVisible) {
return
}
binding.downloadBottomSheet.root.apply {
if (lastScale != 1f && scaleY != 1f) {
val scaleProgress = ((1f - progress) * (1f - lastScale)) + lastScale
scaleX = scaleProgress
scaleY = scaleProgress
for (i in 0 until childCount) {
val childView = getChildAt(i)
childView.scaleY = scaleProgress
}
}
}
if (isControllerVisible) {
activityBinding?.appBar?.alpha = (1 - progress * 3) + 0.5f
}
@ -304,6 +317,25 @@ class RecentsController(bundle: Bundle? = null) :
activityBinding?.tabsFrameLayout?.isVisible =
state != BottomSheetBehavior.STATE_EXPANDED
}
binding.downloadBottomSheet.dlBottomSheet.apply {
if ((
state == BottomSheetBehavior.STATE_COLLAPSED ||
state == BottomSheetBehavior.STATE_EXPANDED ||
state == BottomSheetBehavior.STATE_HIDDEN
) &&
scaleY != 1f
) {
scaleX = 1f
scaleY = 1f
pivotY = 0f
translationX = 0f
for (i in 0 until childCount) {
val childView = getChildAt(i)
childView.scaleY = 1f
}
}
}
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
if (hasQueue()) {
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable =
@ -454,6 +486,24 @@ class RecentsController(bundle: Bundle? = null) :
presenter.preferences.recentsViewType().get() != presenter.viewType.mainValue
}
override fun handleOnBackStarted(backEvent: BackEventCompat) {
if (showingDownloads) {
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.startBackProgress(backEvent)
}
}
override fun handleOnBackProgressed(backEvent: BackEventCompat) {
if (showingDownloads) {
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.updateBackProgress(backEvent)
}
}
override fun handleOnBackCancelled() {
if (showingDownloads) {
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.cancelBackProgress()
}
}
override fun handleBack(): Boolean {
if (showingDownloads) {
binding.downloadBottomSheet.dlBottomSheet.dismiss()

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.security
import android.app.Activity
import android.content.Intent
import android.os.Build
import android.view.Window
import android.view.WindowManager
import androidx.biometric.BiometricManager
@ -44,7 +45,11 @@ object SecureActivityDelegate {
val intent = Intent(activity, BiometricActivity::class.java)
intent.putExtra("fromSearch", (activity is SearchActivity) && !requireSuccess)
activity.startActivity(intent)
activity.overridePendingTransition(0, 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
activity.overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN, 0, 0)
} else {
activity.overridePendingTransition(0, 0)
}
}
} else if (lockApp) {
preferences.useBiometrics().set(false)

View file

@ -10,6 +10,7 @@ import android.view.MenuItem
import android.view.RoundedCorner
import android.view.View
import android.view.ViewGroup
import androidx.activity.BackEventCompat
import androidx.appcompat.widget.SearchView
import androidx.core.graphics.ColorUtils
import androidx.core.view.doOnNextLayout
@ -104,6 +105,7 @@ class BrowseController :
private var ogRadius = 0f
private var deviceRadius = 0f to 0f
private var lastScale = 1f
override val mainRecycler: RecyclerView
get() = binding.sourceRecycler
@ -184,6 +186,17 @@ class BrowseController :
updateTitleAndMenu()
(activity as? MainActivity)?.reEnableBackPressedCallBack()
}
binding.bottomSheet.root.apply {
if (lastScale != 1f && scaleY != 1f) {
val scaleProgress = ((1f - progress) * (1f - lastScale)) + lastScale
scaleX = scaleProgress
scaleY = scaleProgress
for (i in 0 until childCount) {
val childView = getChildAt(i)
childView.scaleY = scaleProgress
}
}
}
binding.bottomSheet.sheetToolbar.isVisible = true
setBottomSheetTabs(max(0f, progress))
}
@ -195,6 +208,27 @@ class BrowseController :
binding.bottomSheet.root.updatedNestedRecyclers()
binding.bottomSheet.root.isExpanding = false
}
binding.bottomSheet.root.apply {
if ((
state == BottomSheetBehavior.STATE_COLLAPSED ||
state == BottomSheetBehavior.STATE_EXPANDED ||
state == BottomSheetBehavior.STATE_HIDDEN
) &&
scaleY != 1f
) {
scaleX = 1f
scaleY = 1f
pivotY = 0f
translationX = 0f
for (i in 0 until childCount) {
val childView = getChildAt(i)
childView.scaleY = 1f
}
lastScale = 1f
}
}
val extBottomSheet = binding.bottomSheet.root
if (state == BottomSheetBehavior.STATE_EXPANDED ||
state == BottomSheetBehavior.STATE_COLLAPSED
@ -440,9 +474,28 @@ class BrowseController :
override fun canStillGoBack(): Boolean = showingExtensions
override fun handleOnBackStarted(backEvent: BackEventCompat) {
if (showingExtensions && !binding.bottomSheet.root.canStillGoBack()) {
binding.bottomSheet.root.sheetBehavior?.startBackProgress(backEvent)
}
}
override fun handleOnBackProgressed(backEvent: BackEventCompat) {
if (showingExtensions && !binding.bottomSheet.root.canStillGoBack()) {
binding.bottomSheet.root.sheetBehavior?.updateBackProgress(backEvent)
}
}
override fun handleOnBackCancelled() {
if (showingExtensions && !binding.bottomSheet.root.canStillGoBack()) {
binding.bottomSheet.root.sheetBehavior?.cancelBackProgress()
}
}
override fun handleBack(): Boolean {
if (showingExtensions) {
if (binding.bottomSheet.root.canGoBack()) {
lastScale = binding.bottomSheet.root.scaleX
binding.bottomSheet.root.sheetBehavior?.collapse()
}
return true