diff options
| author | Andy Wang <andywang@google.com> | 2014-12-02 13:01:11 +0900 |
|---|---|---|
| committer | Andy Wang <andywang@google.com> | 2014-12-05 16:21:20 +0900 |
| commit | 8584db1461d286f8eb966c40eb0bc76e8c9df76a (patch) | |
| tree | 702f83d695aa9d3e4e4ee319d66ad8453c08b022 /java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | |
| parent | d21db3cf617ce3f3d05bfb7d555338994d3c8c3c (diff) | |
Add keyboard margin options to place the keyboard dynamically.
Keyboard location and location can now be set in the debug options
section.
Change-Id: I87c5a1d679489e12dccf26632c399af28087629e
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 5e3a5f17c..d19f506ab 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -22,7 +22,9 @@ import android.util.Log; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; +import android.widget.LinearLayout; import com.android.inputmethod.compat.InputMethodServiceCompatUtils; import com.android.inputmethod.event.Event; @@ -64,7 +66,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private KeyboardTheme mKeyboardTheme; private Context mThemeContext; - + private View mHorizontalKeyboardFrame; private static final KeyboardSwitcher sInstance = new KeyboardSwitcher(); public static KeyboardSwitcher getInstance() { @@ -111,8 +113,16 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder( mThemeContext, editorInfo); final Resources res = mThemeContext.getResources(); - final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); + final ViewGroup.MarginLayoutParams p = + (ViewGroup.MarginLayoutParams) mHorizontalKeyboardFrame.getLayoutParams(); + + final int keyboardLeftMargin = ResourceUtils.getKeyboardLeftMargin(res, settingsValues); + final int keyboardRightMargin = ResourceUtils.getKeyboardRightMargin(res, settingsValues); + final int keyboardBottomMargin = ResourceUtils.getKeyboardBottomMargin(res, settingsValues); + p.setMargins(keyboardLeftMargin, 0, keyboardRightMargin, keyboardBottomMargin); + final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues); + final int keyboardWidth = ResourceUtils.getKeyboardWidth(res, settingsValues); builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setSubtype(RichInputMethodManager.getInstance().getCurrentSubtype()); builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey); @@ -411,6 +421,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled( isHardwareAcceleratedDrawingEnabled); mEmojiPalettesView.setKeyboardActionListener(mLatinIME); + mHorizontalKeyboardFrame = (LinearLayout)mCurrentInputView.findViewById( + R.id.horizontal_keyboard_frame); return mCurrentInputView; } |
