2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00
For https://github.com/mozilla-mobile/fenix/issues/15402: Hide ETP pop-up when top or bottom toolbar is not visible
This commit is contained in:
Sijan Rijal 2020-10-09 06:22:57 -07:00 committed by GitHub
parent 17fc28304a
commit 3aaded4868

View File

@ -15,6 +15,7 @@ import android.view.View
import android.widget.ImageView
import androidx.core.view.isVisible
import androidx.core.view.marginTop
import com.google.android.material.appbar.AppBarLayout
import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.*
import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.view.*
import mozilla.components.browser.session.Session
@ -49,8 +50,27 @@ class TrackingProtectionOverlay(
@Suppress("MagicNumber", "InflateParams")
private fun showTrackingProtectionOnboarding() {
if (!getToolbar().hasWindowFocus()) return
val toolbarPosition = settings.toolbarPosition
when (toolbarPosition) {
ToolbarPosition.BOTTOM -> {
if (getToolbar().translationY > 0) {
return
}
}
ToolbarPosition.TOP -> {
val appBarLayout = getToolbar().parent as? AppBarLayout
appBarLayout?.let { appBar ->
if (appBar.y != 0.toFloat()) {
return
}
}
}
}
val trackingOnboardingDialog = object : Dialog(context) {
override fun onTouchEvent(event: MotionEvent): Boolean {
@ -63,7 +83,6 @@ class TrackingProtectionOverlay(
val layout = LayoutInflater.from(context)
.inflate(R.layout.tracking_protection_onboarding_popup, null)
val toolbarPosition = settings.toolbarPosition
layout.drop_down_triangle.isVisible = toolbarPosition == ToolbarPosition.TOP
layout.pop_up_triangle.isVisible = toolbarPosition == ToolbarPosition.BOTTOM