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

Commit cd161864 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes I3ef361bd,I89a5184c

* changes:
  Refactor PiP logic in preparation for expanded state.
  Modifying RemoteAction callback to PendingIntent.
parents d9b6cf1f 2a82fe58
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -5677,10 +5677,11 @@ package android.app {
  }
  public final class RemoteAction implements android.os.Parcelable {
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.RemoteAction.OnActionListener);
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent);
    method public android.app.RemoteAction clone();
    method public int describeContents();
    method public void dump(java.lang.String, java.io.PrintWriter);
    method public android.app.PendingIntent getActionIntent();
    method public java.lang.CharSequence getContentDescription();
    method public android.graphics.drawable.Icon getIcon();
    method public java.lang.CharSequence getTitle();
@@ -5688,10 +5689,6 @@ package android.app {
    field public static final android.os.Parcelable.Creator<android.app.RemoteAction> CREATOR;
  }
  public static abstract interface RemoteAction.OnActionListener {
    method public abstract void onAction(android.app.RemoteAction);
  }
  public final class RemoteInput implements android.os.Parcelable {
    method public static void addDataResultToIntent(android.app.RemoteInput, android.content.Intent, java.util.Map<java.lang.String, android.net.Uri>);
    method public static void addResultsToIntent(android.app.RemoteInput[], android.content.Intent, android.os.Bundle);
+2 −5
Original line number Diff line number Diff line
@@ -5873,10 +5873,11 @@ package android.app {
  }
  public final class RemoteAction implements android.os.Parcelable {
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.RemoteAction.OnActionListener);
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent);
    method public android.app.RemoteAction clone();
    method public int describeContents();
    method public void dump(java.lang.String, java.io.PrintWriter);
    method public android.app.PendingIntent getActionIntent();
    method public java.lang.CharSequence getContentDescription();
    method public android.graphics.drawable.Icon getIcon();
    method public java.lang.CharSequence getTitle();
