Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
df131d2e
Commit
df131d2e
authored
Jul 08, 2020
by
Sawyer Blatz
Browse files
For #7563: Allow GeckoActions to be sorted
parent
f70216b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
components/browser/engine-gecko-beta/src/test/java/mozilla/components/browser/engine/gecko/selection/GeckoSelectionActionDelegateTest.kt
View file @
df131d2e
...
...
@@ -42,6 +42,9 @@ class GeckoSelectionActionDelegateTest {
override
fun
isActionAvailable
(
id
:
String
):
Boolean
=
false
override
fun
getActionTitle
(
id
:
String
):
CharSequence
?
=
""
override
fun
performAction
(
id
:
String
,
selectedText
:
String
):
Boolean
=
false
override
fun
sortedActions
(
actions
:
Array
<
String
>):
Array
<
String
>
{
return
actions
}
}
val
geckoDelegate
=
TestGeckoSelectionActionDelegate
(
mock
(),
customDelegate
)
...
...
components/browser/engine-gecko-nightly/src/test/java/mozilla/components/browser/engine/gecko/selection/GeckoSelectionActionDelegateTest.kt
View file @
df131d2e
...
...
@@ -42,6 +42,9 @@ class GeckoSelectionActionDelegateTest {
override
fun
isActionAvailable
(
id
:
String
):
Boolean
=
false
override
fun
getActionTitle
(
id
:
String
):
CharSequence
?
=
""
override
fun
performAction
(
id
:
String
,
selectedText
:
String
):
Boolean
=
false
override
fun
sortedActions
(
actions
:
Array
<
String
>):
Array
<
String
>
{
return
actions
}
}
val
geckoDelegate
=
TestGeckoSelectionActionDelegate
(
mock
(),
customDelegate
)
...
...
components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/selection/GeckoSelectionActionDelegate.kt
View file @
df131d2e
...
...
@@ -37,7 +37,7 @@ open class GeckoSelectionActionDelegate(
}
override
fun
getAllActions
():
Array
<
String
>
{
return
super
.
getAllActions
()
+
customDelegate
.
getAllActions
()
return
customDelegate
.
sortedActions
(
super
.
getAllActions
()
+
customDelegate
.
getAllActions
()
)
}
override
fun
isActionAvailable
(
id
:
String
):
Boolean
{
...
...
components/browser/engine-gecko/src/test/java/mozilla/components/browser/engine/gecko/selection/GeckoSelectionActionDelegateTest.kt
View file @
df131d2e
...
...
@@ -42,6 +42,9 @@ class GeckoSelectionActionDelegateTest {
override
fun
isActionAvailable
(
id
:
String
):
Boolean
=
false
override
fun
getActionTitle
(
id
:
String
):
CharSequence
?
=
""
override
fun
performAction
(
id
:
String
,
selectedText
:
String
):
Boolean
=
false
override
fun
sortedActions
(
actions
:
Array
<
String
>):
Array
<
String
>
{
return
actions
}
}
val
geckoDelegate
=
TestGeckoSelectionActionDelegate
(
mock
(),
customDelegate
)
...
...
components/concept/engine/src/main/java/mozilla/components/concept/engine/selection/SelectionActionDelegate.kt
View file @
df131d2e
...
...
@@ -36,4 +36,11 @@ interface SelectionActionDelegate {
* @returns [true] if the action was consumed.
*/
fun
performAction
(
id
:
String
,
selectedText
:
String
):
Boolean
/**
* Takes in a list of actions and sorts them.
*
* @returns the sorted list.
*/
fun
sortedActions
(
actions
:
Array
<
String
>):
Array
<
String
>
}
components/feature/contextmenu/src/main/java/mozilla/components/feature/contextmenu/DefaultSelectionActionDelegate.kt
View file @
df131d2e
...
...
@@ -24,7 +24,8 @@ private val customActions = arrayOf(SEARCH, SEARCH_PRIVATELY, SHARE)
class
DefaultSelectionActionDelegate
(
private
val
searchAdapter
:
SearchAdapter
,
resources
:
Resources
,
private
val
shareTextClicked
:
((
String
)
->
Unit
)?
=
null
private
val
shareTextClicked
:
((
String
)
->
Unit
)?
=
null
,
private
val
actionSorter
:
((
Array
<
String
>)
->
Array
<
String
>)?
=
null
)
:
SelectionActionDelegate
{
private
val
normalSearchText
=
...
...
@@ -64,4 +65,16 @@ class DefaultSelectionActionDelegate(
}
else
->
false
}
/**
* Takes in a list of actions and sorts them.
* @returns the sorted list.
*/
override
fun
sortedActions
(
actions
:
Array
<
String
>):
Array
<
String
>
{
return
if
(
actionSorter
!=
null
)
{
actionSorter
.
invoke
(
actions
)
}
else
{
actions
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment