Move gesture related XML attribute to MainKeyboardView

Change-Id: Ia12f73a3d7d26596ee14a0aff23244ef72753d68
main
Tadashi G. Takaoka 2013-01-21 16:16:48 +09:00
parent 375982106b
commit 9c968b62d1
4 changed files with 55 additions and 58 deletions

View File

@ -60,24 +60,6 @@
<attr name="verticalCorrection" format="dimension" />
<attr name="backgroundDimAlpha" format="integer" />
<!-- Attributes for PreviewPlacerView -->
<attr name="gestureFloatingPreviewTextSize" format="dimension" />
<attr name="gestureFloatingPreviewTextColor" format="color" />
<attr name="gestureFloatingPreviewTextOffset" format="dimension" />
<attr name="gestureFloatingPreviewColor" format="color" />
<attr name="gestureFloatingPreviewHorizontalPadding" format="dimension" />
<attr name="gestureFloatingPreviewVerticalPadding" format="dimension" />
<attr name="gestureFloatingPreviewRoundRadius" format="dimension" />
<!-- Delay after gesture trail starts fading out in millisecond. -->
<attr name="gesturePreviewTrailFadeoutStartDelay" format="integer" />
<!-- Duration while gesture preview trail is fading out in millisecond. -->
<attr name="gesturePreviewTrailFadeoutDuration" format="integer" />
<!-- Interval of updating gesture preview trail in millisecond. -->
<attr name="gesturePreviewTrailUpdateInterval" format="integer" />
<attr name="gesturePreviewTrailColor" format="color" />
<attr name="gesturePreviewTrailStartWidth" format="dimension" />
<attr name="gesturePreviewTrailEndWidth" format="dimension" />
</declare-styleable>
<declare-styleable name="MainKeyboardView">
@ -125,8 +107,25 @@
<attr name="moreKeysKeyboardLayout" format="reference" />
<!-- More keys keyboard will shown at touched point. -->
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
<!-- Delay after gesture trail starts fading out in millisecond. -->
<attr name="gesturePreviewTrailFadeoutStartDelay" format="integer" />
<!-- Duration while gesture preview trail is fading out in millisecond. -->
<attr name="gesturePreviewTrailFadeoutDuration" format="integer" />
<!-- Interval of updating gesture preview trail in millisecond. -->
<attr name="gesturePreviewTrailUpdateInterval" format="integer" />
<attr name="gesturePreviewTrailColor" format="color" />
<attr name="gesturePreviewTrailStartWidth" format="dimension" />
<attr name="gesturePreviewTrailEndWidth" format="dimension" />
<!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" />
<!-- Attributes for GestureFloatingPreviewText -->
<attr name="gestureFloatingPreviewTextSize" format="dimension" />
<attr name="gestureFloatingPreviewTextColor" format="color" />
<attr name="gestureFloatingPreviewTextOffset" format="dimension" />
<attr name="gestureFloatingPreviewColor" format="color" />
<attr name="gestureFloatingPreviewHorizontalPadding" format="dimension" />
<attr name="gestureFloatingPreviewVerticalPadding" format="dimension" />
<attr name="gestureFloatingPreviewRoundRadius" format="dimension" />
<!-- Static threshold for gesture after fast typing (msec) -->
<attr name="gestureStaticTimeThresholdAfterFastTyping" format="integer" />
<!-- Static threshold for starting gesture detection (keyWidth%/sec) -->

View File

@ -57,22 +57,21 @@ public class GestureFloatingPreviewText extends AbstractDrawingPreview {
private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
public GesturePreviewTextParams(final TypedArray keyboardViewAttr) {
// TODO: Move these XML attributes to MainKeyboardView
mGesturePreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
mGesturePreviewTextColor = keyboardViewAttr.getColor(
R.styleable.KeyboardView_gestureFloatingPreviewTextColor, 0);
mGesturePreviewTextOffset = keyboardViewAttr.getDimensionPixelOffset(
R.styleable.KeyboardView_gestureFloatingPreviewTextOffset, 0);
mGesturePreviewColor = keyboardViewAttr.getColor(
R.styleable.KeyboardView_gestureFloatingPreviewColor, 0);
mGesturePreviewHorizontalPadding = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);
mGesturePreviewVerticalPadding = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gestureFloatingPreviewVerticalPadding, 0.0f);
mGesturePreviewRoundRadius = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gestureFloatingPreviewRoundRadius, 0.0f);
public GesturePreviewTextParams(final TypedArray mainKeyboardViewAttr) {
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
mGesturePreviewTextColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0);
mGesturePreviewColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);
mGesturePreviewVerticalPadding = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureFloatingPreviewVerticalPadding, 0.0f);
mGesturePreviewRoundRadius = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureFloatingPreviewRoundRadius, 0.0f);
final Paint textPaint = new Paint();
textPaint.setAntiAlias(true);

View File

@ -26,11 +26,11 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResizableIntArray;
/*
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutStartDelay
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutDuration
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailUpdateInterval
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailColor
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailWidth
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutStartDelay
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutDuration
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailUpdateInterval
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailColor
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailWidth
*/
final class GesturePreviewTrail {
private static final int DEFAULT_CAPACITY = GestureStrokeWithPreviewPoints.PREVIEW_CAPACITY;
@ -53,21 +53,20 @@ final class GesturePreviewTrail {
public final int mTrailLingerDuration;
public Params(final TypedArray keyboardViewAttr) {
// TODO: Move these XML attributes to MainKeyboardView
mTrailColor = keyboardViewAttr.getColor(
R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
mTrailStartWidth = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gesturePreviewTrailStartWidth, 0.0f);
mTrailEndWidth = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gesturePreviewTrailEndWidth, 0.0f);
mFadeoutStartDelay = keyboardViewAttr.getInt(
R.styleable.KeyboardView_gesturePreviewTrailFadeoutStartDelay, 0);
mFadeoutDuration = keyboardViewAttr.getInt(
R.styleable.KeyboardView_gesturePreviewTrailFadeoutDuration, 0);
public Params(final TypedArray mainKeyboardViewAttr) {
mTrailColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gesturePreviewTrailColor, 0);
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gesturePreviewTrailStartWidth, 0.0f);
mTrailEndWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gesturePreviewTrailEndWidth, 0.0f);
mFadeoutStartDelay = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutStartDelay, 0);
mFadeoutDuration = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutDuration, 0);
mTrailLingerDuration = mFadeoutStartDelay + mFadeoutDuration;
mUpdateInterval = keyboardViewAttr.getInt(
R.styleable.KeyboardView_gesturePreviewTrailUpdateInterval, 0);
mUpdateInterval = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailUpdateInterval, 0);
}
}

View File

@ -100,13 +100,13 @@ public final class PreviewPlacerView extends RelativeLayout {
super(context);
setWillNotDraw(false);
final TypedArray keyboardViewAttr = context.obtainStyledAttributes(
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
// TODO: mGestureFloatingPreviewText could be an instance of GestureFloatingPreviewText or
// MultiGesturePreviewText, depending on the user's choice in the settings.
mGestureFloatingPreviewText = new GestureFloatingPreviewText(keyboardViewAttr, context);
mGesturePreviewTrailParams = new Params(keyboardViewAttr);
keyboardViewAttr.recycle();
mGestureFloatingPreviewText = new GestureFloatingPreviewText(mainKeyboardViewAttr, context);
mGesturePreviewTrailParams = new Params(mainKeyboardViewAttr);
mainKeyboardViewAttr.recycle();
mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams);