From 15c42454c0117d869f31ce278021f53ec74c4aa2 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 7 Aug 2013 16:03:57 +0900 Subject: [PATCH] Remove orientation member from KeyboardId Change-Id: I2c16134a24088dbc30b74ae7c5bc578a9d84a960 --- .../android/inputmethod/keyboard/KeyboardId.java | 16 ++++------------ .../inputmethod/keyboard/KeyboardLayoutSet.java | 6 ------ .../inputmethod/keyboard/MainKeyboardView.java | 3 ++- .../inputmethod/research/ResearchLogger.java | 5 +++-- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 8864b7603..2fe081921 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -58,8 +58,6 @@ public final class KeyboardId { public final InputMethodSubtype mSubtype; public final Locale mLocale; - // TODO: Remove this member. It is used only for logging purpose. - public final int mOrientation; public final int mWidth; public final int mHeight; public final int mMode; @@ -77,7 +75,6 @@ public final class KeyboardId { public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) { mSubtype = params.mSubtype; mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype); - mOrientation = params.mOrientation; mWidth = params.mKeyboardWidth; mHeight = params.mKeyboardHeight; mMode = params.mMode; @@ -101,7 +98,6 @@ public final class KeyboardId { private static int computeHashCode(final KeyboardId id) { return Arrays.hashCode(new Object[] { - id.mOrientation, id.mElementId, id.mMode, id.mWidth, @@ -123,8 +119,7 @@ public final class KeyboardId { private boolean equals(final KeyboardId other) { if (other == this) return true; - return other.mOrientation == mOrientation - && other.mElementId == mElementId + return other.mElementId == mElementId && other.mMode == mMode && other.mWidth == mWidth && other.mHeight == mHeight @@ -185,13 +180,10 @@ public final class KeyboardId { @Override public String toString() { - final String orientation = (mOrientation == Configuration.ORIENTATION_PORTRAIT) - ? "port" : "land"; - return String.format(Locale.ROOT, "[%s %s:%s %s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]", + return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s %s%s%s%s%s%s%s%s%s]", elementIdToName(mElementId), - mLocale, - mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), - orientation, mWidth, mHeight, + mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), + mWidth, mHeight, modeName(mMode), imeAction(), (navigateNext() ? "navigateNext" : ""), diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index e15310721..00b096c17 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -119,7 +119,6 @@ public final class KeyboardLayoutSet { boolean mLanguageSwitchKeyEnabled; InputMethodSubtype mSubtype; boolean mIsSpellChecker; - int mOrientation; int mKeyboardWidth; int mKeyboardHeight; // Sparse array of KeyboardLayoutSet element parameters indexed by element's id. @@ -242,9 +241,6 @@ public final class KeyboardLayoutSet { } public Builder setScreenGeometry(final int widthPixels, final int heightPixels) { - final Params params = mParams; - params.mOrientation = (heightPixels > widthPixels) - ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE; setDefaultKeyboardSize(widthPixels, heightPixels); return this; } @@ -317,8 +313,6 @@ public final class KeyboardLayoutSet { } public KeyboardLayoutSet build() { - if (mParams.mOrientation == Configuration.ORIENTATION_UNDEFINED) - throw new RuntimeException("Screen geometry is not specified"); if (mParams.mSubtype == null) throw new RuntimeException("KeyboardLayoutSet subtype is not specified"); final String packageName = mResources.getResourcePackageName( diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 6782317d0..7a5038843 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -615,7 +615,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; mSpacebarTextSize = keyHeight * mSpacebarTextRatio; if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.mainKeyboardView_setKeyboard(keyboard); + final int orientation = getContext().getResources().getConfiguration().orientation; + ResearchLogger.mainKeyboardView_setKeyboard(keyboard, orientation); } // This always needs to be set since the accessibility state can diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 0bd493970..3a3408266 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -1414,7 +1414,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang "navigatePrevious", "clobberSettingsKey", "passwordInput", "shortcutKeyEnabled", "hasShortcutKey", "languageSwitchKeyEnabled", "isMultiLine", "tw", "th", "keys"); - public static void mainKeyboardView_setKeyboard(final Keyboard keyboard) { + public static void mainKeyboardView_setKeyboard(final Keyboard keyboard, + final int orientation) { final KeyboardId kid = keyboard.mId; final boolean isPasswordView = kid.passwordInput(); final ResearchLogger researchLogger = getInstance(); @@ -1422,7 +1423,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang researchLogger.enqueueEvent(LOGSTATEMENT_MAINKEYBOARDVIEW_SETKEYBOARD, KeyboardId.elementIdToName(kid.mElementId), kid.mLocale + ":" + kid.mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), - kid.mOrientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(), + orientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(), kid.navigateNext(), kid.navigatePrevious(), kid.mClobberSettingsKey, isPasswordView, kid.mShortcutKeyEnabled, kid.mHasShortcutKey, kid.mLanguageSwitchKeyEnabled, kid.isMultiLine(), keyboard.mOccupiedWidth,