mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/1879 - Create toolbar background drawable instead of view
This commit is contained in:
parent
d26c380c72
commit
9b0bca8a09
@ -17,7 +17,6 @@ import android.view.ViewGroup
|
|||||||
import android.view.accessibility.AccessibilityManager
|
import android.view.accessibility.AccessibilityManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
@ -123,12 +122,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
|||||||
)
|
)
|
||||||
|
|
||||||
toolbarComponent.uiView.view.apply {
|
toolbarComponent.uiView.view.apply {
|
||||||
setBackgroundColor(
|
setBackgroundResource(R.drawable.toolbar_background)
|
||||||
ContextCompat.getColor(
|
|
||||||
view.context,
|
|
||||||
DefaultThemeManager.resolveAttribute(R.attr.foundation, context)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(layoutParams as CoordinatorLayout.LayoutParams).apply {
|
(layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||||
gravity = getAppropriateLayoutGravity()
|
gravity = getAppropriateLayoutGravity()
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/* 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.browser
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [CoordinatorLayout.Behavior] that will always position the [View] above the [BrowserToolbar] (including
|
|
||||||
* when the browser toolbar is scrolling or performing a snap animation).
|
|
||||||
*/
|
|
||||||
@Suppress("unused") // Referenced from XML
|
|
||||||
class BrowserToolbarDividerBehavior(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet
|
|
||||||
) : CoordinatorLayout.Behavior<View>(context, attrs) {
|
|
||||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean {
|
|
||||||
if (dependency is BrowserToolbar) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.layoutDependsOn(parent, child, dependency)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: View, dependency: View): Boolean {
|
|
||||||
return if (dependency is BrowserToolbar) {
|
|
||||||
repositionView(child, dependency)
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun repositionView(view: View, toolbar: BrowserToolbar) {
|
|
||||||
view.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat()
|
|
||||||
}
|
|
||||||
}
|
|
23
app/src/main/res/drawable/toolbar_background.xml
Normal file
23
app/src/main/res/drawable/toolbar_background.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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/. -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="?foundation" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:gravity="top">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<size android:height="1dp" />
|
||||||
|
<solid android:color="?neutral" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:gravity="bottom">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<size android:height="1dp" />
|
||||||
|
<solid android:color="?neutral" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
@ -26,15 +26,6 @@
|
|||||||
app:behavior_peekHeight="12dp"
|
app:behavior_peekHeight="12dp"
|
||||||
app:layout_behavior="org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior"/>
|
app:layout_behavior="org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior"/>
|
||||||
|
|
||||||
<View
|
|
||||||
android:focusable="false"
|
|
||||||
android:id="@+id/toolbarDivider"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:background="?neutral"
|
|
||||||
app:layout_behavior="org.mozilla.fenix.browser.BrowserToolbarDividerBehavior" />
|
|
||||||
|
|
||||||
<mozilla.components.feature.findinpage.view.FindInPageBar
|
<mozilla.components.feature.findinpage.view.FindInPageBar
|
||||||
android:id="@+id/findInPageView"
|
android:id="@+id/findInPageView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user