summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-11-06 10:12:54 -0800
committerDanesh M <daneshm90@gmail.com>2015-09-27 20:46:52 -0700
commit5b54994fc56c9d00d415f161457c2c7449af912d (patch)
treef78f60595d88ca965a5ffc526fcee478026adbf4 /src/com/android/launcher3/Utilities.java
parent4ca61d13bc2fd0faa18ce76b1f9edf00323ce260 (diff)
downloadandroid_packages_apps_Trebuchet-5b54994fc56c9d00d415f161457c2c7449af912d.tar.gz
android_packages_apps_Trebuchet-5b54994fc56c9d00d415f161457c2c7449af912d.tar.bz2
android_packages_apps_Trebuchet-5b54994fc56c9d00d415f161457c2c7449af912d.zip
Using the default search widget in Launcher3
> Removing all logic related to search and voice overlays from Launcher3 > Using the widget provided by global search provider on the homescreen > Removing VoiceButtonProxy, as it is not being used anymore Change-Id: Ie8b09b44f7213c8fa11bce685914442e4884295d
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 862a96d1e..9102639c8 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -16,8 +16,11 @@
package com.android.launcher3;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.SearchManager;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -581,4 +584,37 @@ public final class Utilities {
return activityName != null;
}
+
+ /**
+ * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
+ * provided by the same package which is set to be global search activity.
+ * If widgetCategory is not supported, or no such widget is found, returns the first widget
+ * provided by the package.
+ */
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
+ public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
+ SearchManager searchManager =
+ (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
+ ComponentName searchComponent = searchManager.getGlobalSearchActivity();
+ if (searchComponent == null) return null;
+ String providerPkg = searchComponent.getPackageName();
+
+ AppWidgetProviderInfo defaultWidgetForSearchPackage = null;
+
+ AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
+ for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
+ if (info.provider.getPackageName().equals(providerPkg)) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
+ return info;
+ } else if (defaultWidgetForSearchPackage == null) {
+ defaultWidgetForSearchPackage = info;
+ }
+ } else {
+ return info;
+ }
+ }
+ }
+ return defaultWidgetForSearchPackage;
+ }
}