Merge "Add noSettingsKey private IME option"

main
Tadashi G. Takaoka 2011-02-23 23:48:45 -08:00 committed by Android (Google) Code Review
commit d77e968942
8 changed files with 114 additions and 49 deletions

View File

@ -187,9 +187,17 @@
left edge key. -->
<Spacer
latin:horizontalGap="8.362%p" />
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"
latin:keyWidth="24.127%p" />

View File

@ -129,9 +129,17 @@
the touch event on the area, "space" is intentionally not marked as a left edge key. -->
<Spacer
latin:horizontalGap="12.340%p" />
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"
latin:keyWidth="16.084%p" />

View File

@ -141,9 +141,17 @@
the touch event on the area, "space" is intentionally not marked as a left edge key. -->
<Spacer
latin:horizontalGap="8.362%p" />
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="8.042%p" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"
latin:keyWidth="24.127%p" />

View File

@ -27,8 +27,16 @@
>
<Spacer
latin:horizontalGap="8.362%p" />
<Key
latin:keyStyle="settingsKeyStyle" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<switch>
<case
latin:languageCode="ru"

View File

@ -167,8 +167,16 @@
>
<Spacer
latin:horizontalGap="8.362%p" />
<Key
latin:keyStyle="settingsKeyStyle" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<Key
latin:keyLabel="/" />
<Key

View File

@ -155,8 +155,16 @@
>
<Spacer
latin:horizontalGap="24.446%p" />
<Key
latin:keyStyle="settingsKeyStyle" />
<switch>
<case latin:hasSettingsKey="true">
<Key
latin:keyStyle="settingsKeyStyle" />
</case>
<default>
<Spacer
latin:horizontalGap="8.042%p" />
</default>
</switch>
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="37.454%p" />

View File

@ -83,8 +83,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private static final int AUTO_MODE_SWITCH_STATE_CHORDING = 4;
private int mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA;
// Indicates whether or not we have the settings key
private boolean mHasSettingsKey;
// Indicates whether or not we have the settings key in option of settings
private boolean mSettingsKeyEnabledInSettings;
private static final int SETTINGS_KEY_MODE_AUTO = R.string.settings_key_mode_auto;
private static final int SETTINGS_KEY_MODE_ALWAYS_SHOW =
R.string.settings_key_mode_always_show;
@ -122,32 +122,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
prefs.registerOnSharedPreferenceChangeListener(sInstance);
}
private void makeSymbolsKeyboardIds(final int mode) {
final Locale locale = mSubtypeSwitcher.getInputLocale();
final Resources res = mInputMethodService.getResources();
final int orientation = res.getConfiguration().orientation;
final int colorScheme = getColorScheme();
final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary;
// Note: This comment is only applied for phone number keyboard layout.
// On non-xlarge device, "@integer/key_switch_alpha_symbol" key code is used to switch
// between "phone keyboard" and "phone symbols keyboard". But on xlarge device,
// "@integer/key_shift" key code is used for that purpose in order to properly display
// "more" and "locked more" key labels. To achieve these behavior, we should initialize
// mSymbolsId and mSymbolsShiftedId to "phone keyboard" and "phone symbols keyboard"
// respectively here for xlarge device's layout switching.
int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols;
final String xmlName = res.getResourceEntryName(xmlId);
mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
mAttribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true);
xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift;
mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
mAttribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true);
}
private boolean hasVoiceKey(boolean isSymbols) {
return mVoiceKeyEnabled && (isSymbols != mVoiceButtonOnPrimary);
}
public void loadKeyboard(EditorInfo attribute, boolean voiceKeyEnabled,
boolean voiceButtonOnPrimary) {
mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA;
@ -170,14 +144,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mVoiceButtonOnPrimary = voiceButtonOnPrimary;
mIsSymbols = isSymbols;
// Update the settings key state because number of enabled IMEs could have been changed
mHasSettingsKey = getSettingsKeyMode(mPrefs, mInputMethodService);
mSettingsKeyEnabledInSettings = getSettingsKeyMode(mPrefs, mInputMethodService);
final KeyboardId id = getKeyboardId(attribute, isSymbols);
final Keyboard oldKeyboard = mInputView.getKeyboard();
if (oldKeyboard != null && oldKeyboard.mId.equals(id))
return;
makeSymbolsKeyboardIds(id.mMode);
makeSymbolsKeyboardIds(id.mMode, attribute);
mCurrentId = id;
mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
setKeyboard(getKeyboard(id));
@ -224,6 +198,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
return keyboard;
}
private boolean hasVoiceKey(boolean isSymbols) {
return mVoiceKeyEnabled && (isSymbols != mVoiceButtonOnPrimary);
}
private boolean hasSettingsKey(EditorInfo attribute) {
return mSettingsKeyEnabledInSettings
&& !Utils.inPrivateImeOptions(mInputMethodService.getPackageName(),
LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute);
}
private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) {
final int mode = Utils.getKeyboardMode(attribute);
final boolean hasVoiceKey = hasVoiceKey(isSymbols);
@ -253,12 +237,36 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
enableShiftLock = true;
}
}
final boolean hasSettingsKey = hasSettingsKey(attribute);
final Resources res = mInputMethodService.getResources();
final int orientation = res.getConfiguration().orientation;
final Locale locale = mSubtypeSwitcher.getInputLocale();
return new KeyboardId(
res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, mode,
attribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
}
private void makeSymbolsKeyboardIds(final int mode, EditorInfo attribute) {
final Locale locale = mSubtypeSwitcher.getInputLocale();
final Resources res = mInputMethodService.getResources();
final int orientation = res.getConfiguration().orientation;
final int colorScheme = getColorScheme();
final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary;
final boolean hasSettingsKey = hasSettingsKey(attribute);
// Note: This comment is only applied for phone number keyboard layout.
// On non-xlarge device, "@integer/key_switch_alpha_symbol" key code is used to switch
// between "phone keyboard" and "phone symbols keyboard". But on xlarge device,
// "@integer/key_shift" key code is used for that purpose in order to properly display
// "more" and "locked more" key labels. To achieve these behavior, we should initialize
// mSymbolsId and mSymbolsShiftedId to "phone keyboard" and "phone symbols keyboard"
// respectively here for xlarge device's layout switching.
int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols;
final String xmlName = res.getResourceEntryName(xmlId);
mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true);
xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift;
mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true);
}
public int getKeyboardMode() {
@ -689,7 +697,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
createInputViewInternal(layoutId, false);
postSetInputView();
} else if (Settings.PREF_SETTINGS_KEY.equals(key)) {
mHasSettingsKey = getSettingsKeyMode(sharedPreferences, mInputMethodService);
mSettingsKeyEnabledInSettings = getSettingsKeyMode(sharedPreferences,
mInputMethodService);
createInputViewInternal(mLayoutId, true);
postSetInputView();
}
@ -725,7 +734,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
Context.INPUT_METHOD_SERVICE))))) {
return true;
}
return false;
}
return false;
// If the show settings key option is disabled, we always try showing the settings key.
return true;
}
}

View File

@ -100,7 +100,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
* shown for a given text field. For instance, this is specified by the
* search dialog when the dialog is already showing a voice search button.
*/
public static final String IME_OPTION_NO_MICROPHONE = "noMicrophone";
public static final String IME_OPTION_NO_MICROPHONE = "noMicrophoneKey";
/**
* The private IME option used to indicate that no settings key should be
* shown for a given text field.
*/
public static final String IME_OPTION_NO_SETTINGS_KEY = "noSettingsKey";
private static final int DELAY_UPDATE_SUGGESTIONS = 180;
private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300;