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

Commit 6558218c authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Merge "Show app ops guts when tap app ops icons" into pi-dev

am: 7b894b3f

Change-Id: Ib61f338fe0ea723c1a3a500902cf200227d2db9a
parents 06ce1e6c 7b894b3f
Loading
Loading
Loading
Loading
+30 −9
Original line number Original line Diff line number Diff line
@@ -51,6 +51,7 @@ public class NotificationHeaderView extends ViewGroup {
    private View mHeaderText;
    private View mHeaderText;
    private View mSecondaryHeaderText;
    private View mSecondaryHeaderText;
    private OnClickListener mExpandClickListener;
    private OnClickListener mExpandClickListener;
    private OnClickListener mAppOpsListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private ImageView mExpandButton;
    private ImageView mExpandButton;
    private CachingIconView mIcon;
    private CachingIconView mIcon;
@@ -267,15 +268,26 @@ public class NotificationHeaderView extends ViewGroup {
    }
    }


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

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


    @Override
    @Override
    public void setOnClickListener(@Nullable OnClickListener l) {
    public void setOnClickListener(@Nullable OnClickListener l) {
        mExpandClickListener = l;
        mExpandClickListener = l;
        setOnTouchListener(mExpandClickListener != null ? mTouchListener : null);
        mExpandButton.setOnClickListener(mExpandClickListener);
        mExpandButton.setOnClickListener(mExpandClickListener);
        updateTouchListener();
        updateTouchListener();
    }
    }
