Remove redundant override methods and extended classes

Bug: 15727335
Change-Id: Icea09f0643e7aeb8e722e473ad322f7439c3497a
This commit is contained in:
Tadashi G. Takaoka 2014-06-24 22:21:57 -07:00
parent 3d8848e5cb
commit adba09b54e
5 changed files with 11 additions and 76 deletions

View File

@ -267,7 +267,7 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
* @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);

View File

@ -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();
}
}

View File

@ -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) {

View File

@ -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<EmojiPageKeyboardView> {
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<EmojiPageKeyboardView> 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 {

View File

@ -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);
}
}