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

Commit 9716d62b authored by Selim Cinek's avatar Selim Cinek Committed by Automerger Merge Worker
Browse files

Merge changes Ia152bc41,Iae8026e7 into rvc-dev am: 71a6d0bf

Change-Id: I5c7672a175c478e36d48287dd4e4748dabba95da
parents baaa8453 71a6d0bf
Loading
Loading
Loading
Loading
+0 −33
Original line number Diff line number Diff line
@@ -60,11 +60,7 @@ 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;
    private boolean mShowExpandButtonAtEnd;
    private boolean mShowWorkBadgeAtEnd;
@@ -121,11 +117,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);
        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);
    }

    @Override
@@ -300,10 +292,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,27 +316,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);
    }

    private void updateExpandButton() {
        int drawableId;
        int contentDescriptionId;
+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() {
+51 −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
@@ -165,6 +166,18 @@
                        android:visibility="gone"
                    />

                    <ImageView
                        android:id="@+id/alerted_icon"
                        android:layout_width="@dimen/notification_alerted_size"
                        android:layout_height="@dimen/notification_alerted_size"
                        android:layout_gravity="center"
                        android:layout_marginStart="4dp"
                        android:paddingTop="2dp"
                        android:scaleType="fitCenter"
                        android:visibility="gone"
                        android:contentDescription="@string/notification_alerted_content_description"
                        android:src="@drawable/ic_notifications_alerted"/>

                    <ImageView
                        android:id="@+id/profile_badge"
                        android:layout_width="@dimen/notification_badge_size"
@@ -176,6 +189,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 -->
+4 −4
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);
@@ -1697,8 +1697,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private final Runnable mExpireRecentlyAlertedFlag = () -> applyAudiblyAlertedRecently(false);

    private void applyAudiblyAlertedRecently(boolean audiblyAlertedRecently) {
        if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() != null) {
            mChildrenContainer.getHeaderView().setRecentlyAudiblyAlerted(audiblyAlertedRecently);
        if (mIsSummaryWithChildren) {
            mChildrenContainer.setRecentlyAudiblyAlerted(audiblyAlertedRecently);
        }
        mPrivateLayout.setRecentlyAudiblyAlerted(audiblyAlertedRecently);
        mPublicLayout.setRecentlyAudiblyAlerted(audiblyAlertedRecently);
+12 −12
Original line number Diff line number Diff line
@@ -1468,27 +1468,27 @@ 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);
        }
    }

    /** Sets whether the notification being displayed audibly alerted the user. */
    public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) {
        if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) {
            mContractedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted);
        if (mContractedChild != null) {
            mContractedWrapper.setRecentlyAudiblyAlerted(audiblyAlerted);
        }
        if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) {
            mExpandedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted);
        if (mExpandedChild != null) {
            mExpandedWrapper.setRecentlyAudiblyAlerted(audiblyAlerted);
        }
        if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) {
            mHeadsUpWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted);
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.setRecentlyAudiblyAlerted(audiblyAlerted);
        }
    }

Loading