forked from mozilla-mobile/focus-android
-
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.
Integrate browser-toolbar component.
- Loading branch information
1 parent
7910bdd
commit c20a52c
Showing
43 changed files
with
597 additions
and
1,359 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
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
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
39 changes: 39 additions & 0 deletions
39
app/src/main/java/org/mozilla/focus/browser/BrowserMenuControllerAdapter.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,39 @@ | ||
/* 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.focus.browser | ||
|
||
import android.view.View | ||
import android.widget.PopupWindow | ||
import mozilla.components.concept.menu.MenuController | ||
import mozilla.components.concept.menu.Orientation | ||
import mozilla.components.concept.menu.candidate.MenuCandidate | ||
import mozilla.components.support.base.observer.Observable | ||
import mozilla.components.support.base.observer.ObserverRegistry | ||
import org.mozilla.focus.ext.ifCustomTab | ||
import org.mozilla.focus.fragment.BrowserFragment | ||
import org.mozilla.focus.menu.browser.BrowserMenu | ||
|
||
/** | ||
* This adapter bridges between `browser-toolbar` and the custom, legacy [BrowserMenu] in Focus. | ||
* It allows launching [BrowserMenu] from `BrowserToolbar`. | ||
*/ | ||
class BrowserMenuControllerAdapter( | ||
private val fragment: BrowserFragment | ||
) : MenuController, Observable<MenuController.Observer> by ObserverRegistry() { | ||
override fun dismiss() { | ||
// Not used. | ||
} | ||
|
||
override fun show(anchor: View, orientation: Orientation?): PopupWindow { | ||
val menu = BrowserMenu(fragment.requireContext(), fragment, fragment.tab.ifCustomTab()?.config) | ||
menu.show(anchor) | ||
|
||
return menu | ||
} | ||
|
||
override fun submitList(list: List<MenuCandidate>) { | ||
// Not used. | ||
} | ||
} |
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.