diff options
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/qsb/QsbContainerView.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/qsb/QsbWidgetHostView.java | 6 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java index 857ea05d6..f83c11ca6 100644 --- a/src/com/android/launcher3/qsb/QsbContainerView.java +++ b/src/com/android/launcher3/qsb/QsbContainerView.java @@ -30,6 +30,8 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; import android.graphics.Rect; import android.os.Bundle; import android.util.AttributeSet; @@ -54,6 +56,8 @@ import com.android.launcher3.graphics.FragmentWithPreview; * AppWidgetManager directly, so that it keeps working in that case. */ public class QsbContainerView extends FrameLayout { + private static final String QSB_PROVIDER_CLASS + = "com.google.android.googlequicksearchbox.SearchWidgetProvider"; public QsbContainerView(Context context) { super(context); @@ -76,6 +80,26 @@ public class QsbContainerView extends FrameLayout { super.setPadding(left, top, right, bottom); } + public static void updateDefaultLayout(Context context, AppWidgetProviderInfo info) { + ComponentName provider = info.provider; + if (QSB_PROVIDER_CLASS.equals(provider.getClassName())) { + try { + ActivityInfo activityInfo = + context.getPackageManager().getReceiverInfo(provider, + PackageManager.GET_META_DATA); + Bundle metaData = activityInfo.metaData; + int resId = metaData.getInt( + "com.google.android.gsa.searchwidget.alt_initial_layout_cqsb", -1); + if (resId != -1) { + info.initialLayout = resId; + } + } catch (Exception e) { + // Ignore the exception since if any exceptions happen + // the original initialyLayout would be used. + } + } + } + /** * A fragment to display the QSB. */ @@ -126,6 +150,11 @@ public class QsbContainerView extends FrameLayout { return getDefaultView(container, false /* show setup icon */); } Bundle opts = createBindOptions(); + // round quick search bar + opts.putString("attached-launcher-identifier", + getActivity().getPackageName()); + opts.putString("requested-widget-style", "cqsb"); + Context context = getContext(); AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); diff --git a/src/com/android/launcher3/qsb/QsbWidgetHostView.java b/src/com/android/launcher3/qsb/QsbWidgetHostView.java index f5ecda3e3..660ff7d7c 100644 --- a/src/com/android/launcher3/qsb/QsbWidgetHostView.java +++ b/src/com/android/launcher3/qsb/QsbWidgetHostView.java @@ -16,6 +16,7 @@ package com.android.launcher3.qsb; +import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -48,6 +49,11 @@ public class QsbWidgetHostView extends NavigableAppWidgetHostView { super.updateAppWidget(remoteViews); } + @Override + public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) { + QsbContainerView.updateDefaultLayout(getContext(), info); + super.setAppWidget(appWidgetId, info); + } public boolean isReinflateRequired(int orientation) { // Re-inflate is required if the orientation has changed since last inflation. |