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

Commit 1d724e02 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Move RemoteInputView inflation to ContentView"

parents db08925a b88b1a1d
Loading
Loading
Loading
Loading
+3 −75
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ public abstract class BaseStatusBar extends SystemUI implements

    protected NotificationGroupManager mGroupManager = new NotificationGroupManager();

    protected RemoteInputController mRemoteInputController;

    // for heads up notifications
    protected HeadsUpManager mHeadsUpManager;

@@ -1417,6 +1419,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                    parent, false);
            row.setExpansionLogger(this, entry.notification.getKey());
            row.setGroupManager(mGroupManager);
            row.setRemoteInputController(mRemoteInputController);
            row.setOnExpandClickListener(this);
        }

@@ -1587,7 +1590,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
        row.setUserLocked(userLocked);
        row.onNotificationUpdated(entry);
        applyRemoteInput(entry);
        return true;
    }

@@ -1630,78 +1632,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    private void applyRemoteInput(final Entry entry) {
        if (!ENABLE_REMOTE_INPUT) return;

        boolean hasRemoteInput = false;

        Notification.Action[] actions = entry.notification.getNotification().actions;
        if (actions != null) {
            for (Notification.Action a : actions) {
                if (a.getRemoteInputs() != null) {
                    for (RemoteInput ri : a.getRemoteInputs()) {
                        if (ri.getAllowFreeFormInput()) {
                            hasRemoteInput = true;
                            break;
                        }
                    }
                }
            }
        }

        View bigContentView = entry.getExpandedContentView();
        if (bigContentView != null) {
            applyRemoteInput(bigContentView, entry, hasRemoteInput);
        }
        View headsUpContentView = entry.getHeadsUpContentView();
        if (headsUpContentView != null) {
            applyRemoteInput(headsUpContentView, entry, hasRemoteInput);
        }

    }

    private RemoteInputView applyRemoteInput(View view, Entry entry, boolean hasRemoteInput) {
        View actionContainerCandidate = view.findViewById(
                com.android.internal.R.id.actions_container);
        if (actionContainerCandidate instanceof FrameLayout) {
            RemoteInputView existing = (RemoteInputView)
                    view.findViewWithTag(RemoteInputView.VIEW_TAG);

            if (hasRemoteInput) {
                if (existing != null) {
                    existing.onNotificationUpdate();
                    return existing;
                }

                ViewGroup actionContainer = (FrameLayout) actionContainerCandidate;
                RemoteInputView riv = inflateRemoteInputView(actionContainer, entry);
                if (riv != null) {
                    riv.setVisibility(View.INVISIBLE);
                    actionContainer.addView(riv, new FrameLayout.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT)
                    );
                    int color = entry.notification.getNotification().color;
                    if (color == Notification.COLOR_DEFAULT) {
                        color = mContext.getColor(R.color.default_remote_input_background);
                    }
                    riv.setBackgroundColor(color);
                    return riv;
                }
            } else {
                if (existing != null) {
                    existing.onNotificationUpdate();
                    return null;
                }
            }
        }
        return null;
    }

    protected RemoteInputView inflateRemoteInputView(ViewGroup root, Entry entry) {
        return null;
    }

    public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
        if (!isDeviceProvisioned()) return;

