Buttons: Add buttons brightness and button backlight timeout options
This commit is contained in:
@@ -60,4 +60,25 @@
|
|||||||
<item>300</item>
|
<item>300</item>
|
||||||
<item>600</item>
|
<item>600</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!--- Buttons backlight timeout -->
|
||||||
|
<string-array name="backlight_timeout_entries">
|
||||||
|
<item>@string/backlight_timeout_on</item>
|
||||||
|
<item>@string/backlight_timeout_3s</item>
|
||||||
|
<item>@string/backlight_timeout_default</item>
|
||||||
|
<item>@string/backlight_timeout_10s</item>
|
||||||
|
<item>@string/backlight_timeout_15s</item>
|
||||||
|
<item>@string/backlight_timeout_20s</item>
|
||||||
|
<item>@string/backlight_timeout_30s</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="backlight_timeout_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>3000</item>
|
||||||
|
<item>5000</item>
|
||||||
|
<item>10000</item>
|
||||||
|
<item>15000</item>
|
||||||
|
<item>20000</item>
|
||||||
|
<item>30000</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -161,4 +161,20 @@
|
|||||||
<!-- Incall Home button behavior-->
|
<!-- Incall Home button behavior-->
|
||||||
<string name="allow_incall_home_title">Home button when ringing</string>
|
<string name="allow_incall_home_title">Home button when ringing</string>
|
||||||
<string name="allow_incall_home_summary">Allow to use Home button when device is ringing</string>
|
<string name="allow_incall_home_summary">Allow to use Home button when device is ringing</string>
|
||||||
</resources>
|
|
||||||
|
<!-- Hardware keys -->
|
||||||
|
<string name="hardware_keys_category">Hardware keys</string>
|
||||||
|
|
||||||
|
<!-- Buttons backlight timeout -->
|
||||||
|
<string name="backlight_timeout_title">Buttons backlight timeout</string>
|
||||||
|
<string name="backlight_timeout_on">Enabled always</string>
|
||||||
|
<string name="backlight_timeout_3s">3 sec</string>
|
||||||
|
<string name="backlight_timeout_default">5 sec (default)</string>
|
||||||
|
<string name="backlight_timeout_10s">10 sec</string>
|
||||||
|
<string name="backlight_timeout_15s">15 sec</string>
|
||||||
|
<string name="backlight_timeout_20s">20 sec</string>
|
||||||
|
<string name="backlight_timeout_30s">30 sec</string>
|
||||||
|
|
||||||
|
<!-- Enable keys backlight-->
|
||||||
|
<string name="button_brightness_title">Backlight</string>
|
||||||
|
</resources>
|
||||||
|
|||||||
@@ -31,11 +31,33 @@
|
|||||||
</Preference>
|
</Preference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="hardware_keys"
|
||||||
|
android:title="@string/hardware_keys_category" >
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||||
|
android:key="button_brightness"
|
||||||
|
android:title="@string/button_brightness_title"
|
||||||
|
android:max="255"
|
||||||
|
settings:min="0"
|
||||||
|
settings:units=""
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:dialogTitle="@string/backlight_timeout_title"
|
||||||
|
android:entries="@array/backlight_timeout_entries"
|
||||||
|
android:entryValues="@array/backlight_timeout_values"
|
||||||
|
android:key="backlight_timeout"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/backlight_timeout_title" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="volume_keys"
|
android:key="volume_keys"
|
||||||
android:title="@string/volume_keys_title">
|
android:title="@string/volume_keys_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<Preference
|
||||||
android:key="volume_key"
|
android:key="volume_key"
|
||||||
android:fragment="com.cherish.settings.fragments.VolumeRockerSettings"
|
android:fragment="com.cherish.settings.fragments.VolumeRockerSettings"
|
||||||
android:title="@string/volume_title" />
|
android:title="@string/volume_title" />
|
||||||
|
|||||||
@@ -36,22 +36,69 @@ import com.android.settings.R;
|
|||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
|
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
|
|
||||||
public class ButtonSettings extends SettingsPreferenceFragment implements
|
public class ButtonSettings extends SettingsPreferenceFragment implements
|
||||||
Preference.OnPreferenceChangeListener{
|
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
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
addPreferencesFromResource(R.xml.cherish_settings_button);
|
addPreferencesFromResource(R.xml.cherish_settings_button);
|
||||||
|
|
||||||
final PreferenceScreen prefScreen = getPreferenceScreen();
|
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) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
|||||||
private int mInterval = 1;
|
private int mInterval = 1;
|
||||||
private int mCurrentValue;
|
private int mCurrentValue;
|
||||||
private int mDefaultValue = -1;
|
private int mDefaultValue = -1;
|
||||||
private int mMax = 100;
|
private int mMax = 255;
|
||||||
private String mUnits = "";
|
private String mUnits = "";
|
||||||
private String mDefaultText = "";
|
private String mDefaultText = "";
|
||||||
private SeekBar mSeekBar;
|
private SeekBar mSeekBar;
|
||||||
@@ -51,7 +51,7 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
|||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.CustomSeekBarPreference);
|
attrs, R.styleable.CustomSeekBarPreference);
|
||||||
|
|
||||||
mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
|
mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 255);
|
||||||
mMin = attrs.getAttributeIntValue(SETTINGS_NS, "min", 0);
|
mMin = attrs.getAttributeIntValue(SETTINGS_NS, "min", 0);
|
||||||
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", -1);
|
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", -1);
|
||||||
if (mDefaultValue > mMax) {
|
if (mDefaultValue > mMax) {
|
||||||
|
|||||||
Reference in New Issue
Block a user