diff options
author | 2013-01-06 11:10:27 +0900 | |
---|---|---|
committer | 2013-01-07 12:13:42 +0900 | |
commit | b6ca354431367b625daf9fff5fbe4b1f5ef996ab (patch) | |
tree | 1358c683e123161cc04bc6ad83eb75c763ec53b3 /java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java | |
parent | f677681330143e3e50871222d33ade594e6348ce (diff) | |
download | latinime-b6ca354431367b625daf9fff5fbe4b1f5ef996ab.tar.gz latinime-b6ca354431367b625daf9fff5fbe4b1f5ef996ab.tar.xz latinime-b6ca354431367b625daf9fff5fbe4b1f5ef996ab.zip |
Small code cleanups
Multi-project commit with I249d5fbe
Change-Id: Ia28c4e970992aa1299a30e604eaa5d096655c3a5
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java')
-rw-r--r-- | java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index fcfa6d4e4..d73924d92 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -42,12 +42,11 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp private Key mLastHoverKey = null; /** - * Inset in pixels to look for keys when the user's finger exits the - * keyboard area. + * Inset in pixels to look for keys when the user's finger exits the keyboard area. */ private int mEdgeSlop; - public static void init(InputMethodService inputMethod) { + public static void init(final InputMethodService inputMethod) { sInstance.initInternal(inputMethod); } @@ -59,7 +58,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp // Not publicly instantiable. } - private void initInternal(InputMethodService inputMethod) { + private void initInternal(final InputMethodService inputMethod) { mInputMethod = inputMethod; mEdgeSlop = inputMethod.getResources().getDimensionPixelSize( R.dimen.accessibility_edge_slop); @@ -70,61 +69,61 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp * * @param view The view to wrap. */ - public void setView(MainKeyboardView view) { + public void setView(final MainKeyboardView view) { if (view == null) { // Ignore null views. return; } - mView = view; // Ensure that the view has an accessibility delegate. ViewCompat.setAccessibilityDelegate(view, this); - if (mAccessibilityNodeProvider != null) { - mAccessibilityNodeProvider.setView(view); + if (mAccessibilityNodeProvider == null) { + return; } + mAccessibilityNodeProvider.setView(view); } - public void setKeyboard(Keyboard keyboard) { - if (mAccessibilityNodeProvider != null) { - mAccessibilityNodeProvider.setKeyboard(keyboard); + public void setKeyboard() { + if (mAccessibilityNodeProvider == null) { + return; } + mAccessibilityNodeProvider.setKeyboard(); } /** - * Proxy method for View.getAccessibilityNodeProvider(). This method is - * called in SDK version 15 and higher to obtain the virtual node hierarchy - * provider. + * Proxy method for View.getAccessibilityNodeProvider(). This method is called in SDK + * version 15 (Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) and higher to obtain the virtual + * node hierarchy provider. * * @return The accessibility node provider for the current keyboard. */ @Override - public AccessibilityEntityProvider getAccessibilityNodeProvider(View host) { + public AccessibilityEntityProvider getAccessibilityNodeProvider(final View host) { return getAccessibilityNodeProvider(); } /** - * Intercepts touch events before dispatch when touch exploration is turned - * on in ICS and higher. + * Intercepts touch events before dispatch when touch exploration is turned on in ICS and + * higher. * * @param event The motion event being dispatched. * @return {@code true} if the event is handled */ - public boolean dispatchTouchEvent(MotionEvent event) { + public boolean dispatchTouchEvent(final MotionEvent event) { // To avoid accidental key presses during touch exploration, always drop // touch events generated by the user. return false; } /** - * Receives hover events when touch exploration is turned on in SDK versions - * ICS and higher. + * Receives hover events when touch exploration is turned on in SDK versions ICS and higher. * * @param event The hover event. * @return {@code true} if the event is handled */ - public boolean dispatchHoverEvent(MotionEvent event, PointerTracker tracker) { + public boolean dispatchHoverEvent(final MotionEvent event, final PointerTracker tracker) { final int x = (int) event.getX(); final int y = (int) event.getY(); final Key previousKey = mLastHoverKey; @@ -135,7 +134,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } else { key = null; } - mLastHoverKey = key; switch (event.getAction()) { @@ -173,30 +171,29 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } /** - * Utility method to determine whether the given point, in local - * coordinates, is inside the view, where the area of the view is contracted - * by the edge slop factor. + * Utility method to determine whether the given point, in local coordinates, is inside the + * view, where the area of the view is contracted by the edge slop factor. * * @param localX The local x-coordinate. * @param localY The local y-coordinate. */ - private boolean pointInView(int localX, int localY) { + private boolean pointInView(final int localX, final int localY) { return (localX >= mEdgeSlop) && (localY >= mEdgeSlop) && (localX < (mView.getWidth() - mEdgeSlop)) && (localY < (mView.getHeight() - mEdgeSlop)); } /** - * Simulates a transition between two {@link Key}s by sending a HOVER_EXIT - * on the previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE - * on the current key. + * Simulates a transition between two {@link Key}s by sending a HOVER_EXIT on the previous key, + * a HOVER_ENTER on the current key, and a HOVER_MOVE on the current key. * * @param currentKey The currently hovered key. * @param previousKey The previously hovered key. * @param event The event that triggered the transition. * @return {@code true} if the event was handled. */ - private boolean onTransitionKey(Key currentKey, Key previousKey, MotionEvent event) { + private boolean onTransitionKey(final Key currentKey, final Key previousKey, + final MotionEvent event) { final int savedAction = event.getAction(); event.setAction(MotionEvent.ACTION_HOVER_EXIT); @@ -214,19 +211,18 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } /** - * Handles a hover event on a key. If {@link Key} extended View, this would - * be analogous to calling View.onHoverEvent(MotionEvent). + * Handles a hover event on a key. If {@link Key} extended View, this would be analogous to + * calling View.onHoverEvent(MotionEvent). * * @param key The currently hovered key. * @param event The hover event. * @return {@code true} if the event was handled. */ - private boolean onHoverKey(Key key, MotionEvent event) { + private boolean onHoverKey(final Key key, final MotionEvent event) { // Null keys can't receive events. if (key == null) { return false; } - final AccessibilityEntityProvider provider = getAccessibilityNodeProvider(); switch (event.getAction()) { @@ -241,7 +237,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT); break; } - return true; } @@ -268,7 +263,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp default: text = context.getText(R.string.spoken_description_shiftmode_off); } - AccessibilityUtils.getInstance().announceForAccessibility(mView, text); } @@ -307,7 +301,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp if (resId < 0) { return; } - final String text = context.getString(resId); AccessibilityUtils.getInstance().announceForAccessibility(mView, text); } |