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

Commit 499cb9f5 authored by Winson Chung's avatar Winson Chung
Browse files

Initial changes to allow collections in widgets.

Change-Id: I3cfa899bae88cd252912cecebc12e93c27a3b7c9
parent b5b37f3b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ LOCAL_SRC_FILES += \
	core/java/com/android/internal/view/IInputMethodClient.aidl \
	core/java/com/android/internal/view/IInputMethodManager.aidl \
	core/java/com/android/internal/view/IInputMethodSession.aidl \
	core/java/com/android/internal/widget/IRemoteViewsFactory.aidl \
	location/java/android/location/IGeocodeProvider.aidl \
	location/java/android/location/IGpsStatusListener.aidl \
	location/java/android/location/IGpsStatusProvider.aidl \
+300 −0
Original line number Diff line number Diff line
@@ -34218,6 +34218,40 @@
<parameter name="context" type="android.content.Context">
</parameter>
</method>
<method name="notifyAppWidgetViewDataChanged"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="appWidgetIds" type="int[]">
</parameter>
<parameter name="views" type="android.widget.RemoteViews">
</parameter>
<parameter name="viewId" type="int">
</parameter>
</method>
<method name="notifyAppWidgetViewDataChanged"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="appWidgetId" type="int">
</parameter>
<parameter name="views" type="android.widget.RemoteViews">
</parameter>
<parameter name="viewId" type="int">
</parameter>
</method>
<method name="updateAppWidget"
 return="void"
 abstract="false"
@@ -207092,6 +207126,28 @@
 visibility="public"
>
</method>
<method name="onRemoteAdapterConnected"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onRemoteAdapterDisconnected"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onRestoreInstanceState"
 return="void"
 abstract="false"
@@ -207269,6 +207325,19 @@
<parameter name="listener" type="android.widget.AbsListView.RecyclerListener">
</parameter>
</method>
<method name="setRemoteViewsAdapter"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
</method>
<method name="setScrollIndicators"
 return="void"
 abstract="false"
@@ -213725,6 +213794,19 @@
<parameter name="verticalSpacing" type="int">
</parameter>
</method>
<method name="smoothScrollByOffset"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="offset" type="int">
</parameter>
</method>
<field name="AUTO_FIT"
 type="int"
 transient="false"
@@ -216276,6 +216358,19 @@
<parameter name="y" type="int">
</parameter>
</method>
<method name="smoothScrollByOffset"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="offset" type="int">
</parameter>
</method>
<field name="CHOICE_MODE_MULTIPLE"
 type="int"
 transient="false"
@@ -219130,6 +219225,23 @@
<parameter name="value" type="int">
</parameter>
</method>
<method name="setIntent"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="methodName" type="java.lang.String">
</parameter>
<parameter name="value" type="android.content.Intent">
</parameter>
</method>
<method name="setLong"
 return="void"
 abstract="false"
@@ -219181,6 +219293,51 @@
<parameter name="indeterminate" type="boolean">
</parameter>
</method>
<method name="setRelativeScrollPosition"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="offset" type="int">
</parameter>
</method>
<method name="setRemoteAdapter"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="intent" type="android.content.Intent">
</parameter>
</method>
<method name="setScrollPosition"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="position" type="int">
</parameter>
</method>
<method name="setShort"
 return="void"
 abstract="false"
@@ -219343,6 +219500,149 @@
<implements name="java.lang.annotation.Annotation">
</implements>
</class>
<class name="RemoteViewsService"
 extends="android.app.Service"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="RemoteViewsService"
 type="android.widget.RemoteViewsService"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<method name="onBind"
 return="android.os.IBinder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
</method>
<method name="onGetViewFactory"
 return="android.widget.RemoteViewsService.RemoteViewsFactory"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
</method>
</class>
<interface name="RemoteViewsService.RemoteViewsFactory"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="getCount"
 return="int"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getItemId"
 return="long"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="position" type="int">
</parameter>
</method>
<method name="getLoadingView"
 return="android.widget.RemoteViews"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getViewAt"
 return="android.widget.RemoteViews"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="position" type="int">