@@ -2230,8 +2160,6 @@ public abstract class BaseStatusBar extends SystemUI implements

        entry.row.onNotificationUpdated(entry);
        entry.row.resetHeight();

        applyRemoteInput(entry);
    }

    protected void notifyHeadsUpScreenOff() {
+6 −2
Original line number Diff line number Diff line
@@ -199,8 +199,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    public void onNotificationUpdated(NotificationData.Entry entry) {
        mEntry = entry;
        mStatusBarNotification = entry.notification;
        mPrivateLayout.onNotificationUpdated(entry.notification);
        mPublicLayout.onNotificationUpdated(entry.notification);
        mPrivateLayout.onNotificationUpdated(entry);
        mPublicLayout.onNotificationUpdated(entry);
        updateVetoButton();
        if (mIsSummaryWithChildren) {
            recreateNotificationHeader();
@@ -254,6 +254,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mPrivateLayout.setGroupManager(groupManager);
    }

    public void setRemoteInputController(RemoteInputController r) {
        mPrivateLayout.setRemoteInputController(r);
    }

    public void addChildNotification(ExpandableNotificationRow row) {
        addChildNotification(row, -1);
    }
+72 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar;

import android.app.Notification;
import android.app.RemoteInput;
import android.content.Context;
import android.graphics.Outline;
import android.graphics.Paint;
@@ -37,6 +39,7 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.notification.HybridNotificationView;
import com.android.systemui.statusbar.notification.HybridNotificationViewManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.RemoteInputView;

/**
 * A frame layout containing the actual payload of the notification, including the contracted,
@@ -79,6 +82,7 @@ public class NotificationContentView extends FrameLayout {
    private int mHeadsUpHeight;
    private StatusBarNotification mStatusBarNotification;
    private NotificationGroupManager mGroupManager;
    private RemoteInputController mRemoteInputController;

    private final ViewTreeObserver.OnPreDrawListener mEnableAnimationPredrawListener
            = new ViewTreeObserver.OnPreDrawListener() {
@@ -484,9 +488,10 @@ public class NotificationContentView extends FrameLayout {
        updateSingleLineView();
    }

    public void onNotificationUpdated(StatusBarNotification statusBarNotification) {
        mStatusBarNotification = statusBarNotification;
    public void onNotificationUpdated(NotificationData.Entry entry) {
        mStatusBarNotification = entry.notification;
        updateSingleLineView();
        applyRemoteInput(entry);
        selectLayout(false /* animate */, true /* force */);
        if (mContractedChild != null) {
            mContractedWrapper.notifyContentUpdated();
@@ -508,10 +513,75 @@ public class NotificationContentView extends FrameLayout {
        }
    }

    private void applyRemoteInput(final NotificationData.Entry entry) {
        if (mRemoteInputController == null) {
            return;
        }

        boolean hasRemoteInput = false;

        Notification.Action[] actions = entry.notification.getNotification().actions;
        if (actions != null) {
            for (Notification.Action a : actions) {
                if (a.getRemoteInputs() != null) {
                    for (RemoteInput ri : a.getRemoteInputs()) {
                        if (ri.getAllowFreeFormInput()) {
                            hasRemoteInput = true;
                            break;
                        }
                    }
                }
            }
        }

        View bigContentView = mExpandedChild;
        if (bigContentView != null) {
            applyRemoteInput(bigContentView, entry, hasRemoteInput);
        }
        View headsUpContentView = mHeadsUpChild;
        if (headsUpContentView != null) {
            applyRemoteInput(headsUpContentView, entry, hasRemoteInput);
        }
    }

    private void applyRemoteInput(View view, NotificationData.Entry entry, boolean hasRemoteInput) {
        View actionContainerCandidate = view.findViewById(
                com.android.internal.R.id.actions_container);
        if (actionContainerCandidate instanceof FrameLayout) {
            RemoteInputView existing = (RemoteInputView)
                    view.findViewWithTag(RemoteInputView.VIEW_TAG);

            if (existing != null) {
                existing.onNotificationUpdate();
            }

            if (existing == null && hasRemoteInput) {
                ViewGroup actionContainer = (FrameLayout) actionContainerCandidate;
                RemoteInputView riv = RemoteInputView.inflate(
                        mContext, actionContainer, entry, mRemoteInputController);

                riv.setVisibility(View.INVISIBLE);
                actionContainer.addView(riv, new LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT)
                );
                int color = entry.notification.getNotification().color;
                if (color == Notification.COLOR_DEFAULT) {
                    color = mContext.getColor(R.color.default_remote_input_background);
                }
                riv.setBackgroundColor(color);
            }
        }
    }

    public void setGroupManager(NotificationGroupManager groupManager) {
        mGroupManager = groupManager;
    }

    public void setRemoteInputController(RemoteInputController r) {
        mRemoteInputController = r;
    }

    public void setExpandClickListener(OnClickListener expandClickListener) {
        mExpandClickListener = expandClickListener;
    }
+0 −7
Original line number Diff line number Diff line
@@ -311,8 +311,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

    StatusBarIconController mIconController;

    private RemoteInputController mRemoteInputController;

    // expanded notifications
    NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
    View mExpandedContents;
@@ -1100,11 +1098,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        return mStatusBarWindow;
    }

    @Override
    protected RemoteInputView inflateRemoteInputView(ViewGroup root, Entry entry) {
        return RemoteInputView.inflate(mContext, root, entry, mRemoteInputController);
    }

    public int getStatusBarHeight() {
        if (mNaturalBarHeight < 0) {
            final Resources res = mContext.getResources();