forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mozilla-mobile#5694: Adds changing toolbar position functionality
- Loading branch information
Showing
18 changed files
with
189 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,7 @@ toolbar_settings: | |
bugs: | ||
- https://github.com/mozilla-mobile/fenix/issue/6054 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/fenix/pull/TODO | ||
- https://github.com/mozilla-mobile/fenix/pull/6571 | ||
notification_emails: | ||
- [email protected] | ||
expires: "2020-03-01" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/org/mozilla/fenix/components/toolbar/EngineViewTopBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.mozilla.fenix.components.toolbar | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.View | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
import mozilla.components.concept.engine.EngineView | ||
import mozilla.components.support.ktx.android.view.findViewInHierarchy | ||
|
||
/** | ||
* A [CoordinatorLayout.Behavior] implementation to be used with [EngineView] when placing a toolbar at the | ||
* bottom of the screen. | ||
* | ||
* Using this behavior requires the toolbar to use the BrowserToolbarTopBehavior. | ||
* | ||
* This implementation will update the vertical clipping of the [EngineView] so that top-aligned web content will | ||
* be drawn above the native toolbar. | ||
*/ | ||
class EngineViewTopBehavior( | ||
context: Context?, | ||
attrs: AttributeSet? | ||
) : CoordinatorLayout.Behavior<View>(context, attrs) { | ||
@SuppressLint("LogUsage") | ||
override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean { | ||
// This package does not have access to "BrowserToolbar" ... so we are just checking the class name here since | ||
// we actually do not need anything from that class - we only need to identify the instance. | ||
// Right now we do not have a component that has access to (concept/browser-toolbar and concept-engine). | ||
// Creating one just for this behavior is too excessive. | ||
if (dependency::class.java.simpleName == "BrowserToolbar") { | ||
return true | ||
} | ||
|
||
return super.layoutDependsOn(parent, child, dependency) | ||
} | ||
|
||
/** | ||
* Apply vertical clipping to [EngineView]. This requires [EngineViewTopehavior] to be set | ||
* in/on the [EngineView] or its parent. Must be a direct descending child of [CoordinatorLayout]. | ||
*/ | ||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: View, dependency: View): Boolean { | ||
val engineView = child.findViewInHierarchy { it is EngineView } as EngineView? | ||
engineView?.setVerticalClipping(dependency.height - dependency.translationY.toInt()) | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.