Move MainKeyboardView.DrawingHandler to top level class

Change-Id: I7a785725d5eb0b594485ceb25695a89c017cc60f
main
Tadashi G. Takaoka 2013-11-28 18:45:39 +09:00
parent b1d87850ec
commit c82e99caa0
2 changed files with 71 additions and 45 deletions

View File

@ -57,6 +57,7 @@ import com.android.inputmethod.keyboard.internal.GestureFloatingPreviewText;
import com.android.inputmethod.keyboard.internal.GestureTrailsPreview;
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
import com.android.inputmethod.keyboard.internal.MainKeyboardViewDrawingHandler;
import com.android.inputmethod.keyboard.internal.NonDistinctMultitouchHelper;
import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview;
@ -387,49 +388,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
}
private final DrawingHandler mDrawingHandler = new DrawingHandler(this);
public static class DrawingHandler extends StaticInnerHandlerWrapper<MainKeyboardView> {
private static final int MSG_DISMISS_KEY_PREVIEW = 0;
private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1;
public DrawingHandler(final MainKeyboardView outerInstance) {
super(outerInstance);
}
@Override
public void handleMessage(final Message msg) {
final MainKeyboardView mainKeyboardView = getOuterInstance();
if (mainKeyboardView == null) return;
switch (msg.what) {
case MSG_DISMISS_KEY_PREVIEW:
mainKeyboardView.dismissKeyPreviewWithoutDelay((Key)msg.obj);
break;
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
mainKeyboardView.showGestureFloatingPreviewText(SuggestedWords.EMPTY);
break;
}
}
public void dismissKeyPreview(final long delay, final Key key) {
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, key), delay);
}
private void cancelAllDismissKeyPreviews() {
removeMessages(MSG_DISMISS_KEY_PREVIEW);
final MainKeyboardView mainKeyboardView = getOuterInstance();
if (mainKeyboardView == null) return;
mainKeyboardView.dismissAllKeyPreviews();
}
public void dismissGestureFloatingPreviewText(final long delay) {
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay);
}
public void cancelAllMessages() {
cancelAllDismissKeyPreviews();
}
}
private final MainKeyboardViewDrawingHandler mDrawingHandler =
new MainKeyboardViewDrawingHandler(this);
public MainKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.mainKeyboardViewStyle);
@ -721,7 +681,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
return previewTextView;
}
private void dismissAllKeyPreviews() {
public void dismissAllKeyPreviews() {
for (final Key key : new HashSet<Key>(mShowingKeyPreviewTextViews.keySet())) {
dismissKeyPreviewWithoutDelay(key);
}
@ -915,7 +875,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
// TODO: Take this method out of this class.
private void dismissKeyPreviewWithoutDelay(final Key key) {
public void dismissKeyPreviewWithoutDelay(final Key key) {
if (key == null) {
return;
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2013 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.keyboard.internal;
import android.os.Message;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
public class MainKeyboardViewDrawingHandler extends StaticInnerHandlerWrapper<MainKeyboardView> {
private static final int MSG_DISMISS_KEY_PREVIEW = 0;
private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1;
public MainKeyboardViewDrawingHandler(final MainKeyboardView outerInstance) {
super(outerInstance);
}
@Override
public void handleMessage(final Message msg) {
final MainKeyboardView mainKeyboardView = getOuterInstance();
if (mainKeyboardView == null) return;
switch (msg.what) {
case MSG_DISMISS_KEY_PREVIEW:
mainKeyboardView.dismissKeyPreviewWithoutDelay((Key)msg.obj);
break;
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
mainKeyboardView.showGestureFloatingPreviewText(SuggestedWords.EMPTY);
break;
}
}
public void dismissKeyPreview(final long delay, final Key key) {
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, key), delay);
}
private void cancelAllDismissKeyPreviews() {
removeMessages(MSG_DISMISS_KEY_PREVIEW);
final MainKeyboardView mainKeyboardView = getOuterInstance();
if (mainKeyboardView == null) return;
mainKeyboardView.dismissAllKeyPreviews();
}
public void dismissGestureFloatingPreviewText(final long delay) {
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay);
}
public void cancelAllMessages() {
cancelAllDismissKeyPreviews();
}
}