diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index 25e71c1..54d9e26 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -12,4 +12,16 @@ limitations under the License. --> + + + + @string/torch_power_button_gesture_none + @string/torch_power_button_gesture_dt + @string/torch_power_button_gesture_lp + + + 0 + 1 + 2 + diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index f3e5c96..2812e50 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -161,4 +161,11 @@ Music control Long press volume buttons to switch tracks while screen off + + Toggle torch when screen off + Disabled + Double tap power button (slower single tap response), Disables double power tap for camera. + Jump to camera gesture is now disabled + Long press power button + diff --git a/res/xml/cherish_settings_button.xml b/res/xml/cherish_settings_button.xml index b289033..c13eaf2 100644 --- a/res/xml/cherish_settings_button.xml +++ b/res/xml/cherish_settings_button.xml @@ -36,6 +36,12 @@ android:defaultValue="false" android:disableDependentsState="true" /> + + \ No newline at end of file diff --git a/src/com/cherish/settings/fragments/ButtonSettings.java b/src/com/cherish/settings/fragments/ButtonSettings.java index b2e6cdd..edc34e5 100644 --- a/src/com/cherish/settings/fragments/ButtonSettings.java +++ b/src/com/cherish/settings/fragments/ButtonSettings.java @@ -31,7 +31,7 @@ import androidx.preference.PreferenceScreen; import androidx.preference.Preference.OnPreferenceChangeListener; import androidx.preference.SwitchPreference; import android.provider.Settings; - +import android.widget.Toast; import com.android.settings.R; import com.cherish.settings.preferences.SystemSettingSwitchPreference; @@ -52,6 +52,9 @@ import java.util.List; @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) public class ButtonSettings extends ActionFragment implements OnPreferenceChangeListener { + private static final String TORCH_POWER_BUTTON_GESTURE = "torch_power_button_gesture"; + + private ListPreference mTorchPowerButton; @Override public void onCreate(Bundle icicle) { @@ -61,10 +64,27 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange final Resources res = getResources(); final ContentResolver resolver = getActivity().getContentResolver(); final PreferenceScreen prefScreen = getPreferenceScreen(); + + // screen off torch + mTorchPowerButton = (ListPreference) findPreference(TORCH_POWER_BUTTON_GESTURE); + int mTorchPowerButtonValue = Settings.System.getInt(resolver, + Settings.System.TORCH_POWER_BUTTON_GESTURE, 0); + mTorchPowerButton.setValue(Integer.toString(mTorchPowerButtonValue)); + mTorchPowerButton.setSummary(mTorchPowerButton.getEntry()); + mTorchPowerButton.setOnPreferenceChangeListener(this); } public boolean onPreferenceChange(Preference preference, Object newValue) { ContentResolver resolver = getActivity().getContentResolver(); + if (preference == mTorchPowerButton) { + int mTorchPowerButtonValue = Integer.valueOf((String) newValue); + int index = mTorchPowerButton.findIndexOfValue((String) newValue); + mTorchPowerButton.setSummary( + mTorchPowerButton.getEntries()[index]); + Settings.System.putInt(resolver, Settings.System.TORCH_POWER_BUTTON_GESTURE, + mTorchPowerButtonValue); + return true; + } return false; }