Load KeyCodeDescriptionMapper class lazily
Change-Id: I2cba2bb5b2f449ed29895365b9c6ca285a7640fe
This commit is contained in:
parent
9a2162e6f2
commit
ae0fab9550
4 changed files with 9 additions and 20 deletions
|
@ -67,7 +67,6 @@ public final class AccessibilityUtils {
|
||||||
|
|
||||||
// These only need to be initialized if the kill switch is off.
|
// These only need to be initialized if the kill switch is off.
|
||||||
sInstance.initInternal(context);
|
sInstance.initInternal(context);
|
||||||
KeyCodeDescriptionMapper.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AccessibilityUtils getInstance() {
|
public static AccessibilityUtils getInstance() {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class KeyCodeDescriptionMapper {
|
final class KeyCodeDescriptionMapper {
|
||||||
private static final String TAG = KeyCodeDescriptionMapper.class.getSimpleName();
|
private static final String TAG = KeyCodeDescriptionMapper.class.getSimpleName();
|
||||||
private static final String SPOKEN_LETTER_RESOURCE_NAME_FORMAT = "spoken_accented_letter_%04X";
|
private static final String SPOKEN_LETTER_RESOURCE_NAME_FORMAT = "spoken_accented_letter_%04X";
|
||||||
private static final String SPOKEN_SYMBOL_RESOURCE_NAME_FORMAT = "spoken_symbol_%04X";
|
private static final String SPOKEN_SYMBOL_RESOURCE_NAME_FORMAT = "spoken_symbol_%04X";
|
||||||
|
@ -40,24 +40,16 @@ public final class KeyCodeDescriptionMapper {
|
||||||
// The resource ID of the string spoken for obscured keys
|
// The resource ID of the string spoken for obscured keys
|
||||||
private static final int OBSCURED_KEY_RES_ID = R.string.spoken_description_dot;
|
private static final int OBSCURED_KEY_RES_ID = R.string.spoken_description_dot;
|
||||||
|
|
||||||
private static KeyCodeDescriptionMapper sInstance = new KeyCodeDescriptionMapper();
|
private static final KeyCodeDescriptionMapper sInstance = new KeyCodeDescriptionMapper();
|
||||||
|
|
||||||
// Sparse array of spoken description resource IDs indexed by key codes
|
|
||||||
private final SparseIntArray mKeyCodeMap;
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
sInstance.initInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KeyCodeDescriptionMapper getInstance() {
|
public static KeyCodeDescriptionMapper getInstance() {
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyCodeDescriptionMapper() {
|
// Sparse array of spoken description resource IDs indexed by key codes
|
||||||
mKeyCodeMap = new SparseIntArray();
|
private final SparseIntArray mKeyCodeMap = new SparseIntArray();
|
||||||
}
|
|
||||||
|
|
||||||
private void initInternal() {
|
private KeyCodeDescriptionMapper() {
|
||||||
// Special non-character codes defined in Keyboard
|
// Special non-character codes defined in Keyboard
|
||||||
mKeyCodeMap.put(Constants.CODE_SPACE, R.string.spoken_description_space);
|
mKeyCodeMap.put(Constants.CODE_SPACE, R.string.spoken_description_space);
|
||||||
mKeyCodeMap.put(Constants.CODE_DELETE, R.string.spoken_description_delete);
|
mKeyCodeMap.put(Constants.CODE_DELETE, R.string.spoken_description_delete);
|
||||||
|
|
|
@ -47,7 +47,7 @@ import java.util.List;
|
||||||
* virtual views, thus conveying their logical structure.
|
* virtual views, thus conveying their logical structure.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat {
|
final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat {
|
||||||
private static final String TAG = KeyboardAccessibilityNodeProvider.class.getSimpleName();
|
private static final String TAG = KeyboardAccessibilityNodeProvider.class.getSimpleName();
|
||||||
private static final int UNDEFINED = Integer.MIN_VALUE;
|
private static final int UNDEFINED = Integer.MIN_VALUE;
|
||||||
|
|
||||||
|
|
|
@ -381,14 +381,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||||
mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
|
mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
|
||||||
|
|
||||||
final MainKeyboardAccessibilityDelegate accessibilityDelegate;
|
|
||||||
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
|
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
|
||||||
accessibilityDelegate = new MainKeyboardAccessibilityDelegate(this, mKeyDetector);
|
mAccessibilityDelegate = new MainKeyboardAccessibilityDelegate(this, mKeyDetector);
|
||||||
accessibilityDelegate.setKeyboard(keyboard);
|
mAccessibilityDelegate.setKeyboard(keyboard);
|
||||||
} else {
|
} else {
|
||||||
accessibilityDelegate = null;
|
mAccessibilityDelegate = null;
|
||||||
}
|
}
|
||||||
mAccessibilityDelegate = accessibilityDelegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue