Merge "Use title-case for language name on spacebar, even for the abbrev."
commit
5e643e9253
|
@ -70,7 +70,7 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
for (int i = 0; i < mAvailableLanguages.size(); i++) {
|
for (int i = 0; i < mAvailableLanguages.size(); i++) {
|
||||||
CheckBoxPreference pref = new CheckBoxPreference(this);
|
CheckBoxPreference pref = new CheckBoxPreference(this);
|
||||||
Locale locale = mAvailableLanguages.get(i).locale;
|
Locale locale = mAvailableLanguages.get(i).locale;
|
||||||
pref.setTitle(toTitleCase(locale.getDisplayName(locale)));
|
pref.setTitle(LanguageSwitcher.toTitleCase(locale.getDisplayName(locale)));
|
||||||
boolean checked = isLocaleIn(locale, languageList);
|
boolean checked = isLocaleIn(locale, languageList);
|
||||||
pref.setChecked(checked);
|
pref.setChecked(checked);
|
||||||
parent.addPreference(pref);
|
parent.addPreference(pref);
|
||||||
|
@ -138,7 +138,7 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
|
|
||||||
if (finalSize == 0) {
|
if (finalSize == 0) {
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
new Loc(toTitleCase(l.getDisplayName(l)), l);
|
new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName(l)), l);
|
||||||
} else {
|
} else {
|
||||||
// check previous entry:
|
// check previous entry:
|
||||||
// same lang and a country -> upgrade to full name and
|
// same lang and a country -> upgrade to full name and
|
||||||
|
@ -146,15 +146,15 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
// diff lang -> insert ours with lang-only name
|
// diff lang -> insert ours with lang-only name
|
||||||
if (preprocess[finalSize-1].locale.getLanguage().equals(
|
if (preprocess[finalSize-1].locale.getLanguage().equals(
|
||||||
language)) {
|
language)) {
|
||||||
preprocess[finalSize-1].label = toTitleCase(
|
preprocess[finalSize-1].label = LanguageSwitcher.toTitleCase(
|
||||||
preprocess[finalSize-1].locale.getDisplayName());
|
preprocess[finalSize-1].locale.getDisplayName());
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
new Loc(toTitleCase(l.getDisplayName()), l);
|
new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName()), l);
|
||||||
} else {
|
} else {
|
||||||
String displayName;
|
String displayName;
|
||||||
if (s.equals("zz_ZZ")) {
|
if (s.equals("zz_ZZ")) {
|
||||||
} else {
|
} else {
|
||||||
displayName = toTitleCase(l.getDisplayName(l));
|
displayName = LanguageSwitcher.toTitleCase(l.getDisplayName(l));
|
||||||
preprocess[finalSize++] = new Loc(displayName, l);
|
preprocess[finalSize++] = new Loc(displayName, l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,13 +166,4 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
}
|
}
|
||||||
return uniqueLocales;
|
return uniqueLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toTitleCase(String s) {
|
|
||||||
if (s.length() == 0) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,4 +169,12 @@ public class LanguageSwitcher {
|
||||||
editor.putString(LatinIME.PREF_INPUT_LANGUAGE, getInputLanguage());
|
editor.putString(LatinIME.PREF_INPUT_LANGUAGE, getInputLanguage());
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String toTitleCase(String s) {
|
||||||
|
if (s.length() == 0) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
|
private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
|
||||||
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
||||||
private static final String VOICE_SETTINGS_KEY = "enable_voice_input";
|
private static final String VOICE_SETTINGS_KEY = "enable_voice_input";
|
||||||
|
private static final String VOICE_ON_PRIMARY_KEY = "voice_on_main";
|
||||||
private static final String VOICE_SERVER_KEY = "voice_server_url";
|
private static final String VOICE_SERVER_KEY = "voice_server_url";
|
||||||
|
|
||||||
private static final String TAG = "LatinIMESettings";
|
private static final String TAG = "LatinIMESettings";
|
||||||
|
@ -58,6 +59,7 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
private CheckBoxPreference mQuickFixes;
|
private CheckBoxPreference mQuickFixes;
|
||||||
private CheckBoxPreference mShowSuggestions;
|
private CheckBoxPreference mShowSuggestions;
|
||||||
private CheckBoxPreference mVoicePreference;
|
private CheckBoxPreference mVoicePreference;
|
||||||
|
private CheckBoxPreference mVoiceOnPrimary;
|
||||||
|
|
||||||
private VoiceInputLogger mLogger;
|
private VoiceInputLogger mLogger;
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
|
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
|
||||||
mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
|
mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
|
||||||
mVoicePreference = (CheckBoxPreference) findPreference(VOICE_SETTINGS_KEY);
|
mVoicePreference = (CheckBoxPreference) findPreference(VOICE_SETTINGS_KEY);
|
||||||
|
mVoiceOnPrimary = (CheckBoxPreference) findPreference(VOICE_ON_PRIMARY_KEY);
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
@ -93,6 +95,7 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
}
|
}
|
||||||
if (!LatinIME.VOICE_INSTALLED
|
if (!LatinIME.VOICE_INSTALLED
|
||||||
|| !RecognitionManager.isRecognitionAvailable(this)) {
|
|| !RecognitionManager.isRecognitionAvailable(this)) {
|
||||||
|
getPreferenceScreen().removePreference(mVoiceOnPrimary);
|
||||||
getPreferenceScreen().removePreference(mVoicePreference);
|
getPreferenceScreen().removePreference(mVoicePreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,19 +298,33 @@ public class LatinKeyboard extends Keyboard {
|
||||||
Bitmap buffer = Bitmap.createBitmap(mSpaceKey.width, mSpaceIcon.getIntrinsicHeight(),
|
Bitmap buffer = Bitmap.createBitmap(mSpaceKey.width, mSpaceIcon.getIntrinsicHeight(),
|
||||||
Bitmap.Config.ARGB_8888);
|
Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(buffer);
|
Canvas canvas = new Canvas(buffer);
|
||||||
|
drawSpaceBar(canvas, buffer.getWidth(), buffer.getHeight(), 255);
|
||||||
|
mSpaceKey.icon = new BitmapDrawable(mRes, buffer);
|
||||||
|
mSpaceKey.repeatable = mLanguageSwitcher.getLocaleCount() < 2;
|
||||||
|
} else {
|
||||||
|
mSpaceKey.icon = mRes.getDrawable(R.drawable.sym_keyboard_space);
|
||||||
|
mSpaceKey.repeatable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawSpaceBar(Canvas canvas, int width, int height, int opacity) {
|
||||||
canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
|
canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setAlpha(opacity);
|
||||||
// Get the text size from the theme
|
// Get the text size from the theme
|
||||||
paint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14));
|
paint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14));
|
||||||
paint.setTextAlign(Align.CENTER);
|
paint.setTextAlign(Align.CENTER);
|
||||||
// Draw a drop shadow for the text
|
//// Draw a drop shadow for the text
|
||||||
paint.setShadowLayer(2f, 0, 0, 0xFF000000);
|
//paint.setShadowLayer(2f, 0, 0, 0xFF000000);
|
||||||
paint.setColor(0xFF808080);
|
|
||||||
final String language = getInputLanguage(mSpaceKey.width, paint);
|
final String language = getInputLanguage(mSpaceKey.width, paint);
|
||||||
final int ascent = (int) -paint.ascent();
|
final int ascent = (int) -paint.ascent();
|
||||||
|
paint.setColor(0x80000000);
|
||||||
canvas.drawText(language,
|
canvas.drawText(language,
|
||||||
buffer.getWidth() / 2, ascent, paint);
|
width / 2, ascent - 1, paint);
|
||||||
|
paint.setColor(0xFF808080);
|
||||||
|
canvas.drawText(language,
|
||||||
|
width / 2, ascent, paint);
|
||||||
// Put arrows on either side of the text
|
// Put arrows on either side of the text
|
||||||
if (mLanguageSwitcher.getLocaleCount() > 1) {
|
if (mLanguageSwitcher.getLocaleCount() > 1) {
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
|
@ -323,17 +337,11 @@ public class LatinKeyboard extends Keyboard {
|
||||||
(mSpaceKey.width + bounds.right) / 2, (int) paint.getTextSize());
|
(mSpaceKey.width + bounds.right) / 2, (int) paint.getTextSize());
|
||||||
}
|
}
|
||||||
// Draw the spacebar icon at the bottom
|
// Draw the spacebar icon at the bottom
|
||||||
int x = (buffer.getWidth() - mSpaceIcon.getIntrinsicWidth()) / 2;
|
int x = (width - mSpaceIcon.getIntrinsicWidth()) / 2;
|
||||||
int y = buffer.getHeight() - mSpaceIcon.getIntrinsicHeight();
|
int y = height - mSpaceIcon.getIntrinsicHeight();
|
||||||
mSpaceIcon.setBounds(x, y,
|
mSpaceIcon.setBounds(x, y,
|
||||||
x + mSpaceIcon.getIntrinsicWidth(), y + mSpaceIcon.getIntrinsicHeight());
|
x + mSpaceIcon.getIntrinsicWidth(), y + mSpaceIcon.getIntrinsicHeight());
|
||||||
mSpaceIcon.draw(canvas);
|
mSpaceIcon.draw(canvas);
|
||||||
mSpaceKey.icon = new BitmapDrawable(mRes, buffer);
|
|
||||||
mSpaceKey.repeatable = mLanguageSwitcher.getLocaleCount() < 2;
|
|
||||||
} else {
|
|
||||||
mSpaceKey.icon = mRes.getDrawable(R.drawable.sym_keyboard_space);
|
|
||||||
mSpaceKey.repeatable = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawButtonArrow(Drawable arrow, Canvas canvas, int x, int bottomY) {
|
private void drawButtonArrow(Drawable arrow, Canvas canvas, int x, int bottomY) {
|
||||||
|
@ -356,9 +364,9 @@ public class LatinKeyboard extends Keyboard {
|
||||||
|
|
||||||
private String chooseDisplayName(Locale locale, int widthAvail, Paint paint) {
|
private String chooseDisplayName(Locale locale, int widthAvail, Paint paint) {
|
||||||
if (widthAvail < (int) (.35 * getMinWidth())) {
|
if (widthAvail < (int) (.35 * getMinWidth())) {
|
||||||
return locale.getLanguage().substring(0, 2).toUpperCase(locale);
|
return LanguageSwitcher.toTitleCase(locale.getLanguage().substring(0, 2));
|
||||||
} else {
|
} else {
|
||||||
return locale.getDisplayLanguage(locale);
|
return LanguageSwitcher.toTitleCase(locale.getDisplayLanguage(locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue