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

Commit 8c0ef2dc authored by Alex Mang's avatar Alex Mang
Browse files

Adding notification guts to feedback icon

Feedback icon is now tappable and opens up notification guts

Test: manually on device
Change-Id: I7c19d612fa90980a274e8c48561333fc1131c688
parent 91974684
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class NotificationHeaderView extends ViewGroup {
    private View mSecondaryHeaderText;
    private OnClickListener mExpandClickListener;
    private OnClickListener mAppOpsListener;
    private OnClickListener mFeedbackListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private LinearLayout mTransferChip;
    private NotificationExpandButton mExpandButton;
@@ -281,7 +282,7 @@ public class NotificationHeaderView extends ViewGroup {
    }

    private void updateTouchListener() {
        if (mExpandClickListener == null && mAppOpsListener == null) {
        if (mExpandClickListener == null && mAppOpsListener == null && mFeedbackListener == null) {
            setOnTouchListener(null);
            return;
        }
@@ -297,6 +298,15 @@ public class NotificationHeaderView extends ViewGroup {
        updateTouchListener();
    }

    /**
     * Sets onclick listener for feedback icon.
     */
    public void setFeedbackOnClickListener(OnClickListener l) {
        mFeedbackListener = l;
        mFeedbackIcon.setOnClickListener(mFeedbackListener);
        updateTouchListener();
    }

    @Override
    public void setOnClickListener(@Nullable OnClickListener l) {
        mExpandClickListener = l;
@@ -385,6 +395,7 @@ public class NotificationHeaderView extends ViewGroup {
        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
        private Rect mExpandButtonRect;
        private Rect mAppOpsRect;
        private Rect mFeedbackRect;
        private int mTouchSlop;
        private boolean mTrackGesture;
        private float mDownX;
@@ -398,6 +409,7 @@ public class NotificationHeaderView extends ViewGroup {
            addRectAroundView(mIcon);
            mExpandButtonRect = addRectAroundView(mExpandButton);
            mAppOpsRect = addRectAroundView(mAppOps);
            mFeedbackRect = addRectAroundView(mFeedbackIcon);
            setTouchDelegate(new TouchDelegate(mAppOpsRect, mAppOps));
            addWidthRect();
            mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
@@ -463,6 +475,11 @@ public class NotificationHeaderView extends ViewGroup {
                                || mAppOpsRect.contains((int) mDownX, (int) mDownY))) {
                            mAppOps.performClick();
                            return true;
                        } else if (mFeedbackIcon.isVisibleToUser()
                                && (mFeedbackRect.contains((int) x, (int) y))
                                || mFeedbackRect.contains((int) mDownX, (int) mDownY)) {
                            mFeedbackIcon.performClick();
                            return true;
                        }
                        mExpandButton.performClick();
                    }
+5 −0
Original line number Diff line number Diff line
@@ -79,6 +79,11 @@ public interface NotificationMenuRowPlugin extends Plugin {
     */
    public MenuItem getAppOpsMenuItem(Context context);

    /**
     * @return the {@link MenuItem} to display when feedback icon is pressed.
     */
    public MenuItem getFeedbackMenuItem(Context context);

    /**
     * @return the {@link MenuItem} to display when snooze item is pressed.
     */
+132 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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.notification.row.FeedbackInfo
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/feedback_info"
        android:clickable="true"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:paddingStart="@*android:dimen/notification_content_margin_start"
        android:paddingEnd="@*android:dimen/notification_content_margin_end"
        android:background="@color/notification_material_background_color"
        android:theme="@*android:style/Theme.DeviceDefault.Light">

    <!-- Package Info -->
    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="@dimen/notification_guts_conversation_header_height"
        android:gravity="center_vertical"
        android:clipChildren="false"
        android:clipToPadding="false">
        <ImageView
            android:id="@+id/pkg_icon"
            android:layout_width="@dimen/notification_guts_conversation_icon_size"
            android:layout_height="@dimen/notification_guts_conversation_icon_size"
            android:layout_centerVertical="true"
            android:layout_alignParentStart="true"
            android:layout_marginEnd="15dp" />
        <LinearLayout
            android:id="@+id/names"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:orientation="vertical"

            android:layout_height="wrap_content"
            android:minHeight="@dimen/notification_guts_conversation_icon_size"
            android:layout_centerVertical="true"
            android:gravity="center_vertical"
            android:layout_alignEnd="@id/pkg_icon"
            android:layout_toEndOf="@id/pkg_icon">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="start"
                android:orientation="horizontal">
                <TextView
                    android:id="@+id/pkg_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.NotificationImportanceChannelGroup"
                    android:ellipsize="end"
                    android:maxLines="1"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <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" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/notification_guts_button_spacing"
        android:layout_marginBottom="@dimen/notification_guts_button_spacing"
        android:gravity="end"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/yes"
            android:text="Yes"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@drawable/ripple_drawable"
            android:minWidth="48dp"
            android:gravity="center"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="-8dp"
            style="@style/TextAppearance.NotificationInfo.Button"/>
        <TextView
            android:id="@+id/no"
            android:text="No"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@drawable/ripple_drawable"
            android:minWidth="48dp"
            android:gravity="center"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="-8dp"
            style="@style/TextAppearance.NotificationInfo.Button"/>
    </LinearLayout>

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

        <TextView
            android:id="@+id/ok"
            android:text="@string/feedback_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.notification.row.FeedbackInfo>
+12 −0
Original line number Diff line number Diff line
@@ -1904,6 +1904,18 @@
    <string name="notification_appops_settings">Settings</string>
    <string name="notification_appops_ok">OK</string>

    <!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
    <string name="feedback_silenced">This notification was silenced by the system.</string>
    <!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
    <string name="feedback_promoted">This notification was promoted by the system.</string>
    <!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
    <string name="feedback_demoted">This notification was demoted by the system.</string>
    <!-- Notification Inline controls: prompts the user for feedback [CHAR_LIMIT=NONE] -->
    <string name="feedback_prompt">Was this correct?</string>
    <!-- Notification Inline controls: responds to user provided feedback [CHAR_LIMIT=NONE] -->
    <string name="feedback_response">Thanks for your feedback!</string>
    <string name="feedback_ok">OK</string>

    <!-- Notification: Control panel: Accessibility description for expanded inline controls view, used
        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>
+24 −3
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private ExpandableNotificationRow mNotificationParent;
    private OnExpandClickListener mOnExpandClickListener;
    private View.OnClickListener mOnAppOpsClickListener;
    private View.OnClickListener mOnFeedbackClickListener;

    // Listener will be called when receiving a long click event.
    // Use #setLongPressPosition to optionally assign positional data with the long press.
@@ -1609,7 +1610,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            RowContentBindStage rowContentBindStage,
            OnExpandClickListener onExpandClickListener,
            NotificationMediaManager notificationMediaManager,
            OnAppOpsClickListener onAppOpsClickListener,
            CoordinateOnClickListener onAppOpsClickListener,
            CoordinateOnClickListener onFeedbackClickListener,
            FalsingManager falsingManager,
            StatusBarStateController statusBarStateController,
            PeopleNotificationIdentifier peopleNotificationIdentifier) {
@@ -1630,6 +1632,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mOnExpandClickListener = onExpandClickListener;
        mMediaManager = notificationMediaManager;
        setAppOpsOnClickListener(onAppOpsClickListener);
        setOnFeedbackClickListener(onFeedbackClickListener);
        mFalsingManager = falsingManager;
        mStatusbarStateController = statusBarStateController;
        mPeopleNotificationIdentifier = peopleNotificationIdentifier;
@@ -1734,7 +1737,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return mOnAppOpsClickListener;
    }

    void setAppOpsOnClickListener(ExpandableNotificationRow.OnAppOpsClickListener l) {
    void setAppOpsOnClickListener(CoordinateOnClickListener l) {
        mOnAppOpsClickListener = v -> {
            createMenu();
            NotificationMenuRowPlugin provider = getProvider();
@@ -1748,6 +1751,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        };
    }

    public View.OnClickListener getFeedbackOnClickListener() {
        return mOnFeedbackClickListener;
    }

    void setOnFeedbackClickListener(CoordinateOnClickListener l) {
        mOnFeedbackClickListener = v -> {
            createMenu();
            NotificationMenuRowPlugin provider = getProvider();
            if (provider == null) {
                return;
            }
            MenuItem menuItem = provider.getFeedbackMenuItem(mContext);
            if (menuItem != null) {
                l.onClick(this, v.getWidth() / 2, v.getHeight() / 2, menuItem);
            }
        };
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
@@ -3243,7 +3264,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    /**
     * Equivalent to View.OnClickListener with coordinates
     */
    public interface OnAppOpsClickListener {
    public interface CoordinateOnClickListener {
        /**
         * Equivalent to {@link View.OnClickListener#onClick(View)} with coordinates
         * @return whether the click was handled
Loading