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

Commit 90362ddd authored by Stevie Kideckel's avatar Stevie Kideckel Committed by Android (Google) Code Review
Browse files

Merge "Add checked change APIs to RemoteViews" into sc-dev

parents 7f1eadbe 289da0b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55077,6 +55077,7 @@ package android.widget {
    method public void setLabelFor(@IdRes int, @IdRes int);
    method public void setLightBackgroundLayoutId(@LayoutRes int);
    method public void setLong(@IdRes int, String, long);
    method public void setOnCheckedChangeResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
    method public void setOnClickFillInIntent(@IdRes int, android.content.Intent);
    method public void setOnClickPendingIntent(@IdRes int, android.app.PendingIntent);
    method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
@@ -55103,6 +55104,7 @@ package android.widget {
    method public void showPrevious(@IdRes int);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.widget.RemoteViews> CREATOR;
    field public static final String EXTRA_CHECKED = "android.widget.extra.CHECKED";
    field public static final String EXTRA_SHARED_ELEMENT_BOUNDS = "android.widget.extra.SHARED_ELEMENT_BOUNDS";
  }
+6 −6
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import android.os.ServiceManager;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.widget.RemoteViews;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.InteractionHandler;

import com.android.internal.R;
import com.android.internal.appwidget.IAppWidgetHost;
@@ -71,7 +71,7 @@ public class AppWidgetHost {
    private final int mHostId;
    private final Callbacks mCallbacks;
    private final SparseArray<AppWidgetHostView> mViews = new SparseArray<>();
    private OnClickHandler mOnClickHandler;
    private InteractionHandler mInteractionHandler;

    static class Callbacks extends IAppWidgetHost.Stub {
        private final WeakReference<Handler> mWeakHandler;
@@ -175,10 +175,10 @@ public class AppWidgetHost {
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public AppWidgetHost(Context context, int hostId, OnClickHandler handler, Looper looper) {
    public AppWidgetHost(Context context, int hostId, InteractionHandler handler, Looper looper) {
        mContextOpPackageName = context.getOpPackageName();
        mHostId = hostId;
        mOnClickHandler = handler;
        mInteractionHandler = handler;
        mHandler = new UpdateHandler(looper);
        mCallbacks = new Callbacks(mHandler);
        mDisplayMetrics = context.getResources().getDisplayMetrics();
@@ -401,7 +401,7 @@ public class AppWidgetHost {
            return null;
        }
        AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
        view.setOnClickHandler(mOnClickHandler);
        view.setInteractionHandler(mInteractionHandler);
        view.setAppWidget(appWidgetId, appWidget);
        synchronized (mViews) {
            mViews.put(appWidgetId, view);
@@ -423,7 +423,7 @@ public class AppWidgetHost {
     */
    protected AppWidgetHostView onCreateView(Context context, int appWidgetId,
            AppWidgetProviderInfo appWidget) {
        return new AppWidgetHostView(context, mOnClickHandler);
        return new AppWidgetHostView(context, mInteractionHandler);
    }

    /**
+13 −13
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.RemoteViews;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.InteractionHandler;
import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback;
import android.widget.TextView;

@@ -90,7 +90,7 @@ public class AppWidgetHostView extends FrameLayout {
    View mView;
    int mViewMode = VIEW_MODE_NOINIT;
    int mLayoutId = -1;
    private OnClickHandler mOnClickHandler;
    private InteractionHandler mInteractionHandler;
    private boolean mOnLightBackground;
    PointF mCurrentSize = null;

@@ -107,9 +107,9 @@ public class AppWidgetHostView extends FrameLayout {
    /**
     * @hide
     */
    public AppWidgetHostView(Context context, OnClickHandler handler) {
    public AppWidgetHostView(Context context, InteractionHandler handler) {
        this(context, android.R.anim.fade_in, android.R.anim.fade_out);
        mOnClickHandler = getHandler(handler);
        mInteractionHandler = getHandler(handler);
    }

    /**
@@ -135,8 +135,8 @@ public class AppWidgetHostView extends FrameLayout {
     * @param handler
     * @hide
     */
    public void setOnClickHandler(OnClickHandler handler) {
        mOnClickHandler = getHandler(handler);
    public void setInteractionHandler(InteractionHandler handler) {
        mInteractionHandler = getHandler(handler);
    }

    /**
@@ -518,7 +518,7 @@ public class AppWidgetHostView extends FrameLayout {
            // layout matches, try recycling it
            if (content == null && layoutId == mLayoutId) {
                try {
                    remoteViews.reapply(mContext, mView, mOnClickHandler);
                    remoteViews.reapply(mContext, mView, mInteractionHandler);
                    content = mView;
                    recycled = true;
                    if (LOGD) Log.d(TAG, "was able to recycle existing layout");
@@ -530,7 +530,7 @@ public class AppWidgetHostView extends FrameLayout {
            // Try normal RemoteView inflation
            if (content == null) {
                try {
                    content = remoteViews.apply(mContext, this, mOnClickHandler, mCurrentSize);
                    content = remoteViews.apply(mContext, this, mInteractionHandler, mCurrentSize);
                    if (LOGD) Log.d(TAG, "had to inflate new layout");
                } catch (RuntimeException e) {
                    exception = e;
@@ -582,7 +582,7 @@ public class AppWidgetHostView extends FrameLayout {
                        mView,
                        mAsyncExecutor,
                        new ViewApplyListener(remoteViews, layoutId, true),
                        mOnClickHandler,
                        mInteractionHandler,
                        mCurrentSize);
            } catch (Exception e) {
                // Reapply failed. Try apply
@@ -593,7 +593,7 @@ public class AppWidgetHostView extends FrameLayout {
                    this,
                    mAsyncExecutor,
                    new ViewApplyListener(remoteViews, layoutId, false),
                    mOnClickHandler,
                    mInteractionHandler,
                    mCurrentSize);
        }
    }
@@ -625,7 +625,7 @@ public class AppWidgetHostView extends FrameLayout {
                        AppWidgetHostView.this,
                        mAsyncExecutor,
                        new ViewApplyListener(mViews, mLayoutId, false),
                        mOnClickHandler,
                        mInteractionHandler,
                        mCurrentSize);
            } else {
                applyContent(null, false, e);
@@ -808,11 +808,11 @@ public class AppWidgetHostView extends FrameLayout {
        return null;
    }

    private OnClickHandler getHandler(OnClickHandler handler) {
    private InteractionHandler getHandler(InteractionHandler handler) {
        return (view, pendingIntent, response) -> {
            AppWidgetManager.getInstance(mContext).noteAppWidgetTapped(mAppWidgetId);
            if (handler != null) {
                return handler.onClickHandler(view, pendingIntent, response);
                return handler.onInteraction(view, pendingIntent, response);
            } else {
                return RemoteViews.startPendingIntent(view, pendingIntent,
                        response.getLaunchOptions(view));
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.SurroundingText;
import android.view.inspector.InspectableProperty;
import android.view.inspector.InspectableProperty.EnumEntry;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.InteractionHandler;

import com.android.internal.R;

@@ -6419,11 +6419,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     *
     * @hide
     */
    public void setRemoteViewsOnClickHandler(OnClickHandler handler) {
    public void setRemoteViewsInteractionHandler(InteractionHandler handler) {
        // Ensure that we don't already have a RemoteViewsAdapter that is bound to an existing
        // service handling the specified intent.
        if (mRemoteAdapter != null) {
            mRemoteAdapter.setRemoteViewsOnClickHandler(handler);
            mRemoteAdapter.setRemoteViewsInteractionHandler(handler);
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.InteractionHandler;

import java.util.ArrayList;
import java.util.HashMap;
@@ -1016,11 +1016,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * 
     * @hide
     */
    public void setRemoteViewsOnClickHandler(OnClickHandler handler) {
    public void setRemoteViewsOnClickHandler(InteractionHandler handler) {
        // Ensure that we don't already have a RemoteViewsAdapter that is bound to an existing
        // service handling the specified intent.
        if (mRemoteViewsAdapter != null) {
            mRemoteViewsAdapter.setRemoteViewsOnClickHandler(handler);
            mRemoteViewsAdapter.setRemoteViewsInteractionHandler(handler);
        }
    }

Loading