summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-06-25 11:52:48 -0700
committerJorim Jaggi <jjaggi@google.com>2015-06-25 22:39:21 +0000
commit7e6571f13da776dca4966dee0159e7741102fca9 (patch)
tree86aca1cbeec3d549c05879afcdf22729c5cd086e /packages
parent9a600725532c3fcf71f3be2610a34f02c88bb16b (diff)
downloadframeworks_base-7e6571f13da776dca4966dee0159e7741102fca9.zip
frameworks_base-7e6571f13da776dca4966dee0159e7741102fca9.tar.gz
frameworks_base-7e6571f13da776dca4966dee0159e7741102fca9.tar.bz2
Use long press of KeyButtonView to invoke assist
This makes sure that accessibility is handled properly. Bug: 18778078 Change-Id: I967b387aabff973b5a9fea649a805540ee08eea8
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/values/dimens.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/assist/AssistManager.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java37
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java20
4 files changed, 21 insertions, 47 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 005077f..155f5ea 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -583,7 +583,7 @@
<dimen name="managed_profile_toast_padding">4dp</dimen>
<!-- Thickness of the assist disclosure beams -->
- <dimen name="assist_disclosure_thickness">4dp</dimen>
+ <dimen name="assist_disclosure_thickness">3dp</dimen>
<!-- Thickness of the shadows of the assist disclosure beams -->
<dimen name="assist_disclosure_shadow_thickness">1.5dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 7838119..6ba5626 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -125,14 +125,11 @@ public class AssistManager {
}
}
- public void onGestureInvoked(boolean vibrate) {
+ public void onGestureInvoked() {
if (mAssistComponent == null) {
return;
}
- if (vibrate) {
- vibrate();
- }
final boolean isService = isAssistantService();
if (isService || !isVoiceSessionRunning()) {
showOrb();
@@ -290,10 +287,6 @@ public class AssistManager {
v.setImageDrawable(null);
}
- private void vibrate() {
- mView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
- }
-
private boolean isAssistantService() {
return mAssistComponent == null ?
false : mAssistComponent.equals(getVoiceInteractorComponentName());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 7f87485..ce5444e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -106,6 +106,7 @@ import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.Prefs;
import com.android.systemui.R;
+import com.android.systemui.SwipeHelper;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
@@ -676,8 +677,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
}
- updateShowSearchHoldoff();
-
try {
boolean showNav = mWindowManagerService.hasNavigationBar();
if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
@@ -1013,11 +1012,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return mStatusBarWindow;
}
- public void invokeAssistGesture(boolean vibrate) {
- mHandler.removeCallbacks(mInvokeAssist);
- mAssistManager.onGestureInvoked(vibrate);
- }
-
public int getStatusBarHeight() {
if (mNaturalBarHeight < 0) {
final Resources res = mContext.getResources();
@@ -1044,31 +1038,28 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
};
- private int mShowSearchHoldoff = 0;
- private Runnable mInvokeAssist = new Runnable() {
- public void run() {
+ private final View.OnLongClickListener mLongPressHomeListener
+ = new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (shouldDisableNavbarGestures()) {
+ return false;
+ }
mAssistManager.prepareBeforeInvocation();
- invokeAssistGesture(true /* vibrate */);
+ mAssistManager.onGestureInvoked();
awakenDreams();
if (mNavigationBarView != null) {
mNavigationBarView.abortCurrentGesture();
}
+ return true;
}
};
- View.OnTouchListener mHomeActionListener = new View.OnTouchListener() {
+ private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if (!shouldDisableNavbarGestures()) {
- mHandler.removeCallbacks(mInvokeAssist);
- mHandler.postDelayed(mInvokeAssist, mShowSearchHoldoff);
- }
- break;
-
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- mHandler.removeCallbacks(mInvokeAssist);
awakenDreams();
break;
}
@@ -1096,6 +1087,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mNavigationBarView.getBackButton().setLongClickable(true);
mNavigationBarView.getBackButton().setOnLongClickListener(mLongPressBackRecentsListener);
mNavigationBarView.getHomeButton().setOnTouchListener(mHomeActionListener);
+ mNavigationBarView.getHomeButton().setOnLongClickListener(mLongPressHomeListener);
mAssistManager.onConfigurationChanged();
}
@@ -1236,10 +1228,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
}
- private void updateShowSearchHoldoff() {
- mShowSearchHoldoff = ViewConfiguration.getLongPressTimeout();
- }
-
private void updateNotificationShade() {
if (mStackScroller == null) return;
@@ -2922,7 +2910,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateResources();
repositionNavigationBar();
- updateShowSearchHoldoff();
updateRowStates();
mIconController.updateResources();
mScreenPinningRequest.onConfigurationChanged();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 6bc51fa..4c99792 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -57,7 +57,7 @@ public class KeyButtonView extends ImageView {
if (isLongClickable()) {
// Just an old-fashioned ImageView
performLongClick();
- } else {
+ } else if (mSupportsLongpress) {
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
}
@@ -92,7 +92,7 @@ public class KeyButtonView extends ImageView {
super.onInitializeAccessibilityNodeInfo(info);
if (mCode != 0) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK, null));
- if (mSupportsLongpress) {
+ if (mSupportsLongpress || isLongClickable()) {
info.addAction(
new AccessibilityNodeInfo.AccessibilityAction(ACTION_LONG_CLICK, null));
}
@@ -115,7 +115,7 @@ public class KeyButtonView extends ImageView {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
playSoundEffect(SoundEffectConstants.CLICK);
return true;
- } else if (action == ACTION_LONG_CLICK && mCode != 0 && mSupportsLongpress) {
+ } else if (action == ACTION_LONG_CLICK && mCode != 0) {
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
sendEvent(KeyEvent.ACTION_UP, 0);
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
@@ -144,10 +144,8 @@ public class KeyButtonView extends ImageView {
// Provide the same haptic feedback that the system offers for virtual keys.
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
- if (mSupportsLongpress) {
- removeCallbacks(mCheckLongPress);
- postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
- }
+ removeCallbacks(mCheckLongPress);
+ postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
break;
case MotionEvent.ACTION_MOVE:
x = (int)ev.getX();
@@ -162,9 +160,7 @@ public class KeyButtonView extends ImageView {
if (mCode != 0) {
sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_CANCELED);
}
- if (mSupportsLongpress) {
- removeCallbacks(mCheckLongPress);
- }
+ removeCallbacks(mCheckLongPress);
break;
case MotionEvent.ACTION_UP:
final boolean doIt = isPressed();
@@ -183,9 +179,7 @@ public class KeyButtonView extends ImageView {
performClick();
}
}
- if (mSupportsLongpress) {
- removeCallbacks(mCheckLongPress);
- }
+ removeCallbacks(mCheckLongPress);
break;
}