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

Commit 53790c1c authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge changes from topic "notification_reply_action" into pi-dev

* changes:
  Cleaned up the paddings of the messaging layout and smart replies
  Changed the size of the largeIcon
  Moved the disabling from alpha to manual color blending
  Updated the color of the reply button to be more neutral
  Updated the reply icon
  Disabled reply action when pending intents are cancelled
  Split the reply icon permanently from the right icon
parents 5f18904a 1c72fa02
Loading
Loading
Loading
Loading
+208 −107

File changed.

Preview size limit exceeded, changes collapsed.

+87 −0
Original line number Diff line number Diff line
@@ -33,8 +33,11 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.AndroidException;
import android.util.ArraySet;
import android.util.proto.ProtoOutputStream;

import com.android.internal.os.IResultReceiver;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -93,7 +96,9 @@ import java.lang.annotation.RetentionPolicy;
 */
public final class PendingIntent implements Parcelable {
    private final IIntentSender mTarget;
    private IResultReceiver mCancelReceiver;
    private IBinder mWhitelistToken;
    private ArraySet<CancelListener> mCancelListeners;

    /** @hide */
    @IntDef(flag = true,
@@ -963,6 +968,74 @@ public final class PendingIntent implements Parcelable {
        }
    }

    /**
     * Register a listener to when this pendingIntent is cancelled. There are no guarantees on which
     * thread a listener will be called and it's up to the caller to synchronize. This may
     * trigger a synchronous binder call so should therefore usually be called on a background
     * thread.
     *
     * @hide
     */
    public void registerCancelListener(CancelListener cancelListener) {
        synchronized (this) {
            if (mCancelReceiver == null) {
                mCancelReceiver = new IResultReceiver.Stub() {
                    @Override
                    public void send(int resultCode, Bundle resultData) throws RemoteException {
                        notifyCancelListeners();
                    }
                };
            }
            if (mCancelListeners == null) {
                mCancelListeners = new ArraySet<>();
            }
            boolean wasEmpty = mCancelListeners.isEmpty();
            mCancelListeners.add(cancelListener);
            if (wasEmpty) {
                try {
                    ActivityManager.getService().registerIntentSenderCancelListener(mTarget,
                            mCancelReceiver);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
            }
        }
    }

    private void notifyCancelListeners() {
        ArraySet<CancelListener> cancelListeners;
        synchronized (this) {
            cancelListeners = new ArraySet<>(mCancelListeners);
        }
        int size = cancelListeners.size();
        for (int i = 0; i < size; i++) {
            cancelListeners.valueAt(i).onCancelled(this);
        }
    }

    /**
     * Un-register a listener to when this pendingIntent is cancelled.
     *
     * @hide
     */
    public void unregisterCancelListener(CancelListener cancelListener) {
        synchronized (this) {
            if (mCancelListeners == null) {
                return;
            }
            boolean wasEmpty = mCancelListeners.isEmpty();
            mCancelListeners.remove(cancelListener);
            if (mCancelListeners.isEmpty() && !wasEmpty) {
                try {
                    ActivityManager.getService().unregisterIntentSenderCancelListener(mTarget,
                            mCancelReceiver);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
            }
        }
    }

    /**
     * Return the user handle of the application that created this
     * PendingIntent, that is the user under which you will actually be
@@ -1184,4 +1257,18 @@ public final class PendingIntent implements Parcelable {
    public IBinder getWhitelistToken() {
        return mWhitelistToken;
    }

    /**
     * A listener to when a pending intent is cancelled
     *
     * @hide
     */
    public interface CancelListener {
        /**
         * Called when a Pending Intent is cancelled.
         *
         * @param intent The intent that was cancelled.
         */
        void onCancelled(PendingIntent intent);
    }
}
+21 −2
Original line number Diff line number Diff line
@@ -946,6 +946,7 @@ public class RemoteViews implements Parcelable, Filter {
                    }
                };
            }
            target.setTagInternal(R.id.pending_intent_tag, pendingIntent);
            target.setOnClickListener(listener);
        }

