diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/NumPadKey.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/NumPadKey.java | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java index a5182055e14d..756d6107570a 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java @@ -18,11 +18,10 @@ package com.android.keyguard; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.os.PowerManager; import android.os.SystemClock; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -48,6 +47,8 @@ public class NumPadKey extends ViewGroup { private int mTextViewResId; private PasswordTextView mTextView; + private final NumPadAnimator mAnimator; + private View.OnClickListener mListener = new View.OnClickListener() { @Override public void onClick(View thisView) { @@ -73,7 +74,7 @@ public class NumPadKey extends ViewGroup { } public NumPadKey(Context context, AttributeSet attrs) { - this(context, attrs, 0); + this(context, attrs, R.attr.numPadKeyStyle); } public NumPadKey(Context context, AttributeSet attrs, int defStyle) { @@ -84,7 +85,8 @@ public class NumPadKey extends ViewGroup { super(context, attrs, defStyle); setFocusable(true); - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumPadKey); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumPadKey, defStyle, + contentResource); try { mDigit = a.getInt(R.styleable.NumPadKey_digit, mDigit); @@ -116,20 +118,16 @@ public class NumPadKey extends ViewGroup { final int len = klondike.length(); if (len > 0) { mKlondikeText.setText(klondike); - } else { + } else if (mKlondikeText.getVisibility() != View.GONE) { mKlondikeText.setVisibility(View.INVISIBLE); } } } - a = context.obtainStyledAttributes(attrs, android.R.styleable.View); - if (!a.hasValueOrEmpty(android.R.styleable.View_background)) { - Drawable rippleDrawable = new ContextThemeWrapper(mContext, - R.style.Widget_TextView_NumPadKey).getDrawable(R.drawable.ripple_drawable_pin); - setBackground(rippleDrawable); - } - a.recycle(); setContentDescription(mDigitText.getText().toString()); + + mAnimator = new NumPadAnimator(context, (GradientDrawable) getBackground(), + R.style.NumPadKey); } /** @@ -142,9 +140,8 @@ public class NumPadKey extends ViewGroup { .getDefaultColor(); mDigitText.setTextColor(textColor); mKlondikeText.setTextColor(klondikeColor); - Drawable rippleDrawable = new ContextThemeWrapper(mContext, - R.style.Widget_TextView_NumPadKey).getDrawable(R.drawable.ripple_drawable_pin); - setBackground(rippleDrawable); + + mAnimator.reloadColors(getContext()); } @Override @@ -152,13 +149,26 @@ public class NumPadKey extends ViewGroup { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { doHapticKeyClick(); } + + mAnimator.start(); + return super.onTouchEvent(event); } @Override + public void setLayoutParams(ViewGroup.LayoutParams params) { + mAnimator.updateMargin((ViewGroup.MarginLayoutParams) params); + + super.setLayoutParams(params); + } + + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); measureChildren(widthMeasureSpec, heightMeasureSpec); + + // Set width/height to the same value to ensure a smooth circle for the bg + setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth()); } @Override @@ -176,6 +186,8 @@ public class NumPadKey extends ViewGroup { left = centerX - mKlondikeText.getMeasuredWidth() / 2; mKlondikeText.layout(left, top, left + mKlondikeText.getMeasuredWidth(), bottom); + + mAnimator.onLayout(b - t); } @Override |