[fenix] For https://github.com/mozilla-mobile/fenix/issues/26957 - Exit search dialog when interacting with home fragment (https://github.com/mozilla-mobile/fenix/pull/27262)
* Revert "For https://github.com/mozilla-mobile/fenix/issues/26790 - Dismiss search dialog when opening recent bookmark dropdown menu" This reverts commit 5caee27b5530517d88e8a3212a3318f1ed75fba7. * Revert "For https://github.com/mozilla-mobile/fenix/issues/26790 - Dismiss search dialog when opening recent visit dropdown menu" This reverts commit b2af04c9 * Revert "For https://github.com/mozilla-mobile/fenix/issues/26790 - Dismiss search dialog when opening recent tab dropdown menu" This reverts commit bfdf6d202133e31930c1eeb24ff60b7035479653. * Revert "For https://github.com/mozilla-mobile/fenix/issues/26690 - Dismiss search dialog when opening recent synced tab dropdown menu" This reverts commit 86d44a46122eafb8bfb7df9cb2f182337cc47aa4. * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with homescreen top sites * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with homescreen collection * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with homescreen recent visits * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with homescreen recent tabs * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with homescreen recent bookmarks * For https://github.com/mozilla-mobile/fenix/issues/26957 - Remove code to dismiss search dialog when interacting with pocket stories * For https://github.com/mozilla-mobile/fenix/issues/26957 - Dismiss search dialog when interacting with home fragment Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>pull/600/head
parent
6e5e551fe3
commit
d05393714a
@ -0,0 +1,57 @@
|
||||
/* 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.home
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.MotionEvent.ACTION_UP
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.navigation.findNavController
|
||||
import mozilla.components.support.ktx.android.view.findViewInHierarchy
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.search.SearchDialogFragment
|
||||
|
||||
/**
|
||||
* Parent layout for [HomeFragment], used to dismiss the [SearchDialogFragment] when
|
||||
* interacting with elements in the [HomeFragment].
|
||||
*/
|
||||
class HomeFragmentLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
) : CoordinatorLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
/**
|
||||
* Returns whether or not the motion event is touching the private browsing button.
|
||||
*
|
||||
* @param x X coordinate of the event.
|
||||
* @param y Y coordinate of the event.
|
||||
*/
|
||||
private fun isTouchingPrivateButton(x: Float, y: Float): Boolean {
|
||||
val view = this.findViewInHierarchy {
|
||||
it.id == R.id.privateBrowsingButton
|
||||
} ?: return false
|
||||
val privateButtonRect = Rect()
|
||||
view.getHitRect(privateButtonRect)
|
||||
return privateButtonRect.contains(x.toInt(), y.toInt())
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
||||
val nav = findNavController()
|
||||
|
||||
// If the private button is touched from the [SearchDialogFragment], then it should not be
|
||||
// dismissed to allow the user to continue the search.
|
||||
if (ev?.action == ACTION_UP &&
|
||||
nav.currentDestination?.id == R.id.searchDialogFragment &&
|
||||
!isTouchingPrivateButton(ev.x, ev.y)
|
||||
) {
|
||||
nav.popBackStack()
|
||||
}
|
||||
|
||||
return super.onInterceptTouchEvent(ev)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<baseline version="1.0">
|
||||
<file name="app/src/main/java/org/mozilla/fenix/home/topsites/TopSiteItemViewHolder.kt">
|
||||
<error line="66" column="35" source="annotation" />
|
||||
<error line="65" column="35" source="annotation" />
|
||||
</file>
|
||||
</baseline>
|
||||
|
Loading…
Reference in New Issue