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

Commit 0bd8a4b2 authored by Adrian Roos's avatar Adrian Roos
Browse files

Copy/Paste on RemoteInputView

Also fixes a bug where the remote input view stays focused
when the inline settings open.

Also prevents sharing from contexts that are not activities,
and prevents text processing when the device is not provisioned.

Bug: 27633360
Change-Id: I8b6e7f661bd873d88e7e2460d043c2aa5f849516
parent 62006a72
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -9642,7 +9642,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    boolean canShare() {
        return canCopy() && isDeviceProvisioned();
        if (!getContext().canStartActivityForResult() || !isDeviceProvisioned()) {
            return false;
        }
        return canCopy();
    }

    boolean isDeviceProvisioned() {
@@ -9665,16 +9668,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    boolean canProcessText() {
        if (!getContext().canStartActivityForResult() || getId() == View.NO_ID
                || hasPasswordTransformationMethod()) {
        if (getId() == View.NO_ID) {
            return false;
        }

        if (mText.length() > 0 && hasSelection() && mEditor != null) {
            return true;
        }

        return false;
        return canShare();
    }

    boolean canSelectAllText() {
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
            android:singleLine="true"
            android:ellipsize="start"
            android:inputType="textShortMessage|textAutoCorrect|textCapSentences"
            android:textIsSelectable="true"
            android:imeOptions="actionSend|flagNoExtractUi" />

    <FrameLayout
+1 −0
Original line number Diff line number Diff line
@@ -1079,6 +1079,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                        });
                        a.start();
                        guts.setExposed(true);
                        row.closeRemoteInput();
                        mStackScroller.onHeightChanged(null, true /* needsAnimation */);
                        mNotificationGutsExposed = guts;
                    }
+5 −0
Original line number Diff line number Diff line
@@ -579,6 +579,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    public void closeRemoteInput() {
        mPrivateLayout.closeRemoteInput();
        mPublicLayout.closeRemoteInput();
    }

    public interface ExpansionLogger {
        public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
    }
+23 −3
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ public class NotificationContentView extends FrameLayout {
    private View mHeadsUpChild;
    private HybridNotificationView mSingleLineView;

    private RemoteInputView mExpandedRemoteInput;
    private RemoteInputView mHeadsUpRemoteInput;

    private NotificationViewWrapper mContractedWrapper;
    private NotificationViewWrapper mExpandedWrapper;
    private NotificationViewWrapper mHeadsUpWrapper;
@@ -743,15 +746,19 @@ public class NotificationContentView extends FrameLayout {

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

    private void applyRemoteInput(View view, NotificationData.Entry entry, boolean hasRemoteInput) {
    private RemoteInputView applyRemoteInput(View view, NotificationData.Entry entry, boolean hasRemoteInput) {
        View actionContainerCandidate = view.findViewById(
                com.android.internal.R.id.actions_container);
        if (actionContainerCandidate instanceof FrameLayout) {
@@ -777,7 +784,20 @@ public class NotificationContentView extends FrameLayout {
                    color = mContext.getColor(R.color.default_remote_input_background);
                }
                riv.setBackgroundColor(color);

                return riv;
            }
            return existing;
        }
        return null;
    }

    public void closeRemoteInput() {
        if (mHeadsUpRemoteInput != null) {
            mHeadsUpRemoteInput.close();
        }
        if (mExpandedRemoteInput != null) {
            mExpandedRemoteInput.close();
        }
    }

Loading