forked from mozilla-mobile/android-components
-
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.
Issue mozilla-mobile#10216: Refactor LoginPickerView to a more generi…
…c view SelectablePromptView
- Loading branch information
1 parent
1cf5f96
commit c5fda3b
Showing
9 changed files
with
109 additions
and
99 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
58 changes: 58 additions & 0 deletions
58
.../prompts/src/main/java/mozilla/components/feature/prompts/concept/SelectablePromptView.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,58 @@ | ||
/* 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.feature.prompts.concept | ||
|
||
import android.view.View | ||
|
||
/** | ||
* An interface for views that can display an option selection prompt. | ||
*/ | ||
interface SelectablePromptView<T> { | ||
|
||
var listener: Listener<T>? | ||
|
||
/** | ||
* Shows an option selection prompt with the provided options. | ||
* | ||
* @param options A list of options to display in the prompt. | ||
*/ | ||
fun showPrompt(options: List<T>) | ||
|
||
/** | ||
* Hides the option selection prompt. | ||
*/ | ||
fun hidePrompt() | ||
|
||
/** | ||
* Casts this [SelectablePromptView] interface to an Android [View] object. | ||
*/ | ||
fun asView(): View = (this as View) | ||
|
||
/** | ||
* Tries to inflate the view if needed. | ||
* | ||
* See: https://github.com/mozilla-mobile/android-components/issues/5491 | ||
* | ||
* @return true if the inflation was completed, false if the view was already inflated. | ||
*/ | ||
fun tryInflate(): Boolean | ||
|
||
/** | ||
* Interface to allow a class to listen to the option selection prompt events. | ||
*/ | ||
interface Listener<in T> { | ||
/** | ||
* Called when an user selects an options from the prompt. | ||
* | ||
* @param option The selected option. | ||
*/ | ||
fun onOptionSelect(option: T) | ||
|
||
/** | ||
* Called when the user invokes the option to manage the list of options. | ||
*/ | ||
fun onManageOptions() | ||
} | ||
} |
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
55 changes: 0 additions & 55 deletions
55
...feature/prompts/src/main/java/mozilla/components/feature/prompts/login/LoginPickerView.kt
This file was deleted.
Oops, something went wrong.
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.