@@ -5884,10 +5885,6 @@ package android.app {
    field public static final android.os.Parcelable.Creator<android.app.RemoteAction> CREATOR;
  }
  public static abstract interface RemoteAction.OnActionListener {
    method public abstract void onAction(android.app.RemoteAction);
  }
  public final class RemoteInput implements android.os.Parcelable {
    method public static void addDataResultToIntent(android.app.RemoteInput, android.content.Intent, java.util.Map<java.lang.String, android.net.Uri>);
    method public static void addResultsToIntent(android.app.RemoteInput[], android.content.Intent, android.os.Bundle);
+2 −5
Original line number Diff line number Diff line
@@ -5688,10 +5688,11 @@ package android.app {
  }
  public final class RemoteAction implements android.os.Parcelable {
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.RemoteAction.OnActionListener);
    ctor public RemoteAction(android.graphics.drawable.Icon, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent);
    method public android.app.RemoteAction clone();
    method public int describeContents();
    method public void dump(java.lang.String, java.io.PrintWriter);
    method public android.app.PendingIntent getActionIntent();
    method public java.lang.CharSequence getContentDescription();
    method public android.graphics.drawable.Icon getIcon();
    method public java.lang.CharSequence getTitle();
@@ -5699,10 +5700,6 @@ package android.app {
    field public static final android.os.Parcelable.Creator<android.app.RemoteAction> CREATOR;
  }
  public static abstract interface RemoteAction.OnActionListener {
    method public abstract void onAction(android.app.RemoteAction);
  }
  public final class RemoteInput implements android.os.Parcelable {
    method public static void addDataResultToIntent(android.app.RemoteInput, android.content.Intent, java.util.Map<java.lang.String, android.net.Uri>);
    method public static void addResultsToIntent(android.app.RemoteInput[], android.content.Intent, android.os.Bundle);
+11 −42
Original line number Diff line number Diff line
@@ -35,55 +35,30 @@ import java.io.PrintWriter;
 */
public final class RemoteAction implements Parcelable {

    /**
     * Interface definition for a callback to be invoked when an action is invoked.
     */
    public interface OnActionListener {
        /**
         * Called when the associated action is invoked.
         *
         * @param action The action that was invoked.
         */
        void onAction(RemoteAction action);
    }

    private static final String TAG = "RemoteAction";

    private static final int MESSAGE_ACTION_INVOKED = 1;

    private final Icon mIcon;
    private final CharSequence mTitle;
    private final CharSequence mContentDescription;
    private OnActionListener mActionCallback;
    private final Messenger mMessenger;
    private final PendingIntent mActionIntent;

    RemoteAction(Parcel in) {
        mIcon = Icon.CREATOR.createFromParcel(in);
        mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        mMessenger = in.readParcelable(Messenger.class.getClassLoader());
        mActionIntent = PendingIntent.CREATOR.createFromParcel(in);
    }

    public RemoteAction(@NonNull Icon icon, @NonNull CharSequence title,
            @NonNull CharSequence contentDescription, @NonNull OnActionListener callback) {
        if (icon == null || title == null || contentDescription == null || callback == null) {
            @NonNull CharSequence contentDescription, @NonNull PendingIntent intent) {
        if (icon == null || title == null || contentDescription == null || intent == null) {
            throw new IllegalArgumentException("Expected icon, title, content description and " +
                    "action callback");
        }
        mIcon = icon;
        mTitle = title;
        mContentDescription = contentDescription;
        mActionCallback = callback;
        mMessenger = new Messenger(new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case MESSAGE_ACTION_INVOKED:
                        mActionCallback.onAction(RemoteAction.this);
                        break;
                }
            }
        });
        mActionIntent = intent;
    }

    /**
@@ -108,22 +83,15 @@ public final class RemoteAction implements Parcelable {
    }

    /**
     * Sends a message that the action was invoked.
     * @hide
     * Return the action intent.
     */
    public void sendActionInvoked() {
        Message m = Message.obtain();
        m.what = MESSAGE_ACTION_INVOKED;
        try {
            mMessenger.send(m);
        } catch (RemoteException e) {
            Log.e(TAG, "Could not send action-invoked", e);
        }
    public @NonNull PendingIntent getActionIntent() {
        return mActionIntent;
    }

    @Override
    public RemoteAction clone() {
        return new RemoteAction(mIcon, mTitle, mContentDescription, mActionCallback);
        return new RemoteAction(mIcon, mTitle, mContentDescription, mActionIntent);
    }

    @Override
@@ -136,7 +104,7 @@ public final class RemoteAction implements Parcelable {
        mIcon.writeToParcel(out, 0);
        TextUtils.writeToParcel(mTitle, out, flags);
        TextUtils.writeToParcel(mContentDescription, out, flags);
        out.writeParcelable(mMessenger, flags);
        mActionIntent.writeToParcel(out, flags);
    }

    public void dump(String prefix, PrintWriter pw) {
@@ -144,6 +112,7 @@ public final class RemoteAction implements Parcelable {
        pw.print("title=" + mTitle);
        pw.print(" contentDescription=" + mContentDescription);
        pw.print(" icon=" + mIcon);
        pw.print(" action=" + mActionIntent.getIntent());
        pw.println();
    }

+1 −13
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.view;

import android.graphics.Rect;

/**
 * An interface to the PinnedStackController to update it of state changes, and to query
 * information based on the current state.
@@ -27,17 +25,7 @@ import android.graphics.Rect;
interface IPinnedStackController {

    /**
     * Notifies the controller that the user is currently interacting with the PIP.
     */
    oneway void setInInteractiveMode(boolean inInteractiveMode);

    /**
     * Notifies the controller that the PIP is currently minimized.
     * Notifies the controller that the PiP is currently minimized.
     */
    oneway void setIsMinimized(boolean isMinimized);

    /**
     * Notifies the controller that the desired snap mode is to the closest edge.
     */
    oneway void setSnapToEdge(boolean snapToEdge);
}
Loading