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

Commit 406d3a2e authored by Rhed Jao's avatar Rhed Jao
Browse files

Update toast to use a11y api for duration timeout.

Using api introduced by A11yManager to get recommended ui timeout
value for toast duration.

Bug: 119893870
Test: atest ToastTest
Change-Id: Ib95630529a3f03b9da34d7f1b32d1b53a7ee96c8
parent 5e00c986
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -5475,7 +5475,12 @@ public class NotificationManagerService extends SystemService {
    {
        mHandler.removeCallbacksAndMessages(r);
        Message m = Message.obtain(mHandler, MESSAGE_DURATION_REACHED, r);
        long delay = r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY;
        int delay = r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY;
        // Accessibility users may need longer timeout duration. This api compares original delay
        // with user's preference and return longer one. It returns original delay if there's no
        // preference.
        delay = mAccessibilityManager.getRecommendedTimeoutMillis(delay,
                AccessibilityManager.FLAG_CONTENT_TEXT);
        mHandler.sendMessageDelayed(m, delay);
    }

+6 −0
Original line number Diff line number Diff line
@@ -755,6 +755,12 @@ public class DisplayPolicy {
                        || attrs.hideTimeoutMilliseconds > TOAST_WINDOW_TIMEOUT) {
                    attrs.hideTimeoutMilliseconds = TOAST_WINDOW_TIMEOUT;
                }
                // Accessibility users may need longer timeout duration. This api compares
                // original timeout with user's preference and return longer one. It returns
                // original timeout if there's no preference.
                attrs.hideTimeoutMilliseconds = mAccessibilityManager.getRecommendedTimeoutMillis(
                        (int) attrs.hideTimeoutMilliseconds,
                        AccessibilityManager.FLAG_CONTENT_TEXT);
                attrs.windowAnimations = com.android.internal.R.style.Animation_Toast;
                break;
        }