Skip to content

Commit

Permalink
Remove showup animator
Browse files Browse the repository at this point in the history
  • Loading branch information
rkkr committed Jan 27, 2019
1 parent ae1445d commit 1c60592
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 88 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "rkr.simplekeyboard.inputmethod"
minSdkVersion 19
targetSdkVersion 28
versionCode 52
versionCode 53
versionName "3.5"
}
buildTypes {
Expand Down
Expand Up @@ -76,7 +76,6 @@
* @attr ref R.styleable#MainKeyboardView_keyPreviewOffset
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
* @attr ref R.styleable#MainKeyboardView_keyPreviewLingerTimeout
* @attr ref R.styleable#MainKeyboardView_keyPreviewShowUpAnimator
* @attr ref R.styleable#MainKeyboardView_keyPreviewDismissAnimator
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardForActionLayout
Expand Down
Expand Up @@ -134,23 +134,10 @@ void showKeyPreview(final Key key, final KeyPreviewView keyPreviewView,
}

// Show preview with animation.
final Animator showUpAnimator = createShowUpAnimator(key, keyPreviewView);
final Animator dismissAnimator = createDismissAnimator(key, keyPreviewView);
final KeyPreviewAnimators animators = new KeyPreviewAnimators(
showUpAnimator, dismissAnimator);
final KeyPreviewAnimators animators = new KeyPreviewAnimators(dismissAnimator);
keyPreviewView.setTag(animators);
animators.startShowUp();
}

public Animator createShowUpAnimator(final Key key, final KeyPreviewView keyPreviewView) {
final Animator showUpAnimator = mParams.createShowUpAnimator(keyPreviewView);
showUpAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(final Animator animator) {
showKeyPreview(key, keyPreviewView, false /* withAnimation */);
}
});
return showUpAnimator;
showKeyPreview(key, keyPreviewView, false /* withAnimation */);
}

