From adba09b54ed1b30bf9b24d632165229a0752b144 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 24 Jun 2014 22:21:57 -0700 Subject: [PATCH] Remove redundant override methods and extended classes Bug: 15727335 Change-Id: Icea09f0643e7aeb8e722e473ad322f7439c3497a --- .../KeyboardAccessibilityDelegate.java | 2 +- .../MoreSuggestionsAccessibilityDelegate.java | 39 ------------------- .../keyboard/MoreKeysKeyboardView.java | 8 ++-- .../keyboard/emoji/EmojiPageKeyboardView.java | 22 +---------- .../suggestions/MoreSuggestionsView.java | 16 ++------ 5 files changed, 11 insertions(+), 76 deletions(-) delete mode 100644 java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java index 7a945e369..eb5b663dc 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java @@ -267,7 +267,7 @@ public class KeyboardAccessibilityDelegate * @param touchAction The action of the synthesizing touch event. * @param hoverEvent The base hover event from that the touch event is synthesized. */ - protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { + private void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); touchEvent.setAction(touchAction); mKeyboardView.onTouchEvent(touchEvent); diff --git a/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java deleted file mode 100644 index 941bac14c..000000000 --- a/java/src/com/android/inputmethod/accessibility/MoreSuggestionsAccessibilityDelegate.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2014 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.accessibility; - -import android.view.MotionEvent; - -import com.android.inputmethod.keyboard.KeyDetector; -import com.android.inputmethod.keyboard.MoreKeysKeyboardView; - -public final class MoreSuggestionsAccessibilityDelegate - extends MoreKeysKeyboardAccessibilityDelegate { - public MoreSuggestionsAccessibilityDelegate(final MoreKeysKeyboardView moreKeysKeyboardView, - final KeyDetector keyDetector) { - super(moreKeysKeyboardView, keyDetector); - } - - // TODO: Remove redundant override method. - @Override - protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { - final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); - touchEvent.setAction(touchAction); - mKeyboardView.onTouchEvent(touchEvent); - touchEvent.recycle(); - } -} diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java index 3994487aa..5140c4ffc 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java @@ -126,7 +126,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel @Override public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime) { mActivePointerId = pointerId; - mCurrentKey = detectKey(x, y, pointerId); + mCurrentKey = detectKey(x, y); } @Override @@ -135,7 +135,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel return; } final boolean hasOldKey = (mCurrentKey != null); - mCurrentKey = detectKey(x, y, pointerId); + mCurrentKey = detectKey(x, y); if (hasOldKey && mCurrentKey == null) { // A more keys keyboard is canceled when detecting no key. mController.onCancelMoreKeysPanel(); @@ -149,7 +149,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel } // Calling {@link #detectKey(int,int,int)} here is harmless because the last move event and // the following up event share the same coordinates. - mCurrentKey = detectKey(x, y, pointerId); + mCurrentKey = detectKey(x, y); if (mCurrentKey != null) { updateReleaseKeyGraphics(mCurrentKey); onKeyInput(mCurrentKey, x, y); @@ -174,7 +174,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel } } - private Key detectKey(int x, int y, int pointerId) { + private Key detectKey(int x, int y) { final Key oldKey = mCurrentKey; final Key newKey = mKeyDetector.detectHitKey(x, y); if (newKey == oldKey) { diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java index 063404028..17dfc9cce 100644 --- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPageKeyboardView.java @@ -56,24 +56,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements private OnKeyEventListener mListener = EMPTY_LISTENER; private final KeyDetector mKeyDetector = new KeyDetector(); private final GestureDetector mGestureDetector; - private EmojiPageKeyboardAccessibilityDelegate mAccessibilityDelegate; - - private static final class EmojiPageKeyboardAccessibilityDelegate - extends KeyboardAccessibilityDelegate { - public EmojiPageKeyboardAccessibilityDelegate(final EmojiPageKeyboardView keyboardView, - final KeyDetector keyDetector) { - super(keyboardView, keyDetector); - } - - // TODO: Remove redundant override method. - @Override - protected void simulateTouchEvent(int touchAction, MotionEvent hoverEvent) { - final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); - touchEvent.setAction(touchAction); - mKeyboardView.onTouchEvent(touchEvent); - touchEvent.recycle(); - } - } + private KeyboardAccessibilityDelegate mAccessibilityDelegate; public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) { this(context, attrs, R.attr.keyboardViewStyle); @@ -100,8 +83,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */); if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) { if (mAccessibilityDelegate == null) { - mAccessibilityDelegate = new EmojiPageKeyboardAccessibilityDelegate( - this, mKeyDetector); + mAccessibilityDelegate = new KeyboardAccessibilityDelegate<>(this, mKeyDetector); } mAccessibilityDelegate.setKeyboard(keyboard); } else { diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 9f9bff5bd..47921ca0a 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -20,8 +20,6 @@ import android.content.Context; import android.util.AttributeSet; import android.util.Log; -import com.android.inputmethod.accessibility.AccessibilityUtils; -import com.android.inputmethod.accessibility.MoreSuggestionsAccessibilityDelegate; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; @@ -59,16 +57,10 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { // above {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call. // With accessibility mode on, {@link #mAccessibilityDelegate} is set to a // {@link MoreKeysKeyboardAccessibilityDelegate} object at the above - // {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call. And the object has to be - // overwritten by a {@link MoreSuggestionsAccessibilityDelegate} object here. - if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) { - if (!(mAccessibilityDelegate instanceof MoreSuggestionsAccessibilityDelegate)) { - mAccessibilityDelegate = new MoreSuggestionsAccessibilityDelegate( - this, mKeyDetector); - mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_suggestions); - mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_suggestions); - } - mAccessibilityDelegate.setKeyboard(keyboard); + // {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call. + if (mAccessibilityDelegate != null) { + mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_suggestions); + mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_suggestions); } }