Consolidate similar methods
This CL consolidates similar methods in MainKeyboardView. - startWhileTypingFadeinAnimation and startWhileTypingFadeoutAnimation - showSlidingKeyInputPreview and dismissSlidingKeyInputPreview Change-Id: I607ab74683820de2456af3e75663cf8cf358ab38
This commit is contained in:
parent
c96bb3e9a7
commit
051f8b1442
5 changed files with 50 additions and 37 deletions
|
@ -64,6 +64,7 @@ import java.util.Locale;
|
|||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A view that is responsible for detecting key presses and touch movements.
|
||||
|
@ -306,17 +307,24 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
animatorToStart.setCurrentPlayTime(startTime);
|
||||
}
|
||||
|
||||
// Implements {@link TimerHander.Callbacks} method.
|
||||
// Implements {@link TimerHander.Callbacks#startWhileTypingAnimation(int)}.
|
||||
/**
|
||||
* Called when a while-typing-animation should be started.
|
||||
* @param fadeInOrOut {@link TimerHandler.Callbacks#FADE_IN} starts while-typing-fade-in
|
||||
* animation. {@link TimerHandler.Callbacks#FADE_OUT} starts while-typing-fade-out animation.
|
||||
*/
|
||||
@Override
|
||||
public void startWhileTypingFadeinAnimation() {
|
||||
public void startWhileTypingAnimation(final int fadeInOrOut) {
|
||||
switch (fadeInOrOut) {
|
||||
case TimerHandler.Callbacks.FADE_IN:
|
||||
cancelAndStartAnimators(
|
||||
mAltCodeKeyWhileTypingFadeoutAnimator, mAltCodeKeyWhileTypingFadeinAnimator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startWhileTypingFadeoutAnimation() {
|
||||
break;
|
||||
case TimerHandler.Callbacks.FADE_OUT:
|
||||
cancelAndStartAnimators(
|
||||
mAltCodeKeyWhileTypingFadeinAnimator, mAltCodeKeyWhileTypingFadeoutAnimator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ExternallyReferenced
|
||||
|
@ -474,7 +482,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
|
||||
// Implements {@link TimerHandler.Callbacks#dismissKeyPreviewWithoutDelay(Key)}.
|
||||
@Override
|
||||
public void dismissKeyPreviewWithoutDelay(final Key key) {
|
||||
public void dismissKeyPreviewWithoutDelay(@Nonnull final Key key) {
|
||||
mKeyPreviewChoreographer.dismissKeyPreview(key, false /* withAnimation */);
|
||||
invalidateKey(key);
|
||||
}
|
||||
|
@ -496,13 +504,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
@Override
|
||||
public void showSlidingKeyInputPreview(final PointerTracker tracker) {
|
||||
locatePreviewPlacerView();
|
||||
if (tracker != null) {
|
||||
mSlidingKeyInputDrawingPreview.setPreviewPosition(tracker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissSlidingKeyInputPreview() {
|
||||
} else {
|
||||
mSlidingKeyInputDrawingPreview.dismissSlidingKeyInputPreview();
|
||||
}
|
||||
}
|
||||
|
||||
private void setGesturePreviewMode(final boolean isGestureTrailEnabled,
|
||||
final boolean isGestureFloatingPreviewTextEnabled) {
|
||||
|
@ -596,13 +603,13 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
return moreKeysKeyboardView;
|
||||
}
|
||||
|
||||
// Implements {@link TimerHandler.Callbacks} method.
|
||||
// Implements {@link TimerHandler.Callbacks#onLongPress(PointerTracker)}.
|
||||
/**
|
||||
* Called when a key is long pressed.
|
||||
* @param tracker the pointer tracker which pressed the parent key
|
||||
*/
|
||||
@Override
|
||||
public void onLongPress(final PointerTracker tracker) {
|
||||
public void onLongPress(@Nonnull final PointerTracker tracker) {
|
||||
if (isShowingMoreKeysPanel()) {
|
||||
return;
|
||||
}
|
||||
|
@ -675,7 +682,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
// Dismiss all key previews that may be being showed.
|
||||
PointerTracker.setReleasedKeyGraphicsToAllKeys();
|
||||
// Dismiss sliding key input preview that may be being showed.
|
||||
dismissSlidingKeyInputPreview();
|
||||
mSlidingKeyInputDrawingPreview.dismissSlidingKeyInputPreview();
|
||||
panel.showInParent(mDrawingPreviewPlacerView);
|
||||
mMoreKeysPanel = panel;
|
||||
}
|
||||
|
@ -744,7 +751,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
mTimerHandler.cancelAllMessages();
|
||||
PointerTracker.setReleasedKeyGraphicsToAllKeys();
|
||||
mGestureFloatingTextDrawingPreview.dismissGestureFloatingPreviewText();
|
||||
dismissSlidingKeyInputPreview();
|
||||
mSlidingKeyInputDrawingPreview.dismissSlidingKeyInputPreview();
|
||||
PointerTracker.dismissAllMoreKeysPanels();
|
||||
PointerTracker.cancelAllPointerTrackers();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ import com.android.inputmethod.latin.utils.ResourceUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class PointerTracker implements PointerTrackerQueue.Element,
|
||||
BatchInputArbiterListener {
|
||||
private static final String TAG = PointerTracker.class.getSimpleName();
|
||||
|
@ -53,9 +56,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
public void invalidateKey(Key key);
|
||||
public void showKeyPreview(Key key);
|
||||
public void dismissKeyPreview(Key key);
|
||||
public void showSlidingKeyInputPreview(PointerTracker tracker);
|
||||
public void dismissSlidingKeyInputPreview();
|
||||
public void showGestureTrail(PointerTracker tracker, boolean showsFloatingPreviewText);
|
||||
public void showSlidingKeyInputPreview(@Nullable PointerTracker tracker);
|
||||
public void showGestureTrail(@Nonnull PointerTracker tracker,
|
||||
boolean showsFloatingPreviewText);
|
||||
}
|
||||
|
||||
public interface TimerProxy {
|
||||
|
@ -416,6 +419,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
return mIsInDraggingFinger;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Key getKey() {
|
||||
return mCurrentKey;
|
||||
}
|
||||
|
@ -765,7 +769,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
private void resetKeySelectionByDraggingFinger() {
|
||||
mIsInDraggingFinger = false;
|
||||
mIsInSlidingKeyInput = false;
|
||||
sDrawingProxy.dismissSlidingKeyInputPreview();
|
||||
sDrawingProxy.showSlidingKeyInputPreview(null /* tracker */);
|
||||
}
|
||||
|
||||
private void onGestureMoveEvent(final int x, final int y, final long eventTime,
|
||||
|
|
|
@ -22,6 +22,8 @@ import android.view.View;
|
|||
import com.android.inputmethod.keyboard.MainKeyboardView;
|
||||
import com.android.inputmethod.keyboard.PointerTracker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Abstract base class for previews that are drawn on DrawingPreviewPlacerView, e.g.,
|
||||
* GestureFloatingTextDrawingPreview, GestureTrailsDrawingPreview, and
|
||||
|
@ -32,7 +34,7 @@ public abstract class AbstractDrawingPreview {
|
|||
private boolean mPreviewEnabled;
|
||||
private boolean mHasValidGeometry;
|
||||
|
||||
public void setDrawingView(final DrawingPreviewPlacerView drawingView) {
|
||||
public void setDrawingView(@Nonnull final DrawingPreviewPlacerView drawingView) {
|
||||
mDrawingView = drawingView;
|
||||
drawingView.addPreview(this);
|
||||
}
|
||||
|
@ -61,7 +63,7 @@ public abstract class AbstractDrawingPreview {
|
|||
* @param width the width of {@link MainKeyboardView}.
|
||||
* @param height the height of {@link MainKeyboardView}.
|
||||
*/
|
||||
public void setKeyboardViewGeometry(final int[] originCoords, final int width,
|
||||
public void setKeyboardViewGeometry(@Nonnull final int[] originCoords, final int width,
|
||||
final int height) {
|
||||
mHasValidGeometry = (width > 0 && height > 0);
|
||||
}
|
||||
|
@ -72,11 +74,11 @@ public abstract class AbstractDrawingPreview {
|
|||
* Draws the preview
|
||||
* @param canvas The canvas where the preview is drawn.
|
||||
*/
|
||||
public abstract void drawPreview(final Canvas canvas);
|
||||
public abstract void drawPreview(@Nonnull final Canvas canvas);
|
||||
|
||||
/**
|
||||
* Set the position of the preview.
|
||||
* @param tracker The new location of the preview is based on the points in PointerTracker.
|
||||
*/
|
||||
public abstract void setPreviewPosition(final PointerTracker tracker);
|
||||
public abstract void setPreviewPosition(@Nonnull final PointerTracker tracker);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ import javax.annotation.Nonnull;
|
|||
// TODO: Separate this class into KeyTimerHandler and BatchInputTimerHandler or so.
|
||||
public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> implements TimerProxy {
|
||||
public interface Callbacks {
|
||||
public void startWhileTypingFadeinAnimation();
|
||||
public void startWhileTypingFadeoutAnimation();
|
||||
public void onLongPress(PointerTracker tracker);
|
||||
public static final int FADE_IN = 0;
|
||||
public static final int FADE_OUT = 1;
|
||||
public void startWhileTypingAnimation(final int fadeInOrOut);
|
||||
public void onLongPress(@Nonnull PointerTracker tracker);
|
||||
public void dismissKeyPreviewWithoutDelay(@Nonnull Key key);
|
||||
public void dismissGestureFloatingPreviewTextWithoutDelay();
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> imple
|
|||
}
|
||||
switch (msg.what) {
|
||||
case MSG_TYPING_STATE_EXPIRED:
|
||||
callbacks.startWhileTypingFadeinAnimation();
|
||||
callbacks.startWhileTypingAnimation(Callbacks.FADE_IN);
|
||||
break;
|
||||
case MSG_REPEAT_KEY:
|
||||
final PointerTracker tracker1 = (PointerTracker) msg.obj;
|
||||
|
@ -163,7 +164,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> imple
|
|||
final int typedCode = typedKey.getCode();
|
||||
if (typedCode == Constants.CODE_SPACE || typedCode == Constants.CODE_ENTER) {
|
||||
if (isTyping) {
|
||||
callbacks.startWhileTypingFadeinAnimation();
|
||||
callbacks.startWhileTypingAnimation(Callbacks.FADE_IN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -173,7 +174,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> imple
|
|||
if (isTyping) {
|
||||
return;
|
||||
}
|
||||
callbacks.startWhileTypingFadeoutAnimation();
|
||||
callbacks.startWhileTypingAnimation(Callbacks.FADE_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -282,7 +282,6 @@ public class UserDictionarySettings extends ListFragment {
|
|||
}
|
||||
|
||||
private static class MyAdapter extends SimpleCursorAdapter implements SectionIndexer {
|
||||
|
||||
private AlphabetIndexer mIndexer;
|
||||
|
||||
private ViewBinder mViewBinder = new ViewBinder() {
|
||||
|
|
Loading…
Reference in a new issue