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

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

Merge "Allow inline replying directly from the image"

parents 528fa948 5d6ef8de
Loading
Loading
Loading
Loading
+57 −4
Original line number Diff line number Diff line
@@ -2742,6 +2742,11 @@ public class Notification implements Parcelable
        private int mBackgroundColor = COLOR_INVALID;
        private int mForegroundColor = COLOR_INVALID;
        private int mBackgroundColorHint = COLOR_INVALID;
        /**
         * A temporary location where actions are stored. If != null the view originally has action
         * but doesn't have any for this inflation.
         */
        private ArrayList<Action> mOriginalActions;
        private boolean mRebuildStyledRemoteViews;

        /**
@@ -4054,8 +4059,54 @@ public class Notification implements Parcelable
                contentView.setViewLayoutMarginEndDimen(R.id.line1, endMargin);
                contentView.setViewLayoutMarginEndDimen(R.id.text, endMargin);
                contentView.setViewLayoutMarginEndDimen(R.id.progress, endMargin);
                // Bind the reply action
                Action action = findReplyAction();
                contentView.setViewVisibility(R.id.reply_icon_action, action != null
                        ? View.VISIBLE
                        : View.GONE);

                if (action != null) {
                    int contrastColor = resolveContrastColor();
                    contentView.setDrawableParameters(R.id.reply_icon_action,
                            true /* targetBackground */,
                            -1,
                            contrastColor,
                            PorterDuff.Mode.SRC_ATOP, -1);
                    int iconColor = NotificationColorUtil.isColorLight(contrastColor)
                            ? Color.BLACK : Color.WHITE;
                    contentView.setDrawableParameters(R.id.reply_icon_action,
                            false /* targetBackground */,
                            -1,
                            iconColor,
                            PorterDuff.Mode.SRC_ATOP, -1);
                    contentView.setOnClickPendingIntent(R.id.right_icon,
                            action.actionIntent);
                    contentView.setOnClickPendingIntent(R.id.reply_icon_action,
                            action.actionIntent);
                    contentView.setRemoteInputs(R.id.right_icon, action.mRemoteInputs);
                    contentView.setRemoteInputs(R.id.reply_icon_action, action.mRemoteInputs);

                }
            }
            contentView.setViewVisibility(R.id.right_icon_container, mN.mLargeIcon != null
                    ? View.VISIBLE
                    : View.GONE);
        }

        private Action findReplyAction() {
            ArrayList<Action> actions = mActions;
            if (mOriginalActions != null) {
                actions = mOriginalActions;
            }
            int numActions = actions.size();
            for (int i = 0; i < numActions; i++) {
                Action action = actions.get(i);
                if (hasValidRemoteInput(action)) {
                    return action;
                }
            }
            return null;
        }

        private void bindNotificationHeader(RemoteViews contentView, boolean ambient) {
            bindSmallIcon(contentView, ambient);
@@ -5604,10 +5655,11 @@ public class Notification implements Parcelable
        @Override
        public RemoteViews makeContentView(boolean increasedHeight) {
            if (increasedHeight) {
                ArrayList<Action> actions = mBuilder.mActions;
                mBuilder.mOriginalActions = mBuilder.mActions;
                mBuilder.mActions = new ArrayList<>();
                RemoteViews remoteViews = makeBigContentView();
                mBuilder.mActions = actions;
                mBuilder.mActions = mBuilder.mOriginalActions;
                mBuilder.mOriginalActions = null;
                return remoteViews;
            }
            return super.makeContentView(increasedHeight);
@@ -5891,10 +5943,11 @@ public class Notification implements Parcelable
                return mBuilder.applyStandardTemplate(mBuilder.getBaseLayoutResource(),
                        mBuilder.mParams.reset().hasProgress(false).title(title).text(text));
            } else {
                ArrayList<Action> actions = mBuilder.mActions;
                mBuilder.mOriginalActions = mBuilder.mActions;
                mBuilder.mActions = new ArrayList<>();
                RemoteViews remoteViews = makeBigContentView();
                mBuilder.mActions = actions;
                mBuilder.mActions = mBuilder.mOriginalActions;
                mBuilder.mOriginalActions = null;
                return remoteViews;
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -2191,7 +2191,7 @@ public class RemoteViews implements Parcelable, Filter {

        @Override
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final TextView target = (TextView) root.findViewById(viewId);
            final View target = root.findViewById(viewId);
            if (target == null) return;

            target.setTagInternal(R.id.remote_input_tag, remoteInputs);
+27 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2017 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="10dp"
        android:height="10dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M10.0,9.0L10.0,5.0l-7.0,7.0 7.0,7.0l0.0,-4.1c5.0,0.0 8.5,1.6 11.0,5.1 -1.0,-5.0 -4.0,-10.0 -11.0,-11.0z"/>
    <path
        android:pathData="M0 0h24v24H0z"
        android:fillColor="#00000000"/>
</vector>
+24 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2017 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid
        android:color="#ff757575"/>
    <size
        android:width="16dp"
        android:height="16dp"/>
</shape>
+23 −9
Original line number Diff line number Diff line
@@ -15,13 +15,27 @@
  ~ limitations under the License
  -->

<ImageView android:id="@+id/right_icon" xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/right_icon_container"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="top|end">
    <ImageView android:id="@+id/right_icon"
               android:layout_width="40dp"
               android:layout_height="40dp"
    android:layout_marginEnd="@dimen/notification_content_margin_end"
               android:layout_gravity="top|end"
               android:layout_marginTop="36dp"
               android:layout_marginEnd="@dimen/notification_content_margin_end"
               android:scaleType="centerCrop"/>
    <ImageView android:id="@+id/reply_icon_action"
               android:layout_width="16dp"
               android:layout_height="16dp"
               android:layout_gravity="top|end"
    android:scaleType="centerCrop"
    />

               android:layout_marginTop="64dp"
               android:layout_marginEnd="12dp"
               android:background="@drawable/notification_reply_background"
               android:src="@drawable/ic_reply_notification"
               android:scaleType="center"
               visiblity="gone"/>
</FrameLayout>
Loading