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

Commit de4de0e2 authored by Selim Cinek's avatar Selim Cinek
Browse files

Added the reply draft as an extra to the content intent

Change-Id: I406833a5875221731baf0834f2e47e283b84aae9
Fixes: 36858677
Test: Add notification, draft reply and click on it. Ensure that extra is sent
parent 7fa385ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5224,6 +5224,7 @@ package android.app {
    field public static final java.lang.String EXTRA_PROGRESS = "android.progress";
    field public static final java.lang.String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
    field public static final java.lang.String EXTRA_PROGRESS_MAX = "android.progressMax";
    field public static final java.lang.String EXTRA_REMOTE_INPUT_DRAFT = "android.remoteInputDraft";
    field public static final java.lang.String EXTRA_REMOTE_INPUT_HISTORY = "android.remoteInputHistory";
    field public static final deprecated java.lang.String EXTRA_SELF_DISPLAY_NAME = "android.selfDisplayName";
    field public static final java.lang.String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";
+10 −0
Original line number Diff line number Diff line
@@ -200,6 +200,16 @@ public class Notification implements Parcelable
     */
    private static final int MAX_REPLY_HISTORY = 5;


    /**
     * If the notification contained an unsent draft for a RemoteInput when the user clicked on it,
     * we're adding the draft as a String extra to the {@link #contentIntent} using this key.
     *
     * <p>Apps may use this extra to prepopulate text fields in the app, where the user usually
     * sends messages.</p>
     */
    public static final String EXTRA_REMOTE_INPUT_DRAFT = "android.remoteInputDraft";

    /**
     * A timestamp related to this notification, in milliseconds since the epoch.
     *
+5 −0
Original line number Diff line number Diff line
@@ -1458,6 +1458,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mMenuRow.resetMenu();
    }

    public CharSequence getActiveRemoteInputText() {
        return mPrivateLayout.getActiveRemoteInputText();
    }


    public void animateTranslateNotification(final float leftTarget) {
        if (mTranslateAnim != null) {
            mTranslateAnim.cancel();
+10 −0
Original line number Diff line number Diff line
@@ -1563,4 +1563,14 @@ public class NotificationContentView extends FrameLayout {
        }
        return visibleWrapper.shouldClipToRounding(topRounded, bottomRounded);
    }

    public CharSequence getActiveRemoteInputText() {
        if (mExpandedRemoteInput != null && mExpandedRemoteInput.isActive()) {
            return mExpandedRemoteInput.getText();
        }
        if (mHeadsUpRemoteInput != null && mHeadsUpRemoteInput.isActive()) {
            return mHeadsUpRemoteInput.getText();
        }
        return null;
    }
}
+20 −2
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
import android.text.SpannedString;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
@@ -4937,9 +4939,25 @@ public class StatusBar extends SystemUI implements DemoMode,
                            }
                        }
                    }
                    Intent fillInIntent = null;
                    Entry entry = row.getEntry();
                    CharSequence remoteInputText = null;
                    RemoteInputController controller = mRemoteInputManager.getController();
                    if (controller.isRemoteInputActive(entry)) {
                        remoteInputText = row.getActiveRemoteInputText();
                    }
                    if (TextUtils.isEmpty(remoteInputText)
                            && !TextUtils.isEmpty(entry.remoteInputText)) {
                        remoteInputText = entry.remoteInputText;
                    }
                    if (!TextUtils.isEmpty(remoteInputText)
                            && !controller.isSpinning(entry.key)) {
                        fillInIntent = new Intent().putExtra(Notification.EXTRA_REMOTE_INPUT_DRAFT,
                                remoteInputText.toString());
                    }
                    try {
                        launchResult = intent.sendAndReturnResult(null, 0, null, null, null, null,
                                getActivityOptions(row));
                        launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null,
                                null, null, getActivityOptions(row));
                    } catch (PendingIntent.CanceledException e) {
                        // the stack trace isn't very helpful here.
                        // Just log the exception message.
Loading