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

Commit 7b9ed0d8 authored by Adrian Roos's avatar Adrian Roos
Browse files

DirectReply: Show historic messages

Test: Post notification with MessagingStyle.addHistoricMessage(), verify they show up while direct replying.
Change-Id: I26b801d05305a5251fe0d6fae1fe1c24064105a9
parent 000f7cd6
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -974,7 +974,6 @@ public class NotificationContentView extends FrameLayout {
        mStatusBarNotification = entry.notification;
        mBeforeN = entry.targetSdk < Build.VERSION_CODES.N;
        updateSingleLineView();
        applyRemoteInput(entry);
        if (mContractedChild != null) {
            mContractedWrapper.notifyContentUpdated(entry.notification);
        }
@@ -987,6 +986,7 @@ public class NotificationContentView extends FrameLayout {
        if (mAmbientChild != null) {
            mAmbientWrapper.notifyContentUpdated(entry.notification);
        }
        applyRemoteInput(entry);
        updateShowingLegacyBackground();
        mForceSelectNextLayout = true;
        setDark(mDark, false /* animate */, 0 /* delay */);
@@ -1028,7 +1028,8 @@ public class NotificationContentView extends FrameLayout {
        View bigContentView = mExpandedChild;
        if (bigContentView != null) {
            mExpandedRemoteInput = applyRemoteInput(bigContentView, entry, hasRemoteInput,
                    mPreviousExpandedRemoteInputIntent, mCachedExpandedRemoteInput);
                    mPreviousExpandedRemoteInputIntent, mCachedExpandedRemoteInput,
                    mExpandedWrapper);
        } else {
            mExpandedRemoteInput = null;
        }
@@ -1042,7 +1043,7 @@ public class NotificationContentView extends FrameLayout {
        View headsUpContentView = mHeadsUpChild;
        if (headsUpContentView != null) {
            mHeadsUpRemoteInput = applyRemoteInput(headsUpContentView, entry, hasRemoteInput,
                    mPreviousHeadsUpRemoteInputIntent, mCachedHeadsUpRemoteInput);
                    mPreviousHeadsUpRemoteInputIntent, mCachedHeadsUpRemoteInput, mHeadsUpWrapper);
        } else {
            mHeadsUpRemoteInput = null;
        }
@@ -1056,7 +1057,7 @@ public class NotificationContentView extends FrameLayout {

    private RemoteInputView applyRemoteInput(View view, NotificationData.Entry entry,
            boolean hasRemoteInput, PendingIntent existingPendingIntent,
            RemoteInputView cachedView) {
            RemoteInputView cachedView, NotificationViewWrapper wrapper) {
        View actionContainerCandidate = view.findViewById(
                com.android.internal.R.id.actions_container);
        if (actionContainerCandidate instanceof FrameLayout) {
@@ -1095,6 +1096,8 @@ public class NotificationContentView extends FrameLayout {
                        mContext.getColor(R.color.remote_input_text_enabled),
                        mContext.getColor(R.color.remote_input_hint)));

                existing.setWrapper(wrapper);

                if (existingPendingIntent != null || existing.isActive()) {
                    // The current action could be gone, or the pending intent no longer valid.
                    // If we find a matching action in the new notification, focus, otherwise close.
+21 −2
Original line number Diff line number Diff line
@@ -22,7 +22,11 @@ import com.android.systemui.statusbar.TransformableView;

import android.content.Context;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Wraps a notification containing a messaging template
@@ -30,6 +34,7 @@ import android.view.View;
public class NotificationMessagingTemplateViewWrapper extends NotificationTemplateViewWrapper {

    private View mContractedMessage;
    private ArrayList<View> mHistoricMessages = new ArrayList<View>();

    protected NotificationMessagingTemplateViewWrapper(Context ctx, View view,
            ExpandableNotificationRow row) {
@@ -44,11 +49,18 @@ public class NotificationMessagingTemplateViewWrapper extends NotificationTempla
                && ((MessagingLinearLayout) container).getChildCount() > 0) {
            MessagingLinearLayout messagingContainer = (MessagingLinearLayout) container;

            // Only consider the first visible child - transforming to a position other than the
            // first looks bad because we have to move across other messages that are fading in.
            int childCount = messagingContainer.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View child = messagingContainer.getChildAt(i);

                if (child.getVisibility() == View.GONE
                        && child instanceof TextView
                        && !TextUtils.isEmpty(((TextView) child).getText())) {
                    mHistoricMessages.add(child);
                }

                // Only consider the first visible child - transforming to a position other than the
                // first looks bad because we have to move across other messages that are fading in.
                if (child.getId() == messagingContainer.getContractedChildId()) {
                    mContractedMessage = child;
                } else if (child.getVisibility() == View.VISIBLE) {
@@ -75,4 +87,11 @@ public class NotificationMessagingTemplateViewWrapper extends NotificationTempla
                    mContractedMessage);
        }
    }

    @Override
    public void setRemoteInputVisible(boolean visible) {
        for (int i = 0; i < mHistoricMessages.size(); i++) {
            mHistoricMessages.get(i).setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -163,4 +163,7 @@ public abstract class NotificationViewWrapper implements TransformableView {

    public void setContentHeight(int contentHeight, int minHeightHint) {
    }

    public void setRemoteInputVisible(boolean visible) {
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.notification.NotificationViewWrapper;
import com.android.systemui.statusbar.stack.ScrollContainer;
import com.android.systemui.statusbar.stack.StackStateAnimator;

@@ -90,6 +91,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
    private int mRevealR;

    private boolean mResetting;
    private NotificationViewWrapper mWrapper;

    public RemoteInputView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -210,11 +212,17 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        setVisibility(INVISIBLE);
                        if (mWrapper != null) {
                            mWrapper.setRemoteInputVisible(false);
                        }
                    }
                });
                reveal.start();
            } else {
                setVisibility(INVISIBLE);
                if (mWrapper != null) {
                    mWrapper.setRemoteInputVisible(false);
                }
            }
        }
        MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_CLOSE,
@@ -267,6 +275,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
                mEntry.notification.getPackageName());

        setVisibility(VISIBLE);
        if (mWrapper != null) {
            mWrapper.setRemoteInputVisible(true);
        }
        mController.addRemoteInput(mEntry, mToken);
        mEditText.setInnerFocusable(true);
        mEditText.mShowImeOnInputConnection = true;
@@ -283,6 +294,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
            // Update came in after we sent the reply, time to reset.
            reset();
        }

        if (isActive() && mWrapper != null) {
            mWrapper.setRemoteInputVisible(true);
        }
    }

    private void reset() {
@@ -452,6 +467,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
        super.dispatchFinishTemporaryDetach();
    }

    public void setWrapper(NotificationViewWrapper wrapper) {
        mWrapper = wrapper;
    }

    /**
     * An EditText that changes appearance based on whether it's focusable and becomes
     * un-focusable whenever the user navigates away from it or it becomes invisible.