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

Commit 8ec5bcb3 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

DO NOT MERGE Revert "Remove app ops indicators from notifications"

This reverts commit 2778b62f.

Reason for revert: these icons are still needed

Change-Id: I219af393f3d4cd08e431f38a3b66408e12f258bb
Bug: 163076432
parent 2778b62f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5151,10 +5151,18 @@ public class Notification implements Parcelable
            bindHeaderChronometerAndTime(contentView, p);
            bindProfileBadge(contentView, p);
            bindAlertedIcon(contentView, p);
            bindActivePermissions(contentView, p);
            bindExpandButton(contentView, p);
            mN.mUsesStandardHeader = true;
        }

        private void bindActivePermissions(RemoteViews contentView, StandardTemplateParams p) {
            int color = getNeutralColor(p);
            contentView.setDrawableTint(R.id.camera, false, color, PorterDuff.Mode.SRC_ATOP);
            contentView.setDrawableTint(R.id.mic, false, color, PorterDuff.Mode.SRC_ATOP);
            contentView.setDrawableTint(R.id.overlay, false, color, PorterDuff.Mode.SRC_ATOP);
        }

        private void bindExpandButton(RemoteViews contentView, StandardTemplateParams p) {
            int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p);
            contentView.setDrawableTint(R.id.expand_button, false, color,
+25 −0
Original line number Diff line number Diff line
@@ -52,11 +52,13 @@ public class NotificationHeaderView extends ViewGroup {
    private View mHeaderText;
    private View mSecondaryHeaderText;
    private OnClickListener mExpandClickListener;
    private OnClickListener mAppOpsListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private LinearLayout mTransferChip;
    private NotificationExpandButton mExpandButton;
    private CachingIconView mIcon;
    private View mProfileBadge;
    private View mAppOps;
    private boolean mExpanded;
    private boolean mShowExpandButtonAtEnd;
    private boolean mShowWorkBadgeAtEnd;
@@ -113,6 +115,7 @@ public class NotificationHeaderView extends ViewGroup {
        mExpandButton = findViewById(com.android.internal.R.id.expand_button);
        mIcon = findViewById(com.android.internal.R.id.icon);
        mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
        mAppOps = findViewById(com.android.internal.R.id.app_ops);
    }

    @Override
@@ -140,6 +143,7 @@ public class NotificationHeaderView extends ViewGroup {
            // Icons that should go at the end
            if ((child == mExpandButton && mShowExpandButtonAtEnd)
                    || child == mProfileBadge
                    || child == mAppOps
                    || child == mTransferChip) {
                iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
            } else {
@@ -204,6 +208,7 @@ public class NotificationHeaderView extends ViewGroup {
            // Icons that should go at the end
            if ((child == mExpandButton && mShowExpandButtonAtEnd)
                    || child == mProfileBadge
                    || child == mAppOps
                    || child == mTransferChip) {
                if (end == getMeasuredWidth()) {
                    layoutRight = end - mContentEndMargin;
@@ -272,10 +277,22 @@ public class NotificationHeaderView extends ViewGroup {
    }

    private void updateTouchListener() {
        if (mExpandClickListener == null && mAppOpsListener == null) {
            setOnTouchListener(null);
            return;
        }
        setOnTouchListener(mTouchListener);
        mTouchListener.bindTouchRects();
    }

    /**
     * Sets onclick listener for app ops icons.
     */
    public void setAppOpsOnClickListener(OnClickListener l) {
        mAppOpsListener = l;
        updateTouchListener();
    }

    @Override
    public void setOnClickListener(@Nullable OnClickListener l) {
        mExpandClickListener = l;
@@ -363,6 +380,7 @@ public class NotificationHeaderView extends ViewGroup {

        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
        private Rect mExpandButtonRect;
        private Rect mAppOpsRect;
        private int mTouchSlop;
        private boolean mTrackGesture;
        private float mDownX;
@@ -375,6 +393,8 @@ public class NotificationHeaderView extends ViewGroup {
            mTouchRects.clear();
            addRectAroundView(mIcon);
            mExpandButtonRect = addRectAroundView(mExpandButton);
            mAppOpsRect = addRectAroundView(mAppOps);
            setTouchDelegate(new TouchDelegate(mAppOpsRect, mAppOps));
            addWidthRect();
            mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
        }
@@ -435,6 +455,11 @@ public class NotificationHeaderView extends ViewGroup {
                    break;
                case MotionEvent.ACTION_UP:
                    if (mTrackGesture) {
                        if (mAppOps.isVisibleToUser() && (mAppOpsRect.contains((int) x, (int) y)
                                || mAppOpsRect.contains((int) mDownX, (int) mDownY))) {
                            mAppOps.performClick();
                            return true;
                        }
                        mExpandButton.performClick();
                    }
                    break;
+44 −0
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ public class ConversationLayout extends FrameLayout
    private int mFacePileProtectionWidthExpanded;
    private boolean mImportantConversation;
    private TextView mUnreadBadge;
    private ViewGroup mAppOps;
    private Rect mAppOpsTouchRect = new Rect();
    private float mMinTouchSize;
    private Icon mConversationIcon;
    private Icon mShortcutIcon;
@@ -208,6 +210,7 @@ public class ConversationLayout extends FrameLayout
        mConversationIconView = findViewById(R.id.conversation_icon);
        mConversationIconContainer = findViewById(R.id.conversation_icon_container);
        mIcon = findViewById(R.id.icon);
        mAppOps = findViewById(com.android.internal.R.id.app_ops);
        mMinTouchSize = 48 * getResources().getDisplayMetrics().density;
        mImportanceRingView = findViewById(R.id.conversation_icon_badge_ring);
        mConversationIconBadge = findViewById(R.id.conversation_icon_badge);
@@ -1163,6 +1166,47 @@ public class ConversationLayout extends FrameLayout
                }
            });
        }
        if (mAppOps.getWidth() > 0) {

            // Let's increase the touch size of the app ops view if it's here
            mAppOpsTouchRect.set(
                    mAppOps.getLeft(),
                    mAppOps.getTop(),
                    mAppOps.getRight(),
                    mAppOps.getBottom());
            for (int i = 0; i < mAppOps.getChildCount(); i++) {
                View child = mAppOps.getChildAt(i);
                if (child.getVisibility() == GONE) {
                    continue;
                }
                // Make sure each child has at least a minTouchSize touch target around it
                float childTouchLeft = child.getLeft() + child.getWidth() / 2.0f
                        - mMinTouchSize / 2.0f;
                float childTouchRight = childTouchLeft + mMinTouchSize;
                mAppOpsTouchRect.left = (int) Math.min(mAppOpsTouchRect.left,
                        mAppOps.getLeft() + childTouchLeft);
                mAppOpsTouchRect.right = (int) Math.max(mAppOpsTouchRect.right,
                        mAppOps.getLeft() + childTouchRight);
            }

            // Increase the height
            int heightIncrease = 0;
            if (mAppOpsTouchRect.height() < mMinTouchSize) {
                heightIncrease = (int) Math.ceil((mMinTouchSize - mAppOpsTouchRect.height())
                        / 2.0f);
            }
            mAppOpsTouchRect.inset(0, -heightIncrease);

            // Let's adjust the hitrect since app ops isn't a direct child
            ViewGroup viewGroup = (ViewGroup) mAppOps.getParent();
            while (viewGroup != this) {
                mAppOpsTouchRect.offset(viewGroup.getLeft(), viewGroup.getTop());
                viewGroup = (ViewGroup) viewGroup.getParent();
            }
            //
            // Extend the size of the app opps to be at least 48dp
            setTouchDelegate(new TouchDelegate(mAppOpsTouchRect, mAppOps));
        }
    }

    public MessagingLinearLayout getMessagingLinearLayout() {
+37 −0
Original line number Diff line number Diff line
@@ -146,6 +146,43 @@
        android:visibility="gone"
        android:contentDescription="@string/notification_work_profile_content_description"
        />
    <LinearLayout
        android:id="@+id/app_ops"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_marginStart="6dp"
        android:background="?android:selectableItemBackgroundBorderless"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/camera"
            android:layout_width="?attr/notificationHeaderIconSize"
            android:layout_height="?attr/notificationHeaderIconSize"
            android:src="@drawable/ic_camera"
            android:visibility="gone"
            android:focusable="false"
            android:contentDescription="@string/notification_appops_camera_active"
            />
        <ImageView
            android:id="@+id/mic"
            android:layout_width="?attr/notificationHeaderIconSize"
            android:layout_height="?attr/notificationHeaderIconSize"
            android:src="@drawable/ic_mic"
            android:layout_marginStart="4dp"
            android:visibility="gone"
            android:focusable="false"
            android:contentDescription="@string/notification_appops_microphone_active"
            />
        <ImageView
            android:id="@+id/overlay"
            android:layout_width="?attr/notificationHeaderIconSize"
            android:layout_height="?attr/notificationHeaderIconSize"
            android:src="@drawable/ic_alert_window_layer"
            android:layout_marginStart="4dp"
            android:visibility="gone"
            android:focusable="false"
            android:contentDescription="@string/notification_appops_overlay_active"
            />
    </LinearLayout>
    <include
        layout="@layout/notification_material_media_transfer_action"
        android:id="@+id/media_seamless"
+5 −0
Original line number Diff line number Diff line
@@ -74,6 +74,11 @@ public interface NotificationMenuRowPlugin extends Plugin {
     */
    public MenuItem getLongpressMenuItem(Context context);

    /**
     * @return the {@link MenuItem} to display when app ops icons are pressed.
     */
    public MenuItem getAppOpsMenuItem(Context context);

    /**
     * @return the {@link MenuItem} to display when snooze item is pressed.
     */
Loading