Permalink
Browse files

Settings: Volume key cursor control (2/2)

Change-Id: If102e2499b68e2672947cb5f57d93a52554572e5
  • Loading branch information...
KonstaT authored and xlxfoxxlx committed Oct 24, 2015
1 parent 5f28eca commit 26c9a4ab247005c4731d8210262e2f2fbc97e246
Showing with 63 additions and 3 deletions.
  1. +13 −0 res/values/arrays.xml
  2. +6 −0 res/values/strings.xml
  3. +8 −0 res/xml/aosip_volume.xml
  4. +36 −3 src/com/aosip/owlsnest/buttons/VolumeCategory.java
View
@@ -649,5 +649,18 @@ limitations under the License.
<item>2</item>
</string-array>
<!-- Volume key cursor control -->
<string-array name="volbtn_cursor_control_entries" translatable="false">
<item>@string/volbtn_cursor_control_off</item>
<item>@string/volbtn_cursor_control_on</item>
<item>@string/volbtn_cursor_control_on_reverse</item>
</string-array>
<string-array name="volbtn_cursor_control_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>
View
@@ -589,6 +589,12 @@
<string name="volbtn_music_controls_title">Music control</string>
<string name="volbtn_music_controls_summary">With screen off, long pressing the volume keys will seek tracks</string>
<!-- Volume key cursor control -->
<string name="volbtn_cursor_control_title">Volume key cursor control</string>
<string name="volbtn_cursor_control_off">Disabled</string>
<string name="volbtn_cursor_control_on">Volume up/down moves cursor left/right</string>
<string name="volbtn_cursor_control_on_reverse">Volume up/down moves cursor right/left</string>
<!-- Volume button wake -->
<string name="volbtn_wake_device_title">Volume button wake</string>
<string name="button_wake_summary">May not wake device if music control is active and music is playing</string>
View
@@ -21,6 +21,14 @@
android:layout="@layout/tab_ui"
android:title="@string/volume_category" >
<ListPreference
android:key="volume_key_cursor_control"
android:dialogTitle="@string/volbtn_cursor_control_title"
android:title="@string/volbtn_cursor_control_title"
android:entries="@array/volbtn_cursor_control_entries"
android:entryValues="@array/volbtn_cursor_control_values"
android:persistent="false" />
<com.aosip.owlsnest.preference.SecureSettingSwitchPreference
android:key="volbtn_music_controls"
android:title="@string/volbtn_music_controls_title"
@@ -16,11 +16,12 @@
package com.aosip.owlsnest.buttons;
import android.content.ContentResolver;
import android.os.Bundle;
import android.provider.Settings;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.PreferenceScreen;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -29,6 +30,10 @@
public class VolumeCategory extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String KEY_VOLUME_KEY_CURSOR_CONTROL = "volume_key_cursor_control";
private ListPreference mVolumeKeyCursorControl;
@Override
protected int getMetricsCategory() {
return MetricsEvent.OWLSNEST;
@@ -39,14 +44,42 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.aosip_volume);
final ContentResolver resolver = getActivity().getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
int cursorControlAction = Settings.System.getInt(resolver,
Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
mVolumeKeyCursorControl = initActionList(KEY_VOLUME_KEY_CURSOR_CONTROL,
cursorControlAction);
}
@Override
public void onResume() {
super.onResume();
}
private ListPreference initActionList(String key, int value) {
ListPreference list = (ListPreference) getPreferenceScreen().findPreference(key);
list.setValue(Integer.toString(value));
list.setSummary(list.getEntry());
list.setOnPreferenceChangeListener(this);
return list;
}
private void handleActionListChange(ListPreference pref, Object newValue, String setting) {
String value = (String) newValue;
int index = pref.findIndexOfValue(value);
pref.setSummary(pref.getEntries()[index]);
Settings.System.putInt(getActivity().getContentResolver(), setting, Integer.valueOf(value));
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mVolumeKeyCursorControl) {
handleActionListChange(mVolumeKeyCursorControl, newValue,
Settings.System.VOLUME_KEY_CURSOR_CONTROL);
return true;
}
return false;
}
}

0 comments on commit 26c9a4a

Please sign in to comment.