am 9c968b62: Move gesture related XML attribute to MainKeyboardView

* commit '9c968b62d1b4049959b7b7b0f05388c90e31b46e':
  Move gesture related XML attribute to MainKeyboardView
main
Tadashi G. Takaoka 2013-01-20 23:37:22 -08:00 committed by Android Git Automerger
commit 99b5393422
4 changed files with 55 additions and 58 deletions

View File

@ -60,24 +60,6 @@
<attr name="verticalCorrection" format="dimension" /> <attr name="verticalCorrection" format="dimension" />
<attr name="backgroundDimAlpha" format="integer" /> <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>
<declare-styleable name="MainKeyboardView"> <declare-styleable name="MainKeyboardView">
@ -125,8 +107,25 @@
<attr name="moreKeysKeyboardLayout" format="reference" /> <attr name="moreKeysKeyboardLayout" format="reference" />
<!-- More keys keyboard will shown at touched point. --> <!-- More keys keyboard will shown at touched point. -->
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" /> <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 --> <!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" /> <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) --> <!-- Static threshold for gesture after fast typing (msec) -->
<attr name="gestureStaticTimeThresholdAfterFastTyping" format="integer" /> <attr name="gestureStaticTimeThresholdAfterFastTyping" format="integer" />
<!-- Static threshold for starting gesture detection (keyWidth%/sec) --> <!-- 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' }; private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
public GesturePreviewTextParams(final TypedArray keyboardViewAttr) { public GesturePreviewTextParams(final TypedArray mainKeyboardViewAttr) {
// TODO: Move these XML attributes to MainKeyboardView mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
mGesturePreviewTextSize = keyboardViewAttr.getDimensionPixelSize( R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0); mGesturePreviewTextColor = mainKeyboardViewAttr.getColor(
mGesturePreviewTextColor = keyboardViewAttr.getColor( R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
R.styleable.KeyboardView_gestureFloatingPreviewTextColor, 0); mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
mGesturePreviewTextOffset = keyboardViewAttr.getDimensionPixelOffset( R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0);
R.styleable.KeyboardView_gestureFloatingPreviewTextOffset, 0); mGesturePreviewColor = mainKeyboardViewAttr.getColor(
mGesturePreviewColor = keyboardViewAttr.getColor( R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
R.styleable.KeyboardView_gestureFloatingPreviewColor, 0); mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension(
mGesturePreviewHorizontalPadding = keyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);
R.styleable.KeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f); mGesturePreviewVerticalPadding = mainKeyboardViewAttr.getDimension(
mGesturePreviewVerticalPadding = keyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gestureFloatingPreviewVerticalPadding, 0.0f);
R.styleable.KeyboardView_gestureFloatingPreviewVerticalPadding, 0.0f); mGesturePreviewRoundRadius = mainKeyboardViewAttr.getDimension(
mGesturePreviewRoundRadius = keyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gestureFloatingPreviewRoundRadius, 0.0f);
R.styleable.KeyboardView_gestureFloatingPreviewRoundRadius, 0.0f);
final Paint textPaint = new Paint(); final Paint textPaint = new Paint();
textPaint.setAntiAlias(true); textPaint.setAntiAlias(true);

View File

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

View File

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