@@ -1999,6 +2000,7 @@ public class RemoteViews implements Parcelable, Filter {
        /** Set width */
        public static final int LAYOUT_WIDTH = 2;
        public static final int LAYOUT_MARGIN_BOTTOM_DIMEN = 3;
        public static final int LAYOUT_MARGIN_END = 4;

        final int mProperty;
        final int mValue;
@@ -2036,11 +2038,14 @@ public class RemoteViews implements Parcelable, Filter {
            if (layoutParams == null) {
                return;
            }
            int value = mValue;
            switch (mProperty) {
                case LAYOUT_MARGIN_END_DIMEN:
                    value = resolveDimenPixelOffset(target, mValue);
                    // fall-through
                case LAYOUT_MARGIN_END:
                    if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                        int resolved = resolveDimenPixelOffset(target, mValue);
                        ((ViewGroup.MarginLayoutParams) layoutParams).setMarginEnd(resolved);
                        ((ViewGroup.MarginLayoutParams) layoutParams).setMarginEnd(value);
                        target.setLayoutParams(layoutParams);
                    }
                    break;
@@ -2979,6 +2984,20 @@ public class RemoteViews implements Parcelable, Filter {
                endMarginDimen));
    }

    /**
     * Equivalent to calling {@link android.view.ViewGroup.MarginLayoutParams#setMarginEnd(int)}.
     * Only works if the {@link View#getLayoutParams()} supports margins.
     * Hidden for now since we don't want to support this for all different layout margins yet.
     *
     * @param viewId The id of the view to change
     * @param endMargin a value in pixels for the end margin.
     * @hide
     */
    public void setViewLayoutMarginEnd(int viewId, @DimenRes int endMargin) {
        addAction(new LayoutParamAction(viewId, LayoutParamAction.LAYOUT_MARGIN_END,
                endMargin));
    }

    /**
     * Equivalent to setting {@link android.view.ViewGroup.MarginLayoutParams#bottomMargin}.
     *
+7 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class ImageFloatingTextView extends TextView {
    private boolean mFirstMeasure = true;
    private int mLayoutMaxLines = -1;
    private boolean mBlockLayouts;
    private int mImageEndMargin;

    public ImageFloatingTextView(Context context) {
        this(context, null);
@@ -98,13 +99,11 @@ public class ImageFloatingTextView extends TextView {
        }

        // we set the endmargin on the requested number of lines.
        int endMargin = getContext().getResources().getDimensionPixelSize(
                R.dimen.notification_content_picture_margin);
        int[] margins = null;
        if (mIndentLines > 0) {
            margins = new int[mIndentLines + 1];
            for (int i = 0; i < mIndentLines; i++) {
                margins[i] = endMargin;
                margins[i] = mImageEndMargin;
            }
        }
        if (mResolvedDirection == LAYOUT_DIRECTION_RTL) {
@@ -116,6 +115,11 @@ public class ImageFloatingTextView extends TextView {
        return builder.build();
    }

    @RemotableViewMethod
    public void setImageEndMargin(int imageEndMargin) {
        mImageEndMargin = imageEndMargin;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int height = MeasureSpec.getSize(heightMeasureSpec);
+7 −1
Original line number Diff line number Diff line
@@ -416,10 +416,16 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
            mImageContainer.removeAllViews();
        }
        mIsolatedMessage = isolatedMessage;
        updateImageContainerVisibility();
        mMessages = group;
        updateMessageColor();
    }

    private void updateImageContainerVisibility() {
        mImageContainer.setVisibility(mIsolatedMessage != null && mImagesAtEnd
                ? View.VISIBLE : View.GONE);
    }

    /**
     * Remove the message from the parent if the parent isn't the one provided
     * @return whether the message was removed
@@ -519,7 +525,7 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
    public void setDisplayImagesAtEnd(boolean atEnd) {
        if (mImagesAtEnd != atEnd) {
            mImagesAtEnd = atEnd;
            mImageContainer.setVisibility(atEnd ? View.VISIBLE : View.GONE);
            updateImageContainerVisibility();
        }
    }

Loading