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

Commit 7cae77b6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Iefcaf262,I9c397d83

* changes:
  Fixed a bug where the expand icon could show but nothing happens
  Improved expand accessibility experience
parents 25e98e3c 9635cf3d
Loading
Loading
Loading
Loading
+7 −33
Original line number Original line Diff line number Diff line
@@ -23,9 +23,7 @@ import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.RemoteViews;


@@ -67,33 +65,6 @@ public class NotificationHeaderView extends ViewGroup {
            }
            }
        }
        }
    };
    };
    final AccessibilityDelegate mExpandDelegate = new AccessibilityDelegate() {

        @Override
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
            if (super.performAccessibilityAction(host, action, args)) {
                return true;
            }
            if (action == AccessibilityNodeInfo.ACTION_COLLAPSE
                    || action == AccessibilityNodeInfo.ACTION_EXPAND) {
                mExpandClickListener.onClick(mExpandButton);
                return true;
            }
            return false;
        }

        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            // Avoid that the button description is also spoken
            info.setClassName(getClass().getName());
            if (mExpanded) {
                info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
            } else {
                info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
            }
        }
    };
    private boolean mAcceptAllTouches;
    private boolean mAcceptAllTouches;


    public NotificationHeaderView(Context context) {
    public NotificationHeaderView(Context context) {
@@ -124,9 +95,6 @@ public class NotificationHeaderView extends ViewGroup {
        mAppName = findViewById(com.android.internal.R.id.app_name_text);
        mAppName = findViewById(com.android.internal.R.id.app_name_text);
        mHeaderText = findViewById(com.android.internal.R.id.header_text);
        mHeaderText = findViewById(com.android.internal.R.id.header_text);
        mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
        mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
        if (mExpandButton != null) {
            mExpandButton.setAccessibilityDelegate(mExpandDelegate);
        }
        mIcon = (CachingIconView) findViewById(com.android.internal.R.id.icon);
        mIcon = (CachingIconView) findViewById(com.android.internal.R.id.icon);
        mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
        mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
    }
    }
@@ -295,13 +263,19 @@ public class NotificationHeaderView extends ViewGroup {


    private void updateExpandButton() {
    private void updateExpandButton() {
        int drawableId;
        int drawableId;
        int contentDescriptionId;
        if (mExpanded) {
        if (mExpanded) {
            drawableId = com.android.internal.R.drawable.ic_collapse_notification;
            drawableId = com.android.internal.R.drawable.ic_collapse_notification;
            contentDescriptionId
                    = com.android.internal.R.string.expand_button_content_description_expanded;
        } else {
        } else {
            drawableId = com.android.internal.R.drawable.ic_expand_notification;
            drawableId = com.android.internal.R.drawable.ic_expand_notification;
            contentDescriptionId
                    = com.android.internal.R.string.expand_button_content_description_collapsed;
        }
        }
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setColorFilter(mOriginalNotificationColor);
        mExpandButton.setColorFilter(mOriginalNotificationColor);
        mExpandButton.setContentDescription(mContext.getText(contentDescriptionId));
    }
    }


    public void setShowWorkBadgeAtEnd(boolean showWorkBadgeAtEnd) {
    public void setShowWorkBadgeAtEnd(boolean showWorkBadgeAtEnd) {
@@ -391,7 +365,7 @@ public class NotificationHeaderView extends ViewGroup {
                    break;
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_UP:
                    if (mTrackGesture) {
                    if (mTrackGesture) {
                        mExpandClickListener.onClick(NotificationHeaderView.this);
                        mExpandButton.performClick();
                    }
                    }
                    break;
                    break;
            }
            }
+8 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.RemoteViews;


@@ -59,4 +61,10 @@ public class NotificationExpandButton extends ImageView {
        rect.top = rect.centerY() - touchTargetSize / 2;
        rect.top = rect.centerY() - touchTargetSize / 2;
        rect.bottom = rect.top + touchTargetSize;
        rect.bottom = rect.top + touchTargetSize;
    }
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Button.class.getName());
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -97,7 +97,7 @@
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="1dp"
        android:paddingTop="1dp"
        android:visibility="gone"
        android:visibility="gone"
        android:contentDescription="@string/expand_button_content_description"
        android:contentDescription="@string/expand_button_content_description_collapsed"
        />
        />
    <ImageView android:id="@+id/profile_badge"
    <ImageView android:id="@+id/profile_badge"
        android:layout_width="@dimen/notification_badge_size"
        android:layout_width="@dimen/notification_badge_size"
+5 −2
Original line number Original line Diff line number Diff line
@@ -4382,8 +4382,11 @@
    <!-- Content description of the work profile icon in the notification. -->
    <!-- Content description of the work profile icon in the notification. -->
    <string name="notification_work_profile_content_description">Work profile</string>
    <string name="notification_work_profile_content_description">Work profile</string>


    <!-- Content description of the expand button icon in the notification.-->
    <!-- Content description of the expand button icon in the notification when collaped.-->
    <string name="expand_button_content_description">Expand button</string>
    <string name="expand_button_content_description_collapsed">Expand</string>

    <!-- Content description of the expand button icon in the notification when expanded.-->
    <string name="expand_button_content_description_expanded">Collapse</string>


    <!-- Accessibility action description on the expand button. -->
    <!-- Accessibility action description on the expand button. -->
    <string name="expand_action_accessibility">toggle expansion</string>
    <string name="expand_action_accessibility">toggle expansion</string>
+3 −0
Original line number Original line Diff line number Diff line
@@ -2888,6 +2888,9 @@
  <java-symbol type="style" name="Widget.LockPatternView" />
  <java-symbol type="style" name="Widget.LockPatternView" />
  <java-symbol type="attr" name="lockPatternStyle" />
  <java-symbol type="attr" name="lockPatternStyle" />


  <java-symbol type="string" name="expand_button_content_description_collapsed" />
  <java-symbol type="string" name="expand_button_content_description_expanded" />

  <!-- Colon separated list of package names that should be granted Notification Listener access -->
  <!-- Colon separated list of package names that should be granted Notification Listener access -->
  <java-symbol type="string" name="config_defaultListenerAccessPackages" />
  <java-symbol type="string" name="config_defaultListenerAccessPackages" />


Loading