Settings: Introduce shake gesture
Change-Id: Id5f1bd28381566fd6a0facf328098b0b19d5abe4 Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -220,4 +220,49 @@
|
||||
<item>17</item>
|
||||
<item>18</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Hardware key rebinding -->
|
||||
<string-array name="hardware_keys_action_entries" translatable="false">
|
||||
<item>@string/hardware_keys_action_nothing</item>
|
||||
<item>@string/hardware_keys_action_menu</item>
|
||||
<item>@string/hardware_keys_action_app_switch</item>
|
||||
<item>@string/hardware_keys_action_search</item>
|
||||
<item>@string/hardware_keys_action_voice_search</item>
|
||||
<item>@string/hardware_keys_action_in_app_search</item>
|
||||
<item>@string/hardware_keys_action_launch_camera</item>
|
||||
<item>@string/hardware_keys_action_sleep</item>
|
||||
<item>@string/hardware_keys_action_last_app</item>
|
||||
<item>@string/hardware_keys_action_split_screen</item>
|
||||
<item>@string/hardware_keys_action_close_app</item>
|
||||
<item>@string/hardware_keys_action_play_pause_music</item>
|
||||
<item>@string/hardware_keys_action_torch</item>
|
||||
<item>@string/hardware_keys_action_screenshot</item>
|
||||
<item>@string/hardware_keys_action_volume_panel</item>
|
||||
<item>@string/hardware_keys_action_clear_all_notifications</item>
|
||||
<item>@string/hardware_keys_action_notifications_panel</item>
|
||||
<item>@string/hardware_keys_action_expand_qs_panel</item>
|
||||
<item>@string/hardware_keys_action_ringer_modes</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="hardware_keys_action_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
<item>13</item>
|
||||
<item>14</item>
|
||||
<item>15</item>
|
||||
<item>16</item>
|
||||
<item>17</item>
|
||||
<item>18</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -436,4 +436,18 @@
|
||||
<!-- Override Mock Location restriction -->
|
||||
<string name="override_mock_location_title">Override MockLocation restriction</string>
|
||||
<string name="override_mock_location_summary">When enabled, apps cannot detect mock locations</string>
|
||||
|
||||
<!-- Shake Gestures -->
|
||||
<string name="shake_gestures_enabled_title">Shake Gestures</string>
|
||||
<string name="shake_gestures_enabled_summary">Shake your device to perform actions</string>
|
||||
<string name="shake_gestures_action_title">Shake Gestures Actions</string>
|
||||
<string name="shake_gestures_toggle_flashlight">Toggle Flashlight</string>
|
||||
<string name="shake_gestures_media_playback">Play/Skip Media</string>
|
||||
<string name="shake_gestures_volume_panel">Show Volume Panel</string>
|
||||
<string name="shake_gestures_screen_wake">Turn Screen On/Off</string>
|
||||
<string name="shake_gestures_clear_notifs">Clear All Notifications</string>
|
||||
<string name="shake_gestures_toggle_ringer">Toggle Ringer Mode</string>
|
||||
<string name="shake_gestures_screenshot">Take Screenshot</string>
|
||||
<string name="shake_gestures_intensity_title">Shake Gestures Intensity</string>
|
||||
<string name="shake_gestures_intensity_summary">Adjust the sensitivity of shake gestures</string>
|
||||
</resources>
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
settings:searchable="false"
|
||||
settings:controller="com.android.settings.gestures.ThreeFingerSwipePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_shake_action"
|
||||
android:title="@string/shake_gestures_enabled_title"
|
||||
android:summary="@string/shake_gestures_enabled_summary"
|
||||
android:fragment="com.android.settings.gestures.Gestures" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_double_twist_input_summary"
|
||||
android:title="@string/double_twist_for_camera_mode_title"
|
||||
|
||||
55
res/xml/shake_settings_gestures.xml
Normal file
55
res/xml/shake_settings_gestures.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2023-2024 the risingOS Android Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/shake_gestures_enabled_title">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="shake_gestures"
|
||||
android:title="@string/shake_gestures_enabled_title">
|
||||
|
||||
<org.mist.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="shake_gestures_enabled"
|
||||
android:title="@string/shake_gestures_enabled_title"
|
||||
android:summary="@string/shake_gestures_enabled_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<lineageos.preference.LineageSystemSettingListPreference
|
||||
android:key="shake_gestures_action"
|
||||
android:title="@string/shake_gestures_action_title"
|
||||
android:summary="%s"
|
||||
android:dialogTitle="@string/shake_gestures_action_title"
|
||||
android:entries="@array/hardware_keys_action_entries"
|
||||
android:entryValues="@array/hardware_keys_action_values"
|
||||
android:defaultValue="0"
|
||||
android:dependency="shake_gestures_enabled" />
|
||||
|
||||
<org.mist.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="shake_gestures_intensity"
|
||||
android:title="@string/shake_gestures_intensity_title"
|
||||
android:summary="@string/shake_gestures_intensity_summary"
|
||||
android:dependency="shake_gestures_enabled"
|
||||
android:defaultValue="3"
|
||||
settings:interval="1"
|
||||
android:max="12"
|
||||
android:min="1" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
63
src/com/android/settings/gestures/Gestures.java
Normal file
63
src/com/android/settings/gestures/Gestures.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 the risingOS Android Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Log;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class Gestures extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.shake_settings_gestures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.VIEW_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* For search
|
||||
*/
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.shake_settings_gestures) {
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user