Merge "Keyguard: Remove fancy colon" into oc-dr1-dev
am: 55bc522d0d
Change-Id: I37e3b2ca2d54f9f84b3d309ba0b099bd032da65a
This commit is contained in:
@@ -99,12 +99,12 @@
|
|||||||
<string name="keyguard_sim_unlock_progress_dialog_message">Unlocking SIM card\u2026</string>
|
<string name="keyguard_sim_unlock_progress_dialog_message">Unlocking SIM card\u2026</string>
|
||||||
|
|
||||||
<!-- Time format strings for fall-back clock widget -->
|
<!-- Time format strings for fall-back clock widget -->
|
||||||
<string name="keyguard_widget_12_hours_format" translatable="false">h\uee01mm</string>
|
<string name="keyguard_widget_12_hours_format" translatable="false">h:mm</string>
|
||||||
<!-- Time format strings for fall-back clock widget -->
|
<!-- Time format strings for fall-back clock widget -->
|
||||||
<string name="keyguard_widget_24_hours_format" translatable="false">kk\uee01mm</string>
|
<string name="keyguard_widget_24_hours_format" translatable="false">kk:mm</string>
|
||||||
<!-- The character used in keyguard_widget_12_hours_format and keyguard_widget_24_hours_format
|
<!-- The character used in keyguard_widget_12_hours_format and keyguard_widget_24_hours_format
|
||||||
to represent a ":". -->
|
to represent a ":". -->
|
||||||
<string name="keyguard_fancy_colon" translatable="false">\uee01</string>
|
<string name="keyguard_fancy_colon" translatable="false"></string>
|
||||||
|
|
||||||
<!-- Accessibility description of the PIN password view. [CHAR_LIMIT=none] -->
|
<!-- Accessibility description of the PIN password view. [CHAR_LIMIT=none] -->
|
||||||
<string name="keyguard_accessibility_pin_area">PIN area</string>
|
<string name="keyguard_accessibility_pin_area">PIN area</string>
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ class KeyguardClockAccessibilityDelegate extends View.AccessibilityDelegate {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
|
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
|
||||||
super.onInitializeAccessibilityEvent(host, event);
|
super.onInitializeAccessibilityEvent(host, event);
|
||||||
|
if (TextUtils.isEmpty(mFancyColon)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CharSequence text = event.getContentDescription();
|
CharSequence text = event.getContentDescription();
|
||||||
if (!TextUtils.isEmpty(text)) {
|
if (!TextUtils.isEmpty(text)) {
|
||||||
event.setContentDescription(replaceFancyColon(text));
|
event.setContentDescription(replaceFancyColon(text));
|
||||||
@@ -44,15 +47,22 @@ class KeyguardClockAccessibilityDelegate extends View.AccessibilityDelegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
|
public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
|
||||||
CharSequence text = ((TextView) host).getText();
|
if (TextUtils.isEmpty(mFancyColon)) {
|
||||||
if (!TextUtils.isEmpty(text)) {
|
super.onPopulateAccessibilityEvent(host, event);
|
||||||
event.getText().add(replaceFancyColon(text));
|
} else {
|
||||||
|
CharSequence text = ((TextView) host).getText();
|
||||||
|
if (!TextUtils.isEmpty(text)) {
|
||||||
|
event.getText().add(replaceFancyColon(text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||||
|
if (TextUtils.isEmpty(mFancyColon)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!TextUtils.isEmpty(info.getText())) {
|
if (!TextUtils.isEmpty(info.getText())) {
|
||||||
info.setText(replaceFancyColon(info.getText()));
|
info.setText(replaceFancyColon(info.getText()));
|
||||||
}
|
}
|
||||||
@@ -62,6 +72,13 @@ class KeyguardClockAccessibilityDelegate extends View.AccessibilityDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence replaceFancyColon(CharSequence text) {
|
private CharSequence replaceFancyColon(CharSequence text) {
|
||||||
|
if (TextUtils.isEmpty(mFancyColon)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
return text.toString().replace(mFancyColon, ":");
|
return text.toString().replace(mFancyColon, ":");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNeeded(Context context) {
|
||||||
|
return !TextUtils.isEmpty(context.getString(R.string.keyguard_fancy_colon));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,9 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
mDateView = findViewById(R.id.date_view);
|
mDateView = findViewById(R.id.date_view);
|
||||||
mClockView = findViewById(R.id.clock_view);
|
mClockView = findViewById(R.id.clock_view);
|
||||||
mClockView.setShowCurrentUserTime(true);
|
mClockView.setShowCurrentUserTime(true);
|
||||||
mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) {
|
||||||
|
mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
||||||
|
}
|
||||||
mOwnerInfo = findViewById(R.id.owner_info);
|
mOwnerInfo = findViewById(R.id.owner_info);
|
||||||
mBatteryDoze = findViewById(R.id.battery_doze);
|
mBatteryDoze = findViewById(R.id.battery_doze);
|
||||||
mKeyguardStatusArea = findViewById(R.id.keyguard_status_area);
|
mKeyguardStatusArea = findViewById(R.id.keyguard_status_area);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@@ -36,12 +37,17 @@ import java.util.List;
|
|||||||
public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase {
|
public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase {
|
||||||
|
|
||||||
private TextView mView;
|
private TextView mView;
|
||||||
|
private String m12HoursFormat;
|
||||||
|
private String m24HoursFormat;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
m12HoursFormat = mContext.getString(R.string.keyguard_widget_12_hours_format);
|
||||||
|
m24HoursFormat = mContext.getString(R.string.keyguard_widget_24_hours_format);
|
||||||
|
|
||||||
mView = new TextView(mContext);
|
mView = new TextView(mContext);
|
||||||
mView.setText(R.string.keyguard_widget_12_hours_format);
|
mView.setText(m12HoursFormat);
|
||||||
mView.setContentDescription(mContext.getString(R.string.keyguard_widget_12_hours_format));
|
mView.setContentDescription(m12HoursFormat);
|
||||||
mView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
mView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +83,21 @@ public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase {
|
|||||||
assertTrue(isAscii(info.getContentDescription()));
|
assertTrue(isAscii(info.getContentDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNeeded_returnsTrueIfDateFormatsContainNonAscii() {
|
||||||
|
if (!isAscii(m12HoursFormat) || !isAscii(m24HoursFormat)) {
|
||||||
|
assertTrue(KeyguardClockAccessibilityDelegate.isNeeded(mContext));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNeeded_returnsWhetherFancyColonExists() {
|
||||||
|
boolean hasFancyColon = !TextUtils.isEmpty(mContext.getString(
|
||||||
|
R.string.keyguard_fancy_colon));
|
||||||
|
|
||||||
|
assertEquals(hasFancyColon, KeyguardClockAccessibilityDelegate.isNeeded(mContext));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isAscii(CharSequence text) {
|
private boolean isAscii(CharSequence text) {
|
||||||
return text.chars().allMatch((i) -> i < 128);
|
return text.chars().allMatch((i) -> i < 128);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user