diff --git a/res/drawable/ic_torch.xml b/res/drawable/ic_torch.xml
new file mode 100644
index 0000000..48a59d5
--- /dev/null
+++ b/res/drawable/ic_torch.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml
index 6247bd5..479b5b7 100644
--- a/res/values/cherish_arrays.xml
+++ b/res/values/cherish_arrays.xml
@@ -44,4 +44,20 @@
- 1
- 2
+
+
+ - @string/torch_long_press_power_timeout_never
+ - @string/torch_long_press_power_timeout_1min
+ - @string/torch_long_press_power_timeout_2min
+ - @string/torch_long_press_power_timeout_5min
+ - @string/torch_long_press_power_timeout_10min
+
+
+
+ - 0
+ - 60
+ - 120
+ - 300
+ - 600
+
diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index 2feac6a..011c73e 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -137,4 +137,13 @@
Disabled
Volume up/down moves cursor left/right
Volume up/down moves cursor right/left
+
+ Screen off power button torch
+ Long press power button while the screen is off to turn on the flashlight
+ Automatically turn torch off
+ Never
+ 1 minute
+ 2 minutes
+ 5 minutes
+ 10 minutes
\ No newline at end of file
diff --git a/res/xml/cherish_settings_gestures.xml b/res/xml/cherish_settings_gestures.xml
index e72f6a0..6de8696 100644
--- a/res/xml/cherish_settings_gestures.xml
+++ b/res/xml/cherish_settings_gestures.xml
@@ -18,4 +18,20 @@
android:title="@string/gestures_title"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+
+
+
diff --git a/src/com/cherish/settings/fragments/GestureSettings.java b/src/com/cherish/settings/fragments/GestureSettings.java
index 0d73a58..9008855 100644
--- a/src/com/cherish/settings/fragments/GestureSettings.java
+++ b/src/com/cherish/settings/fragments/GestureSettings.java
@@ -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