mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Remove AccessibilityManagerCompatUtils and MorionEventCompatUtils
Bug: 6129704 Change-Id: Icb7e80588536066c4fe5b4a1afc100a724b43e7b
This commit is contained in:
parent
244c825c4b
commit
c6435f92a8
@ -21,17 +21,14 @@ import android.inputmethodservice.InputMethodService;
|
|||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.view.MotionEventCompat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.AccessibilityManagerCompatUtils;
|
|
||||||
import com.android.inputmethod.compat.AudioManagerCompatWrapper;
|
import com.android.inputmethod.compat.AudioManagerCompatWrapper;
|
||||||
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
||||||
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
|
||||||
import com.android.inputmethod.compat.SettingsSecureCompatUtils;
|
import com.android.inputmethod.compat.SettingsSecureCompatUtils;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
@ -93,7 +90,7 @@ public class AccessibilityUtils {
|
|||||||
public boolean isTouchExplorationEnabled() {
|
public boolean isTouchExplorationEnabled() {
|
||||||
return ENABLE_ACCESSIBILITY
|
return ENABLE_ACCESSIBILITY
|
||||||
&& mAccessibilityManager.isEnabled()
|
&& mAccessibilityManager.isEnabled()
|
||||||
&& AccessibilityManagerCompatUtils.isTouchExplorationEnabled(mAccessibilityManager);
|
&& mAccessibilityManager.isTouchExplorationEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,9 +104,9 @@ public class AccessibilityUtils {
|
|||||||
public boolean isTouchExplorationEvent(MotionEvent event) {
|
public boolean isTouchExplorationEvent(MotionEvent event) {
|
||||||
final int action = event.getAction();
|
final int action = event.getAction();
|
||||||
|
|
||||||
return action == MotionEventCompatUtils.ACTION_HOVER_ENTER
|
return action == MotionEvent.ACTION_HOVER_ENTER
|
||||||
|| action == MotionEventCompatUtils.ACTION_HOVER_EXIT
|
|| action == MotionEvent.ACTION_HOVER_EXIT
|
||||||
|| action == MotionEventCompat.ACTION_HOVER_MOVE;
|
|| action == MotionEvent.ACTION_HOVER_MOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,14 +21,12 @@ import android.graphics.Color;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.support.v4.view.AccessibilityDelegateCompat;
|
import android.support.v4.view.AccessibilityDelegateCompat;
|
||||||
import android.support.v4.view.MotionEventCompat;
|
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.view.accessibility.AccessibilityEventCompat;
|
import android.support.v4.view.accessibility.AccessibilityEventCompat;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
|
||||||
import com.android.inputmethod.compat.ViewParentCompatUtils;
|
import com.android.inputmethod.compat.ViewParentCompatUtils;
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
@ -136,10 +134,10 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
|||||||
mLastHoverKey = key;
|
mLastHoverKey = key;
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEventCompatUtils.ACTION_HOVER_ENTER:
|
case MotionEvent.ACTION_HOVER_ENTER:
|
||||||
case MotionEventCompatUtils.ACTION_HOVER_EXIT:
|
case MotionEvent.ACTION_HOVER_EXIT:
|
||||||
return onHoverKey(key, event);
|
return onHoverKey(key, event);
|
||||||
case MotionEventCompat.ACTION_HOVER_MOVE:
|
case MotionEvent.ACTION_HOVER_MOVE:
|
||||||
if (key != previousKey) {
|
if (key != previousKey) {
|
||||||
return onTransitionKey(key, previousKey, event);
|
return onTransitionKey(key, previousKey, event);
|
||||||
} else {
|
} else {
|
||||||
@ -163,13 +161,13 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
|||||||
private boolean onTransitionKey(Key currentKey, Key previousKey, MotionEvent event) {
|
private boolean onTransitionKey(Key currentKey, Key previousKey, MotionEvent event) {
|
||||||
final int savedAction = event.getAction();
|
final int savedAction = event.getAction();
|
||||||
|
|
||||||
event.setAction(MotionEventCompatUtils.ACTION_HOVER_EXIT);
|
event.setAction(MotionEvent.ACTION_HOVER_EXIT);
|
||||||
onHoverKey(previousKey, event);
|
onHoverKey(previousKey, event);
|
||||||
|
|
||||||
event.setAction(MotionEventCompatUtils.ACTION_HOVER_ENTER);
|
event.setAction(MotionEvent.ACTION_HOVER_ENTER);
|
||||||
onHoverKey(currentKey, event);
|
onHoverKey(currentKey, event);
|
||||||
|
|
||||||
event.setAction(MotionEventCompat.ACTION_HOVER_MOVE);
|
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
|
||||||
final boolean handled = onHoverKey(currentKey, event);
|
final boolean handled = onHoverKey(currentKey, event);
|
||||||
|
|
||||||
event.setAction(savedAction);
|
event.setAction(savedAction);
|
||||||
@ -192,10 +190,10 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEventCompatUtils.ACTION_HOVER_ENTER:
|
case MotionEvent.ACTION_HOVER_ENTER:
|
||||||
sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER);
|
sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER);
|
||||||
break;
|
break;
|
||||||
case MotionEventCompatUtils.ACTION_HOVER_EXIT:
|
case MotionEvent.ACTION_HOVER_EXIT:
|
||||||
sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT);
|
sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,9 @@ package com.android.inputmethod.accessibility;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.support.v4.view.MotionEventCompat;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.MotionEventCompatUtils;
|
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
import com.android.inputmethod.keyboard.PointerTracker;
|
||||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||||
|
|
||||||
@ -32,10 +30,10 @@ import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
|||||||
* A flick gesture is defined as a stream of hover events with the following
|
* A flick gesture is defined as a stream of hover events with the following
|
||||||
* properties:
|
* properties:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Begins with a {@link MotionEventCompatUtils#ACTION_HOVER_ENTER} event
|
* <li>Begins with a {@link MotionEvent#ACTION_HOVER_ENTER} event
|
||||||
* <li>Contains any number of {@link MotionEventCompat#ACTION_HOVER_MOVE}
|
* <li>Contains any number of {@link MotionEvent#ACTION_HOVER_MOVE}
|
||||||
* events
|
* events
|
||||||
* <li>Ends with a {@link MotionEventCompatUtils#ACTION_HOVER_EXIT} event
|
* <li>Ends with a {@link MotionEvent#ACTION_HOVER_EXIT} event
|
||||||
* <li>Maximum duration of 250 milliseconds
|
* <li>Maximum duration of 250 milliseconds
|
||||||
* <li>Minimum distance between enter and exit points must be at least equal to
|
* <li>Minimum distance between enter and exit points must be at least equal to
|
||||||
* scaled double tap slop (see
|
* scaled double tap slop (see
|
||||||
@ -113,7 +111,7 @@ public abstract class FlickGestureDetector {
|
|||||||
public boolean onHoverEvent(MotionEvent event, AccessibleKeyboardViewProxy view,
|
public boolean onHoverEvent(MotionEvent event, AccessibleKeyboardViewProxy view,
|
||||||
PointerTracker tracker) {
|
PointerTracker tracker) {
|
||||||
// Always cache and consume the first hover event.
|
// Always cache and consume the first hover event.
|
||||||
if (event.getAction() == MotionEventCompatUtils.ACTION_HOVER_ENTER) {
|
if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
|
||||||
mCachedView = view;
|
mCachedView = view;
|
||||||
mCachedTracker = tracker;
|
mCachedTracker = tracker;
|
||||||
mCachedHoverEnter = MotionEvent.obtain(event);
|
mCachedHoverEnter = MotionEvent.obtain(event);
|
||||||
@ -129,10 +127,10 @@ public abstract class FlickGestureDetector {
|
|||||||
final float distanceSquare = calculateDistanceSquare(mCachedHoverEnter, event);
|
final float distanceSquare = calculateDistanceSquare(mCachedHoverEnter, event);
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEventCompat.ACTION_HOVER_MOVE:
|
case MotionEvent.ACTION_HOVER_MOVE:
|
||||||
// Consume all valid move events before timeout.
|
// Consume all valid move events before timeout.
|
||||||
return true;
|
return true;
|
||||||
case MotionEventCompatUtils.ACTION_HOVER_EXIT:
|
case MotionEvent.ACTION_HOVER_EXIT:
|
||||||
// Ignore exit events outside the flick radius.
|
// Ignore exit events outside the flick radius.
|
||||||
if (distanceSquare < mFlickRadiusSquare) {
|
if (distanceSquare < mFlickRadiusSquare) {
|
||||||
clearFlick(true);
|
clearFlick(true);
|
||||||
@ -171,10 +169,8 @@ public abstract class FlickGestureDetector {
|
|||||||
* Computes the direction of a flick gesture and forwards it to
|
* Computes the direction of a flick gesture and forwards it to
|
||||||
* {@link #onFlick(MotionEvent, MotionEvent, int)} for handling.
|
* {@link #onFlick(MotionEvent, MotionEvent, int)} for handling.
|
||||||
*
|
*
|
||||||
* @param e1 The {@link MotionEventCompatUtils#ACTION_HOVER_ENTER} event
|
* @param e1 The {@link MotionEvent#ACTION_HOVER_ENTER} event where the flick started.
|
||||||
* where the flick started.
|
* @param e2 The {@link MotionEvent#ACTION_HOVER_EXIT} event where the flick ended.
|
||||||
* @param e2 The {@link MotionEventCompatUtils#ACTION_HOVER_EXIT} event
|
|
||||||
* where the flick ended.
|
|
||||||
* @return {@code true} if the flick event was handled.
|
* @return {@code true} if the flick event was handled.
|
||||||
*/
|
*/
|
||||||
private boolean dispatchFlick(MotionEvent e1, MotionEvent e2) {
|
private boolean dispatchFlick(MotionEvent e1, MotionEvent e2) {
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
|
||||||
|
|
||||||
import android.view.accessibility.AccessibilityManager;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class AccessibilityManagerCompatUtils {
|
|
||||||
private static final Method METHOD_isTouchExplorationEnabled = CompatUtils.getMethod(
|
|
||||||
AccessibilityManager.class, "isTouchExplorationEnabled");
|
|
||||||
|
|
||||||
private AccessibilityManagerCompatUtils() {
|
|
||||||
// This class is non-instantiable.
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTouchExplorationEnabled(AccessibilityManager receiver) {
|
|
||||||
return (Boolean) CompatUtils.invoke(receiver, false, METHOD_isTouchExplorationEnabled);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
|
||||||
|
|
||||||
public class MotionEventCompatUtils {
|
|
||||||
// TODO: Remove after these are added to MotionEventCompat.
|
|
||||||
public static final int ACTION_HOVER_ENTER = 0x9;
|
|
||||||
public static final int ACTION_HOVER_EXIT = 0xA;
|
|
||||||
}
|
|
@ -828,15 +828,13 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives hover events from the input framework. This method overrides
|
* Receives hover events from the input framework.
|
||||||
* View.dispatchHoverEvent(MotionEvent) on SDK version ICS or higher. On
|
|
||||||
* lower SDK versions, this method is never called.
|
|
||||||
*
|
*
|
||||||
* @param event The motion event to be dispatched.
|
* @param event The motion event to be dispatched.
|
||||||
* @return {@code true} if the event was handled by the view, {@code false}
|
* @return {@code true} if the event was handled by the view, {@code false}
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
//Should not annotate @override
|
@Override
|
||||||
public boolean dispatchHoverEvent(MotionEvent event) {
|
public boolean dispatchHoverEvent(MotionEvent event) {
|
||||||
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user