mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 02:08:20 +00:00
Announce for accessiblity when taskbar is invoked/closed
Test: Manual Bug: 265620540 Change-Id: I6660be7716ec59c765f3d54f8fe9889eaaf56e10
This commit is contained in:
@@ -278,6 +278,10 @@
|
||||
<string name="taskbar_button_quick_settings">Quick Settings</string>
|
||||
<!-- Accessibility title for the Taskbar window. [CHAR_LIMIT=NONE] -->
|
||||
<string name="taskbar_a11y_title">Taskbar</string>
|
||||
<!-- Accessibility title for the Taskbar window appeared. [CHAR_LIMIT=NONE] -->
|
||||
<string name="taskbar_a11y_shown_title">Taskbar shown</string>
|
||||
<!-- Accessibility title for the Taskbar window being close. [CHAR_LIMIT=NONE] -->
|
||||
<string name="taskbar_a11y_hidden_title">Taskbar hidden</string>
|
||||
<!-- Accessibility title for the Taskbar window on phones. [CHAR_LIMIT=NONE] -->
|
||||
<string name="taskbar_phone_a11y_title">Navigation bar</string>
|
||||
|
||||
|
||||
@@ -600,6 +600,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
if (!mIsStashed) {
|
||||
tryStartTaskbarTimeout();
|
||||
}
|
||||
mControllers.taskbarViewController.announceForAccessibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static android.content.pm.PackageManager.FEATURE_PC;
|
||||
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
@@ -153,7 +156,26 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
// TODO: Disable touch events on QSB otherwise it can crash.
|
||||
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
|
||||
if (action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
|
||||
announceForAccessibility(mContext.getString(R.string.taskbar_a11y_shown_title));
|
||||
} else if (action == AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) {
|
||||
announceForAccessibility(mContext.getString(R.string.taskbar_a11y_hidden_title));
|
||||
}
|
||||
return super.performAccessibilityActionInternal(action, arguments);
|
||||
|
||||
}
|
||||
|
||||
protected void announceAccessibilityChanges() {
|
||||
this.performAccessibilityAction(
|
||||
isVisibleToUser() ? AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS
|
||||
: AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS, null);
|
||||
|
||||
ActivityContext.lookupContext(getContext()).getDragLayer()
|
||||
.sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
|
||||
}
|
||||
|
||||
private int getColorWithGivenLuminance(int color, float luminance) {
|
||||
|
||||
@@ -189,6 +189,13 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
mActivity.addOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcement for Accessibility when Taskbar stashes/unstashes.
|
||||
*/
|
||||
public void announceForAccessibility() {
|
||||
mTaskbarView.announceAccessibilityChanges();
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
|
||||
mActivity.removeOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -78,6 +79,12 @@ public class IconButtonView extends BubbleTextView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
super.onPopulateAccessibilityEvent(event);
|
||||
event.getText().add(this.getContentDescription());
|
||||
}
|
||||
|
||||
/** Sets given Drawable as icon */
|
||||
public void setIconDrawable(@NonNull Drawable drawable) {
|
||||
ColorStateList tintList = getBackgroundTintList();
|
||||
|
||||
Reference in New Issue
Block a user