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

Commit 4237e827 authored by Selim Cinek's avatar Selim Cinek
Browse files

Reintroduced app ops for conversation notifications

Previously app ops weren't showing in conversation notifications
Also made sure that they show in case the app name is long.
Additionally this fixes the coloring of the sender name.

Fixes: 150905003
Test: atest SystemUITests
Change-Id: Iae8026e7efdec8c207d1984dac4ee089abe116b9
parent b69f2bc1
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -60,9 +60,6 @@ public class NotificationHeaderView extends ViewGroup {
    private NotificationExpandButton mExpandButton;
    private CachingIconView mIcon;
    private View mProfileBadge;
    private View mOverlayIcon;
    private View mCameraIcon;
    private View mMicIcon;
    private View mAppOps;
    private View mAudiblyAlertedIcon;
    private boolean mExpanded;
@@ -121,9 +118,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);
        mCameraIcon = findViewById(com.android.internal.R.id.camera);
        mMicIcon = findViewById(com.android.internal.R.id.mic);
        mOverlayIcon = findViewById(com.android.internal.R.id.overlay);
        mAppOps = findViewById(com.android.internal.R.id.app_ops);
        mAudiblyAlertedIcon = findViewById(com.android.internal.R.id.alerted_icon);
    }
@@ -300,10 +294,6 @@ public class NotificationHeaderView extends ViewGroup {
     */
    public void setAppOpsOnClickListener(OnClickListener l) {
        mAppOpsListener = l;
        mAppOps.setOnClickListener(mAppOpsListener);
        mCameraIcon.setOnClickListener(mAppOpsListener);
        mMicIcon.setOnClickListener(mAppOpsListener);
        mOverlayIcon.setOnClickListener(mAppOpsListener);
        updateTouchListener();
    }

@@ -328,22 +318,6 @@ public class NotificationHeaderView extends ViewGroup {
        updateExpandButton();
    }

    /**
     * Shows or hides 'app op in use' icons based on app usage.
     */
    public void showAppOpsIcons(ArraySet<Integer> appOps) {
        if (mOverlayIcon == null || mCameraIcon == null || mMicIcon == null || appOps == null) {
            return;
        }

        mOverlayIcon.setVisibility(appOps.contains(AppOpsManager.OP_SYSTEM_ALERT_WINDOW)
                ? View.VISIBLE : View.GONE);
        mCameraIcon.setVisibility(appOps.contains(AppOpsManager.OP_CAMERA)
                ? View.VISIBLE : View.GONE);
        mMicIcon.setVisibility(appOps.contains(AppOpsManager.OP_RECORD_AUDIO)
                ? View.VISIBLE : View.GONE);
    }

    /** Updates icon visibility based on the noisiness of the notification. */
    public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) {
        mAudiblyAlertedIcon.setVisibility(audiblyAlerted ? View.VISIBLE : View.GONE);
+48 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.RemotableViewMethod;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -153,6 +154,9 @@ 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;

    public ConversationLayout(@NonNull Context context) {
        super(context);
@@ -191,6 +195,8 @@ public class ConversationLayout extends FrameLayout
        mConversationIcon = 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);
        mConversationIconBadgeBg = findViewById(R.id.conversation_icon_badge_bg);
@@ -871,6 +877,7 @@ public class ConversationLayout extends FrameLayout
    @RemotableViewMethod
    public void setSenderTextColor(int color) {
        mSenderTextColor = color;
        mConversationText.setTextColor(color);
    }

    /**
@@ -1071,6 +1078,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() {
+39 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@
                        android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title"
                        android:textSize="16sp"
                        android:singleLine="true"
                        android:layout_weight="1"
                        />

                    <TextView
@@ -176,6 +177,44 @@
                        android:visibility="gone"
                        android:contentDescription="@string/notification_work_profile_content_description"
                    />
                    <LinearLayout
                        android:id="@+id/app_ops"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:paddingTop="3dp"
                        android:layout_marginStart="2dp"
                        android:orientation="horizontal" >
                        <ImageButton
                            android:layout_marginStart="4dp"
                            android:id="@+id/camera"
                            android:layout_width="?attr/notificationHeaderIconSize"
                            android:layout_height="?attr/notificationHeaderIconSize"
                            android:src="@drawable/ic_camera"
                            android:background="?android:selectableItemBackgroundBorderless"
                            android:visibility="gone"
                            android:contentDescription="@string/notification_appops_camera_active"
                            />
                        <ImageButton
                            android:id="@+id/mic"
                            android:layout_width="?attr/notificationHeaderIconSize"
                            android:layout_height="?attr/notificationHeaderIconSize"
                            android:src="@drawable/ic_mic"
                            android:background="?android:selectableItemBackgroundBorderless"
                            android:layout_marginStart="4dp"
                            android:visibility="gone"
                            android:contentDescription="@string/notification_appops_microphone_active"
                            />
                        <ImageButton
                            android:id="@+id/overlay"
                            android:layout_width="?attr/notificationHeaderIconSize"
                            android:layout_height="?attr/notificationHeaderIconSize"
                            android:src="@drawable/ic_alert_window_layer"
                            android:background="?android:selectableItemBackgroundBorderless"
                            android:layout_marginStart="4dp"
                            android:visibility="gone"
                            android:contentDescription="@string/notification_appops_overlay_active"
                            />
                    </LinearLayout>
                </LinearLayout>

                <!-- App Name -->
+2 −2
Original line number Diff line number Diff line
@@ -1669,8 +1669,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    public void showAppOpsIcons(ArraySet<Integer> activeOps) {
        if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() != null) {
            mChildrenContainer.getHeaderView().showAppOpsIcons(activeOps);
        if (mIsSummaryWithChildren) {
            mChildrenContainer.showAppOpsIcons(activeOps);
        }
        mPrivateLayout.showAppOpsIcons(activeOps);
        mPublicLayout.showAppOpsIcons(activeOps);
+6 −6
Original line number Diff line number Diff line
@@ -1468,14 +1468,14 @@ public class NotificationContentView extends FrameLayout {
    }

    public void showAppOpsIcons(ArraySet<Integer> activeOps) {
        if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) {
            mContractedWrapper.getNotificationHeader().showAppOpsIcons(activeOps);
        if (mContractedChild != null) {
            mContractedWrapper.showAppOpsIcons(activeOps);
        }
        if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) {
            mExpandedWrapper.getNotificationHeader().showAppOpsIcons(activeOps);
        if (mExpandedChild != null) {
            mExpandedWrapper.showAppOpsIcons(activeOps);
        }
        if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) {
            mHeadsUpWrapper.getNotificationHeader().showAppOpsIcons(activeOps);
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.showAppOpsIcons(activeOps);
        }
    }

Loading