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

Commit 63bce03c authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Switch state text not added to accessibility events.

1. Adding the text to the events now.

bug:5071053

Change-Id: If36afb1f5327720fc002b8c49e5d7b00c5f189f7
parent d24cd904
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.view.Gravity;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;

import com.android.internal.R;

@@ -360,6 +361,13 @@ public class Switch extends CompoundButton {
        }
    }

    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        super.onPopulateAccessibilityEvent(event);
        Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
        event.getText().add(switchText.getText());
    }

    private Layout makeLayout(CharSequence text) {
        return new StaticLayout(text, mTextPaint,
                (int) Math.ceil(Layout.getDesiredWidth(text, mTextPaint)),