Loading java/res/values/dimens.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -122,4 +122,6 @@ <dimen name="accessibility_edge_slop">8dp</dimen> <dimen name="accessibility_edge_slop">8dp</dimen> <integer name="user_dictionary_max_word_length" translatable="false">48</integer> <integer name="user_dictionary_max_word_length" translatable="false">48</integer> <dimen name="language_on_spacebar_horizontal_margin">1dp</dimen> </resources> </resources> java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -183,6 +183,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private final NonDistinctMultitouchHelper mNonDistinctMultitouchHelper; private final NonDistinctMultitouchHelper mNonDistinctMultitouchHelper; private final KeyTimerHandler mKeyTimerHandler; private final KeyTimerHandler mKeyTimerHandler; private final int mLanguageOnSpacebarHorizontalMargin; private static final class KeyTimerHandler extends StaticInnerHandlerWrapper<MainKeyboardView> private static final class KeyTimerHandler extends StaticInnerHandlerWrapper<MainKeyboardView> implements TimerProxy { implements TimerProxy { Loading Loading @@ -512,6 +513,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack altCodeKeyWhileTypingFadeinAnimatorResId, this); altCodeKeyWhileTypingFadeinAnimatorResId, this); mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; mLanguageOnSpacebarHorizontalMargin = (int) getResources().getDimension(R.dimen.language_on_spacebar_horizontal_margin); } } @Override @Override Loading Loading @@ -1188,26 +1192,27 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack } } } } private static boolean fitsTextIntoWidth(final int width, final String text, private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) { final Paint paint) { final int maxTextWidth = width - mLanguageOnSpacebarHorizontalMargin * 2; paint.setTextScaleX(1.0f); paint.setTextScaleX(1.0f); final float textWidth = TypefaceUtils.getLabelWidth(text, paint); final float textWidth = TypefaceUtils.getLabelWidth(text, paint); if (textWidth < width) { if (textWidth < width) { return true; return true; } } final float scaleX = width / textWidth; final float scaleX = maxTextWidth / textWidth; if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) { if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) { return false; return false; } } paint.setTextScaleX(scaleX); paint.setTextScaleX(scaleX); return TypefaceUtils.getLabelWidth(text, paint) < width; return TypefaceUtils.getLabelWidth(text, paint) < maxTextWidth; } } // Layout language name on spacebar. // Layout language name on spacebar. private static String layoutLanguageOnSpacebar(final Paint paint, private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype, final int width) { final InputMethodSubtype subtype, final int width) { // Choose appropriate language name to fit into the width. // Choose appropriate language name to fit into the width. final String fullText = SubtypeLocaleUtils.getFullDisplayName(subtype); final String fullText = SubtypeLocaleUtils.getFullDisplayName(subtype); if (fitsTextIntoWidth(width, fullText, paint)) { if (fitsTextIntoWidth(width, fullText, paint)) { Loading Loading
java/res/values/dimens.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -122,4 +122,6 @@ <dimen name="accessibility_edge_slop">8dp</dimen> <dimen name="accessibility_edge_slop">8dp</dimen> <integer name="user_dictionary_max_word_length" translatable="false">48</integer> <integer name="user_dictionary_max_word_length" translatable="false">48</integer> <dimen name="language_on_spacebar_horizontal_margin">1dp</dimen> </resources> </resources>
java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -183,6 +183,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private final NonDistinctMultitouchHelper mNonDistinctMultitouchHelper; private final NonDistinctMultitouchHelper mNonDistinctMultitouchHelper; private final KeyTimerHandler mKeyTimerHandler; private final KeyTimerHandler mKeyTimerHandler; private final int mLanguageOnSpacebarHorizontalMargin; private static final class KeyTimerHandler extends StaticInnerHandlerWrapper<MainKeyboardView> private static final class KeyTimerHandler extends StaticInnerHandlerWrapper<MainKeyboardView> implements TimerProxy { implements TimerProxy { Loading Loading @@ -512,6 +513,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack altCodeKeyWhileTypingFadeinAnimatorResId, this); altCodeKeyWhileTypingFadeinAnimatorResId, this); mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER; mLanguageOnSpacebarHorizontalMargin = (int) getResources().getDimension(R.dimen.language_on_spacebar_horizontal_margin); } } @Override @Override Loading Loading @@ -1188,26 +1192,27 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack } } } } private static boolean fitsTextIntoWidth(final int width, final String text, private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) { final Paint paint) { final int maxTextWidth = width - mLanguageOnSpacebarHorizontalMargin * 2; paint.setTextScaleX(1.0f); paint.setTextScaleX(1.0f); final float textWidth = TypefaceUtils.getLabelWidth(text, paint); final float textWidth = TypefaceUtils.getLabelWidth(text, paint); if (textWidth < width) { if (textWidth < width) { return true; return true; } } final float scaleX = width / textWidth; final float scaleX = maxTextWidth / textWidth; if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) { if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) { return false; return false; } } paint.setTextScaleX(scaleX); paint.setTextScaleX(scaleX); return TypefaceUtils.getLabelWidth(text, paint) < width; return TypefaceUtils.getLabelWidth(text, paint) < maxTextWidth; } } // Layout language name on spacebar. // Layout language name on spacebar. private static String layoutLanguageOnSpacebar(final Paint paint, private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype, final int width) { final InputMethodSubtype subtype, final int width) { // Choose appropriate language name to fit into the width. // Choose appropriate language name to fit into the width. final String fullText = SubtypeLocaleUtils.getFullDisplayName(subtype); final String fullText = SubtypeLocaleUtils.getFullDisplayName(subtype); if (fitsTextIntoWidth(width, fullText, paint)) { if (fitsTextIntoWidth(width, fullText, paint)) { Loading