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

Commit ad56a6c0 authored by Roman Birg's avatar Roman Birg Committed by Ricardo Cerqueira
Browse files

Add ability to use volume rockers as cursor

Patchset 1: cleanup code
Patchset 2: adjust strings and whitespace

Change-Id: Ie0356a7377fe1984c4176a5808cc2c8ba0f0b4c0
parent e1b8b380
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -350,4 +350,7 @@
    <string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration settings</string>
    <!-- Title of the settings for keypress sound volume -->
    <string name="prefs_keypress_sound_volume_settings">Keypress sound volume settings</string>

    <string name="prefs_volume_cursor">Volume cursor</string>
    <string name="prefs_volume_cursor_summary">Use the volume keys to move the cursor</string>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -56,6 +56,12 @@
            android:entryValues="@array/voice_input_modes_values"
            android:entries="@array/voice_input_modes"
            android:defaultValue="@string/voice_mode_main" />
        <CheckBoxPreference
            android:key="volume_cursor"
            android:title="@string/prefs_volume_cursor"
            android:summary="@string/prefs_volume_cursor_summary"
            android:persistent="true"
            android:defaultValue="false" />
    </PreferenceCategory>
    <PreferenceCategory
        android:title="@string/correction_category"
+12 −0
Original line number Diff line number Diff line
@@ -1113,6 +1113,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
                }
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (mKeyboardSwitcher.isInputViewShown() && mSettingsValues.mEnableVolumeCursor) {
                sendDownUpKeyEvents((keyCode == KeyEvent.KEYCODE_VOLUME_UP ? KeyEvent.KEYCODE_DPAD_RIGHT
                        : KeyEvent.KEYCODE_DPAD_LEFT));
                return true;
            }
            break;
        }
        return super.onKeyDown(keyCode, event);
    }
@@ -1137,6 +1145,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
                return true;
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (mKeyboardSwitcher.isInputViewShown() && mSettingsValues.mEnableVolumeCursor)
                return true;
        }
        return super.onKeyUp(keyCode, event);
    }
+6 −1
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ public class Settings extends InputMethodSettingsActivity

    public static final String PREF_KEYPRESS_SOUND_VOLUME =
            "pref_keypress_sound_volume";

    public static final String PREF_VOLUME_KEYS_AS_CURSOR = "volume_cursor";

    // Dialog ids
    private static final int VOICE_INPUT_CONFIRM_DIALOG = 0;

@@ -124,6 +127,7 @@ public class Settings extends InputMethodSettingsActivity
        public final boolean mBigramPredictionEnabled;
        public final boolean mUseContactsDict;
        public final boolean mEnableSuggestionSpanInsertion;
        public final boolean mEnableVolumeCursor;

        private final boolean mShowSettingsKey;
        private final boolean mVoiceKeyEnabled;
@@ -187,6 +191,7 @@ public class Settings extends InputMethodSettingsActivity
            final String voiceMode = prefs.getString(PREF_VOICE_SETTINGS_KEY, voiceModeMain);
            mVoiceKeyEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff);
            mVoiceKeyOnMain = voiceMode != null && voiceMode.equals(voiceModeMain);
            mEnableVolumeCursor = prefs.getBoolean(Settings.PREF_VOLUME_KEYS_AS_CURSOR, false);

            LocaleUtils.setSystemLocale(res, savedLocale);
        }