Fixing custom widgets support:

> Moving the definitions to xml so that it is easier to override in derivative projects
> Fixing verious bind and save logic for custom widgets
> Adding feature flag to easily disable custom widgets

Change-Id: I0e278bc7dd415713029364060ef10842da990be9
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index 6f23e56..051846c 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -71,7 +71,7 @@
     /**
      * Indicates that this is a locally defined widget and hence has no system allocated id.
      */
-    static final int CUSTOM_WIDGET_ID = -100;
+    public static final int CUSTOM_WIDGET_ID = -100;
 
     /**
      * Identifier for this widget when talking with
@@ -104,15 +104,15 @@
     private boolean mHasNotifiedInitialWidgetSizeChanged;
 
     public LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) {
-        if (appWidgetId == CUSTOM_WIDGET_ID) {
+        this.appWidgetId = appWidgetId;
+        this.providerName = providerName;
+
+        if (isCustomWidget()) {
             itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
         } else {
             itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
         }
 
-        this.appWidgetId = appWidgetId;
-        this.providerName = providerName;
-
         // Since the widget isn't instantiated yet, we don't know these values. Set them to -1
         // to indicate that they should be calculated based on the layout and minWidth/minHeight
         spanX = -1;
@@ -128,7 +128,7 @@
     }
 
     public boolean isCustomWidget() {
-        return appWidgetId == CUSTOM_WIDGET_ID;
+        return appWidgetId <= CUSTOM_WIDGET_ID;
     }
 
     @Override