Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add ability to use volume rockers as cursors while typing
  • Loading branch information
romanbb committed Dec 28, 2011
1 parent 79efbec commit 26155ff
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions java/res/values/strings.xml
Expand Up @@ -346,4 +346,8 @@
<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="aokp_category">AOKP Keyboard Options</string>
<string name="prefs_volume_cursor">Volume cursor</string>
<string name="prefs_volume_cursor_summary">While typing, the volume keys will move your cursor.</string>
</resources>
10 changes: 10 additions & 0 deletions java/res/xml/prefs.xml
Expand Up @@ -57,6 +57,16 @@
android:entries="@array/voice_input_modes"
android:defaultValue="@string/voice_mode_main" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/aokp_category"
android:key="aokp_settings">
<CheckBoxPreference
android:key="volume_cursor"
android:title="@string/prefs_volume_cursor"
android:summary="@string/prefs_volume_cursor_summary"
android:persistent="true"
android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/correction_category"
android:key="correction_settings">
Expand Down
16 changes: 15 additions & 1 deletion java/src/com/android/inputmethod/latin/LatinIME.java
Expand Up @@ -1099,18 +1099,28 @@ public void updateFullscreenMode() {

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();

switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (event.getRepeatCount() == 0) {
if (mSuggestionsView != null && mSuggestionsView.handleBack()) {
return true;
}
final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();

if (keyboardView != null && keyboardView.handleBack()) {
return true;
}
}
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);
}
Expand All @@ -1135,6 +1145,10 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
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);
}
Expand Down
6 changes: 6 additions & 0 deletions java/src/com/android/inputmethod/latin/Settings.java
Expand Up @@ -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;

Expand Down Expand Up @@ -124,6 +127,7 @@ public static class Values {
public final boolean mBigramPredictionEnabled;
public final boolean mUseContactsDict;
public final boolean mEnableSuggestionSpanInsertion;
public final boolean mEnableVolumeCursor;

private final boolean mShowSettingsKey;
private final boolean mVoiceKeyEnabled;
Expand Down Expand Up @@ -188,6 +192,8 @@ public Values(final SharedPreferences prefs, final Context context,
mVoiceKeyEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff);
mVoiceKeyOnMain = voiceMode != null && voiceMode.equals(voiceModeMain);

mEnableVolumeCursor = prefs.getBoolean(Settings.PREF_VOLUME_KEYS_AS_CURSOR, true);

LocaleUtils.setSystemLocale(res, savedLocale);
}

Expand Down

0 comments on commit 26155ff

Please sign in to comment.