diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml
index 479b5b7..295ffa7 100644
--- a/res/values/cherish_arrays.xml
+++ b/res/values/cherish_arrays.xml
@@ -60,4 +60,25 @@
- 300
- 600
+
+
+
+ - @string/backlight_timeout_on
+ - @string/backlight_timeout_3s
+ - @string/backlight_timeout_default
+ - @string/backlight_timeout_10s
+ - @string/backlight_timeout_15s
+ - @string/backlight_timeout_20s
+ - @string/backlight_timeout_30s
+
+
+
+ - 0
+ - 3000
+ - 5000
+ - 10000
+ - 15000
+ - 20000
+ - 30000
+
diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index bb51bcf..5077de4 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -161,4 +161,20 @@
Home button when ringing
Allow to use Home button when device is ringing
-
\ No newline at end of file
+
+
+ Hardware keys
+
+
+ Buttons backlight timeout
+ Enabled always
+ 3 sec
+ 5 sec (default)
+ 10 sec
+ 15 sec
+ 20 sec
+ 30 sec
+
+
+ Backlight
+
diff --git a/res/xml/cherish_settings_button.xml b/res/xml/cherish_settings_button.xml
index 4816ac4..8252330 100644
--- a/res/xml/cherish_settings_button.xml
+++ b/res/xml/cherish_settings_button.xml
@@ -31,11 +31,33 @@
+
+
+
+
+
+
+
+
-
diff --git a/src/com/cherish/settings/fragments/ButtonSettings.java b/src/com/cherish/settings/fragments/ButtonSettings.java
index fa9df14..4833631 100644
--- a/src/com/cherish/settings/fragments/ButtonSettings.java
+++ b/src/com/cherish/settings/fragments/ButtonSettings.java
@@ -36,22 +36,69 @@ import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.cherish.settings.preferences.CustomSeekBarPreference;
+
import com.android.internal.logging.nano.MetricsProto;
public class ButtonSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener{
+ //Keys
+ private static final String KEY_BUTTON_BRIGHTNESS = "button_brightness";
+ private static final String KEY_BACKLIGHT_TIMEOUT = "backlight_timeout";
+
+ // category keys
+ private static final String CATEGORY_HWKEY = "hardware_keys";
+
+ private ListPreference mBacklightTimeout;
+ private CustomSeekBarPreference mButtonBrightness;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.cherish_settings_button);
final PreferenceScreen prefScreen = getPreferenceScreen();
+
+ mBacklightTimeout =
+ (ListPreference) findPreference(KEY_BACKLIGHT_TIMEOUT);
+ mButtonBrightness =
+ (CustomSeekBarPreference) findPreference(KEY_BUTTON_BRIGHTNESS);
+
+ if (mBacklightTimeout != null) {
+ mBacklightTimeout.setOnPreferenceChangeListener(this);
+ int BacklightTimeout = Settings.System.getInt(getContentResolver(),
+ Settings.System.BUTTON_BACKLIGHT_TIMEOUT, 5000);
+ mBacklightTimeout.setValue(Integer.toString(BacklightTimeout));
+ mBacklightTimeout.setSummary(mBacklightTimeout.getEntry());
+ }
+
+ if (mButtonBrightness != null) {
+ int ButtonBrightness = Settings.System.getInt(getContentResolver(),
+ Settings.System.BUTTON_BRIGHTNESS, 255);
+ mButtonBrightness.setValue(ButtonBrightness / 1);
+ mButtonBrightness.setOnPreferenceChangeListener(this);
+ }
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
-
+ if (preference == mBacklightTimeout) {
+ String BacklightTimeout = (String) newValue;
+ int BacklightTimeoutValue = Integer.parseInt(BacklightTimeout);
+ Settings.System.putInt(getActivity().getContentResolver(),
+ Settings.System.BUTTON_BACKLIGHT_TIMEOUT, BacklightTimeoutValue);
+ int BacklightTimeoutIndex = mBacklightTimeout
+ .findIndexOfValue(BacklightTimeout);
+ mBacklightTimeout
+ .setSummary(mBacklightTimeout.getEntries()[BacklightTimeoutIndex]);
+ return true;
+ } else if (preference == mButtonBrightness) {
+ int value = (Integer) newValue;
+ Settings.System.putInt(getActivity().getContentResolver(),
+ Settings.System.BUTTON_BRIGHTNESS, value * 1);
+ return true;
+ }
return false;
}
diff --git a/src/com/cherish/settings/preferences/CustomSeekBarPreference.java b/src/com/cherish/settings/preferences/CustomSeekBarPreference.java
index 2fca63b..908bce4 100644
--- a/src/com/cherish/settings/preferences/CustomSeekBarPreference.java
+++ b/src/com/cherish/settings/preferences/CustomSeekBarPreference.java
@@ -38,7 +38,7 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
private int mInterval = 1;
private int mCurrentValue;
private int mDefaultValue = -1;
- private int mMax = 100;
+ private int mMax = 255;
private String mUnits = "";
private String mDefaultText = "";
private SeekBar mSeekBar;
@@ -51,7 +51,7 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.CustomSeekBarPreference);
- mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
+ mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 255);
mMin = attrs.getAttributeIntValue(SETTINGS_NS, "min", 0);
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", -1);
if (mDefaultValue > mMax) {