Fix ALT key light behavior

This change also cleanups some imports, unnecessary cast and null check.

Bug: 2977256
Change-Id: I81b9e539ff8a13ae0cc1eb5c4fb2246732cca3e9
main
Tadashi G. Takaoka 2010-09-06 14:50:50 +09:00
parent f02e42080b
commit 12659d4c0c
3 changed files with 20 additions and 17 deletions

View File

@ -16,10 +16,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -27,6 +23,10 @@ import android.content.res.Resources;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.InflateException; import android.view.InflateException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener { public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final int MODE_NONE = 0; public static final int MODE_NONE = 0;
@ -197,8 +197,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
mHasVoice = enableVoice; mHasVoice = enableVoice;
mVoiceOnPrimary = voiceOnPrimary; mVoiceOnPrimary = voiceOnPrimary;
setKeyboardMode(mMode, mImeOptions, mHasVoice, setKeyboardMode(mMode, mImeOptions, mHasVoice, mIsSymbols);
mIsSymbols);
} }
boolean hasVoiceButton(boolean isSymbols) { boolean hasVoiceButton(boolean isSymbols) {
@ -338,19 +337,23 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
void toggleShift() { void toggleShift() {
if (mCurrentId.equals(mSymbolsId)) { if (mCurrentId.equals(mSymbolsId)) {
LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId);
LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId); LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId);
symbolsKeyboard.setShifted(true);
mCurrentId = mSymbolsShiftedId; mCurrentId = mSymbolsShiftedId;
mInputView.setKeyboard(symbolsShiftedKeyboard); mInputView.setKeyboard(symbolsShiftedKeyboard);
symbolsShiftedKeyboard.setShifted(true); // Symbol shifted keyboard has an ALT key that has a caps lock style indicator. To
// enable the indicator, we need to call enableShiftLock() and setShiftLocked(true).
// Thus we can keep the ALT key's Key.on value true while LatinKey.onRelease() is
// called.
symbolsShiftedKeyboard.enableShiftLock();
symbolsShiftedKeyboard.setShiftLocked(true);
symbolsShiftedKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); symbolsShiftedKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions);
} else if (mCurrentId.equals(mSymbolsShiftedId)) { } else if (mCurrentId.equals(mSymbolsShiftedId)) {
LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId); LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId);
LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId);
symbolsShiftedKeyboard.setShifted(false);
mCurrentId = mSymbolsId; mCurrentId = mSymbolsId;
mInputView.setKeyboard(symbolsKeyboard); mInputView.setKeyboard(symbolsKeyboard);
// Symbol keyboard has an ALT key that has a caps lock style indicator. To disable the
// indicator, we need to call enableShiftLock() and setShiftLocked(false).
symbolsKeyboard.enableShiftLock();
symbolsKeyboard.setShifted(false); symbolsKeyboard.setShifted(false);
symbolsKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); symbolsKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions);
} }

View File

@ -16,9 +16,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import java.util.List;
import java.util.Locale;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@ -27,10 +24,10 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Paint.Align;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard;
@ -39,6 +36,9 @@ import android.util.Log;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import java.util.List;
import java.util.Locale;
public class LatinKeyboard extends Keyboard { public class LatinKeyboard extends Keyboard {
private static final boolean DEBUG_PREFERRED_LETTER = false; private static final boolean DEBUG_PREFERRED_LETTER = false;
@ -128,7 +128,7 @@ public class LatinKeyboard extends Keyboard {
R.dimen.spacebar_vertical_correction); R.dimen.spacebar_vertical_correction);
mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty
|| xmlLayoutResId == R.xml.kbd_qwerty_black; || xmlLayoutResId == R.xml.kbd_qwerty_black;
mSpaceKeyIndex = indexOf((int) ' '); mSpaceKeyIndex = indexOf(' ');
} }
public LatinKeyboard(Context context, int layoutTemplateResId, public LatinKeyboard(Context context, int layoutTemplateResId,

View File

@ -131,7 +131,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
public boolean setShiftLocked(boolean shiftLocked) { public boolean setShiftLocked(boolean shiftLocked) {
Keyboard keyboard = getKeyboard(); Keyboard keyboard = getKeyboard();
if (keyboard != null && keyboard instanceof LatinKeyboard) { if (keyboard instanceof LatinKeyboard) {
((LatinKeyboard)keyboard).setShiftLocked(shiftLocked); ((LatinKeyboard)keyboard).setShiftLocked(shiftLocked);
invalidateAllKeys(); invalidateAllKeys();
return true; return true;