From 9c968b62d1b4049959b7b7b0f05388c90e31b46e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 21 Jan 2013 16:16:48 +0900 Subject: [PATCH] Move gesture related XML attribute to MainKeyboardView Change-Id: Ia12f73a3d7d26596ee14a0aff23244ef72753d68 --- java/res/values/attrs.xml | 35 +++++++++--------- .../internal/GestureFloatingPreviewText.java | 31 ++++++++-------- .../internal/GesturePreviewTrail.java | 37 +++++++++---------- .../keyboard/internal/PreviewPlacerView.java | 10 ++--- 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 63c29bf29..721df5ec3 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -60,24 +60,6 @@ - - - - - - - - - - - - - - - - - - @@ -125,8 +107,25 @@ + + + + + + + + + + + + + + + + + diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java b/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java index a3f70ab24..897d856c8 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java @@ -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); diff --git a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java index 80780c69d..a74c3236b 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java @@ -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); } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java index 7c87467bb..4471cd0fe 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -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);