Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aec914b1 authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "Adding notion of keyguard widgets" into jb-mr1-dev

parents ea42443e 0aa2d42e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -555,6 +555,7 @@ package android {
    field public static final int indicatorRight = 16843022; // 0x101010e
    field public static final int inflatedId = 16842995; // 0x10100f3
    field public static final int initOrder = 16842778; // 0x101001a
    field public static final int initialKeyguardLayout = 16843714; // 0x10103c2
    field public static final int initialLayout = 16843345; // 0x1010251
    field public static final int innerRadius = 16843359; // 0x101025f
    field public static final int innerRadiusRatio = 16843163; // 0x101019b
@@ -1120,6 +1121,7 @@ package android {
    field public static final int weekNumberColor = 16843589; // 0x1010345
    field public static final int weekSeparatorLineColor = 16843590; // 0x1010346
    field public static final int weightSum = 16843048; // 0x1010128
    field public static final int widgetFeatures = 16843715; // 0x10103c3
    field public static final int widgetLayout = 16843243; // 0x10101eb
    field public static final int width = 16843097; // 0x1010159
    field public static final int windowActionBar = 16843469; // 0x10102cd
@@ -4399,6 +4401,7 @@ package android.appwidget {
  public class AppWidgetManager {
    method public boolean bindAppWidgetIdIfAllowed(int, android.content.ComponentName);
    method public boolean bindAppWidgetIdIfAllowed(int, android.content.ComponentName, android.os.Bundle);
    method public int[] getAppWidgetIds(android.content.ComponentName);
    method public android.appwidget.AppWidgetProviderInfo getAppWidgetInfo(int);
    method public android.os.Bundle getAppWidgetOptions(int);
@@ -4428,6 +4431,7 @@ package android.appwidget {
    field public static final java.lang.String EXTRA_CUSTOM_INFO = "customInfo";
    field public static final int INVALID_APPWIDGET_ID = 0; // 0x0
    field public static final java.lang.String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
    field public static final java.lang.String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";
    field public static final java.lang.String OPTION_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";
    field public static final java.lang.String OPTION_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";
    field public static final java.lang.String OPTION_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";
@@ -4454,9 +4458,15 @@ package android.appwidget {
    field public static final int RESIZE_HORIZONTAL = 1; // 0x1
    field public static final int RESIZE_NONE = 0; // 0x0
    field public static final int RESIZE_VERTICAL = 2; // 0x2
    field public static final int WIDGET_CATEGORY_HOME_SCREEN = 1; // 0x1
    field public static final int WIDGET_CATEGORY_KEYGUARD = 2; // 0x2
    field public static final int WIDGET_FEATURES_CLOCK = 1; // 0x1
    field public static final int WIDGET_FEATURES_NONE = 0; // 0x0
    field public static final int WIDGET_FEATURES_STATUS = 2; // 0x2
    field public int autoAdvanceViewId;
    field public android.content.ComponentName configure;
    field public int icon;
    field public int initialKeyguardLayout;
    field public int initialLayout;
    field public java.lang.String label;
    field public int minHeight;
@@ -4467,6 +4477,8 @@ package android.appwidget {
    field public android.content.ComponentName provider;
    field public int resizeMode;
    field public int updatePeriodMillis;
    field public int widgetCategory;
    field public int widgetFeatures;
  }
}
+11 −1
Original line number Diff line number Diff line
@@ -513,7 +513,17 @@ public class AppWidgetHostView extends FrameLayout {
                        theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                inflater = inflater.cloneInContext(theirContext);
                inflater.setFilter(sInflaterFilter);
                defaultView = inflater.inflate(mInfo.initialLayout, this, false);
                AppWidgetManager manager = AppWidgetManager.getInstance(mContext);
                Bundle options = manager.getAppWidgetOptions(mAppWidgetId);

                int layoutId = mInfo.initialLayout;
                if (options.containsKey(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY)) {
                    int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY);
                    if (category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) {
                        layoutId = mInfo.initialKeyguardLayout;
                    }
                }
                defaultView = inflater.inflate(layoutId, this, false);
            } else {
                Log.w(TAG, "can't inflate defaultView because mInfo is missing");
            }
+68 −6
Original line number Diff line number Diff line
@@ -150,25 +150,33 @@ public class AppWidgetManager {
    public static final String EXTRA_APPWIDGET_ID = "appWidgetId";

    /**
     * An bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
     * A bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
     */
    public static final String OPTION_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth";

    /**
     * An bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
     * A bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
     */
    public static final String OPTION_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";

    /**
     * An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
     * A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
     */
    public static final String OPTION_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";

    /**
     * An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
     * A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
     */
    public static final String OPTION_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";

    /**
     * A bundle extra that hints to the AppWidgetProvider the category of host that owns this
     * this widget. Can have the value {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or {@link
     * AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}.
     */
    public static final String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";

    /**
     * An intent extra which points to a bundle of extra information for a particular widget id.
     * In particular this bundle can contain EXTRA_APPWIDGET_WIDTH and EXTRA_APPWIDGET_HEIGHT.
@@ -568,7 +576,31 @@ public class AppWidgetManager {
     */
    public void bindAppWidgetId(int appWidgetId, ComponentName provider) {
        try {
            sService.bindAppWidgetId(appWidgetId, provider);
            sService.bindAppWidgetId(appWidgetId, provider, null);
        }
        catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
        }
    }

    /**
     * Set the component for a given appWidgetId.
     *
     * <p class="note">You need the BIND_APPWIDGET permission or the user must have enabled binding
     *         widgets always for your component. This method is used by the AppWidget picker and
     *         should not be used by other apps.
     *
     * @param appWidgetId     The AppWidget instance for which to set the RemoteViews.
     * @param provider      The {@link android.content.BroadcastReceiver} that will be the AppWidget
     *                      provider for this AppWidget.
     * @param options       Bundle containing options for the AppWidget. See also
     *                      {@link #updateAppWidgetOptions(int, Bundle)}
     *
     * @hide
     */
    public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options) {
        try {
            sService.bindAppWidgetId(appWidgetId, provider, options);
        }
        catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
@@ -594,7 +626,37 @@ public class AppWidgetManager {
        }
        try {
            return sService.bindAppWidgetIdIfAllowed(
                    mContext.getPackageName(), appWidgetId, provider);
                    mContext.getPackageName(), appWidgetId, provider, null);
        }
        catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
        }
    }

    /**
     * Set the component for a given appWidgetId.
     *
     * <p class="note">You need the BIND_APPWIDGET permission or the user must have enabled binding
     *         widgets always for your component. Should be used by apps that host widgets; if this
     *         method returns false, call {@link #ACTION_APPWIDGET_BIND} to request permission to
     *         bind
     *
     * @param appWidgetId     The AppWidget instance for which to set the RemoteViews.
     * @param provider      The {@link android.content.BroadcastReceiver} that will be the AppWidget
     *                      provider for this AppWidget.
     * @param options       Bundle containing options for the AppWidget. See also
     *                      {@link #updateAppWidgetOptions(int, Bundle)}
     *
     * @return true if this component has permission to bind the AppWidget
     */
    public boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider,
            Bundle options) {
        if (mContext == null) {
            return false;
        }
        try {
            return sService.bindAppWidgetIdIfAllowed(
                    mContext.getPackageName(), appWidgetId, provider, options);
        }
        catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
+65 −0
Original line number Diff line number Diff line
@@ -43,6 +43,34 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    public static final int RESIZE_BOTH = RESIZE_HORIZONTAL | RESIZE_VERTICAL;

    /**
     * Indicates that the widget can be displayed on the home screen. This is the default value.
     */
    public static final int WIDGET_CATEGORY_HOME_SCREEN = 1;

    /**
     * Indicates that the widget can be displayed on the keyguard.
     */
    public static final int WIDGET_CATEGORY_KEYGUARD = 2;

    /**
     * Indicates that the widget supports no special features.
     */
    public static final int WIDGET_FEATURES_NONE = 0;

    /**
     * Indicates that the widget displays the current time. The host may use this as a hint to not
     * display the time in other places.
     */
    public static final int WIDGET_FEATURES_CLOCK = 1;

    /**
     * Indicates that the widget is output only, ie. has nothing clickable. This may be enforced by
     * the host. Presently, this flag is used by the keyguard to indicate that it can be placed
     * in the first position.
     */
    public static final int WIDGET_FEATURES_STATUS = 2;

    /**
     * Identity of this AppWidget component.  This component should be a {@link
     * android.content.BroadcastReceiver}, and it will be sent the AppWidget intents
@@ -110,6 +138,16 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    public int initialLayout;

    /**
     * The resource id of the initial layout for this AppWidget when it is displayed on keyguard.
     * This parameter only needs to be provided if the widget can be displayed on the keyguard,
     * see {@link #widgetCategory}.
     *
     * <p>This field corresponds to the <code>android:initialKeyguardLayout</code> attribute in
     * the AppWidget meta-data file.
     */
    public int initialKeyguardLayout;

    /**
     * The activity to launch that will configure the AppWidget.
     *
@@ -164,6 +202,27 @@ public class AppWidgetProviderInfo implements Parcelable {
     */
    public int resizeMode;

    /**
     * Determines whether this widget can be displayed on the home screen, the keyguard, or both.
     * A widget which is displayed on both needs to ensure that it follows the design guidelines
     * for both widget classes. This can be achieved by querying the AppWidget options in its
     * widget provider's update method.
     *
     * <p>This field corresponds to the <code>widgetCategory</code> attribute in
     * the AppWidget meta-data file.
     */
    public int widgetCategory;

    /**
     * A field which specifies any special features that this widget supports. See
     * {@link #WIDGET_FEATURES_NONE}, {@link #WIDGET_FEATURES_CLOCK},
     * {@link #WIDGET_FEATURES_STATUS}.
     *
     * <p>This field corresponds to the <code>widgetFeatures</code> attribute in
     * the AppWidget meta-data file.
     */
    public int widgetFeatures;

    public AppWidgetProviderInfo() {
    }

@@ -180,6 +239,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        this.minResizeHeight = in.readInt();
        this.updatePeriodMillis = in.readInt();
        this.initialLayout = in.readInt();
        this.initialKeyguardLayout = in.readInt();
        if (0 != in.readInt()) {
            this.configure = new ComponentName(in);
        }
@@ -188,6 +248,8 @@ public class AppWidgetProviderInfo implements Parcelable {
        this.previewImage = in.readInt();
        this.autoAdvanceViewId = in.readInt();
        this.resizeMode = in.readInt();
        this.widgetCategory = in.readInt();
        this.widgetFeatures = in.readInt();
    }

    public void writeToParcel(android.os.Parcel out, int flags) {
@@ -203,6 +265,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        out.writeInt(this.minResizeHeight);
        out.writeInt(this.updatePeriodMillis);
        out.writeInt(this.initialLayout);
        out.writeInt(this.initialKeyguardLayout);
        if (this.configure != null) {
            out.writeInt(1);
            this.configure.writeToParcel(out, flags);
@@ -214,6 +277,8 @@ public class AppWidgetProviderInfo implements Parcelable {
        out.writeInt(this.previewImage);
        out.writeInt(this.autoAdvanceViewId);
        out.writeInt(this.resizeMode);
        out.writeInt(this.widgetCategory);
        out.writeInt(this.widgetFeatures);
    }

    public int describeContents() {
+2 −2
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ interface IAppWidgetService {
    AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId);
    boolean hasBindAppWidgetPermission(in String packageName);
    void setBindAppWidgetPermission(in String packageName, in boolean permission);
    void bindAppWidgetId(int appWidgetId, in ComponentName provider);
    void bindAppWidgetId(int appWidgetId, in ComponentName provider, in Bundle options);
    boolean bindAppWidgetIdIfAllowed(
            in String packageName, int appWidgetId, in ComponentName provider);
            in String packageName, int appWidgetId, in ComponentName provider, in Bundle options);
    void bindRemoteViewsService(int appWidgetId, in Intent intent, in IBinder connection);
    void unbindRemoteViewsService(int appWidgetId, in Intent intent);
    int[] getAppWidgetIds(in ComponentName provider);
Loading