am c9c3ea0b: Merge "Remove redundant override methods and extended classes"

* commit 'c9c3ea0b68a1bad1febb7532fa941b430a1b941a':
  Remove redundant override methods and extended classes
main
Tadashi G. Takaoka 2014-06-27 07:38:09 +00:00 committed by Android Git Automerger
commit c1d0d17891
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 touchAction The action of the synthesizing touch event.
* @param hoverEvent The base hover event from that the touch event is synthesized. * @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); final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent);
touchEvent.setAction(touchAction); touchEvent.setAction(touchAction);
mKeyboardView.onTouchEvent(touchEvent); 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 @Override
public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime) { public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime) {
mActivePointerId = pointerId; mActivePointerId = pointerId;
mCurrentKey = detectKey(x, y, pointerId); mCurrentKey = detectKey(x, y);
} }
@Override @Override
@ -135,7 +135,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
return; return;
} }
final boolean hasOldKey = (mCurrentKey != null); final boolean hasOldKey = (mCurrentKey != null);
mCurrentKey = detectKey(x, y, pointerId); mCurrentKey = detectKey(x, y);
if (hasOldKey && mCurrentKey == null) { if (hasOldKey && mCurrentKey == null) {
// A more keys keyboard is canceled when detecting no key. // A more keys keyboard is canceled when detecting no key.
mController.onCancelMoreKeysPanel(); 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 // Calling {@link #detectKey(int,int,int)} here is harmless because the last move event and
// the following up event share the same coordinates. // the following up event share the same coordinates.
mCurrentKey = detectKey(x, y, pointerId); mCurrentKey = detectKey(x, y);
if (mCurrentKey != null) { if (mCurrentKey != null) {
updateReleaseKeyGraphics(mCurrentKey); updateReleaseKeyGraphics(mCurrentKey);
onKeyInput(mCurrentKey, x, y); 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 oldKey = mCurrentKey;
final Key newKey = mKeyDetector.detectHitKey(x, y); final Key newKey = mKeyDetector.detectHitKey(x, y);
if (newKey == oldKey) { if (newKey == oldKey) {

View File

@ -56,24 +56,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
private OnKeyEventListener mListener = EMPTY_LISTENER; private OnKeyEventListener mListener = EMPTY_LISTENER;
private final KeyDetector mKeyDetector = new KeyDetector(); private final KeyDetector mKeyDetector = new KeyDetector();
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
private EmojiPageKeyboardAccessibilityDelegate mAccessibilityDelegate; private KeyboardAccessibilityDelegate<EmojiPageKeyboardView> 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();
}
}
public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) { public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.keyboardViewStyle); this(context, attrs, R.attr.keyboardViewStyle);
@ -100,8 +83,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */); mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */);
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) { if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
if (mAccessibilityDelegate == null) { if (mAccessibilityDelegate == null) {
mAccessibilityDelegate = new EmojiPageKeyboardAccessibilityDelegate( mAccessibilityDelegate = new KeyboardAccessibilityDelegate<>(this, mKeyDetector);
this, mKeyDetector);
} }
mAccessibilityDelegate.setKeyboard(keyboard); mAccessibilityDelegate.setKeyboard(keyboard);
} else { } else {

View File

@ -20,8 +20,6 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; 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.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardActionListener;
@ -59,17 +57,11 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
// above {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call. // above {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call.
// With accessibility mode on, {@link #mAccessibilityDelegate} is set to a // With accessibility mode on, {@link #mAccessibilityDelegate} is set to a
// {@link MoreKeysKeyboardAccessibilityDelegate} object at the above // {@link MoreKeysKeyboardAccessibilityDelegate} object at the above
// {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call. And the object has to be // {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call.
// overwritten by a {@link MoreSuggestionsAccessibilityDelegate} object here. if (mAccessibilityDelegate != null) {
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
if (!(mAccessibilityDelegate instanceof MoreSuggestionsAccessibilityDelegate)) {
mAccessibilityDelegate = new MoreSuggestionsAccessibilityDelegate(
this, mKeyDetector);
mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_suggestions); mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_suggestions);
mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_suggestions); mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_suggestions);
} }
mAccessibilityDelegate.setKeyboard(keyboard);
}
} }
@Override @Override