Move language on spacebar parameters to LatinKeyboardView attributes
Change-Id: I06e5d7d158a9b14b00df34e68b12cd012faf17d1main
parent
6fbcd0d219
commit
dabf96896e
|
@ -132,6 +132,14 @@
|
||||||
<attr name="spacebarTextRatio" format="fraction" />
|
<attr name="spacebarTextRatio" format="fraction" />
|
||||||
<attr name="spacebarTextColor" format="color" />
|
<attr name="spacebarTextColor" format="color" />
|
||||||
<attr name="spacebarTextShadowColor" format="color" />
|
<attr name="spacebarTextShadowColor" format="color" />
|
||||||
|
<!-- Animation parameters for spacebar language label. -->
|
||||||
|
<attr name="durationOfFadeoutLanguageOnSpacebar" format="integer|enum">
|
||||||
|
<!-- This should be aligned with LatinKeyboardView.LANGUAGE_ON_SPACEBAR_* -->
|
||||||
|
<enum name="neverDisplay" value="0" />
|
||||||
|
<enum name="alwaysDisplay" value="-1" />
|
||||||
|
</attr>
|
||||||
|
<attr name="delayBeforeFadeoutLangageOnSpacebar" format="integer" />
|
||||||
|
<attr name="finalFadeoutFactorOfLanguageOnSpacebar" format="float" />
|
||||||
<!-- Key detection hysteresis distance. -->
|
<!-- Key detection hysteresis distance. -->
|
||||||
<attr name="keyHysteresisDistance" format="dimension" />
|
<attr name="keyHysteresisDistance" format="dimension" />
|
||||||
<!-- Touch noise threshold time in millisecond -->
|
<!-- Touch noise threshold time in millisecond -->
|
||||||
|
|
|
@ -35,13 +35,9 @@
|
||||||
<bool name="config_default_bigram_prediction">false</bool>
|
<bool name="config_default_bigram_prediction">false</bool>
|
||||||
<bool name="config_default_sound_enabled">false</bool>
|
<bool name="config_default_sound_enabled">false</bool>
|
||||||
<bool name="config_default_vibration_enabled">true</bool>
|
<bool name="config_default_vibration_enabled">true</bool>
|
||||||
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
|
||||||
<integer name="config_delay_before_fadeout_language_on_spacebar">1200</integer>
|
|
||||||
<integer name="config_delay_update_suggestions">100</integer>
|
<integer name="config_delay_update_suggestions">100</integer>
|
||||||
<integer name="config_delay_update_old_suggestions">300</integer>
|
<integer name="config_delay_update_old_suggestions">300</integer>
|
||||||
<integer name="config_delay_update_shift_state">100</integer>
|
<integer name="config_delay_update_shift_state">100</integer>
|
||||||
<integer name="config_duration_of_fadeout_language_on_spacebar">200</integer>
|
|
||||||
<integer name="config_final_fadeout_percentage_of_language_on_spacebar">50</integer>
|
|
||||||
<integer name="config_more_keys_keyboard_fadein_anim_time">0</integer>
|
<integer name="config_more_keys_keyboard_fadein_anim_time">0</integer>
|
||||||
<integer name="config_more_keys_keyboard_fadeout_anim_time">100</integer>
|
<integer name="config_more_keys_keyboard_fadeout_anim_time">100</integer>
|
||||||
<integer name="config_keyboard_grid_width">32</integer>
|
<integer name="config_keyboard_grid_width">32</integer>
|
||||||
|
|
|
@ -78,6 +78,9 @@
|
||||||
<item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item>
|
<item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item>
|
||||||
<item name="ignoreSpecialKeyTimeout">@integer/config_ignore_special_key_timeout</item>
|
<item name="ignoreSpecialKeyTimeout">@integer/config_ignore_special_key_timeout</item>
|
||||||
<item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item>
|
<item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item>
|
||||||
|
<item name="durationOfFadeoutLanguageOnSpacebar">200</item>
|
||||||
|
<item name="delayBeforeFadeoutLangageOnSpacebar">1200</item>
|
||||||
|
<item name="finalFadeoutFactorOfLanguageOnSpacebar">0.5</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="LatinKeyboardView"
|
name="LatinKeyboardView"
|
||||||
|
|
|
@ -180,11 +180,11 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
|
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
|
||||||
mKeyboardView.updateAutoCorrectionState(mIsAutoCorrectionActive);
|
mKeyboardView.updateAutoCorrectionState(mIsAutoCorrectionActive);
|
||||||
mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
|
mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
|
||||||
|
final boolean subtypeChanged = (oldKeyboard == null)
|
||||||
|
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
|
||||||
final boolean needsToDisplayLanguage = mSubtypeSwitcher.needsToDisplayLanguage(
|
final boolean needsToDisplayLanguage = mSubtypeSwitcher.needsToDisplayLanguage(
|
||||||
keyboard.mId.mLocale);
|
keyboard.mId.mLocale);
|
||||||
final boolean localeChanged = (oldKeyboard == null)
|
mKeyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, needsToDisplayLanguage);
|
||||||
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
|
|
||||||
mKeyboardView.startDisplayLanguageOnSpacebar(localeChanged, needsToDisplayLanguage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Keyboard getKeyboard() {
|
public Keyboard getKeyboard() {
|
||||||
|
|
|
@ -19,7 +19,6 @@ package com.android.inputmethod.keyboard;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -79,7 +78,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
// Stuff to draw language name on spacebar.
|
// Stuff to draw language name on spacebar.
|
||||||
private ValueAnimator mLanguageOnSpacebarAnimator;
|
private ValueAnimator mLanguageOnSpacebarAnimator;
|
||||||
private float mFinalFadeoutFactorOfLanguageOnSpacebar;
|
private float mFinalFadeoutFactorOfLanguageOnSpacebar;
|
||||||
private int mDelayBeforeFadeoutLanguageOnSpacebar;
|
private int mDurationOfFadeoutLanguageOnSpacebar;
|
||||||
|
private static final int LANGUAGE_ON_SPACEBAR_NEVER_DISPLAY = 0;
|
||||||
|
private static final int LANGUAGE_ON_SPACEBAR_ALWAYS_DISPLAY = -1;
|
||||||
private boolean mNeedsToDisplayLanguage;
|
private boolean mNeedsToDisplayLanguage;
|
||||||
private Locale mSpacebarLocale;
|
private Locale mSpacebarLocale;
|
||||||
private float mSpacebarTextFadeFactor = 0.0f;
|
private float mSpacebarTextFadeFactor = 0.0f;
|
||||||
|
@ -338,6 +339,13 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboardView_spacebarTextColor, 0);
|
mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboardView_spacebarTextColor, 0);
|
||||||
mSpacebarTextShadowColor = a.getColor(
|
mSpacebarTextShadowColor = a.getColor(
|
||||||
R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0);
|
R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0);
|
||||||
|
mDurationOfFadeoutLanguageOnSpacebar = a.getInt(
|
||||||
|
R.styleable.LatinKeyboardView_durationOfFadeoutLanguageOnSpacebar,
|
||||||
|
LANGUAGE_ON_SPACEBAR_NEVER_DISPLAY);
|
||||||
|
final int delayBeforeFadeoutLanguageOnSpacebar = a.getInt(
|
||||||
|
R.styleable.LatinKeyboardView_delayBeforeFadeoutLangageOnSpacebar, 0);
|
||||||
|
mFinalFadeoutFactorOfLanguageOnSpacebar = a.getFloat(
|
||||||
|
R.styleable.LatinKeyboardView_finalFadeoutFactorOfLanguageOnSpacebar, 0.0f);
|
||||||
|
|
||||||
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
||||||
mPointerTrackerParams = new PointerTrackerParams(a);
|
mPointerTrackerParams = new PointerTrackerParams(a);
|
||||||
|
@ -353,18 +361,12 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
|
|
||||||
PointerTracker.setParameters(mPointerTrackerParams);
|
PointerTracker.setParameters(mPointerTrackerParams);
|
||||||
|
|
||||||
// TODO: These resources should be attributes of LatinKeyboardView.
|
|
||||||
final Resources res = getResources();
|
|
||||||
mFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
|
|
||||||
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
|
|
||||||
mDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger(
|
|
||||||
R.integer.config_delay_before_fadeout_language_on_spacebar);
|
|
||||||
final int durationOfFadeoutLanguageOnSpacebar = res.getInteger(
|
|
||||||
R.integer.config_duration_of_fadeout_language_on_spacebar);
|
|
||||||
mLanguageOnSpacebarAnimator = ValueAnimator.ofFloat(
|
mLanguageOnSpacebarAnimator = ValueAnimator.ofFloat(
|
||||||
1.0f, mFinalFadeoutFactorOfLanguageOnSpacebar);
|
1.0f, mFinalFadeoutFactorOfLanguageOnSpacebar);
|
||||||
mLanguageOnSpacebarAnimator.setStartDelay(mDelayBeforeFadeoutLanguageOnSpacebar);
|
mLanguageOnSpacebarAnimator.setStartDelay(delayBeforeFadeoutLanguageOnSpacebar);
|
||||||
mLanguageOnSpacebarAnimator.setDuration(durationOfFadeoutLanguageOnSpacebar);
|
if (mDurationOfFadeoutLanguageOnSpacebar > 0) {
|
||||||
|
mLanguageOnSpacebarAnimator.setDuration(mDurationOfFadeoutLanguageOnSpacebar);
|
||||||
|
}
|
||||||
mLanguageOnSpacebarAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
mLanguageOnSpacebarAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationUpdate(ValueAnimator animation) {
|
public void onAnimationUpdate(ValueAnimator animation) {
|
||||||
|
@ -747,7 +749,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
super.draw(c);
|
super.draw(c);
|
||||||
tryGC = false;
|
tryGC = false;
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
tryGC = Utils.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e);
|
tryGC = Utils.GCUtils.getInstance().tryGCOrWait(TAG, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,22 +789,21 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
invalidateKey(shortcutKey);
|
invalidateKey(shortcutKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startDisplayLanguageOnSpacebar(boolean localeChanged,
|
public void startDisplayLanguageOnSpacebar(boolean subtypeChanged,
|
||||||
boolean needsToDisplayLanguage) {
|
boolean needsToDisplayLanguage) {
|
||||||
mLanguageOnSpacebarAnimator.cancel();
|
mLanguageOnSpacebarAnimator.cancel();
|
||||||
mNeedsToDisplayLanguage = needsToDisplayLanguage;
|
mNeedsToDisplayLanguage = needsToDisplayLanguage;
|
||||||
if (mDelayBeforeFadeoutLanguageOnSpacebar == 0) {
|
if (mDurationOfFadeoutLanguageOnSpacebar == LANGUAGE_ON_SPACEBAR_NEVER_DISPLAY) {
|
||||||
// The language is never displayed when the delay is zero.
|
|
||||||
mSpacebarTextFadeFactor = 0.0f;
|
mSpacebarTextFadeFactor = 0.0f;
|
||||||
} else if (localeChanged || mDelayBeforeFadeoutLanguageOnSpacebar < 0) {
|
} else if (mDurationOfFadeoutLanguageOnSpacebar == LANGUAGE_ON_SPACEBAR_ALWAYS_DISPLAY) {
|
||||||
// The language is always displayed when the delay is negative.
|
|
||||||
mSpacebarTextFadeFactor = 1.0f;
|
mSpacebarTextFadeFactor = 1.0f;
|
||||||
|
} else {
|
||||||
|
if (subtypeChanged && needsToDisplayLanguage) {
|
||||||
|
mSpacebarTextFadeFactor = 1.0f;
|
||||||
|
mLanguageOnSpacebarAnimator.start();
|
||||||
} else {
|
} else {
|
||||||
mSpacebarTextFadeFactor = mFinalFadeoutFactorOfLanguageOnSpacebar;
|
mSpacebarTextFadeFactor = mFinalFadeoutFactorOfLanguageOnSpacebar;
|
||||||
}
|
}
|
||||||
if (localeChanged && mDelayBeforeFadeoutLanguageOnSpacebar > 0 && mNeedsToDisplayLanguage) {
|
|
||||||
// The fadeout animation will start when the delay is positive.
|
|
||||||
mLanguageOnSpacebarAnimator.start();
|
|
||||||
}
|
}
|
||||||
invalidateKey(mSpaceKey);
|
invalidateKey(mSpaceKey);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue