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

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

Merge "Adding framework support for resizable widgets"

parents 7532d997 d2e20de6
Loading
Loading
Loading
Loading
+65 −0
Original line number Original line Diff line number Diff line
@@ -7924,6 +7924,17 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="resizeMode"
 type="int"
 transient="false"
 volatile="false"
 value="16843619"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="resizeable"
<field name="resizeable"
 type="int"
 type="int"
 transient="false"
 transient="false"
@@ -39802,6 +39813,50 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="RESIZE_BOTH"
 type="int"
 transient="false"
 volatile="false"
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="RESIZE_HORIZONTAL"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="RESIZE_NONE"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="RESIZE_VERTICAL"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="autoAdvanceViewId"
<field name="autoAdvanceViewId"
 type="int"
 type="int"
 transient="false"
 transient="false"
@@ -39892,6 +39947,16 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="resizableMode"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="updatePeriodMillis"
<field name="updatePeriodMillis"
 type="int"
 type="int"
 transient="false"
 transient="false"
+17 −4
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package android.appwidget;
package android.appwidget;


import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.content.Context;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
@@ -23,11 +26,10 @@ import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.widget.RemoteViews;
import android.widget.RemoteViews;


import java.util.ArrayList;
import java.util.HashMap;

import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.appwidget.IAppWidgetService;


@@ -43,6 +45,7 @@ public class AppWidgetHost {


    final static Object sServiceLock = new Object();
    final static Object sServiceLock = new Object();
    static IAppWidgetService sService;
    static IAppWidgetService sService;
    private DisplayMetrics mDisplayMetrics;


    Context mContext;
    Context mContext;
    String mPackageName;
    String mPackageName;
@@ -103,6 +106,7 @@ public class AppWidgetHost {
        mContext = context;
        mContext = context;
        mHostId = hostId;
        mHostId = hostId;
        mHandler = new UpdateHandler(context.getMainLooper());
        mHandler = new UpdateHandler(context.getMainLooper());
        mDisplayMetrics = context.getResources().getDisplayMetrics();
        synchronized (sServiceLock) {
        synchronized (sServiceLock) {
            if (sService == null) {
            if (sService == null) {
                IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
                IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
@@ -249,6 +253,15 @@ public class AppWidgetHost {
     */
     */
    protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
    protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
        AppWidgetHostView v;
        AppWidgetHostView v;

        // Convert complex to dp -- we are getting the AppWidgetProviderInfo from the
        // AppWidgetService, which doesn't have our context, hence we need to do the 
        // conversion here.
        appWidget.minWidth =
            TypedValue.complexToDimensionPixelSize(appWidget.minWidth, mDisplayMetrics);
        appWidget.minHeight =
            TypedValue.complexToDimensionPixelSize(appWidget.minHeight, mDisplayMetrics);

        synchronized (mViews) {
        synchronized (mViews) {
            v = mViews.get(appWidgetId);
            v = mViews.get(appWidgetId);
        }
        }
+27 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,24 @@ import android.content.ComponentName;
 * correspond to the fields in the <code>&lt;appwidget-provider&gt;</code> xml tag.
 * correspond to the fields in the <code>&lt;appwidget-provider&gt;</code> xml tag.
 */
 */
public class AppWidgetProviderInfo implements Parcelable {
public class AppWidgetProviderInfo implements Parcelable {

    /**
     * Widget is not resizable.
     */
    public static final int RESIZE_NONE             = 0;
    /**
     * Widget is resizable in the horizontal axis only.
     */
    public static final int RESIZE_HORIZONTAL       = 1;
    /**
     * Widget is resizable in the vertical axis only.
     */
    public static final int RESIZE_VERTICAL         = 2;
    /**
     * Widget is resizable in both the horizontal and vertical axes.
     */
    public static final int RESIZE_BOTH = RESIZE_HORIZONTAL | RESIZE_VERTICAL;

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


    /**
     * The rules by which a widget can be resized. See {@link #RESIZE_NONE},
     * {@link #RESIZE_NONE}, {@link #RESIZE_HORIZONTAL},
     * {@link #RESIZE_VERTICAL}, {@link #RESIZE_BOTH}.
     */
    public int resizableMode;

    public AppWidgetProviderInfo() {
    public AppWidgetProviderInfo() {
    }
    }


@@ -145,6 +170,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        this.icon = in.readInt();
        this.icon = in.readInt();
        this.previewImage = in.readInt();
        this.previewImage = in.readInt();
        this.autoAdvanceViewId = in.readInt();
        this.autoAdvanceViewId = in.readInt();
        this.resizableMode = in.readInt();
    }
    }


    public void writeToParcel(android.os.Parcel out, int flags) {
    public void writeToParcel(android.os.Parcel out, int flags) {
@@ -168,6 +194,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        out.writeInt(this.icon);
        out.writeInt(this.icon);
        out.writeInt(this.previewImage);
        out.writeInt(this.previewImage);
        out.writeInt(this.autoAdvanceViewId);
        out.writeInt(this.autoAdvanceViewId);
        out.writeInt(this.resizableMode);
    }
    }


    public int describeContents() {
    public int describeContents() {
+7 −0
Original line number Original line Diff line number Diff line
@@ -4549,6 +4549,13 @@
        <!-- The view id of the AppWidget subview which should be auto-advanced.
        <!-- The view id of the AppWidget subview which should be auto-advanced.
             by the widget's host. -->
             by the widget's host. -->
        <attr name="autoAdvanceViewId" format="reference" />
        <attr name="autoAdvanceViewId" format="reference" />
        <!-- Optional parameter which indicates if and how this widget can be 
             resized. -->
        <attr name="resizeMode" format="integer">
            <flag name="none" value="0x0" />
            <flag name="horizontal" value="0x1" />
            <flag name="vertical" value="0x2" />
        </attr>
    </declare-styleable>
    </declare-styleable>


    <!-- =============================== -->
    <!-- =============================== -->
+2 −1
Original line number Original line Diff line number Diff line
@@ -1647,4 +1647,5 @@
     =============================================================== -->
     =============================================================== -->
  <eat-comment />
  <eat-comment />
  <public type="attr" name="textCursorDrawable" id="0x01010362" />
  <public type="attr" name="textCursorDrawable" id="0x01010362" />
  <public type="attr" name="resizeMode" />
</resources>
</resources>
Loading