am c99c0ed9: Merge "Notify keyboard language on space bar when it has changed" into honeycomb
* commit 'c99c0ed939bb441a4ee7b2c3eb643620f3dbce28': Notify keyboard language on space bar when it has changedmain
commit
42b62c1440
|
@ -28,6 +28,9 @@
|
||||||
<bool name="config_digit_popup_characters_enabled">false</bool>
|
<bool name="config_digit_popup_characters_enabled">false</bool>
|
||||||
<!-- Whether or not Popup on key press is enabled by default -->
|
<!-- Whether or not Popup on key press is enabled by default -->
|
||||||
<bool name="config_default_popup_preview">false</bool>
|
<bool name="config_default_popup_preview">false</bool>
|
||||||
|
<bool name="config_use_spacebar_language_switcher">false</bool>
|
||||||
|
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
||||||
|
<integer name="config_delay_before_fadeout_language_on_spacebar">1200</integer>
|
||||||
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
||||||
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
||||||
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
<bool name="config_digit_popup_characters_enabled">true</bool>
|
<bool name="config_digit_popup_characters_enabled">true</bool>
|
||||||
<!-- Whether or not Popup on key press is enabled by default -->
|
<!-- Whether or not Popup on key press is enabled by default -->
|
||||||
<bool name="config_default_popup_preview">true</bool>
|
<bool name="config_default_popup_preview">true</bool>
|
||||||
|
<bool name="config_use_spacebar_language_switcher">true</bool>
|
||||||
|
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
||||||
|
<integer name="config_delay_before_fadeout_language_on_spacebar">-1</integer>
|
||||||
|
<integer name="config_duration_of_fadeout_language_on_spacebar">50</integer>
|
||||||
<integer name="config_delay_before_preview">0</integer>
|
<integer name="config_delay_before_preview">0</integer>
|
||||||
<integer name="config_delay_after_preview">10</integer>
|
<integer name="config_delay_after_preview">10</integer>
|
||||||
<integer name="config_preview_fadein_anim_time">0</integer>
|
<integer name="config_preview_fadein_anim_time">0</integer>
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
|
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
|
||||||
latin:code="@integer/key_space"
|
latin:code="@integer/key_space"
|
||||||
latin:keyIcon="@drawable/sym_keyboard_space_holo"
|
|
||||||
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="smileyKeyStyle"
|
latin:styleName="smileyKeyStyle"
|
||||||
|
@ -102,12 +101,10 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="spaceKeyStyle"
|
latin:styleName="spaceKeyStyle"
|
||||||
latin:code="@integer/key_space"
|
latin:code="@integer/key_space"
|
||||||
latin:keyIcon="@drawable/sym_bkeyboard_space"
|
|
||||||
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
|
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
|
||||||
latin:code="@integer/key_space"
|
latin:code="@integer/key_space"
|
||||||
latin:keyIcon="@drawable/sym_bkeyboard_space"
|
|
||||||
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="smileyKeyStyle"
|
latin:styleName="smileyKeyStyle"
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="numSpaceKeyStyle"
|
latin:styleName="numSpaceKeyStyle"
|
||||||
latin:code="@integer/key_space"
|
latin:code="@integer/key_space"
|
||||||
latin:keyIcon="@drawable/sym_keyboard_space_holo"
|
|
||||||
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
<case
|
||||||
|
@ -143,7 +142,6 @@
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="numSpaceKeyStyle"
|
latin:styleName="numSpaceKeyStyle"
|
||||||
latin:code="@integer/key_space"
|
latin:code="@integer/key_space"
|
||||||
latin:keyIcon="@drawable/sym_bkeyboard_space"
|
|
||||||
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
|
||||||
</case>
|
</case>
|
||||||
</switch>
|
</switch>
|
||||||
|
|
|
@ -157,7 +157,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
boolean voiceButtonOnPrimary) {
|
boolean voiceButtonOnPrimary) {
|
||||||
mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA;
|
mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA;
|
||||||
try {
|
try {
|
||||||
|
if (mInputView == null) return;
|
||||||
|
final Keyboard oldKeyboard = mInputView.getKeyboard();
|
||||||
loadKeyboardInternal(mode, imeOptions, voiceKeyEnabled, voiceButtonOnPrimary, false);
|
loadKeyboardInternal(mode, imeOptions, voiceKeyEnabled, voiceButtonOnPrimary, false);
|
||||||
|
final Keyboard newKeyboard = mInputView.getKeyboard();
|
||||||
|
if (newKeyboard.isAlphaKeyboard() && (oldKeyboard == null
|
||||||
|
|| !newKeyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale))) {
|
||||||
|
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar();
|
||||||
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
LatinImeLogger.logOnException(mode + "," + imeOptions, e);
|
LatinImeLogger.logOnException(mode + "," + imeOptions, e);
|
||||||
|
@ -167,6 +174,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
private void loadKeyboardInternal(int mode, int imeOptions, boolean voiceButtonEnabled,
|
private void loadKeyboardInternal(int mode, int imeOptions, boolean voiceButtonEnabled,
|
||||||
boolean voiceButtonOnPrimary, boolean isSymbols) {
|
boolean voiceButtonOnPrimary, boolean isSymbols) {
|
||||||
if (mInputView == null) return;
|
if (mInputView == null) return;
|
||||||
|
final Keyboard oldKeyboard = mInputView.getKeyboard();
|
||||||
|
final KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
|
||||||
|
if (oldKeyboard != null && oldKeyboard.mId.equals(id))
|
||||||
|
return;
|
||||||
|
|
||||||
mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
|
mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
|
||||||
|
|
||||||
mMode = mode;
|
mMode = mode;
|
||||||
|
@ -178,11 +190,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mHasSettingsKey = getSettingsKeyMode(mPrefs, mInputMethodService);
|
mHasSettingsKey = getSettingsKeyMode(mPrefs, mInputMethodService);
|
||||||
makeSymbolsKeyboardIds();
|
makeSymbolsKeyboardIds();
|
||||||
|
|
||||||
KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
|
|
||||||
LatinKeyboard keyboard = getKeyboard(id);
|
|
||||||
|
|
||||||
mCurrentId = id;
|
mCurrentId = id;
|
||||||
mInputView.setKeyboard(keyboard);
|
mInputView.setKeyboard(getKeyboard(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
private LatinKeyboard getKeyboard(KeyboardId id) {
|
private LatinKeyboard getKeyboard(KeyboardId id) {
|
||||||
|
@ -210,6 +219,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
|
|
||||||
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
|
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
|
||||||
keyboard.setShifted(false);
|
keyboard.setShifted(false);
|
||||||
|
// If the cached keyboard had been switched to another keyboard while the language was
|
||||||
|
// displayed on its spacebar, it might have had arbitrary text fade factor. In such case,
|
||||||
|
// we should reset the text fade factor.
|
||||||
|
keyboard.setSpacebarTextFadeFactor(0.0f, null);
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -912,9 +912,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
// We should re-draw popup preview when 1) we need to hide the preview, 2) we will show
|
// We should re-draw popup preview when 1) we need to hide the preview, 2) we will show
|
||||||
// the space key preview and 3) pointer moves off the space key to other letter key, we
|
// the space key preview and 3) pointer moves off the space key to other letter key, we
|
||||||
// should hide the preview of the previous key.
|
// should hide the preview of the previous key.
|
||||||
@SuppressWarnings("unused")
|
|
||||||
final boolean hidePreviewOrShowSpaceKeyPreview = (tracker == null)
|
final boolean hidePreviewOrShowSpaceKeyPreview = (tracker == null)
|
||||||
|| (SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER
|
|| (SubtypeSwitcher.getInstance().useSpacebarLanguageSwitcher()
|
||||||
&& SubtypeSwitcher.getInstance().needsToDisplayLanguage()
|
&& SubtypeSwitcher.getInstance().needsToDisplayLanguage()
|
||||||
&& (tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex)));
|
&& (tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex)));
|
||||||
// If key changed and preview is on or the key is space (language switch is enabled)
|
// If key changed and preview is on or the key is space (language switch is enabled)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
@ -47,7 +48,9 @@ public class LatinKeyboard extends Keyboard {
|
||||||
private final Drawable mSpaceAutoCorrectionIndicator;
|
private final Drawable mSpaceAutoCorrectionIndicator;
|
||||||
private final Drawable mButtonArrowLeftIcon;
|
private final Drawable mButtonArrowLeftIcon;
|
||||||
private final Drawable mButtonArrowRightIcon;
|
private final Drawable mButtonArrowRightIcon;
|
||||||
private final int mSpaceBarTextShadowColor;
|
private final int mSpacebarTextColor;
|
||||||
|
private final int mSpacebarTextShadowColor;
|
||||||
|
private float mSpacebarTextFadeFactor = 0.0f;
|
||||||
private final int[] mSpaceKeyIndexArray;
|
private final int[] mSpaceKeyIndexArray;
|
||||||
private int mSpaceDragStartX;
|
private int mSpaceDragStartX;
|
||||||
private int mSpaceDragLastDiff;
|
private int mSpaceDragLastDiff;
|
||||||
|
@ -67,6 +70,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
private static final float SPACEBAR_POPUP_MIN_RATIO = 0.4f;
|
private static final float SPACEBAR_POPUP_MIN_RATIO = 0.4f;
|
||||||
// Height in space key the language name will be drawn. (proportional to space key height)
|
// Height in space key the language name will be drawn. (proportional to space key height)
|
||||||
public static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f;
|
public static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f;
|
||||||
|
private static final float SPACEBAR_LANGUAGE_BASELINE_WITHOUT_ICON = 0.65f;
|
||||||
// If the full language name needs to be smaller than this value to be drawn on space key,
|
// If the full language name needs to be smaller than this value to be drawn on space key,
|
||||||
// its short language name will be used instead.
|
// its short language name will be used instead.
|
||||||
private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f;
|
private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f;
|
||||||
|
@ -80,11 +84,12 @@ public class LatinKeyboard extends Keyboard {
|
||||||
super(context, id.getXmlId(), id);
|
super(context, id.getXmlId(), id);
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mSpacebarTextColor = res.getColor(R.color.latinkeyboard_bar_language_text);
|
||||||
if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) {
|
if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) {
|
||||||
mSpaceBarTextShadowColor = res.getColor(
|
mSpacebarTextShadowColor = res.getColor(
|
||||||
R.color.latinkeyboard_bar_language_shadow_black);
|
R.color.latinkeyboard_bar_language_shadow_black);
|
||||||
} else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE
|
} else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE
|
||||||
mSpaceBarTextShadowColor = res.getColor(
|
mSpacebarTextShadowColor = res.getColor(
|
||||||
R.color.latinkeyboard_bar_language_shadow_white);
|
R.color.latinkeyboard_bar_language_shadow_white);
|
||||||
}
|
}
|
||||||
mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led);
|
mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led);
|
||||||
|
@ -96,25 +101,38 @@ public class LatinKeyboard extends Keyboard {
|
||||||
mSpaceKeyIndexArray = new int[] { indexOf(CODE_SPACE) };
|
mSpaceKeyIndexArray = new int[] { indexOf(CODE_SPACE) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) {
|
||||||
|
mSpacebarTextFadeFactor = fadeFactor;
|
||||||
|
updateSpacebarForLocale(false);
|
||||||
|
if (view != null)
|
||||||
|
view.invalidateKey(mSpaceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getSpacebarTextColor(int color, float fadeFactor) {
|
||||||
|
final int newColor = Color.argb((int)(Color.alpha(color) * fadeFactor),
|
||||||
|
Color.red(color), Color.green(color), Color.blue(color));
|
||||||
|
return newColor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a key which should be invalidated.
|
* @return a key which should be invalidated.
|
||||||
*/
|
*/
|
||||||
public Key onAutoCorrectionStateChanged(boolean isAutoCorrection) {
|
public Key onAutoCorrectionStateChanged(boolean isAutoCorrection) {
|
||||||
updateSpaceBarForLocale(isAutoCorrection);
|
updateSpacebarForLocale(isAutoCorrection);
|
||||||
return mSpaceKey;
|
return mSpaceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSpaceBarForLocale(boolean isAutoCorrection) {
|
private void updateSpacebarForLocale(boolean isAutoCorrection) {
|
||||||
final Resources res = mContext.getResources();
|
final Resources res = mContext.getResources();
|
||||||
// If application locales are explicitly selected.
|
// If application locales are explicitly selected.
|
||||||
if (SubtypeSwitcher.getInstance().needsToDisplayLanguage()) {
|
if (SubtypeSwitcher.getInstance().needsToDisplayLanguage()) {
|
||||||
mSpaceKey.setIcon(new BitmapDrawable(res,
|
mSpaceKey.setIcon(new BitmapDrawable(res,
|
||||||
drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCorrection)));
|
drawSpacebar(OPACITY_FULLY_OPAQUE, isAutoCorrection)));
|
||||||
} else {
|
} else {
|
||||||
// sym_keyboard_space_led can be shared with Black and White symbol themes.
|
// sym_keyboard_space_led can be shared with Black and White symbol themes.
|
||||||
if (isAutoCorrection) {
|
if (isAutoCorrection) {
|
||||||
mSpaceKey.setIcon(new BitmapDrawable(res,
|
mSpaceKey.setIcon(new BitmapDrawable(res,
|
||||||
drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCorrection)));
|
drawSpacebar(OPACITY_FULLY_OPAQUE, isAutoCorrection)));
|
||||||
} else {
|
} else {
|
||||||
mSpaceKey.setIcon(mSpaceIcon);
|
mSpaceKey.setIcon(mSpaceIcon);
|
||||||
}
|
}
|
||||||
|
@ -128,8 +146,8 @@ public class LatinKeyboard extends Keyboard {
|
||||||
return bounds.width();
|
return bounds.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout local language name and left and right arrow on space bar.
|
// Layout local language name and left and right arrow on spacebar.
|
||||||
private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow,
|
private static String layoutSpacebar(Paint paint, Locale locale, Drawable lArrow,
|
||||||
Drawable rArrow, int width, int height, float origTextSize,
|
Drawable rArrow, int width, int height, float origTextSize,
|
||||||
boolean allowVariableTextSize) {
|
boolean allowVariableTextSize) {
|
||||||
final float arrowWidth = lArrow.getIntrinsicWidth();
|
final float arrowWidth = lArrow.getIntrinsicWidth();
|
||||||
|
@ -138,7 +156,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
final Rect bounds = new Rect();
|
final Rect bounds = new Rect();
|
||||||
|
|
||||||
// Estimate appropriate language name text size to fit in maxTextWidth.
|
// Estimate appropriate language name text size to fit in maxTextWidth.
|
||||||
String language = SubtypeSwitcher.getDisplayLanguage(locale);
|
String language = SubtypeSwitcher.getFullDisplayName(locale, true);
|
||||||
int textWidth = getTextWidth(paint, language, origTextSize, bounds);
|
int textWidth = getTextWidth(paint, language, origTextSize, bounds);
|
||||||
// Assuming text width and text size are proportional to each other.
|
// Assuming text width and text size are proportional to each other.
|
||||||
float textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f);
|
float textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f);
|
||||||
|
@ -171,8 +189,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
private Bitmap drawSpacebar(int opacity, boolean isAutoCorrection) {
|
||||||
private Bitmap drawSpaceBar(int opacity, boolean isAutoCorrection) {
|
|
||||||
final int width = mSpaceKey.mWidth;
|
final int width = mSpaceKey.mWidth;
|
||||||
final int height = mSpaceIcon != null ? mSpaceIcon.getIntrinsicHeight() : mSpaceKey.mHeight;
|
final int height = mSpaceIcon != null ? mSpaceIcon.getIntrinsicHeight() : mSpaceKey.mHeight;
|
||||||
final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
@ -202,21 +219,22 @@ public class LatinKeyboard extends Keyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean allowVariableTextSize = true;
|
final boolean allowVariableTextSize = true;
|
||||||
final String language = layoutSpaceBar(paint, subtypeSwitcher.getInputLocale(),
|
final String language = layoutSpacebar(paint, subtypeSwitcher.getInputLocale(),
|
||||||
mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height,
|
mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height,
|
||||||
getTextSizeFromTheme(textStyle, defaultTextSize),
|
getTextSizeFromTheme(textStyle, defaultTextSize),
|
||||||
allowVariableTextSize);
|
allowVariableTextSize);
|
||||||
|
|
||||||
// Draw language text with shadow
|
// Draw language text with shadow
|
||||||
final float baseline = height * SPACEBAR_LANGUAGE_BASELINE;
|
final float baseline = height * (mSpaceIcon != null ? SPACEBAR_LANGUAGE_BASELINE
|
||||||
|
: SPACEBAR_LANGUAGE_BASELINE_WITHOUT_ICON);
|
||||||
final float descent = paint.descent();
|
final float descent = paint.descent();
|
||||||
paint.setColor(mSpaceBarTextShadowColor);
|
paint.setColor(getSpacebarTextColor(mSpacebarTextShadowColor, mSpacebarTextFadeFactor));
|
||||||
canvas.drawText(language, width / 2, baseline - descent - 1, paint);
|
canvas.drawText(language, width / 2, baseline - descent - 1, paint);
|
||||||
paint.setColor(res.getColor(R.color.latinkeyboard_bar_language_text));
|
paint.setColor(getSpacebarTextColor(mSpacebarTextColor, mSpacebarTextFadeFactor));
|
||||||
canvas.drawText(language, width / 2, baseline - descent, paint);
|
canvas.drawText(language, width / 2, baseline - descent, paint);
|
||||||
|
|
||||||
// Put arrows that are already layed out on either side of the text
|
// Put arrows that are already layed out on either side of the text
|
||||||
if (SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER
|
if (SubtypeSwitcher.getInstance().useSpacebarLanguageSwitcher()
|
||||||
&& subtypeSwitcher.getEnabledKeyboardLocaleCount() > 1) {
|
&& subtypeSwitcher.getEnabledKeyboardLocaleCount() > 1) {
|
||||||
mButtonArrowLeftIcon.draw(canvas);
|
mButtonArrowLeftIcon.draw(canvas);
|
||||||
mButtonArrowRightIcon.draw(canvas);
|
mButtonArrowRightIcon.draw(canvas);
|
||||||
|
@ -291,7 +309,6 @@ public class LatinKeyboard extends Keyboard {
|
||||||
* switching input languages.
|
* switching input languages.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unused") // SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER is constant
|
|
||||||
public boolean isInside(Key key, int pointX, int pointY) {
|
public boolean isInside(Key key, int pointX, int pointY) {
|
||||||
int x = pointX;
|
int x = pointX;
|
||||||
int y = pointY;
|
int y = pointY;
|
||||||
|
@ -302,7 +319,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
if (code == CODE_DELETE) x -= key.mWidth / 6;
|
if (code == CODE_DELETE) x -= key.mWidth / 6;
|
||||||
} else if (code == CODE_SPACE) {
|
} else if (code == CODE_SPACE) {
|
||||||
y += LatinKeyboard.sSpacebarVerticalCorrection;
|
y += LatinKeyboard.sSpacebarVerticalCorrection;
|
||||||
if (SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER
|
if (SubtypeSwitcher.getInstance().useSpacebarLanguageSwitcher()
|
||||||
&& SubtypeSwitcher.getInstance().getEnabledKeyboardLocaleCount() > 1) {
|
&& SubtypeSwitcher.getInstance().getEnabledKeyboardLocaleCount() > 1) {
|
||||||
if (mCurrentlyInSpace) {
|
if (mCurrentlyInSpace) {
|
||||||
int diff = x - mSpaceDragStartX;
|
int diff = x - mSpaceDragStartX;
|
||||||
|
|
|
@ -85,6 +85,14 @@ public class LatinKeyboardView extends KeyboardView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
|
||||||
|
final LatinKeyboard currentKeyboard = getLatinKeyboard();
|
||||||
|
// We should not set text fade factor to the keyboard which does not display the language on
|
||||||
|
// its spacebar.
|
||||||
|
if (currentKeyboard != null && currentKeyboard == oldKeyboard)
|
||||||
|
currentKeyboard.setSpacebarTextFadeFactor(fadeFactor, this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onLongPress(Key key) {
|
protected boolean onLongPress(Key key) {
|
||||||
int primaryCode = key.mCode;
|
int primaryCode = key.mCode;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.KeyboardView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
|
import com.android.inputmethod.keyboard.LatinKeyboard;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
||||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||||
|
@ -151,6 +152,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private boolean mAutoCap;
|
private boolean mAutoCap;
|
||||||
private boolean mQuickFixes;
|
private boolean mQuickFixes;
|
||||||
private boolean mConfigSwipeDownDismissKeyboardEnabled;
|
private boolean mConfigSwipeDownDismissKeyboardEnabled;
|
||||||
|
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
|
||||||
|
private int mConfigDurationOfFadeoutLanguageOnSpacebar;
|
||||||
|
|
||||||
private int mCorrectionMode;
|
private int mCorrectionMode;
|
||||||
private int mCommittedLength;
|
private int mCommittedLength;
|
||||||
|
@ -241,9 +244,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private static final int MSG_UPDATE_OLD_SUGGESTIONS = 1;
|
private static final int MSG_UPDATE_OLD_SUGGESTIONS = 1;
|
||||||
private static final int MSG_UPDATE_SHIFT_STATE = 2;
|
private static final int MSG_UPDATE_SHIFT_STATE = 2;
|
||||||
private static final int MSG_VOICE_RESULTS = 3;
|
private static final int MSG_VOICE_RESULTS = 3;
|
||||||
|
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4;
|
||||||
|
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
|
final LatinKeyboardView inputView = switcher.getInputView();
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_UPDATE_SUGGESTIONS:
|
case MSG_UPDATE_SUGGESTIONS:
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
|
@ -252,12 +259,21 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
setOldSuggestions();
|
setOldSuggestions();
|
||||||
break;
|
break;
|
||||||
case MSG_UPDATE_SHIFT_STATE:
|
case MSG_UPDATE_SHIFT_STATE:
|
||||||
mKeyboardSwitcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
break;
|
break;
|
||||||
case MSG_VOICE_RESULTS:
|
case MSG_VOICE_RESULTS:
|
||||||
mVoiceConnector.handleVoiceResults(preferCapitalization()
|
mVoiceConnector.handleVoiceResults(preferCapitalization()
|
||||||
|| (mKeyboardSwitcher.isAlphabetMode()
|
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
|
||||||
&& mKeyboardSwitcher.isShiftedOrShiftLocked()));
|
break;
|
||||||
|
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
|
||||||
|
if (inputView != null)
|
||||||
|
inputView.setSpacebarTextFadeFactor(0.5f, (LatinKeyboard)msg.obj);
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
|
||||||
|
mConfigDurationOfFadeoutLanguageOnSpacebar);
|
||||||
|
break;
|
||||||
|
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
|
||||||
|
if (inputView != null)
|
||||||
|
inputView.setSpacebarTextFadeFactor(0.0f, (LatinKeyboard)msg.obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +313,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
public void updateVoiceResults() {
|
public void updateVoiceResults() {
|
||||||
sendMessage(obtainMessage(MSG_VOICE_RESULTS));
|
sendMessage(obtainMessage(MSG_VOICE_RESULTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startDisplayLanguageOnSpacebar() {
|
||||||
|
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
|
||||||
|
removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR);
|
||||||
|
final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||||
|
if (inputView != null) {
|
||||||
|
final LatinKeyboard keyboard = inputView.getLatinKeyboard();
|
||||||
|
// The language is never displayed when the delay is zero.
|
||||||
|
if (mConfigDelayBeforeFadeoutLanguageOnSpacebar != 0)
|
||||||
|
inputView.setSpacebarTextFadeFactor(1.0f, keyboard);
|
||||||
|
// The language is always displayed when the delay is negative.
|
||||||
|
if (mConfigDelayBeforeFadeoutLanguageOnSpacebar > 0) {
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR, keyboard),
|
||||||
|
mConfigDelayBeforeFadeoutLanguageOnSpacebar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -319,6 +352,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
res.getBoolean(R.bool.default_recorrection_enabled));
|
res.getBoolean(R.bool.default_recorrection_enabled));
|
||||||
mConfigSwipeDownDismissKeyboardEnabled = res.getBoolean(
|
mConfigSwipeDownDismissKeyboardEnabled = res.getBoolean(
|
||||||
R.bool.config_swipe_down_dismiss_keyboard_enabled);
|
R.bool.config_swipe_down_dismiss_keyboard_enabled);
|
||||||
|
mConfigDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger(
|
||||||
|
R.integer.config_delay_before_fadeout_language_on_spacebar);
|
||||||
|
mConfigDurationOfFadeoutLanguageOnSpacebar = res.getInteger(
|
||||||
|
R.integer.config_duration_of_fadeout_language_on_spacebar);
|
||||||
|
|
||||||
Utils.GCUtils.getInstance().reset();
|
Utils.GCUtils.getInstance().reset();
|
||||||
boolean tryGC = true;
|
boolean tryGC = true;
|
||||||
|
@ -401,23 +438,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration conf) {
|
public void onConfigurationChanged(Configuration conf) {
|
||||||
mSubtypeSwitcher.onConfigurationChanged(conf);
|
|
||||||
if (mSubtypeSwitcher.isKeyboardMode())
|
|
||||||
onKeyboardLanguageChanged();
|
|
||||||
updateAutoTextEnabled();
|
|
||||||
|
|
||||||
// If orientation changed while predicting, commit the change
|
// If orientation changed while predicting, commit the change
|
||||||
if (conf.orientation != mOrientation) {
|
if (conf.orientation != mOrientation) {
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
commitTyped(ic);
|
commitTyped(ic);
|
||||||
if (ic != null) ic.finishComposingText(); // For voice input
|
if (ic != null) ic.finishComposingText(); // For voice input
|
||||||
mOrientation = conf.orientation;
|
mOrientation = conf.orientation;
|
||||||
final int mode = mKeyboardSwitcher.getKeyboardMode();
|
|
||||||
final EditorInfo attribute = getCurrentInputEditorInfo();
|
|
||||||
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
|
|
||||||
mKeyboardSwitcher.loadKeyboard(mode, imeOptions,
|
|
||||||
mVoiceConnector.isVoiceButtonEnabled(),
|
|
||||||
mVoiceConnector.isVoiceButtonOnPrimary());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mConfigurationChanging = true;
|
mConfigurationChanging = true;
|
||||||
|
@ -1817,7 +1843,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
// "reset" and "next" are used only for USE_SPACEBAR_LANGUAGE_SWITCHER.
|
// "reset" and "next" are used only for USE_SPACEBAR_LANGUAGE_SWITCHER.
|
||||||
private void toggleLanguage(boolean reset, boolean next) {
|
private void toggleLanguage(boolean reset, boolean next) {
|
||||||
if (SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mSubtypeSwitcher.useSpacebarLanguageSwitcher()) {
|
||||||
mSubtypeSwitcher.toggleLanguage(reset, next);
|
mSubtypeSwitcher.toggleLanguage(reset, next);
|
||||||
}
|
}
|
||||||
// Reload keyboard because the current language has been changed.
|
// Reload keyboard because the current language has been changed.
|
||||||
|
|
|
@ -41,10 +41,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SubtypeSwitcher {
|
public class SubtypeSwitcher {
|
||||||
// TODO: This should be configurable by resource
|
|
||||||
// This flag indicates if we support language switching by swipe on space bar.
|
|
||||||
// We may or may not draw the current language on space bar regardless of this flag.
|
|
||||||
public static final boolean USE_SPACEBAR_LANGUAGE_SWITCHER = false;
|
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final String TAG = "SubtypeSwitcher";
|
private static final String TAG = "SubtypeSwitcher";
|
||||||
|
|
||||||
|
@ -63,6 +59,8 @@ public class SubtypeSwitcher {
|
||||||
new ArrayList<InputMethodSubtype>();
|
new ArrayList<InputMethodSubtype>();
|
||||||
private final ArrayList<String> mEnabledLanguagesOfCurrentInputMethod = new ArrayList<String>();
|
private final ArrayList<String> mEnabledLanguagesOfCurrentInputMethod = new ArrayList<String>();
|
||||||
|
|
||||||
|
private boolean mConfigUseSpacebarLanguageSwitcher;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
// Variants which should be changed only by reload functions.
|
// Variants which should be changed only by reload functions.
|
||||||
private boolean mNeedsToDisplayLanguage;
|
private boolean mNeedsToDisplayLanguage;
|
||||||
|
@ -84,10 +82,6 @@ public class SubtypeSwitcher {
|
||||||
public static void init(LatinIME service, SharedPreferences prefs) {
|
public static void init(LatinIME service, SharedPreferences prefs) {
|
||||||
sInstance.mPrefs = prefs;
|
sInstance.mPrefs = prefs;
|
||||||
sInstance.resetParams(service);
|
sInstance.resetParams(service);
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
|
||||||
sInstance.initLanguageSwitcher(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
sInstance.updateAllParameters();
|
sInstance.updateAllParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +103,10 @@ public class SubtypeSwitcher {
|
||||||
mAllEnabledSubtypesOfCurrentInputMethod = null;
|
mAllEnabledSubtypesOfCurrentInputMethod = null;
|
||||||
// TODO: Voice input should be created here
|
// TODO: Voice input should be created here
|
||||||
mVoiceInput = null;
|
mVoiceInput = null;
|
||||||
|
mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean(
|
||||||
|
R.bool.config_use_spacebar_language_switcher);
|
||||||
|
if (mConfigUseSpacebarLanguageSwitcher)
|
||||||
|
initLanguageSwitcher(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update all parameters stored in SubtypeSwitcher.
|
// Update all parameters stored in SubtypeSwitcher.
|
||||||
|
@ -122,8 +120,8 @@ public class SubtypeSwitcher {
|
||||||
// Update parameters which are changed outside LatinIME. This parameters affect UI so they
|
// Update parameters which are changed outside LatinIME. This parameters affect UI so they
|
||||||
// should be updated every time onStartInputview.
|
// should be updated every time onStartInputview.
|
||||||
public void updateParametersOnStartInputView() {
|
public void updateParametersOnStartInputView() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
updateForSpaceBarLanguageSwitch();
|
updateForSpacebarLanguageSwitch();
|
||||||
} else {
|
} else {
|
||||||
updateEnabledSubtypes();
|
updateEnabledSubtypes();
|
||||||
}
|
}
|
||||||
|
@ -307,19 +305,23 @@ public class SubtypeSwitcher {
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
public int getEnabledKeyboardLocaleCount() {
|
public int getEnabledKeyboardLocaleCount() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return mLanguageSwitcher.getLocaleCount();
|
return mLanguageSwitcher.getLocaleCount();
|
||||||
} else {
|
} else {
|
||||||
return mEnabledKeyboardSubtypesOfCurrentInputMethod.size();
|
return mEnabledKeyboardSubtypesOfCurrentInputMethod.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean useSpacebarLanguageSwitcher() {
|
||||||
|
return mConfigUseSpacebarLanguageSwitcher;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean needsToDisplayLanguage() {
|
public boolean needsToDisplayLanguage() {
|
||||||
return mNeedsToDisplayLanguage;
|
return mNeedsToDisplayLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getInputLocale() {
|
public Locale getInputLocale() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return mLanguageSwitcher.getInputLocale();
|
return mLanguageSwitcher.getInputLocale();
|
||||||
} else {
|
} else {
|
||||||
return mInputLocale;
|
return mInputLocale;
|
||||||
|
@ -327,7 +329,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInputLocaleStr() {
|
public String getInputLocaleStr() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
String inputLanguage = null;
|
String inputLanguage = null;
|
||||||
inputLanguage = mLanguageSwitcher.getInputLanguage();
|
inputLanguage = mLanguageSwitcher.getInputLanguage();
|
||||||
// Should return system locale if there is no Language available.
|
// Should return system locale if there is no Language available.
|
||||||
|
@ -341,7 +343,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEnabledLanguages() {
|
public String[] getEnabledLanguages() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return mLanguageSwitcher.getEnabledLanguages();
|
return mLanguageSwitcher.getEnabledLanguages();
|
||||||
} else {
|
} else {
|
||||||
return mEnabledLanguagesOfCurrentInputMethod.toArray(
|
return mEnabledLanguagesOfCurrentInputMethod.toArray(
|
||||||
|
@ -350,7 +352,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getSystemLocale() {
|
public Locale getSystemLocale() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return mLanguageSwitcher.getSystemLocale();
|
return mLanguageSwitcher.getSystemLocale();
|
||||||
} else {
|
} else {
|
||||||
return mSystemLocale;
|
return mSystemLocale;
|
||||||
|
@ -358,7 +360,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSystemLanguageSameAsInputLanguage() {
|
public boolean isSystemLanguageSameAsInputLanguage() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return getSystemLocale().getLanguage().equalsIgnoreCase(
|
return getSystemLocale().getLanguage().equalsIgnoreCase(
|
||||||
getInputLocaleStr().substring(0, 2));
|
getInputLocaleStr().substring(0, 2));
|
||||||
} else {
|
} else {
|
||||||
|
@ -366,25 +368,8 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConfigurationChanged(Configuration conf) {
|
|
||||||
final Locale systemLocale = conf.locale;
|
|
||||||
// If system configuration was changed, update all parameters.
|
|
||||||
if (!TextUtils.equals(systemLocale.toString(), mSystemLocale.toString())) {
|
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
|
||||||
// If the system locale changes and is different from the saved
|
|
||||||
// locale (mSystemLocale), then reload the input locale list from the
|
|
||||||
// latin ime settings (shared prefs) and reset the input locale
|
|
||||||
// to the first one.
|
|
||||||
mLanguageSwitcher.loadLocales(mPrefs);
|
|
||||||
mLanguageSwitcher.setSystemLocale(systemLocale);
|
|
||||||
} else {
|
|
||||||
updateAllParameters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
if (Settings.PREF_SELECTED_LANGUAGES.equals(key)) {
|
if (Settings.PREF_SELECTED_LANGUAGES.equals(key)) {
|
||||||
mLanguageSwitcher.loadLocales(sharedPreferences);
|
mLanguageSwitcher.loadLocales(sharedPreferences);
|
||||||
}
|
}
|
||||||
|
@ -438,7 +423,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// SpaceBar Language Switch support //
|
// Spacebar Language Switch support //
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
private LanguageSwitcher mLanguageSwitcher;
|
private LanguageSwitcher mLanguageSwitcher;
|
||||||
|
@ -466,7 +451,7 @@ public class SubtypeSwitcher {
|
||||||
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateForSpaceBarLanguageSwitch() {
|
private void updateForSpacebarLanguageSwitch() {
|
||||||
// We need to update mNeedsToDisplayLanguage in onStartInputView because
|
// We need to update mNeedsToDisplayLanguage in onStartInputView because
|
||||||
// getEnabledKeyboardLocaleCount could have been changed.
|
// getEnabledKeyboardLocaleCount could have been changed.
|
||||||
mNeedsToDisplayLanguage = !(getEnabledKeyboardLocaleCount() <= 1
|
mNeedsToDisplayLanguage = !(getEnabledKeyboardLocaleCount() <= 1
|
||||||
|
@ -479,7 +464,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNextInputLanguageName() {
|
public String getNextInputLanguageName() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return getDisplayLanguage(mLanguageSwitcher.getNextInputLocale());
|
return getDisplayLanguage(mLanguageSwitcher.getNextInputLocale());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
@ -487,7 +472,7 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPreviousInputLanguageName() {
|
public String getPreviousInputLanguageName() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
return getDisplayLanguage(mLanguageSwitcher.getPrevInputLocale());
|
return getDisplayLanguage(mLanguageSwitcher.getPrevInputLocale());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
@ -524,13 +509,13 @@ public class SubtypeSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
mLanguageSwitcher.loadLocales(mPrefs);
|
mLanguageSwitcher.loadLocales(mPrefs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleLanguage(boolean reset, boolean next) {
|
public void toggleLanguage(boolean reset, boolean next) {
|
||||||
if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
|
if (mConfigUseSpacebarLanguageSwitcher) {
|
||||||
if (reset) {
|
if (reset) {
|
||||||
mLanguageSwitcher.reset();
|
mLanguageSwitcher.reset();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue