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

Commit 2778b62f authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Remove app ops indicators from notifications

Test: atest
Bug: 163076432
Change-Id: I5b7514f765811ffd3b0aca63d0108591755974ab
Merged-In: I5b7514f765811ffd3b0aca63d0108591755974ab
parent 48629095
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -5151,18 +5151,10 @@ 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,
+0 −25
Original line number Diff line number Diff line
@@ -52,13 +52,11 @@ 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;
@@ -115,7 +113,6 @@ 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
@@ -143,7 +140,6 @@ 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 {
@@ -208,7 +204,6 @@ 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;
@@ -277,22 +272,10 @@ 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;
@@ -380,7 +363,6 @@ 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;
@@ -393,8 +375,6 @@ 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();
        }
@@ -455,11 +435,6 @@ 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;
+0 −44
Original line number Diff line number Diff line
@@ -167,8 +167,6 @@ 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;
@@ -210,7 +208,6 @@ 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);
@@ -1166,47 +1163,6 @@ 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() {
+0 −37
Original line number Diff line number Diff line
@@ -146,43 +146,6 @@
        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"
+0 −5
Original line number Diff line number Diff line
@@ -74,11 +74,6 @@ 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