private Animator createDismissAnimator(final Key key, final KeyPreviewView keyPreviewView) {
Expand All @@ -165,28 +152,13 @@ public void onAnimationEnd(final Animator animator) {
}

private static class KeyPreviewAnimators extends AnimatorListenerAdapter {
private final Animator mShowUpAnimator;
private final Animator mDismissAnimator;

public KeyPreviewAnimators(final Animator showUpAnimator, final Animator dismissAnimator) {
mShowUpAnimator = showUpAnimator;
public KeyPreviewAnimators(final Animator dismissAnimator) {
mDismissAnimator = dismissAnimator;
}

public void startShowUp() {
mShowUpAnimator.start();
}

public void startDismiss() {
if (mShowUpAnimator.isRunning()) {
mShowUpAnimator.addListener(this);
return;
}
mDismissAnimator.start();
}

@Override
public void onAnimationEnd(final Animator animator) {
mDismissAnimator.start();
}
}
Expand Down
Expand Up @@ -21,7 +21,6 @@
import android.content.res.TypedArray;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;

import rkr.simplekeyboard.inputmethod.R;

Expand All @@ -30,7 +29,6 @@ public final class KeyPreviewDrawParams {
public final int mPreviewOffset;
public final int mPreviewHeight;
public final int mPreviewBackgroundResId;
private final int mShowUpAnimatorResId;
private final int mDismissAnimatorResId;
private int mLingerTimeout;
private boolean mShowPopup = true;
Expand Down Expand Up @@ -69,8 +67,6 @@ public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr) {
R.styleable.MainKeyboardView_keyPreviewBackground, 0);
mLingerTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
mShowUpAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_keyPreviewShowUpAnimator, 0);
mDismissAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_keyPreviewDismissAnimator, 0);
}
Expand Down Expand Up @@ -120,16 +116,6 @@ public int getLingerTimeout() {

private static final AccelerateInterpolator ACCELERATE_INTERPOLATOR =
new AccelerateInterpolator();
private static final DecelerateInterpolator DECELERATE_INTERPOLATOR =
new DecelerateInterpolator();

public Animator createShowUpAnimator(final View target) {
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mShowUpAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(DECELERATE_INTERPOLATOR);
return animator;
}

public Animator createDismissAnimator(final View target) {
final Animator animator = AnimatorInflater.loadAnimator(
Expand Down
Expand Up @@ -35,7 +35,6 @@
import java.util.TreeSet;

import rkr.simplekeyboard.inputmethod.R;
import rkr.simplekeyboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
import rkr.simplekeyboard.inputmethod.latin.RichInputMethodManager;
import rkr.simplekeyboard.inputmethod.latin.utils.AdditionalSubtypeUtils;
import rkr.simplekeyboard.inputmethod.latin.utils.SubtypeLocaleUtils;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import rkr.simplekeyboard.inputmethod.R;
import rkr.simplekeyboard.inputmethod.latin.InputAttributes;
import rkr.simplekeyboard.inputmethod.latin.RichInputMethodManager;
import rkr.simplekeyboard.inputmethod.latin.utils.ResourceUtils;

/**
* When you call the constructor of this class, you may want to change the current system locale by
Expand Down
Expand Up @@ -24,7 +24,6 @@
import java.util.Arrays;

import rkr.simplekeyboard.inputmethod.R;
import rkr.simplekeyboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
import rkr.simplekeyboard.inputmethod.latin.common.StringUtils;

import static rkr.simplekeyboard.inputmethod.latin.common.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
Expand Down
32 changes: 0 additions & 32 deletions app/src/main/res/anim/key_preview_show_up_lxx.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/attrs.xml
Expand Up @@ -103,8 +103,6 @@
<!-- TODO: consolidate key preview linger timeout with the key preview animation parameters. -->
<!-- Delay after key releasing and key press feedback dismissing in millisecond -->
<attr name="keyPreviewLingerTimeout" format="integer" />
<!-- Key preview show up animator -->
<attr name="keyPreviewShowUpAnimator" format="reference" />
<!-- Key preview dismiss animator -->
<attr name="keyPreviewDismissAnimator" format="reference" />
<!-- Layout resource for more keys keyboard -->
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/themes-lxx-dark-border.xml
Expand Up @@ -60,7 +60,6 @@
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback_background_lxx_dark</item>
<item name="keyPreviewHeight">@dimen/config_key_preview_height_lxx</item>
<item name="keyPreviewOffset">@dimen/config_key_preview_offset_lxx</item>
<item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item>
<item name="keyPreviewDismissAnimator">@anim/key_preview_dismiss_lxx</item>
<item name="slidingKeyInputPreviewColor">@color/sliding_key_input_preview_color_lxx_dark</item>
<item name="languageOnSpacebarTextColor">@color/key_text_inactive_color_lxx_dark</item>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/themes-lxx-dark.xml
Expand Up @@ -60,7 +60,6 @@
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback_background_lxx_dark</item>
<item name="keyPreviewHeight">@dimen/config_key_preview_height_lxx</item>
<item name="keyPreviewOffset">@dimen/config_key_preview_offset_lxx</item>
<item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item>
<item name="keyPreviewDismissAnimator">@anim/key_preview_dismiss_lxx</item>
<item name="slidingKeyInputPreviewColor">@color/sliding_key_input_preview_color_lxx_dark</item>
<item name="languageOnSpacebarTextColor">@color/key_text_inactive_color_lxx_dark</item>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/themes-lxx-light-border.xml
Expand Up @@ -60,7 +60,6 @@
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback_background_lxx_light</item>
<item name="keyPreviewHeight">@dimen/config_key_preview_height_lxx</item>
<item name="keyPreviewOffset">@dimen/config_key_preview_offset_lxx</item>
<item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item>
<item name="keyPreviewDismissAnimator">@anim/key_preview_dismiss_lxx</item>
<item name="slidingKeyInputPreviewColor">@color/sliding_key_input_preview_color_lxx_light</item>
<item name="languageOnSpacebarTextColor">@color/language_on_spacebar_text_color_lxx_light</item>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/themes-lxx-light.xml
Expand Up @@ -60,7 +60,6 @@
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback_background_lxx_light</item>
<item name="keyPreviewHeight">@dimen/config_key_preview_height_lxx</item>
<item name="keyPreviewOffset">@dimen/config_key_preview_offset_lxx</item>
<item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item>
<item name="keyPreviewDismissAnimator">@anim/key_preview_dismiss_lxx</item>
<item name="slidingKeyInputPreviewColor">@color/sliding_key_input_preview_color_lxx_light</item>
<item name="languageOnSpacebarTextColor">@color/language_on_spacebar_text_color_lxx_light</item>
Expand Down

0 comments on commit 1c60592

Please sign in to comment.