Merge "Make TextView respect ACCESSIBILITY_SPEAK_PASSWORD preference." into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
de83e7aa32
@@ -39,6 +39,7 @@ import android.os.Message;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.text.BoringLayout;
|
||||
import android.text.DynamicLayout;
|
||||
import android.text.Editable;
|
||||
@@ -7705,14 +7706,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
super.onPopulateAccessibilityEvent(event);
|
||||
|
||||
final boolean isPassword = hasPasswordTransformationMethod();
|
||||
if (!isPassword) {
|
||||
CharSequence text = getTextForAccessibility();
|
||||
if (!isPassword || shouldSpeakPasswordsForAccessibility()) {
|
||||
final CharSequence text = getTextForAccessibility();
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
event.getText().add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the user has explicitly allowed accessibility services
|
||||
* to speak passwords.
|
||||
*/
|
||||
private boolean shouldSpeakPasswordsForAccessibility() {
|
||||
return (Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
|
||||
super.onInitializeAccessibilityEvent(event);
|
||||
|
||||
Reference in New Issue
Block a user