Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
New haptic feedback constants
Browse files Browse the repository at this point in the history
This CL introduces several haptic feedback constants that are ready
to be exposed to developers.

Test: checkbuild
Fixes: 64537070
Change-Id: If54d5bc6cab4e2c405615b7a40648c74a1097ea3
  • Loading branch information
yukawa committed Aug 24, 2017
1 parent 1c1e709 commit 262dadf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions api/current.txt
Expand Up @@ -44166,9 +44166,13 @@ package android.view {
field public static final int CONTEXT_CLICK = 6; // 0x6
field public static final int FLAG_IGNORE_GLOBAL_SETTING = 2; // 0x2
field public static final int FLAG_IGNORE_VIEW_SETTING = 1; // 0x1
field public static final int KEYBOARD_PRESS = 3; // 0x3
field public static final int KEYBOARD_RELEASE = 7; // 0x7
field public static final int KEYBOARD_TAP = 3; // 0x3
field public static final int LONG_PRESS = 0; // 0x0
field public static final int TEXT_HANDLE_MOVE = 9; // 0x9
field public static final int VIRTUAL_KEY = 1; // 0x1
field public static final int VIRTUAL_KEY_RELEASE = 8; // 0x8
}

public class InflateException extends java.lang.RuntimeException {
Expand Down
4 changes: 4 additions & 0 deletions api/system-current.txt
Expand Up @@ -47751,9 +47751,13 @@ package android.view {
field public static final int CONTEXT_CLICK = 6; // 0x6
field public static final int FLAG_IGNORE_GLOBAL_SETTING = 2; // 0x2
field public static final int FLAG_IGNORE_VIEW_SETTING = 1; // 0x1
field public static final int KEYBOARD_PRESS = 3; // 0x3
field public static final int KEYBOARD_RELEASE = 7; // 0x7
field public static final int KEYBOARD_TAP = 3; // 0x3
field public static final int LONG_PRESS = 0; // 0x0
field public static final int TEXT_HANDLE_MOVE = 9; // 0x9
field public static final int VIRTUAL_KEY = 1; // 0x1
field public static final int VIRTUAL_KEY_RELEASE = 8; // 0x8
}

public class InflateException extends java.lang.RuntimeException {
Expand Down
4 changes: 4 additions & 0 deletions api/test-current.txt
Expand Up @@ -44597,9 +44597,13 @@ package android.view {
field public static final int CONTEXT_CLICK = 6; // 0x6
field public static final int FLAG_IGNORE_GLOBAL_SETTING = 2; // 0x2
field public static final int FLAG_IGNORE_VIEW_SETTING = 1; // 0x1
field public static final int KEYBOARD_PRESS = 3; // 0x3
field public static final int KEYBOARD_RELEASE = 7; // 0x7
field public static final int KEYBOARD_TAP = 3; // 0x3
field public static final int LONG_PRESS = 0; // 0x0
field public static final int TEXT_HANDLE_MOVE = 9; // 0x9
field public static final int VIRTUAL_KEY = 1; // 0x1
field public static final int VIRTUAL_KEY_RELEASE = 8; // 0x8
}

public class InflateException extends java.lang.RuntimeException {
Expand Down
18 changes: 13 additions & 5 deletions core/java/android/view/HapticFeedbackConstants.java
Expand Up @@ -57,16 +57,24 @@ private HapticFeedbackConstants() {}
public static final int CONTEXT_CLICK = 6;

/**
* The user has released a virtual or software keyboard key.
* @hide
* The user has pressed a virtual or software keyboard key.
*/
public static final int KEYBOARD_PRESS = KEYBOARD_TAP;

/**
* The user has released a virtual keyboard key.
*/
public static final int VIRTUAL_KEY_RELEASE = 7;
public static final int KEYBOARD_RELEASE = 7;

/**
* The user has released a virtual key.
*/
public static final int VIRTUAL_KEY_RELEASE = 8;

/**
* The user has performed a selection/insertion handle move on text field.
* @hide
*/
public static final int TEXT_HANDLE_MOVE = 8;
public static final int TEXT_HANDLE_MOVE = 9;

/**
* The phone has booted with safe mode enabled.
Expand Down
Expand Up @@ -7793,13 +7793,9 @@ public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean al
private VibrationEffect getVibrationEffect(int effectId) {
long[] pattern;
switch (effectId) {
case HapticFeedbackConstants.VIRTUAL_KEY:
return VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
case HapticFeedbackConstants.LONG_PRESS:
pattern = mLongPressVibePattern;
break;
case HapticFeedbackConstants.KEYBOARD_TAP:
return VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
case HapticFeedbackConstants.CLOCK_TICK:
return VibrationEffect.get(VibrationEffect.EFFECT_TICK);
case HapticFeedbackConstants.CALENDAR_DATE:
Expand All @@ -7810,8 +7806,14 @@ private VibrationEffect getVibrationEffect(int effectId) {
break;
case HapticFeedbackConstants.CONTEXT_CLICK:
return VibrationEffect.get(VibrationEffect.EFFECT_TICK);
case HapticFeedbackConstants.VIRTUAL_KEY:
return VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
case HapticFeedbackConstants.VIRTUAL_KEY_RELEASE:
return VibrationEffect.get(VibrationEffect.EFFECT_TICK);
case HapticFeedbackConstants.KEYBOARD_PRESS: // == HapticFeedbackConstants.KEYBOARD_TAP
return VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
case HapticFeedbackConstants.KEYBOARD_RELEASE:
return VibrationEffect.get(VibrationEffect.EFFECT_TICK);
case HapticFeedbackConstants.TEXT_HANDLE_MOVE:
return VibrationEffect.get(VibrationEffect.EFFECT_TICK);
default:
Expand Down

0 comments on commit 262dadf

Please sign in to comment.