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#26957 - Exit search dialog when interacting with h…
…ome fragment (mozilla-mobile#27262) * Revert "For mozilla-mobile#26790 - Dismiss search dialog when opening recent bookmark dropdown menu" This reverts commit 262aa16. * Revert "For mozilla-mobile#26790 - Dismiss search dialog when opening recent visit dropdown menu" This reverts commit b93b085 * Revert "For mozilla-mobile#26790 - Dismiss search dialog when opening recent tab dropdown menu" This reverts commit 44b71bb. * Revert "For mozilla-mobile#26690 - Dismiss search dialog when opening recent synced tab dropdown menu" This reverts commit bda817a. * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with homescreen top sites * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with homescreen collection * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with homescreen recent visits * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with homescreen recent tabs * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with homescreen recent bookmarks * For mozilla-mobile#26957 - Remove code to dismiss search dialog when interacting with pocket stories * For mozilla-mobile#26957 - Dismiss search dialog when interacting with home fragment Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
df4e08f
commit 4ee62dd
Showing
39 changed files
with
87 additions
and
483 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
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
57 changes: 57 additions & 0 deletions
57
app/src/main/java/org/mozilla/fenix/home/HomeFragmentLayout.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,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) | ||
} | ||
} |
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
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.