-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Lawnchair Advance Search #3785
Conversation
Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage.
- Use retrofit for fetching suggestions
Haven’t looked into the code yet, but I think suggestions should be under the search provider that it comes from instead. Having it under device search is a bit misleading because “device search” sounds like a local search. |
Shouldn't suggestions be disabled by default, since it's sending data to 3rd party? Also ability to choose search provider would be nice. Otherwise everything's working fine, albeit a bit slower then with only app search. |
Can this be a replacement for Pixel Search app? |
Right, that make sense, let's add new category as Search provider / Suggestion provider in app drawer since it doesn't make sense to put it in dock since most of the dock func is redirect to browser / apps. |
lawnchair/src/app/lawnchair/allapps/SearchResultRightLeftIcon.kt
Outdated
Show resolved
Hide resolved
lawnchair/src/app/lawnchair/allapps/SearchResultRightLeftIcon.kt
Outdated
Show resolved
Hide resolved
https://i.imgur.com/d9evRkx.png after spotlessApply https://i.imgur.com/IDvJeS1.png please revert it @Goooler |
Ooops, mis-read them. |
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 few string changes.
Regarding "suggestions", I've also clarified that the suggestions come from the web (startpage).
I'm gonna suggest more changes related to the UI in both preferences and the actual search interface later.
lawnchair/src/app/lawnchair/ui/preferences/AppDrawerPreferences.kt
Outdated
Show resolved
Hide resolved
|
||
val startPageService: StartPageService = retrofit.create(StartPageService::class.java) | ||
|
||
suspend fun getStartPageSuggestions(query: String, max: Int): List<String> { |
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.
Still think that this should be tied to the user's current search provider.
For example, a user that selected startpage as the provider should get suggestions from startpage, or a user that selected duckduckgo should get suggestions from duckduckgo.
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 see, but we don't have endpoint for other provider, we only have from startpage. and also the current dock search implementation doesnt support your suggestions. it just redirect to browser when click.
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.
We could make tapping the dock open the drawer search instead. That way the user could type instantly without waiting for the browser to load.
About the other providers, what happens if the user clicks a startpage suggestion while using another provider?
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.
Yes we can do that.
nothing, since it's not tied in the search provider in dock. I guess we can update it later on when we tied dock search bar to all appsearch
val fileUri = when (info) { | ||
is FileInfo -> Uri.withAppendedPath( | ||
MediaStore.Files.getContentUri("external"), | ||
info.fileId, |
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 don't use file path to generate uri?
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 doesn't open the file as it's intended, it just redirected/open the selected app
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.
val intent = Intent(Intent.ACTION_VIEW)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
.setDataAndType(path.path2Uri(), mime.mimeCompat)
context?.startActivity(intent)
This should work, I just tried it on my file manager.
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.
Probably cause I grant it with ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
?
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.
Adding startActivity is useless here as it's already exists in SearchResultView
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.
And it doesn't open the png/MP4 etc in respected app like Photos/gallery
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.
Wired, it opens mp4 in my video player, and opens png in my photo viewer.
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.
Wired, it opens mp4 in my video player, and opens png in my photo viewer.
I'm pretty sure it doesn't, I tested in several apps and android 10 to 14 using emulator
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.
Alright, will investigate it when I'm free of time.
|
||
if (response.isSuccessful) { | ||
val responseBody = response.body()?.string() | ||
val suggestions = JSONArray(responseBody).optJSONArray(1)?.let { array -> |
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.
May KotlinX Json API instead.
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 doesn't need to since the response is something like this
["popcorn",["popcorn", "popcorn instrumental", "popcorn sutton", "popcornflix" ]]
and the current is very straight forward and it's works as intended
- As we don't how long gonna take to receive response in startpage
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 have some minor string suggestions.
Also, the current Preferences UI seems to be very convoluted and not-user friendly at all. I'll make a PR to fix this once this PR is merged.
lawnchair/res/values/strings.xml
Outdated
<string name="perform_wide_search_file">Files</string> | ||
<string name="pref_suggestion_title">Web suggestions (via <xliff:g id="startpage">Startpage</xliff:g>)</string> | ||
<string name="pref_advance_search_category">Advanced Search</string> | ||
<string name="perform_wide_search_description">Search your contacts and files in app drawer search. Enable in App Drawer settings.</string> |
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.
Actually, removing the last line should be fine.
<string name="perform_wide_search_description">Search your contacts and files in app drawer search. Enable in App Drawer settings.</string> | |
<string name="perform_wide_search_description">Search your contacts, files, and settings in app drawer search.</string> |
lawnchair/res/values/strings.xml
Outdated
<string name="warn_contact_permission_content">Requires contact permission</string> | ||
<string name="warn_files_permission_content">Requires storage permission</string> | ||
|
||
<string name="all_apps_search_result_files_description">Show files in search result</string> |
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.
<string name="all_apps_search_result_files_description">Show files in search result</string> | |
<string name="all_apps_search_result_files_description">Media, documents, folders, and more.</string> |
lawnchair/res/values/strings.xml
Outdated
<string name="warn_files_permission_content">Requires storage permission</string> | ||
|
||
<string name="all_apps_search_result_files_description">Show files in search result</string> | ||
<string name="all_apps_search_result_contacts_description">Show contacts in search result</string> |
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.
<string name="all_apps_search_result_contacts_description">Show contacts in search result</string> | |
<string name="all_apps_search_result_contacts_description">Contacts and more</string> |
internal fun getStartPageSearchItem(query: String): SearchTargetCompat { | ||
val url = getStartPageUrl(query) | ||
val id = "browser:$query" | ||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
val action = SearchActionCompat.Builder(id, context.getString(R.string.all_apps_search_startpage_message)) | ||
.setIcon(Icon.createWithResource(context, R.drawable.ic_startpage)) | ||
.setIntent(browserIntent) | ||
.build() | ||
val extras = bundleOf( | ||
SearchResultView.EXTRA_HIDE_SUBTITLE to true, | ||
) | ||
return createSearchTarget(id, action, START_PAGE, extras) | ||
} |
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.
Search item is always showing in the results, even if after turning Web suggestions
off, is this an intended behavior?
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.
No it doesn't show in my end, and this is not related to showing or showing of web suggestion, this only for wrapping the search result item , please check : https://github.com/LawnchairLauncher/lawnchair/blob/13-dev/lawnchair/src/app/lawnchair/search/LawnchairSearchAlgorithm.kt#L213
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.
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.
maybe you got confused, there's a web suggestion and recent suggestion : https://github.com/LawnchairLauncher/lawnchair/blob/13-dev/lawnchair/src/app/lawnchair/search/LawnchairSearchAlgorithm.kt#L226
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.
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.
No, that is not web suggestion
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.
and we don't have option for that
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.
and we don't have option for that
Is this intended?
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.
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.
and we don't have option for that
Is this intended?
Yes but if you want to add option you can do it here : https://github.com/LawnchairLauncher/lawnchair/blob/13-dev/lawnchair/src/app/lawnchair/search/LawnchairAppSearchAlgorithm.kt#L149
* Introduce Lawnchair Device Search Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage. * Apply reviewed suggestions by @gooler - Use retrofit for fetching suggestions * use kotlinxJson * Separate suggestion * Apply changes code refine @Goooler * Fix styling * Implement MIME Type Compat * Apply suggestion changes by @suphon-t * Apply suggestion changes by @SuperDragonXD * Cleanup * Remodel FileInfo * Private retrofit * Clean up SearchRequest * Add FileExtensions * Optimize file search method * Fix style * Rename * Optimize file opening * Add type checkers * Reformat AVDs * Fixed crash java.lang.ClassCastException error logs : https://katb.in/abahivihaqu * More fixes * Surround try catch to give proper error logs java.lang.NullPointerException at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invokeSuspend(SearchRequest.kt:124) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:8) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at app.lawnchair.search.data.SearchRequestKt.findContactsByName(SearchRequest.kt:68) at app.lawnchair.search.LawnchairSearchAlgorithm$performDeviceWideSearch$2.invokeSuspend(LawnchairSearchAlgorithm.kt:152) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) * Fixed opened file instead of just redirect to file manager * Fixed crash opening folder * Initial implementation callback * Add max results option for files, suggestion and people * Add initial settings entry * Properly use folder mimetype * Fixed target icon styling * Cleanups * Revert * Fixes * Apply suggestions by @Goooler * Fixed crash on external storage directory * Implement history keyword using built-in SearchRecentSuggestionsProvider * misc fixes * Add timeout 3 seconds - As we don't how long gonna take to receive response in startpage * Misc fixes * Misc fixes --------- Co-authored-by: Goooler <wangzongler@gmail.com>
* Introduce Lawnchair Device Search Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage. * Apply reviewed suggestions by @gooler - Use retrofit for fetching suggestions * use kotlinxJson * Separate suggestion * Apply changes code refine @Goooler * Fix styling * Implement MIME Type Compat * Apply suggestion changes by @suphon-t * Apply suggestion changes by @SuperDragonXD * Cleanup * Remodel FileInfo * Private retrofit * Clean up SearchRequest * Add FileExtensions * Optimize file search method * Fix style * Rename * Optimize file opening * Add type checkers * Reformat AVDs * Fixed crash java.lang.ClassCastException error logs : https://katb.in/abahivihaqu * More fixes * Surround try catch to give proper error logs java.lang.NullPointerException at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invokeSuspend(SearchRequest.kt:124) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:8) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at app.lawnchair.search.data.SearchRequestKt.findContactsByName(SearchRequest.kt:68) at app.lawnchair.search.LawnchairSearchAlgorithm$performDeviceWideSearch$2.invokeSuspend(LawnchairSearchAlgorithm.kt:152) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) * Fixed opened file instead of just redirect to file manager * Fixed crash opening folder * Initial implementation callback * Add max results option for files, suggestion and people * Add initial settings entry * Properly use folder mimetype * Fixed target icon styling * Cleanups * Revert * Fixes * Apply suggestions by @Goooler * Fixed crash on external storage directory * Implement history keyword using built-in SearchRecentSuggestionsProvider * misc fixes * Add timeout 3 seconds - As we don't how long gonna take to receive response in startpage * Misc fixes * Misc fixes --------- Co-authored-by: Goooler <wangzongler@gmail.com>
* Introduce Lawnchair Device Search Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage. * Apply reviewed suggestions by @gooler - Use retrofit for fetching suggestions * use kotlinxJson * Separate suggestion * Apply changes code refine @Goooler * Fix styling * Implement MIME Type Compat * Apply suggestion changes by @suphon-t * Apply suggestion changes by @SuperDragonXD * Cleanup * Remodel FileInfo * Private retrofit * Clean up SearchRequest * Add FileExtensions * Optimize file search method * Fix style * Rename * Optimize file opening * Add type checkers * Reformat AVDs * Fixed crash java.lang.ClassCastException error logs : https://katb.in/abahivihaqu * More fixes * Surround try catch to give proper error logs java.lang.NullPointerException at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invokeSuspend(SearchRequest.kt:124) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:8) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at app.lawnchair.search.data.SearchRequestKt.findContactsByName(SearchRequest.kt:68) at app.lawnchair.search.LawnchairSearchAlgorithm$performDeviceWideSearch$2.invokeSuspend(LawnchairSearchAlgorithm.kt:152) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) * Fixed opened file instead of just redirect to file manager * Fixed crash opening folder * Initial implementation callback * Add max results option for files, suggestion and people * Add initial settings entry * Properly use folder mimetype * Fixed target icon styling * Cleanups * Revert * Fixes * Apply suggestions by @Goooler * Fixed crash on external storage directory * Implement history keyword using built-in SearchRecentSuggestionsProvider * misc fixes * Add timeout 3 seconds - As we don't how long gonna take to receive response in startpage * Misc fixes * Misc fixes --------- Co-authored-by: Goooler <wangzongler@gmail.com>
* Introduce Lawnchair Device Search Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage. * Apply reviewed suggestions by @gooler - Use retrofit for fetching suggestions * use kotlinxJson * Separate suggestion * Apply changes code refine @Goooler * Fix styling * Implement MIME Type Compat * Apply suggestion changes by @suphon-t * Apply suggestion changes by @SuperDragonXD * Cleanup * Remodel FileInfo * Private retrofit * Clean up SearchRequest * Add FileExtensions * Optimize file search method * Fix style * Rename * Optimize file opening * Add type checkers * Reformat AVDs * Fixed crash java.lang.ClassCastException error logs : https://katb.in/abahivihaqu * More fixes * Surround try catch to give proper error logs java.lang.NullPointerException at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invokeSuspend(SearchRequest.kt:124) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:8) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at app.lawnchair.search.data.SearchRequestKt.findContactsByName(SearchRequest.kt:68) at app.lawnchair.search.LawnchairSearchAlgorithm$performDeviceWideSearch$2.invokeSuspend(LawnchairSearchAlgorithm.kt:152) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) * Fixed opened file instead of just redirect to file manager * Fixed crash opening folder * Initial implementation callback * Add max results option for files, suggestion and people * Add initial settings entry * Properly use folder mimetype * Fixed target icon styling * Cleanups * Revert * Fixes * Apply suggestions by @Goooler * Fixed crash on external storage directory * Implement history keyword using built-in SearchRecentSuggestionsProvider * misc fixes * Add timeout 3 seconds - As we don't how long gonna take to receive response in startpage * Misc fixes * Misc fixes --------- Co-authored-by: Goooler <wangzongler@gmail.com>
* Introduce Lawnchair Device Search Initial Implementation device search in Lawnchair: Enables search functionality across Files, Contacts, and Suggestions on the Startpage. * Apply reviewed suggestions by @gooler - Use retrofit for fetching suggestions * use kotlinxJson * Separate suggestion * Apply changes code refine @Goooler * Fix styling * Implement MIME Type Compat * Apply suggestion changes by @suphon-t * Apply suggestion changes by @SuperDragonXD * Cleanup * Remodel FileInfo * Private retrofit * Clean up SearchRequest * Add FileExtensions * Optimize file search method * Fix style * Rename * Optimize file opening * Add type checkers * Reformat AVDs * Fixed crash java.lang.ClassCastException error logs : https://katb.in/abahivihaqu * More fixes * Surround try catch to give proper error logs java.lang.NullPointerException at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invokeSuspend(SearchRequest.kt:124) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:8) at app.lawnchair.search.data.SearchRequestKt$findContactsByName$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at app.lawnchair.search.data.SearchRequestKt.findContactsByName(SearchRequest.kt:68) at app.lawnchair.search.LawnchairSearchAlgorithm$performDeviceWideSearch$2.invokeSuspend(LawnchairSearchAlgorithm.kt:152) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) * Fixed opened file instead of just redirect to file manager * Fixed crash opening folder * Initial implementation callback * Add max results option for files, suggestion and people * Add initial settings entry * Properly use folder mimetype * Fixed target icon styling * Cleanups * Revert * Fixes * Apply suggestions by @Goooler * Fixed crash on external storage directory * Implement history keyword using built-in SearchRecentSuggestionsProvider * misc fixes * Add timeout 3 seconds - As we don't how long gonna take to receive response in startpage * Misc fixes * Misc fixes --------- Co-authored-by: Goooler <wangzongler@gmail.com>
Screenshot
Description
Initial Implementation advance search in Lawnchair
Enables search functionality across Files, Contacts, Settings Entry, History keyword and Suggestions on the Startpage.
Fixes #3740
Type of change
❌ General change (non-breaking change that doesn't fit the below categories like copyediting)
✅ Bug fix (non-breaking change which fixes an issue)
✅ New feature (non-breaking change which adds functionality)
❌ Breaking change (fix or feature that would cause existing functionality to not work as expected)