Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8584db14 authored by Andy Wang's avatar Andy Wang
Browse files

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
parent d21db3cf
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -23,10 +23,18 @@
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="?attr/inputViewStyle">
    <LinearLayout
        android:id="@+id/horizontal_keyboard_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="bottom"
        android:orientation="horizontal">
        <include
            android:id="@+id/main_keyboard_frame"
            layout="@layout/main_keyboard_frame" />
        <include
            android:id="@+id/emoji_palettes_view"
            layout="@layout/emoji_palettes_view" />
    </LinearLayout>
</com.android.inputmethod.latin.InputView>
+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,12 @@
    <string name="prefs_resize_keyboard">Enable keyboard resizing</string>
    <!-- Title of the settings for setting keyboard height -->
    <string name="prefs_keyboard_height_scale">Keyboard height scale</string>
    <!-- Title of the settings for setting keyboard width -->
    <string name="prefs_keyboard_bottom_margin">Keyboard bottom margin</string>
    <!-- Title of the settings for setting keyboard width -->
    <string name="prefs_keyboard_left_margin">Keyboard left margin</string>
    <!-- Title of the settings for setting keyboard width -->
    <string name="prefs_keyboard_right_margin">Keyboard right margin</string>
    <!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
    <string name="read_external_dictionary_no_files_message">No dictionary files in the Downloads folder</string>
    <!-- Title of the dialog that selects a file to install as an external dictionary [CHAR LIMIT=50] -->
+18 −0
Original line number Diff line number Diff line
@@ -87,6 +87,24 @@
        android:title="@string/prefs_keyboard_height_scale"
        latin:minValue="50"
        latin:maxValue="120" /> <!-- percentage -->
    <com.android.inputmethod.latin.settings.SeekBarDialogPreference
        android:dependency="pref_resize_keyboard"
        android:key="pref_keyboard_bottom_margin"
        android:title="@string/prefs_keyboard_bottom_margin"
        latin:minValue="0"
        latin:maxValue="50" /> <!-- percentage -->
    <com.android.inputmethod.latin.settings.SeekBarDialogPreference
        android:dependency="pref_resize_keyboard"
        android:key="pref_keyboard_left_margin"
        android:title="@string/prefs_keyboard_left_margin"
        latin:minValue="0"
        latin:maxValue="50" /> <!-- percentage -->
    <com.android.inputmethod.latin.settings.SeekBarDialogPreference
        android:dependency="pref_resize_keyboard"
        android:key="pref_keyboard_right_margin"
        android:title="@string/prefs_keyboard_right_margin"
        latin:minValue="0"
        latin:maxValue="50" /> <!-- percentage -->
    <PreferenceScreen
        android:key="read_external_dictionary"
        android:title="@string/prefs_read_external_dictionary" />
+14 −2
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ final class EmojiLayoutParams {

    public EmojiLayoutParams(final Resources res) {
        final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
        final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
        final int defaultKeyboardWidth = ResourceUtils.getKeyboardFrameWidth(res);
        mKeyVerticalGap = (int) res.getFraction(R.fraction.config_key_vertical_gap_holo,
                defaultKeyboardHeight, defaultKeyboardHeight);
        mBottomPadding = (int) res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
Loading