本文整理汇总了Java中android.view.MotionEvent.ACTION_HOVER_ENTER属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.ACTION_HOVER_ENTER属性的具体用法?Java MotionEvent.ACTION_HOVER_ENTER怎么用?Java MotionEvent.ACTION_HOVER_ENTER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.ACTION_HOVER_ENTER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHoverEvent
@Override
public boolean onHoverEvent(MotionEvent event) {
if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isTouchExplorationEnabled()) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
event.setAction(MotionEvent.ACTION_DOWN);
break;
case MotionEvent.ACTION_HOVER_MOVE:
event.setAction(MotionEvent.ACTION_MOVE);
break;
case MotionEvent.ACTION_HOVER_EXIT:
event.setAction(MotionEvent.ACTION_UP);
break;
}
onTouchEvent(event);
event.setAction(action);
}
super.onHoverEvent(event);
return true;
}
示例2: onHoverEvent
@Override
public boolean onHoverEvent(MotionEvent event) {
if (((AccessibilityManager) getContext().getSystemService(
Context.ACCESSIBILITY_SERVICE)).isTouchExplorationEnabled()) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
event.setAction(MotionEvent.ACTION_DOWN);
break;
case MotionEvent.ACTION_HOVER_MOVE:
event.setAction(MotionEvent.ACTION_MOVE);
break;
case MotionEvent.ACTION_HOVER_EXIT:
event.setAction(MotionEvent.ACTION_UP);
break;
}
onTouchEvent(event);
event.setAction(action);
}
return super.onHoverEvent(event);
}
示例3: setContentViewMotionEventOffsets
private void setContentViewMotionEventOffsets(MotionEvent e, boolean canClear) {
// TODO(dtrainor): Factor this out to LayoutDriver.
if (e == null || mTabVisible == null) return;
ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
if (contentViewCore == null) return;
int actionMasked = e.getActionMasked();
if (SPenSupport.isSPenSupported(getContext())) {
actionMasked = SPenSupport.convertSPenEventAction(actionMasked);
}
if (actionMasked == MotionEvent.ACTION_DOWN
|| actionMasked == MotionEvent.ACTION_HOVER_ENTER) {
if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
} else if (canClear && (actionMasked == MotionEvent.ACTION_UP
|| actionMasked == MotionEvent.ACTION_CANCEL
|| actionMasked == MotionEvent.ACTION_HOVER_EXIT)) {
contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
}
}
示例4: getMotionOffsets
private Point getMotionOffsets(MotionEvent e) {
int actionMasked = e.getActionMasked();
if (SPenSupport.isSPenSupported(mHost.getContext())) {
actionMasked = SPenSupport.convertSPenEventAction(actionMasked);
}
if (actionMasked == MotionEvent.ACTION_DOWN
|| actionMasked == MotionEvent.ACTION_HOVER_ENTER) {
getViewportPixel(mCachedRect);
mCachedPoint.set(-mCachedRect.left, -mCachedRect.top);
return mCachedPoint;
} else if (actionMasked == MotionEvent.ACTION_UP
|| actionMasked == MotionEvent.ACTION_CANCEL
|| actionMasked == MotionEvent.ACTION_HOVER_EXIT) {
mCachedPoint.set(0, 0);
return mCachedPoint;
}
return null;
}
示例5: onHoverEvent
@SuppressLint("NewApi")
@Override
public boolean onHoverEvent(MotionEvent event) {
if (isEnabled()) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
event.setAction(MotionEvent.ACTION_DOWN);
break;
case MotionEvent.ACTION_HOVER_MOVE:
event.setAction(MotionEvent.ACTION_MOVE);
break;
case MotionEvent.ACTION_HOVER_EXIT:
event.setAction(MotionEvent.ACTION_UP);
break;
}
onTouchEvent(event);
event.setAction(action);
}
return super.onHoverEvent(event);
}
示例6: onGenericMotion
public boolean onGenericMotion(View v, MotionEvent event) {
if(!isTVMenuDisplayed){
if (DBG)
Log.d(TAG, "onGenericMotion : event=" + event);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M&&event.getActionButton()==MotionEvent.BUTTON_PRIMARY) //
return false;
int action = event.getAction();
if (action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_MOVE || action == MotionEvent.ACTION_HOVER_EXIT) {
// Ignore events sent by the remote control when it is in pointer mode
return false;
}
show(FLAG_SIDE_ALL_EXCEPT_UNLOCK_INSTRUCTIONS, 3000);
return true;
}
return false;
}
示例7: onHoverEvent
@Override
public boolean onHoverEvent(MotionEvent event) {
if (Build.VERSION.SDK_INT >= 11) {
if (((AccessibilityManager) getContext().getSystemService(
Context.ACCESSIBILITY_SERVICE)).isTouchExplorationEnabled()) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
event.setAction(MotionEvent.ACTION_DOWN);
break;
case MotionEvent.ACTION_HOVER_MOVE:
event.setAction(MotionEvent.ACTION_MOVE);
break;
case MotionEvent.ACTION_HOVER_EXIT:
event.setAction(MotionEvent.ACTION_UP);
break;
}
onTouchEvent(event);
event.setAction(action);
}
}
return super.onHoverEvent(event);
}
示例8: processGenericEvent
public void processGenericEvent(final MotionEvent event)
{
super.processGenericEvent(event);
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_MOVE ||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_ENTER ||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_EXIT )
{
hover = true;
hoverX = event.getX();
hoverY = event.getY();
hoverTime = System.currentTimeMillis();
if( ExternalMouseDetected == 0 && (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_MOVE )
fingerHover = true;
if( tap && System.currentTimeMillis() < tapTime + 1000 )
{
tap = false;
hoverTouchDistance += Math.abs(tapX - hoverX) + Math.abs(tapY - hoverY);
Log.i("SDL", "Hover hoverX " + hoverX + " tapX " + tapX + " hoverY " + hoverX + " tapY " + tapY + " hoverTouchDistance " + hoverTouchDistance);
}
}
}
示例9: getMotionEventString
public static String getMotionEventString(int action){
switch(action){
case(MotionEvent.ACTION_DOWN): return "action_down";
case(MotionEvent.ACTION_UP): return "action_down";
case(MotionEvent.ACTION_CANCEL): return "action_down";
case(MotionEvent.ACTION_MOVE): return "action_move";
case(MotionEvent.ACTION_OUTSIDE): return "action_outside";
case(MotionEvent.ACTION_HOVER_ENTER): return "action_hover_enter";
case(MotionEvent.ACTION_HOVER_EXIT): return "action_hover_exit";
case(MotionEvent.ACTION_HOVER_MOVE): return "action_hover_move";
case(MotionEvent.ACTION_MASK): return "action_mask";
}
return "unknown action event";
}
示例10: onHoverEvent
@Override
public boolean onHoverEvent(MotionEvent event) {
try {
if (Common.isTouchToExploreEnabled()) {
if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER) {
clickTime = System.currentTimeMillis();
}
//This is double tap
if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER && Math.abs(xPosition - event.getX()) < 20 && Math.abs(yPosition - event.getY()) < 20 && firstTap && clickTime - lastClickTime < 1000) {
lastClickTime = 0;
firstTap = false;
gestureDoubleTap.onDoubleTap(event);
return false;
} //This is long single tap
else if (event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
firstTap = true;
lastClickTime = clickTime;
xPosition = event.getX();
yPosition = event.getY();
}
return onTouchEvent(event);
} else {
return super.onHoverEvent(event);
}
} catch (Exception e) {
e.printStackTrace();
return super.onHoverEvent(event);
}
}
示例11: actionToString
public static String actionToString(int action) {
switch (action) {
case MotionEvent.ACTION_DOWN:
return "ACTION_DOWN";
case MotionEvent.ACTION_UP:
return "ACTION_UP";
case MotionEvent.ACTION_CANCEL:
return "ACTION_CANCEL";
case MotionEvent.ACTION_OUTSIDE:
return "ACTION_OUTSIDE";
case MotionEvent.ACTION_MOVE:
return "ACTION_MOVE";
case MotionEvent.ACTION_HOVER_MOVE:
return "ACTION_HOVER_MOVE";
case MotionEvent.ACTION_SCROLL:
return "ACTION_SCROLL";
case MotionEvent.ACTION_HOVER_ENTER:
return "ACTION_HOVER_ENTER";
case MotionEvent.ACTION_HOVER_EXIT:
return "ACTION_HOVER_EXIT";
case MotionEvent.ACTION_BUTTON_PRESS:
return "ACTION_BUTTON_PRESS";
case MotionEvent.ACTION_BUTTON_RELEASE:
return "ACTION_BUTTON_RELEASE";
}
int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN:
return "ACTION_POINTER_DOWN(" + index + ")";
case MotionEvent.ACTION_POINTER_UP:
return "ACTION_POINTER_UP(" + index + ")";
default:
return Integer.toString(action);
}
}
示例12: onInterceptHoverEvent
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
if (mLauncher == null || mLauncher.getWorkspace() == null) {
return false;
}
Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
if (currentFolder == null) {
return false;
} else {
AccessibilityManager accessibilityManager = (AccessibilityManager)
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isTouchExplorationEnabled()) {
final int action = ev.getAction();
boolean isOverFolderOrSearchBar;
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
(isInAccessibleDrag() && isEventOverDropTargetBar(ev));
if (!isOverFolderOrSearchBar) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
}
mHoverPointClosesFolder = false;
break;
case MotionEvent.ACTION_HOVER_MOVE:
isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
(isInAccessibleDrag() && isEventOverDropTargetBar(ev));
if (!isOverFolderOrSearchBar && !mHoverPointClosesFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
} else if (!isOverFolderOrSearchBar) {
return true;
}
mHoverPointClosesFolder = false;
}
}
}
return false;
}
示例13: dispatchHoverEvent
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
if (!mHasSelectorWheel) {
return super.dispatchHoverEvent(event);
}
if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) {
final int eventY = (int) event.getY();
final int hoveredVirtualViewId;
if (eventY < mTopSelectionDividerTop) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
} else if (eventY > mBottomSelectionDividerBottom) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
} else {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
}
final int action = event.getAction() & MotionEvent.ACTION_MASK;
SupportAccessibilityNodeProvider provider = getSupportAccessibilityNodeProvider();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER: {
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
} break;
case MotionEvent.ACTION_HOVER_MOVE: {
if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
&& mLastHoveredChildVirtualViewId != View.NO_ID) {
provider.sendAccessibilityEventForVirtualView(
mLastHoveredChildVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}
} break;
case MotionEvent.ACTION_HOVER_EXIT: {
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
mLastHoveredChildVirtualViewId = View.NO_ID;
} break;
}
}
return false;
}
示例14: dispatchHoverEvent
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
final int eventY = (int) event.getY();
final int hoveredVirtualViewId;
if (eventY < mTopSelectionDividerTop) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
} else if (eventY > mBottomSelectionDividerBottom) {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
} else {
hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
}
final int action = event.getActionMasked();
AccessibilityNodeProviderImpl provider = (AccessibilityNodeProviderImpl) getAccessibilityNodeProviderCompat();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER: {
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}
break;
case MotionEvent.ACTION_HOVER_MOVE: {
if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
&& mLastHoveredChildVirtualViewId != View.NO_ID) {
provider.sendAccessibilityEventForVirtualView(
mLastHoveredChildVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}
}
break;
case MotionEvent.ACTION_HOVER_EXIT: {
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
mLastHoveredChildVirtualViewId = View.NO_ID;
}
break;
}
}
return false;
}
示例15: onHoverEvent
@Override
public boolean onHoverEvent(MotionEvent event) {
// When touch exploration is turned on, lifting a finger while inside
// the button's hover target bounds should perform a click action.
if (mAccessibilityManager.isEnabled() && mAccessibilityManager.isTouchExplorationEnabled()) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER:
// Lift-to-type temporarily disables double-tap activation.
mWasClickable = isClickable();
mWasLongClickable = isLongClickable();
if (mWasLongClickable && mLongHoverContentDesc != null) {
if (mLongHoverRunnable == null) {
mLongHoverRunnable =
new Runnable() {
@Override
public void run() {
setLongHovered(true);
announceForAccessibility(mLongHoverContentDesc);
}
};
}
postDelayed(mLongHoverRunnable, LONG_HOVER_TIMEOUT);
}
setClickable(false);
setLongClickable(false);
break;
case MotionEvent.ACTION_HOVER_EXIT:
if (mHoverBounds.contains(event.getX(), event.getY())) {
if (mLongHovered) {
performLongClick();
} else {
simulateClickForAccessibility();
}
}
cancelLongHover();
setClickable(mWasClickable);
setLongClickable(mWasLongClickable);
break;
}
}
return super.onHoverEvent(event);
}