Buttons: Add buttons brightness and button backlight timeout options
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user