Ensure Talkback announces text correctly in Gesture tutorial

This change modifies how Talkback announces the title and the subtitle
in the gesture navigation tutorial. It no longer shifts the focus to the
subtitle, but instead makes the whole window focusable.

Fix: 386884587
Test: Open the gesture tutorial with talkback and ensure the text is
announced without change of focus. Ensure the Done button doesn't get
announced
Flag: EXEMPT bugfix

Change-Id: Id28382acbebe763f2f64f4e49eb00d6ea61e0553
This commit is contained in:
Saumya Prakash
2025-02-26 05:41:08 +00:00
parent 5a8fcc3d40
commit 3fe4e7d90f
2 changed files with 5 additions and 43 deletions
@@ -137,6 +137,7 @@
android:layout_above="@id/gesture_tutorial_fragment_action_button"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
android:screenReaderFocusable="true"
android:paddingTop="24dp"
android:paddingHorizontal="24dp"
android:layout_marginBottom="16dp">
@@ -146,8 +147,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="104dp"
android:accessibilityHeading="true"
android:accessibilityTraversalBefore="@id/gesture_tutorial_fragment_feedback_subtitle"
android:gravity="top"
android:lineSpacingExtra="-1sp"
android:textAppearance="@style/TextAppearance.GestureTutorial.MainTitle"
@@ -162,8 +161,6 @@
android:layout_marginTop="24dp"
android:lineSpacingExtra="4sp"
android:textAppearance="@style/TextAppearance.GestureTutorial.MainSubtitle"
android:accessibilityTraversalAfter="@id/gesture_tutorial_fragment_feedback_title"
android:accessibilityTraversalBefore="@id/gesture_tutorial_fragment_action_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/gesture_tutorial_fragment_feedback_title" />
@@ -36,7 +36,6 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.Button;
import android.widget.FrameLayout;
@@ -123,13 +122,10 @@ abstract class TutorialController implements BackGestureAttemptCallback,
// These runnables should be used when posting callbacks to their views and cleared from their
// views before posting new callbacks.
private final Runnable mTitleViewCallback;
private final Runnable mSubtitleViewCallback;
@Nullable private Runnable mFeedbackViewCallback;
@Nullable private Runnable mFakeTaskViewCallback;
@Nullable private Runnable mFakeTaskbarViewCallback;
private final Runnable mShowFeedbackRunnable;
private final AccessibilityManager mAccessibilityManager;
TutorialController(TutorialFragment tutorialFragment, TutorialType tutorialType) {
mTutorialFragment = tutorialFragment;
@@ -185,17 +181,6 @@ abstract class TutorialController implements BackGestureAttemptCallback,
outline.setRoundRect(mExitingAppRect, mExitingAppRadius);
}
});
mAccessibilityManager = AccessibilityManager.getInstance(mContext);
mTitleViewCallback = () -> {
mFeedbackTitleView.requestFocus();
mFeedbackTitleView.sendAccessibilityEvent(
AccessibilityEvent.TYPE_VIEW_FOCUSED);
};
mSubtitleViewCallback = () -> {
mFeedbackSubtitleView.requestFocus();
mFeedbackSubtitleView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
};
mShowFeedbackRunnable = () -> {
mFeedbackView.setAlpha(0f);
mFeedbackView.setScaleX(0.95f);
@@ -214,14 +199,14 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mFeedbackViewCallback = mTutorialFragment::continueTutorial;
mFeedbackView.postDelayed(
mFeedbackViewCallback,
mAccessibilityManager.getRecommendedTimeoutMillis(
ADVANCE_TUTORIAL_TIMEOUT_MS,
AccessibilityManager.FLAG_CONTENT_TEXT
AccessibilityManager.getInstance(mContext)
.getRecommendedTimeoutMillis(
ADVANCE_TUTORIAL_TIMEOUT_MS,
AccessibilityManager.FLAG_CONTENT_TEXT
| AccessibilityManager.FLAG_CONTENT_CONTROLS));
}
})
.start();
mFeedbackTitleView.postDelayed(mTitleViewCallback, FEEDBACK_ANIMATION_MS);
};
}
@@ -414,8 +399,6 @@ abstract class TutorialController implements BackGestureAttemptCallback,
int titleResId,
int subtitleResId,
boolean isGestureSuccessful) {
mFeedbackTitleView.removeCallbacks(mTitleViewCallback);
mFeedbackSubtitleView.removeCallbacks(mSubtitleViewCallback);
if (mFeedbackViewCallback != null) {
mFeedbackView.removeCallbacks(mFeedbackViewCallback);
mFeedbackViewCallback = null;
@@ -423,15 +406,6 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mFeedbackTitleView.setText(titleResId);
mFeedbackSubtitleView.setText(subtitleResId);
mFeedbackTitleView.postDelayed(mTitleViewCallback, mAccessibilityManager
.getRecommendedTimeoutMillis(
FEEDBACK_ANIMATION_MS,
AccessibilityManager.FLAG_CONTENT_TEXT));
mFeedbackSubtitleView.postDelayed(mSubtitleViewCallback, mAccessibilityManager
.getRecommendedTimeoutMillis(
SUBTITLE_ANNOUNCE_DELAY_MS,
AccessibilityManager.FLAG_CONTENT_TEXT));
if (isGestureSuccessful) {
if (mTutorialFragment.isAtFinalStep()) {
showActionButton();
@@ -487,8 +461,6 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mFakeTaskbarView.removeCallbacks(mFakeTaskbarViewCallback);
mFakeTaskbarViewCallback = null;
}
mFeedbackTitleView.removeCallbacks(mTitleViewCallback);
mFeedbackSubtitleView.removeCallbacks(mSubtitleViewCallback);
}
private void playFeedbackAnimation() {
@@ -564,13 +536,6 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mSkipButton.setVisibility(GONE);
mDoneButton.setVisibility(View.VISIBLE);
mDoneButton.setOnClickListener(this::onActionButtonClicked);
mDoneButton.postDelayed(() -> {
mDoneButton.requestFocus();
mDoneButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
}, mAccessibilityManager
.getRecommendedTimeoutMillis(
DONE_BUTTON_ANNOUNCE_DELAY_MS,
AccessibilityManager.FLAG_CONTENT_CONTROLS));
}
void hideFakeTaskbar(boolean animateToHotseat) {