Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CMParts: Add touchscreen gesture settings and keyhandler
With the new TouchscreenGesture CMHW API, devices can advertise
support for different sorts of touchscreen gestures.

Add settings in CMParts to allow users to configure each and
every one of the gesture to their liking.

Change-Id: I7c0f80cbae52ee85b9fdf12bdcebe99a78febd6a
  • Loading branch information
zwliew committed Feb 1, 2017
1 parent c82eb89 commit 2ccca73
Show file tree
Hide file tree
Showing 20 changed files with 994 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -42,6 +42,7 @@
<protected-broadcast android:name="cyanogenmod.platform.app.profiles.PROFILES_STATE_CHANGED" />
<protected-broadcast android:name="org.cyanogenmod.cmparts.PART_CHANGED" />
<protected-broadcast android:name="org.cyanogenmod.cmparts.REFRESH_PART" />
<protected-broadcast android:name="org.cyanogenmod.cmparts.gestures.UPDATE_SETTINGS" />

<application android:label="@string/cmparts_title"
android:theme="@style/Theme.Settings"
Expand Down Expand Up @@ -132,6 +133,8 @@
android:value="button_settings" />
</activity-alias>

<activity android:name=".gestures.KeyHandler" />

<!-- Profiles settings (dashboard) -->
<activity-alias
android:name=".profiles.ProfilesSettings"
Expand Down
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_browser.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M17.9,17.39C17.64,16.59 16.89,16 16,16H15V13A1,1 0 0,0 14,12H8V10H10A1,1 0 0,0 11,9V7H13A2,2 0 0,0 15,5V4.59C17.93,5.77 20,8.64 20,12C20,14.08 19.2,15.97 17.9,17.39M11,19.93C7.05,19.44 4,16.08 4,12C4,11.38 4.08,10.78 4.21,10.21L9,15V16A2,2 0 0,0 11,18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_camera.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M4,4H7L9,2H15L17,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9Z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_dialer.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_email.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_flashlight.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M9,10L6,5H18L15,10H9M18,4H6V2H18V4M9,22V11H15V22H9M12,13A1,1 0 0,0 11,14A1,1 0 0,0 12,15A1,1 0 0,0 13,14A1,1 0 0,0 12,13Z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_messages.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M6,9H18V11H6M14,14H6V12H14M18,8H6V6H18" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_next_track.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M8,8L13,12L8,16M14,8H16V16H14" />
</vector>
30 changes: 30 additions & 0 deletions res/drawable/ic_gesture_action_none.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42
3.58-8 8-8 1.85 0 3.55 .63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85
0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_play_pause.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M3,5V19L11,12M13,19H16V5H13M18,5V19H21V5" />
</vector>
27 changes: 27 additions & 0 deletions res/drawable/ic_gesture_action_previous_track.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 The CyanogenMod 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M8,8H10V16H8M16,8V16L11,12" />
</vector>
27 changes: 27 additions & 0 deletions res/values/arrays.xml
Expand Up @@ -285,4 +285,31 @@
<item>1</item>
<item>2</item>
</string-array>

<!-- Gestures - touchscreen gesture actions -->
<string-array name="touchscreen_gesture_action_entries">
<item>@string/touchscreen_gesture_action_do_nothing</item>
<item>@string/touchscreen_gesture_action_flashlight</item>
<item>@string/touchscreen_gesture_action_camera</item>
<item>@string/touchscreen_gesture_action_browser</item>
<item>@string/touchscreen_gesture_action_dialer</item>
<item>@string/touchscreen_gesture_action_email</item>
<item>@string/touchscreen_gesture_action_messages</item>
<item>@string/touchscreen_gesture_action_play_pause_music</item>
<item>@string/touchscreen_gesture_action_previous_track</item>
<item>@string/touchscreen_gesture_action_next_track</item>
</string-array>

<string-array name="touchscreen_gesture_action_values">
<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>
</string-array>
</resources>
4 changes: 4 additions & 0 deletions res/values/config.xml
Expand Up @@ -23,4 +23,8 @@
<!-- When true, weather options will be displayed in settings dashboard -->
<bool name="config_showWeatherMenu">true</bool>

<!-- Default action ids for a device's touchscreen gestures
The array should be sorted in the same order as the
touchscreen gestures advertised by the device's CMHW impl. -->
<integer-array name="config_defaultTouchscreenGestureActions" />
</resources>
36 changes: 36 additions & 0 deletions res/values/strings.xml
Expand Up @@ -573,4 +573,40 @@
<string name="power_notifications_vibrate_title">Vibrate</string>
<string name="charging_sounds_ringtone_title">Notification sound</string>
<string name="charging_sounds_ringtone_silent">Silent</string>

<!-- Gestures: Touchscreen gestures -->
<string name="touchscreen_gesture_settings_title">Touchscreen gestures</string>
<string name="touchscreen_gesture_settings_summary">Perform various touchscreen gestures for quick actions</string>

<string name="touchscreen_gestures_haptic_feedback_title">Haptic feedback</string>
<string name="touchscreen_gestures_haptic_feedback_summary">Vibrate when a touchscreen gesture is detected</string>

<string name="touchscreen_gesture_two_finger_down_swipe_title">Swipe down with two fingers</string>
<string name="touchscreen_gesture_one_finger_up_swipe_title">Swipe up with one finger</string>
<string name="touchscreen_gesture_one_finger_down_swipe_title">Swipe down with one finger</string>
<string name="touchscreen_gesture_one_finger_left_swipe_title">Swipe left with one finger</string>
<string name="touchscreen_gesture_one_finger_right_swipe_title">Swipe right with one finger</string>
<string name="touchscreen_gesture_up_arrow_title">Draw a \"Λ\"</string>
<string name="touchscreen_gesture_down_arrow_title">Draw a \"V\"</string>
<string name="touchscreen_gesture_left_arrow_title">Draw a \"&lt;\"</string>
<string name="touchscreen_gesture_right_arrow_title">Draw a \"&gt;\"</string>
<string name="touchscreen_gesture_letter_c_title">Draw the letter \"C\"</string>
<string name="touchscreen_gesture_letter_e_title">Draw the letter \"e\"</string>
<string name="touchscreen_gesture_letter_o_title">Draw the letter \"O\"</string>
<string name="touchscreen_gesture_letter_m_title">Draw the letter \"M\"</string>
<string name="touchscreen_gesture_letter_s_title">Draw the letter \"S\"</string>
<string name="touchscreen_gesture_letter_w_title">Draw the letter \"W\"</string>
<string name="touchscreen_gesture_letter_z_title">Draw the letter \"Z\"</string>

<string name="touchscreen_gesture_action_dialog_title">Gesture action</string>
<string name="touchscreen_gesture_action_do_nothing">Do nothing</string>
<string name="touchscreen_gesture_action_flashlight">Toggle the flashlight</string>
<string name="touchscreen_gesture_action_camera">Open the camera</string>
<string name="touchscreen_gesture_action_browser">Open the browser</string>
<string name="touchscreen_gesture_action_dialer">Open the dialer</string>
<string name="touchscreen_gesture_action_email">View your emails</string>
<string name="touchscreen_gesture_action_messages">View your messages</string>
<string name="touchscreen_gesture_action_play_pause_music">Play/pause music playback</string>
<string name="touchscreen_gesture_action_previous_track">Navigate to the previous music track</string>
<string name="touchscreen_gesture_action_next_track">Skip to the next music track</string>
</resources>
5 changes: 5 additions & 0 deletions res/xml/parts_catalog.xml
Expand Up @@ -111,4 +111,9 @@
android:fragment="org.cyanogenmod.cmparts.sounds.ChargingSoundsSettings"
cm:xmlRes="@xml/charging_sounds_settings" />

<part android:key="touchscreen_gesture_settings"
android:title="@string/touchscreen_gesture_settings_title"
android:summary="@string/touchscreen_gesture_settings_summary"
android:fragment="org.cyanogenmod.cmparts.gestures.TouchscreenGestureSettings"
cm:xmlRes="@xml/touchscreen_gesture_settings" />
</parts-catalog>

0 comments on commit 2ccca73

Please sign in to comment.