am 7e6571f1: Use long press of KeyButtonView to invoke assist
* commit '7e6571f13da776dca4966dee0159e7741102fca9': Use long press of KeyButtonView to invoke assist
This commit is contained in:
@@ -583,7 +583,7 @@
|
|||||||
<dimen name="managed_profile_toast_padding">4dp</dimen>
|
<dimen name="managed_profile_toast_padding">4dp</dimen>
|
||||||
|
|
||||||
<!-- Thickness of the assist disclosure beams -->
|
<!-- 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 -->
|
<!-- Thickness of the shadows of the assist disclosure beams -->
|
||||||
<dimen name="assist_disclosure_shadow_thickness">1.5dp</dimen>
|
<dimen name="assist_disclosure_shadow_thickness">1.5dp</dimen>
|
||||||
|
|||||||
@@ -125,14 +125,11 @@ public class AssistManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGestureInvoked(boolean vibrate) {
|
public void onGestureInvoked() {
|
||||||
if (mAssistComponent == null) {
|
if (mAssistComponent == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vibrate) {
|
|
||||||
vibrate();
|
|
||||||
}
|
|
||||||
final boolean isService = isAssistantService();
|
final boolean isService = isAssistantService();
|
||||||
if (isService || !isVoiceSessionRunning()) {
|
if (isService || !isVoiceSessionRunning()) {
|
||||||
showOrb();
|
showOrb();
|
||||||
@@ -290,10 +287,6 @@ public class AssistManager {
|
|||||||
v.setImageDrawable(null);
|
v.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void vibrate() {
|
|
||||||
mView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isAssistantService() {
|
private boolean isAssistantService() {
|
||||||
return mAssistComponent == null ?
|
return mAssistComponent == null ?
|
||||||
false : mAssistComponent.equals(getVoiceInteractorComponentName());
|
false : mAssistComponent.equals(getVoiceInteractorComponentName());
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ import com.android.systemui.EventLogConstants;
|
|||||||
import com.android.systemui.EventLogTags;
|
import com.android.systemui.EventLogTags;
|
||||||
import com.android.systemui.Prefs;
|
import com.android.systemui.Prefs;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.SwipeHelper;
|
||||||
import com.android.systemui.assist.AssistManager;
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.doze.DozeHost;
|
import com.android.systemui.doze.DozeHost;
|
||||||
import com.android.systemui.doze.DozeLog;
|
import com.android.systemui.doze.DozeLog;
|
||||||
@@ -676,8 +677,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
|
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShowSearchHoldoff();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean showNav = mWindowManagerService.hasNavigationBar();
|
boolean showNav = mWindowManagerService.hasNavigationBar();
|
||||||
if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
|
if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
|
||||||
@@ -1013,11 +1012,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
return mStatusBarWindow;
|
return mStatusBarWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invokeAssistGesture(boolean vibrate) {
|
|
||||||
mHandler.removeCallbacks(mInvokeAssist);
|
|
||||||
mAssistManager.onGestureInvoked(vibrate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatusBarHeight() {
|
public int getStatusBarHeight() {
|
||||||
if (mNaturalBarHeight < 0) {
|
if (mNaturalBarHeight < 0) {
|
||||||
final Resources res = mContext.getResources();
|
final Resources res = mContext.getResources();
|
||||||
@@ -1044,31 +1038,28 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private int mShowSearchHoldoff = 0;
|
private final View.OnLongClickListener mLongPressHomeListener
|
||||||
private Runnable mInvokeAssist = new Runnable() {
|
= new View.OnLongClickListener() {
|
||||||
public void run() {
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (shouldDisableNavbarGestures()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mAssistManager.prepareBeforeInvocation();
|
mAssistManager.prepareBeforeInvocation();
|
||||||
invokeAssistGesture(true /* vibrate */);
|
mAssistManager.onGestureInvoked();
|
||||||
awakenDreams();
|
awakenDreams();
|
||||||
if (mNavigationBarView != null) {
|
if (mNavigationBarView != null) {
|
||||||
mNavigationBarView.abortCurrentGesture();
|
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) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
if (!shouldDisableNavbarGestures()) {
|
|
||||||
mHandler.removeCallbacks(mInvokeAssist);
|
|
||||||
mHandler.postDelayed(mInvokeAssist, mShowSearchHoldoff);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
mHandler.removeCallbacks(mInvokeAssist);
|
|
||||||
awakenDreams();
|
awakenDreams();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1096,6 +1087,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mNavigationBarView.getBackButton().setLongClickable(true);
|
mNavigationBarView.getBackButton().setLongClickable(true);
|
||||||
mNavigationBarView.getBackButton().setOnLongClickListener(mLongPressBackRecentsListener);
|
mNavigationBarView.getBackButton().setOnLongClickListener(mLongPressBackRecentsListener);
|
||||||
mNavigationBarView.getHomeButton().setOnTouchListener(mHomeActionListener);
|
mNavigationBarView.getHomeButton().setOnTouchListener(mHomeActionListener);
|
||||||
|
mNavigationBarView.getHomeButton().setOnLongClickListener(mLongPressHomeListener);
|
||||||
mAssistManager.onConfigurationChanged();
|
mAssistManager.onConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,10 +1228,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShowSearchHoldoff() {
|
|
||||||
mShowSearchHoldoff = ViewConfiguration.getLongPressTimeout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateNotificationShade() {
|
private void updateNotificationShade() {
|
||||||
if (mStackScroller == null) return;
|
if (mStackScroller == null) return;
|
||||||
|
|
||||||
@@ -2922,7 +2910,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
|
|
||||||
updateResources();
|
updateResources();
|
||||||
repositionNavigationBar();
|
repositionNavigationBar();
|
||||||
updateShowSearchHoldoff();
|
|
||||||
updateRowStates();
|
updateRowStates();
|
||||||
mIconController.updateResources();
|
mIconController.updateResources();
|
||||||
mScreenPinningRequest.onConfigurationChanged();
|
mScreenPinningRequest.onConfigurationChanged();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class KeyButtonView extends ImageView {
|
|||||||
if (isLongClickable()) {
|
if (isLongClickable()) {
|
||||||
// Just an old-fashioned ImageView
|
// Just an old-fashioned ImageView
|
||||||
performLongClick();
|
performLongClick();
|
||||||
} else {
|
} else if (mSupportsLongpress) {
|
||||||
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
|
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
|
||||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
|
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ public class KeyButtonView extends ImageView {
|
|||||||
super.onInitializeAccessibilityNodeInfo(info);
|
super.onInitializeAccessibilityNodeInfo(info);
|
||||||
if (mCode != 0) {
|
if (mCode != 0) {
|
||||||
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK, null));
|
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK, null));
|
||||||
if (mSupportsLongpress) {
|
if (mSupportsLongpress || isLongClickable()) {
|
||||||
info.addAction(
|
info.addAction(
|
||||||
new AccessibilityNodeInfo.AccessibilityAction(ACTION_LONG_CLICK, null));
|
new AccessibilityNodeInfo.AccessibilityAction(ACTION_LONG_CLICK, null));
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ public class KeyButtonView extends ImageView {
|
|||||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
|
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
|
||||||
playSoundEffect(SoundEffectConstants.CLICK);
|
playSoundEffect(SoundEffectConstants.CLICK);
|
||||||
return true;
|
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_DOWN, KeyEvent.FLAG_LONG_PRESS);
|
||||||
sendEvent(KeyEvent.ACTION_UP, 0);
|
sendEvent(KeyEvent.ACTION_UP, 0);
|
||||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
|
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.
|
// Provide the same haptic feedback that the system offers for virtual keys.
|
||||||
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||||
}
|
}
|
||||||
if (mSupportsLongpress) {
|
removeCallbacks(mCheckLongPress);
|
||||||
removeCallbacks(mCheckLongPress);
|
postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
|
||||||
postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
x = (int)ev.getX();
|
x = (int)ev.getX();
|
||||||
@@ -162,9 +160,7 @@ public class KeyButtonView extends ImageView {
|
|||||||
if (mCode != 0) {
|
if (mCode != 0) {
|
||||||
sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_CANCELED);
|
sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_CANCELED);
|
||||||
}
|
}
|
||||||
if (mSupportsLongpress) {
|
removeCallbacks(mCheckLongPress);
|
||||||
removeCallbacks(mCheckLongPress);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
final boolean doIt = isPressed();
|
final boolean doIt = isPressed();
|
||||||
@@ -183,9 +179,7 @@ public class KeyButtonView extends ImageView {
|
|||||||
performClick();
|
performClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mSupportsLongpress) {
|
removeCallbacks(mCheckLongPress);
|
||||||
removeCallbacks(mCheckLongPress);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user