@@ -308,7 +320,7 @@ public class NotificationHeaderView extends ViewGroup {
     * Shows or hides 'app op in use' icons based on app usage.
     * Shows or hides 'app op in use' icons based on app usage.
     */
     */
    public void showAppOpsIcons(ArraySet<Integer> appOps) {
    public void showAppOpsIcons(ArraySet<Integer> appOps) {
        if (mOverlayIcon == null || mCameraIcon == null || mMicIcon == null) {
        if (mOverlayIcon == null || mCameraIcon == null || mMicIcon == null || appOps == null) {
            return;
            return;
        }
        }


@@ -366,6 +378,7 @@ public class NotificationHeaderView extends ViewGroup {


        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
        private Rect mExpandButtonRect;
        private Rect mExpandButtonRect;
        private Rect mAppOpsRect;
        private int mTouchSlop;
        private int mTouchSlop;
        private boolean mTrackGesture;
        private boolean mTrackGesture;
        private float mDownX;
        private float mDownX;
@@ -378,6 +391,7 @@ public class NotificationHeaderView extends ViewGroup {
            mTouchRects.clear();
            mTouchRects.clear();
            addRectAroundView(mIcon);
            addRectAroundView(mIcon);
            mExpandButtonRect = addRectAroundView(mExpandButton);
            mExpandButtonRect = addRectAroundView(mExpandButton);
            mAppOpsRect = addRectAroundView(mAppOps);
            addWidthRect();
            addWidthRect();
            mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
            mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
        }
        }
@@ -399,16 +413,18 @@ public class NotificationHeaderView extends ViewGroup {


        private Rect getRectAroundView(View view) {
        private Rect getRectAroundView(View view) {
            float size = 48 * getResources().getDisplayMetrics().density;
            float size = 48 * getResources().getDisplayMetrics().density;
            float width = Math.max(size, view.getWidth());
            float height = Math.max(size, view.getHeight());
            final Rect r = new Rect();
            final Rect r = new Rect();
            if (view.getVisibility() == GONE) {
            if (view.getVisibility() == GONE) {
                view = getFirstChildNotGone();
                view = getFirstChildNotGone();
                r.left = (int) (view.getLeft() - size / 2.0f);
                r.left = (int) (view.getLeft() - width / 2.0f);
            } else {
            } else {
                r.left = (int) ((view.getLeft() + view.getRight()) / 2.0f - size / 2.0f);
                r.left = (int) ((view.getLeft() + view.getRight()) / 2.0f - width / 2.0f);
            }
            }
            r.top = (int) ((view.getTop() + view.getBottom()) / 2.0f - size / 2.0f);
            r.top = (int) ((view.getTop() + view.getBottom()) / 2.0f - height / 2.0f);
            r.bottom = (int) (r.top + size);
            r.bottom = (int) (r.top + height);
            r.right = (int) (r.left + size);
            r.right = (int) (r.left + width);
            return r;
            return r;
        }
        }


@@ -436,6 +452,11 @@ public class NotificationHeaderView extends ViewGroup {
                    break;
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_UP:
                    if (mTrackGesture) {
                    if (mTrackGesture) {
                        if (mAppOps.isVisibleToUser() && (mAppOpsRect.contains((int) x, (int) y)
                                || mAppOpsRect.contains((int) mDownX, (int) mDownY))) {
                            mAppOps.performClick();
                            return true;
                        }
                        mExpandButton.performClick();
                        mExpandButton.performClick();
                    }
                    }
                    break;
                    break;
+2 −2
Original line number Original line Diff line number Diff line
@@ -129,8 +129,9 @@


    <LinearLayout
    <LinearLayout
        android:id="@+id/app_ops"
        android:id="@+id/app_ops"
        android:layout_height="wrap_content"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginStart="6dp"
        android:orientation="horizontal" >
        android:orientation="horizontal" >
        <ImageButton
        <ImageButton
            android:id="@+id/camera"
            android:id="@+id/camera"
@@ -139,7 +140,6 @@
            android:src="@drawable/ic_camera"
            android:src="@drawable/ic_camera"
            android:tint="@color/notification_secondary_text_color_light"
            android:tint="@color/notification_secondary_text_color_light"
            android:background="?android:selectableItemBackgroundBorderless"
            android:background="?android:selectableItemBackgroundBorderless"
            android:layout_marginStart="6dp"
            android:visibility="gone"
            android:visibility="gone"
            />
            />
        <ImageButton
        <ImageButton
+5 −0
Original line number Original line Diff line number Diff line
@@ -70,6 +70,11 @@ public interface NotificationMenuRowPlugin extends Plugin {
     */
     */
    public MenuItem getLongpressMenuItem(Context context);
    public MenuItem getLongpressMenuItem(Context context);


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

    public void setMenuItems(ArrayList<MenuItem> items);
    public void setMenuItems(ArrayList<MenuItem> items);


    public void setMenuClickListener(OnMenuEventListener listener);
    public void setMenuClickListener(OnMenuEventListener listener);
+89 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 2018, The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<com.android.systemui.statusbar.AppOpsInfo
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/app_ops_info"
        android:clickable="true"
        android:orientation="vertical"
        android:paddingStart="@*android:dimen/notification_content_margin_start"
        android:paddingEnd="@*android:dimen/notification_content_margin_end"
        android:background="@color/notification_guts_bg_color"
        android:theme="@*android:style/Theme.DeviceDefault.Light">

    <!-- Package Info -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:layout_marginTop="@*android:dimen/notification_header_padding_top" >
        <ImageView
            android:id="@+id/pkgicon"
            android:layout_width="@dimen/notification_guts_header_height"
            android:layout_height="@dimen/notification_guts_header_height"
            android:layout_centerVertical="true"
            android:layout_marginEnd="3dp" />
        <TextView
            android:id="@+id/pkgname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@*android:style/TextAppearance.Material.Notification.Info"
            android:layout_marginStart="3dp"
            android:layout_marginEnd="2dp"
            android:singleLine="true"
            android:layout_centerVertical="true"
            android:layout_toEndOf="@id/pkgicon" />
    </RelativeLayout>

    <TextView
        android:id="@+id/prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@*android:dimen/notification_header_padding_top"
        style="@style/TextAppearance.NotificationInfo.Secondary" />

    <!-- Settings and Done buttons -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="@dimen/notification_guts_button_spacing"
        android:layout_marginBottom="@dimen/notification_guts_button_spacing"
        android:gravity="end" >

        <TextView
            android:id="@+id/settings"
            android:text="@string/notification_appops_settings"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@drawable/ripple_drawable"
            style="@style/TextAppearance.NotificationInfo.Button"/>
        <TextView
            android:id="@+id/ok"
            android:text="@string/notification_appops_ok"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@drawable/ripple_drawable"
            android:minWidth="48dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="-8dp"
            style="@style/TextAppearance.NotificationInfo.Button"/>
    </LinearLayout>
</com.android.systemui.statusbar.AppOpsInfo>
+19 −0
Original line number Original line Diff line number Diff line
@@ -1545,6 +1545,25 @@
    <!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
    <!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
    <string name="notification_unblockable_desc">These notifications can\'t be turned off</string>
    <string name="notification_unblockable_desc">These notifications can\'t be turned off</string>


    <string name="notification_appops_camera_active">camera</string>

    <string name="notification_appops_microphone_active">microphone</string>

    <string name="notification_appops_overlay_active">displaying over other apps on your screen</string>

    <plurals name="notification_appops">
        <item quantity="one">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g>.</item>
        <item quantity="other">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="using the microphone">%2$s</xliff:g>.</item>
    </plurals>

    <plurals name="notification_using">
        <item quantity="one">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g></item>
        <item quantity="other">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="microphone">%2$s</xliff:g></item>
    </plurals>

    <string name="notification_appops_settings">Settings</string>
    <string name="notification_appops_ok">Ok</string>

    <!-- Notification: Control panel: Accessibility description for expanded inline controls view, used
    <!-- Notification: Control panel: Accessibility description for expanded inline controls view, used
        to control settings about notifications related to the current notification.  -->
        to control settings about notifications related to the current notification.  -->
    <string name="notification_channel_controls_opened_accessibility">Notification controls for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> opened</string>
    <string name="notification_channel_controls_opened_accessibility">Notification controls for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> opened</string>
Loading