summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherAppWidgetHost.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/LauncherAppWidgetHost.java')
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetHost.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java
index a309f268c..840508a1d 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -21,9 +21,11 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.os.TransactionTooLargeException;
+import android.view.LayoutInflater;
import java.util.ArrayList;
+
/**
* Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
* which correctly captures all long-press events. This ensures that users can
@@ -85,4 +87,29 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
callback.run();
}
}
+
+ public AppWidgetHostView createView(Context context, int appWidgetId,
+ LauncherAppWidgetProviderInfo appWidget) {
+ if (appWidget.isCustomWidget) {
+ LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
+ LayoutInflater inflater = (LayoutInflater)
+ context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ inflater.inflate(appWidget.initialLayout, lahv);
+ lahv.setAppWidget(0, appWidget);
+ lahv.updateLastInflationOrientation();
+ return lahv;
+ } else {
+ return super.createView(context, appWidgetId, appWidget);
+ }
+ }
+
+ /**
+ * Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
+ */
+ @Override
+ protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
+ LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo.fromProviderInfo(
+ mLauncher, appWidget);
+ super.onProviderChanged(appWidgetId, info);
+ }
}