summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Cross <edward.k.cross@gmail.com>2018-12-26 21:18:30 (GMT)
committerBruno Martins <bgcngm@gmail.com>2019-10-21 18:57:54 (GMT)
commita7bf32efcbda56c9a53129be8c258401aaf5afd5 (patch)
tree7f855afda51c006e140b3624b0c2dabf431dd86b
parent7f3d8d10db1aa823f9ea740943c39495e476bc97 (diff)
downloadandroid_packages_apps_Trebuchet-a7bf32efcbda56c9a53129be8c258401aaf5afd5.zip
android_packages_apps_Trebuchet-a7bf32efcbda56c9a53129be8c258401aaf5afd5.tar.gz
android_packages_apps_Trebuchet-a7bf32efcbda56c9a53129be8c258401aaf5afd5.tar.bz2
QSB: request round search bar
Change-Id: Icf81d36e467fdbe5cc4e4a081c8e3ec2ebaa4263
-rw-r--r--proguard.flags5
-rw-r--r--src/com/android/launcher3/qsb/QsbContainerView.java29
-rw-r--r--src/com/android/launcher3/qsb/QsbWidgetHostView.java6
3 files changed, 40 insertions, 0 deletions
diff --git a/proguard.flags b/proguard.flags
index 6fc5624..a4a2407 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -16,6 +16,11 @@
public <init>(...);
}
+# QSB
+-keep class com.android.launcher3.qsb.QsbContainerView$QsbFragment {
+ public <init>(...);
+}
+
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java
index 857ea05..f83c11c 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 f5ecda3..660ff7d 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.