Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_apps_Browser
Commits
62b71f79
Commit
62b71f79
authored
15 years ago
by
Leon Scroggins
Browse files
Options
Download
Email Patches
Plain Diff
Honor the system setting of whether to show web suggestions.
parent
0494cc61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
14 deletions
+63
-14
src/com/android/browser/BrowserProvider.java
src/com/android/browser/BrowserProvider.java
+63
-14
No files found.
src/com/android/browser/BrowserProvider.java
View file @
62b71f79
...
...
@@ -31,12 +31,15 @@ import android.content.SharedPreferences.Editor;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.database.AbstractCursor
;
import
android.database.ContentObserver
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.preference.PreferenceManager
;
import
android.provider.Browser
;
import
android.provider.Settings
;
import
android.server.search.SearchableInfo
;
import
android.text.TextUtils
;
import
android.text.util.Regex
;
...
...
@@ -264,9 +267,65 @@ public class BrowserProvider extends ContentProvider {
ed
.
commit
();
}
}
mShowWebSuggestionsSettingChangeObserver
=
new
ShowWebSuggestionsSettingChangeObserver
();
context
.
getContentResolver
().
registerContentObserver
(
Settings
.
System
.
getUriFor
(
Settings
.
System
.
SHOW_WEB_SUGGESTIONS
),
true
,
mShowWebSuggestionsSettingChangeObserver
);
updateShowWebSuggestions
();
return
true
;
}
/**
* This Observer will ensure that if the user changes the system
* setting of whether to display web suggestions, we will
* change accordingly.
*/
/* package */
class
ShowWebSuggestionsSettingChangeObserver
extends
ContentObserver
{
public
ShowWebSuggestionsSettingChangeObserver
()
{
super
(
new
Handler
());
}
@Override
public
void
onChange
(
boolean
selfChange
)
{
updateShowWebSuggestions
();
}
}
private
ShowWebSuggestionsSettingChangeObserver
mShowWebSuggestionsSettingChangeObserver
;
// If non-null, then the system is set to show web suggestions,
// and this is the SearchableInfo to use to get them.
private
SearchableInfo
mSearchableInfo
;
/**
* Check the system settings to see whether web suggestions are
* allowed. If so, store the SearchableInfo to grab suggestions
* while the user is typing.
*/
private
void
updateShowWebSuggestions
()
{
mSearchableInfo
=
null
;
Context
context
=
getContext
();
if
(
Settings
.
System
.
getInt
(
context
.
getContentResolver
(),
Settings
.
System
.
SHOW_WEB_SUGGESTIONS
,
1
/* default on */
)
==
1
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_WEB_SEARCH
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
ResolveInfo
info
=
context
.
getPackageManager
().
resolveActivity
(
intent
,
PackageManager
.
MATCH_DEFAULT_ONLY
);
if
(
info
!=
null
)
{
ComponentName
googleSearchComponent
=
new
ComponentName
(
info
.
activityInfo
.
packageName
,
info
.
activityInfo
.
name
);
mSearchableInfo
=
SearchManager
.
getSearchableInfo
(
googleSearchComponent
,
false
);
}
}
}
private
void
fixPicasaBookmark
()
{
SQLiteDatabase
db
=
mOpenHelper
.
getWritableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
"SELECT _id FROM bookmarks WHERE "
+
...
...
@@ -598,21 +657,11 @@ public class BrowserProvider extends ContentProvider {
}
else
{
// get Google suggest if there is still space in the list
if
(
myArgs
!=
null
&&
myArgs
.
length
>
1
&&
mSearchableInfo
!=
null
&&
c
.
getCount
()
<
(
MAX_SUGGESTION_SHORT_ENTRIES
-
1
))
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_WEB_SEARCH
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
ResolveInfo
info
=
getContext
().
getPackageManager
().
resolveActivity
(
intent
,
PackageManager
.
MATCH_DEFAULT_ONLY
);
if
(
info
!=
null
)
{
ComponentName
googleSearchComponent
=
new
ComponentName
(
info
.
activityInfo
.
packageName
,
info
.
activityInfo
.
name
);
SearchableInfo
si
=
SearchManager
.
getSearchableInfo
(
googleSearchComponent
,
false
);
Cursor
sc
=
SearchManager
.
getSuggestions
(
getContext
(),
si
,
selectionArgs
[
0
]);
return
new
MySuggestionCursor
(
c
,
sc
,
selectionArgs
[
0
]);
}
Cursor
sc
=
SearchManager
.
getSuggestions
(
getContext
(),
mSearchableInfo
,
selectionArgs
[
0
]);
return
new
MySuggestionCursor
(
c
,
sc
,
selectionArgs
[
0
]);
}
return
new
MySuggestionCursor
(
c
,
null
,
selectionArgs
[
0
]);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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