Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
663d4a8d
Commit
663d4a8d
authored
Jun 10, 2020
by
Sawyer Blatz
Browse files
For #7301: Fix drawable ripple issues on BrowserToolbar
Co-authored-by:
pocmo
<
skaspari@mozilla.com
>
parent
bc6c6a74
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbarView.kt
0 → 100644
View file @
663d4a8d
/* 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
mozilla.components.browser.toolbar.display
import
android.content.Context
import
android.graphics.Canvas
import
android.util.AttributeSet
import
android.view.View
import
android.widget.ImageView
import
androidx.constraintlayout.widget.ConstraintLayout
import
mozilla.components.browser.toolbar.R
/**
* Custom ConstraintLayout for DisplayToolbar that allows us to draw ripple backgrounds on the toolbar
* by setting a background to transparent.
*/
class
DisplayToolbarView
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
defStyleAttr
:
Int
=
0
)
:
ConstraintLayout
(
context
,
attrs
,
defStyleAttr
)
{
init
{
// Forcing transparent background so that draw methods will get called and ripple effect
// for children will be drawn on this layout.
setBackgroundColor
(
0x00000000
)
}
lateinit
var
backgroundView
:
ImageView
override
fun
onFinishInflate
()
{
backgroundView
=
findViewById
(
R
.
id
.
mozac_browser_toolbar_background
)
backgroundView
.
visibility
=
View
.
INVISIBLE
super
.
onFinishInflate
()
}
// Overriding draw instead of onDraw since we want to draw the background before the actual
// (transparent) background (with a ripple effect) is drawn.
override
fun
draw
(
canvas
:
Canvas
)
{
canvas
.
save
()
canvas
.
translate
(
backgroundView
.
x
,
backgroundView
.
y
)
backgroundView
.
drawable
?.
draw
(
canvas
)
canvas
.
restore
()
super
.
draw
(
canvas
)
}
}
components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_displaytoolbar.xml
View file @
663d4a8d
...
...
@@ -2,7 +2,7 @@
<!-- 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/. -->
<
androidx.constraintlayout.widget.ConstraintLayout
<
mozilla.components.browser.toolbar.display.DisplayToolbarView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:mozac=
"http://schemas.android.com/apk/res-auto"
...
...
@@ -144,4 +144,4 @@
app:layout_constraintStart_toStartOf=
"parent"
style=
"?android:attr/progressBarStyleHorizontal"
/>
</
androidx.constraintlayout.widget.ConstraintLayout
>
</
mozilla.components.browser.toolbar.display.DisplayToolbarView
>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment