Skip to content

Commit

Permalink
TouchGestures: Add ambient as a gesture action
Browse files Browse the repository at this point in the history
Also add the string for single tap which is used by OnePlus sm8150 devices

Change-Id: I318674423fbffa6997a868ba36246336ac08237e
  • Loading branch information
anirudhgupta109 authored and SKULSHADY committed Feb 19, 2020
1 parent 6a7f523 commit 51913ea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<item>@string/touchscreen_gesture_action_next_track</item>
<item>@string/touchscreen_gesture_action_volume_down</item>
<item>@string/touchscreen_gesture_action_volume_up</item>
<item>@string/touchscreen_gesture_action_ambient_display</item>
</string-array>
<string-array name="touchscreen_gesture_action_values">
<item>0</item>
Expand All @@ -44,6 +45,7 @@
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
</string-array>

</resources>
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<string name="touchscreen_gesture_letter_v_title">Draw the letter \"V\"</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_single_tap_title">Single tap</string>

<!-- Gesture: Stylus gestures -->
<string name="touchscreen_gesture_swipe_up_stylus_title">Swipe up with the stylus</string>
Expand All @@ -62,5 +63,6 @@
<string name="touchscreen_gesture_action_next_track">Play the next music track</string>
<string name="touchscreen_gesture_action_volume_down">Lower media volume</string>
<string name="touchscreen_gesture_action_volume_up">Raise media volume</string>
<string name="touchscreen_gesture_action_ambient_display">Show ambient display</string>

</resources>
15 changes: 15 additions & 0 deletions src/com/android/touch/gestures/KeyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class KeyHandler implements DeviceKeyHandler {
private static final String TAG = KeyHandler.class.getSimpleName();

private static final String GESTURE_WAKEUP_REASON = "touchscreen-gesture-wakeup";
private static final String PULSE_ACTION = "com.android.systemui.doze.pulse";
private static final int GESTURE_REQUEST = 0;
private static final int GESTURE_WAKELOCK_DURATION = 3000;
private static final int EVENT_PROCESS_WAKELOCK_DURATION = 500;
Expand Down Expand Up @@ -230,6 +231,9 @@ public void handleMessage(final Message msg) {
case TouchscreenGestureConstants.ACTION_VOLUME_UP:
volumeUp();
break;
case TouchscreenGestureConstants.ACTION_AMBIENT_DISPLAY:
launchDozePulse();
break;
}
}
}
Expand Down Expand Up @@ -318,6 +322,17 @@ private void volumeUp() {
doHapticFeedback();
}

private void launchDozePulse() {
final boolean dozeEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.DOZE_ENABLED, 1) != 0;
if (dozeEnabled) {
mGestureWakeLock.acquire(GESTURE_WAKELOCK_DURATION);
final Intent intent = new Intent(PULSE_ACTION);
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
doHapticFeedback();
}
}

private void dispatchMediaKeyWithWakeLockToMediaSession(final int keycode) {
final MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mContext);
if (helper == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ class TouchscreenGestureConstants {
static final int ACTION_NEXT_TRACK = 9;
static final int ACTION_VOLUME_DOWN = 10;
static final int ACTION_VOLUME_UP = 11;
static final int ACTION_AMBIENT_DISPLAY = 12;
}

0 comments on commit 51913ea

Please sign in to comment.