</parameter>
</method>
<method name="getViewTypeCount"
 return="int"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="hasStableIds"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onCreate"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onDestroy"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</interface>
<class name="ResourceCursorAdapter"
 extends="android.widget.CursorAdapter"
 abstract="true"
+23 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public class AppWidgetHost {

    static final int HANDLE_UPDATE = 1;
    static final int HANDLE_PROVIDER_CHANGED = 2;
    static final int HANDLE_VIEW_DATA_CHANGED = 3;

    final static Object sServiceLock = new Object();
    static IAppWidgetService sService;
@@ -60,6 +61,14 @@ public class AppWidgetHost {
            msg.obj = info;
            msg.sendToTarget();
        }

        public void viewDataChanged(int appWidgetId, RemoteViews views, int viewId) {
            Message msg = mHandler.obtainMessage(HANDLE_VIEW_DATA_CHANGED);
            msg.arg1 = appWidgetId;
            msg.arg2 = viewId;
            msg.obj = views;
            msg.sendToTarget();
        }
    }

    class UpdateHandler extends Handler {
@@ -77,6 +86,10 @@ public class AppWidgetHost {
                    onProviderChanged(msg.arg1, (AppWidgetProviderInfo)msg.obj);
                    break;
                }
                case HANDLE_VIEW_DATA_CHANGED: {
                    viewDataChanged(msg.arg1, (RemoteViews) msg.obj, msg.arg2);
                    break;
                }
            }
        }
    }
@@ -250,6 +263,16 @@ public class AppWidgetHost {
            v.updateAppWidget(views);
        }
    }

    void viewDataChanged(int appWidgetId, RemoteViews views, int viewId) {
        AppWidgetHostView v;
        synchronized (mViews) {
            v = mViews.get(appWidgetId);
        }
        if (v != null) {
            v.viewDataChanged(views, viewId);
        }
    }
}

+19 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
@@ -257,6 +260,22 @@ public class AppWidgetHostView extends FrameLayout {
        }
    }

    /**
     * Process data-changed notifications for the specified view in the specified
     * set of {@link RemoteViews} views.
     */
    void viewDataChanged(RemoteViews remoteViews, int viewId) {
        View v = findViewById(viewId);
        if ((v != null) && (v instanceof AdapterView<?>)) {
            AdapterView<?> adapterView = (AdapterView<?>) v;
            Adapter adapter = adapterView.getAdapter();
            if (adapter instanceof BaseAdapter) {
                BaseAdapter baseAdapter = (BaseAdapter) adapter;
                baseAdapter.notifyDataSetChanged();
            }
        }
    }

    /**
     * Build a {@link Context} cloned into another package name, usually for the
     * purposes of reading remote resources.
+29 −0
Original line number Diff line number Diff line
@@ -287,6 +287,35 @@ public class AppWidgetManager {
        }
    }

    /**
     * Notifies the specified collection view in all the specified AppWidget instances
     * to invalidate their currently data.
     *
     * @param appWidgetIds  The AppWidget instances for which to notify of view data changes.
     * @param views         The RemoteViews which contains the view referenced at viewId.
     * @param viewId        The collection view id.
     */
    public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, RemoteViews views, int viewId) {
        try {
            sService.notifyAppWidgetViewDataChanged(appWidgetIds, views, viewId);
        }
        catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
        }
    }

    /**
     * Notifies the specified collection view in all the specified AppWidget instance
     * to invalidate it's currently data.
     *
     * @param appWidgetId  The AppWidget instance for which to notify of view data changes.
     * @param views         The RemoteViews which contains the view referenced at viewId.
     * @param viewId        The collection view id.
     */
    public void notifyAppWidgetViewDataChanged(int appWidgetId, RemoteViews views, int viewId) {
        notifyAppWidgetViewDataChanged(new int[] { appWidgetId }, views, viewId);
    }

    /**
     * Return a list of the AppWidget providers that are currently installed.
     */
Loading