Cherish:Torch long press power: add with auto-off function
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -3,17 +3,51 @@ package com.cherish.settings.fragments;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.ListPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
public class GestureSettings extends SettingsPreferenceFragment {
|
||||
public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_TORCH_LONG_PRESS_POWER_TIMEOUT =
|
||||
"torch_long_press_power_timeout";
|
||||
|
||||
private ListPreference mTorchLongPressPowerTimeout;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
addPreferencesFromResource(R.xml.cherish_settings_gestures);
|
||||
|
||||
mTorchLongPressPowerTimeout =
|
||||
(ListPreference) findPreference(KEY_TORCH_LONG_PRESS_POWER_TIMEOUT);
|
||||
|
||||
mTorchLongPressPowerTimeout.setOnPreferenceChangeListener(this);
|
||||
int TorchTimeout = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.TORCH_LONG_PRESS_POWER_TIMEOUT, 0);
|
||||
mTorchLongPressPowerTimeout.setValue(Integer.toString(TorchTimeout));
|
||||
mTorchLongPressPowerTimeout.setSummary(mTorchLongPressPowerTimeout.getEntry());
|
||||
}
|
||||
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mTorchLongPressPowerTimeout) {
|
||||
String TorchTimeout = (String) newValue;
|
||||
int TorchTimeoutValue = Integer.parseInt(TorchTimeout);
|
||||
Settings.System.putInt(getActivity().getContentResolver(),
|
||||
Settings.System.TORCH_LONG_PRESS_POWER_TIMEOUT, TorchTimeoutValue);
|
||||
int TorchTimeoutIndex = mTorchLongPressPowerTimeout
|
||||
.findIndexOfValue(TorchTimeout);
|
||||
mTorchLongPressPowerTimeout
|
||||
.setSummary(mTorchLongPressPowerTimeout.getEntries()[TorchTimeoutIndex]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user