[fenix] For https://github.com/mozilla-mobile/fenix/issues/6940: Fixes top dynamic toolbar behavior (https://github.com/mozilla-mobile/fenix/pull/9900)
parent
d08756b53a
commit
c81052bd6d
@ -0,0 +1,48 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.components.toolbar
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
|
import mozilla.components.concept.engine.EngineView
|
||||||
|
import mozilla.components.concept.engine.EngineView.InputResult.INPUT_RESULT_UNHANDLED
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ScrollingViewBehavior that will setScrollFlags on BrowserToolbar based on EngineView touch handling
|
||||||
|
*/
|
||||||
|
class SwipeRefreshScrollingViewBehavior(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet?,
|
||||||
|
private val engineView: EngineView,
|
||||||
|
private val browserToolbarView: BrowserToolbarView
|
||||||
|
) : AppBarLayout.ScrollingViewBehavior(context, attrs) {
|
||||||
|
override fun onStartNestedScroll(
|
||||||
|
coordinatorLayout: CoordinatorLayout,
|
||||||
|
child: View,
|
||||||
|
directTargetChild: View,
|
||||||
|
target: View,
|
||||||
|
axes: Int,
|
||||||
|
type: Int
|
||||||
|
): Boolean {
|
||||||
|
|
||||||
|
if (!browserToolbarView.view.context.settings().shouldUseBottomToolbar) {
|
||||||
|
val shouldDisable = engineView.getInputResult() == INPUT_RESULT_UNHANDLED
|
||||||
|
browserToolbarView.setScrollFlags(shouldDisable)
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onStartNestedScroll(
|
||||||
|
coordinatorLayout,
|
||||||
|
child,
|
||||||
|
directTargetChild,
|
||||||
|
target,
|
||||||
|
axes,
|
||||||
|
type
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue