Skip to content
Snippets Groups Projects
Commit b9770cb7 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Add device form factor to KeyboardId" into jb-mr1-dev

parents f0211161 4731b676
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@
-->
<resources>
<!-- Device form factor. This value must be aligned with {@link KeyboardId.DEVICE_FORM_FACTOR_TABLET7} -->
<integer name="config_device_form_factor">1</integer>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_enable_show_popup_on_keypress_option">false</bool>
<bool name="config_enable_bigram_suggestions_option">false</bool>
......
......@@ -19,6 +19,8 @@
-->
<resources>
<!-- Device form factor. This value must be aligned with {@link KeyboardId.DEVICE_FORM_FACTOR_TABLET10} -->
<integer name="config_device_form_factor">2</integer>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_enable_show_popup_on_keypress_option">false</bool>
<bool name="config_enable_bigram_suggestions_option">false</bool>
......
......@@ -19,6 +19,8 @@
-->
<resources>
<!-- Device form factor. This value must be aligned with {@link KeyboardId.DEVICE_FORM_FACTOR_PHONE} -->
<integer name="config_device_form_factor">0</integer>
<bool name="config_use_fullscreen_mode">false</bool>
<bool name="config_enable_show_voice_key_option">true</bool>
<bool name="config_enable_show_popup_on_keypress_option">true</bool>
......
......@@ -55,10 +55,15 @@ public class KeyboardId {
public static final int ELEMENT_PHONE_SYMBOLS = 8;
public static final int ELEMENT_NUMBER = 9;
public static final int FORM_FACTOR_PHONE = 0;
public static final int FORM_FACTOR_TABLET7 = 1;
public static final int FORM_FACTOR_TABLET10 = 2;
private static final int IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1;
public final InputMethodSubtype mSubtype;
public final Locale mLocale;
public final int mDeviceFormFactor;
public final int mOrientation;
public final int mWidth;
public final int mMode;
......@@ -72,11 +77,12 @@ public class KeyboardId {
private final int mHashCode;
public KeyboardId(int elementId, InputMethodSubtype subtype, int orientation, int width,
int mode, EditorInfo editorInfo, boolean clobberSettingsKey, boolean shortcutKeyEnabled,
boolean hasShortcutKey, boolean languageSwitchKeyEnabled) {
public KeyboardId(int elementId, InputMethodSubtype subtype, int deviceFormFactor,
int orientation, int width, int mode, EditorInfo editorInfo, boolean clobberSettingsKey,
boolean shortcutKeyEnabled, boolean hasShortcutKey, boolean languageSwitchKeyEnabled) {
mSubtype = subtype;
mLocale = SubtypeLocale.getSubtypeLocale(subtype);
mDeviceFormFactor = deviceFormFactor;
mOrientation = orientation;
mWidth = width;
mMode = mode;
......@@ -94,6 +100,7 @@ public class KeyboardId {
private static int computeHashCode(KeyboardId id) {
return Arrays.hashCode(new Object[] {
id.mDeviceFormFactor,
id.mOrientation,
id.mElementId,
id.mMode,
......@@ -115,7 +122,8 @@ public class KeyboardId {
private boolean equals(KeyboardId other) {
if (other == this)
return true;
return other.mOrientation == mOrientation
return other.mDeviceFormFactor == mDeviceFormFactor
&& other.mOrientation == mOrientation
&& other.mElementId == mElementId
&& other.mMode == mMode
&& other.mWidth == mWidth
......@@ -184,11 +192,11 @@ public class KeyboardId {
@Override
public String toString() {
return String.format("[%s %s:%s %s%d %s %s %s%s%s%s%s%s%s%s]",
return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s]",
elementIdToName(mElementId),
mLocale,
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
(mOrientation == 1 ? "port" : "land"), mWidth,
deviceFormFactor(mDeviceFormFactor), (mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
imeAction(),
(navigateNext() ? "navigateNext" : ""),
......@@ -226,6 +234,15 @@ public class KeyboardId {
}
}
public static String deviceFormFactor(int devoceFormFactor) {
switch (devoceFormFactor) {
case FORM_FACTOR_PHONE: return "phone";
case FORM_FACTOR_TABLET7: return "tablet7";
case FORM_FACTOR_TABLET10: return "tablet10";
default: return null;
}
}
public static String modeName(int mode) {
switch (mode) {
case MODE_TEXT: return "text";
......
......@@ -115,6 +115,7 @@ public class KeyboardLayoutSet {
boolean mNoSettingsKey;
boolean mLanguageSwitchKeyEnabled;
InputMethodSubtype mSubtype;
int mDeviceFormFactor;
int mOrientation;
int mWidth;
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
......@@ -211,9 +212,10 @@ public class KeyboardLayoutSet {
final boolean noLanguage = SubtypeLocale.isNoLanguage(params.mSubtype);
final boolean voiceKeyEnabled = params.mVoiceKeyEnabled && !noLanguage;
final boolean hasShortcutKey = voiceKeyEnabled && (isSymbols != params.mVoiceKeyOnMain);
return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mOrientation,
params.mWidth, params.mMode, params.mEditorInfo, params.mNoSettingsKey,
voiceKeyEnabled, hasShortcutKey, params.mLanguageSwitchKeyEnabled);
return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mDeviceFormFactor,
params.mOrientation, params.mWidth, params.mMode, params.mEditorInfo,
params.mNoSettingsKey, voiceKeyEnabled, hasShortcutKey,
params.mLanguageSwitchKeyEnabled);
}
public static class Builder {
......@@ -239,9 +241,11 @@ public class KeyboardLayoutSet {
mPackageName, NO_SETTINGS_KEY, mEditorInfo);
}
public Builder setScreenGeometry(int orientation, int widthPixels) {
mParams.mOrientation = orientation;
mParams.mWidth = widthPixels;
public Builder setScreenGeometry(int deviceFormFactor, int orientation, int widthPixels) {
final Params params = mParams;
params.mDeviceFormFactor = deviceFormFactor;
params.mOrientation = orientation;
params.mWidth = widthPixels;
return this;
}
......
......@@ -137,8 +137,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
public void loadKeyboard(EditorInfo editorInfo, SettingsValues settingsValues) {
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
mThemeContext, editorInfo);
builder.setScreenGeometry(mThemeContext.getResources().getConfiguration().orientation,
mThemeContext.getResources().getDisplayMetrics().widthPixels);
final Resources res = mThemeContext.getResources();
builder.setScreenGeometry(res.getInteger(R.integer.config_device_form_factor),
res.getConfiguration().orientation, res.getDisplayMetrics().widthPixels);
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
builder.setOptions(
settingsValues.isVoiceKeyEnabled(editorInfo),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment