-
Notifications
You must be signed in to change notification settings - Fork 473
For #12565 Implement the common part of search widget in Android Components #12584
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick driveby, this is looking great!
...ts/feature/searchwidget/src/main/java/mozilla/components/feature/searchwidget/IntentUtils.kt
Outdated
Show resolved
Hide resolved
components/feature/searchwidget/src/main/res/xml/mozac_search_widget_info.xml
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,83 @@ | |||
<?xml version="1.0" encoding="utf-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A-C should be "client agnostic" and not include the launcher icon of Fenix.
If this resource is really needed maybe we can set the source to be mozac_ic_globe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added mozac_search_widget_icon that is an empty file . This file will be overridden in Focus and Fenix with the specific app icon .
a9027c9
to
c37f416
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really nice! Left a few comments below too.
...earchwidget/src/main/java/mozilla/components/feature/searchwidget/AppSearchWidgetProvider.kt
Outdated
Show resolved
Hide resolved
components/feature/searchwidget/src/main/res/values/strings.xml
Outdated
Show resolved
Hide resolved
package="mozilla.components.feature.search"> | ||
|
||
<uses-permission | ||
android:name="android.permission.QUERY_ALL_PACKAGES" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I missed this earlier - why do we need the permission to query all packages (apps) installed on the user's phone? This permission is very powerful and requires us to provide a reason on how we use it when submitting an app to the Play store.
The warning QueryAllPackagesPermission
below is meant to make us aware of what we are requesting, so if we do need this permission here, we should at the very least leave a comment on how it's used. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for intentSpeech.resolveActivity from
val intentSpeech = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
return intentSpeech.resolveActivity(context.packageManager)?.let {
PendingIntent.getActivity(
context,
REQUEST_CODE_VOICE, voiceIntent, PendingIntentUtils.defaultFlags
)
}
I can do this in manifest like in Focus and Fenix ,it's the same code or I can add this @SuppressLint("QueryPermissionsNeeded") to the method .
@jonalmeida
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iorgamgabriel it's not clear to me from the docs why the component or the apps need to have this permission. Could you share a link to where this requirement is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done I rewrote this code without resolveActivity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed for
val intentSpeech = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intentSpeech.resolveActivity(context.packageManager)
to check if the phone has voice recognition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left an offline comment to this discuss this since the permission was removed from the change and no longer a concern for this PR.
...ure/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt
Show resolved
Hide resolved
...ure/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt
Outdated
Show resolved
Hide resolved
No RelEng items, removing review request |
...ure/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt
Outdated
Show resolved
Hide resolved
...feature/search/src/main/java/mozilla/components/feature/search/widget/VoiceSearchActivity.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Seeing all previous comments were addressed I'll also give this a r+ but we should check with Jonathan for any other updates to be made before merging.
...ure/search/src/main/java/mozilla/components/feature/search/widget/BaseVoiceSearchActivity.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/mozilla/components/feature/search/widget/BaseVoiceSearchActivity.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/mozilla/components/feature/search/widget/AppSearchWidgetProvider.kt
Outdated
Show resolved
Hide resolved
package="mozilla.components.feature.search"> | ||
|
||
<uses-permission | ||
android:name="android.permission.QUERY_ALL_PACKAGES" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iorgamgabriel it's not clear to me from the docs why the component or the apps need to have this permission. Could you share a link to where this requirement is?
@VisibleForTesting | ||
private var activityResultLauncher: ActivityResultLauncher<Intent>? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we create this result launcher in onCreate
to only use it later on in the same callback method?
Also, you use the @VisibleForTesting
, but I don't see any tests that use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still unclear to me why we need to hold this in a var in this fashion. :)
7eb2fba
to
0f1d65b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me to land (after the logger lint is fixed). Great work! 🎉
Please make sure the land as a single change so we can squash the commits that land on main into one.
3ddb57c
to
4d4565e
Compare
Pull Request checklist
After merge
GitHub Automation
Fixes #12565