summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/NumPadKey.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/NumPadKey.java34
1 files changed, 25 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
index 756d6107570a..a4a781dc6ff5 100644
--- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
+++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
@@ -18,10 +18,11 @@ package com.android.keyguard;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.LayerDrawable;
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;
@@ -47,7 +48,7 @@ public class NumPadKey extends ViewGroup {
private int mTextViewResId;
private PasswordTextView mTextView;
- private final NumPadAnimator mAnimator;
+ private NumPadAnimator mAnimator;
private View.OnClickListener mListener = new View.OnClickListener() {
@Override
@@ -126,11 +127,22 @@ public class NumPadKey extends ViewGroup {
setContentDescription(mDigitText.getText().toString());
- mAnimator = new NumPadAnimator(context, (GradientDrawable) getBackground(),
+ mAnimator = new NumPadAnimator(context, (LayerDrawable) getBackground(),
R.style.NumPadKey);
}
/**
+ * By default, the new layout will be enabled. Invoking will revert to the old style
+ */
+ public void disableNewLayout() {
+ findViewById(R.id.klondike_text).setVisibility(View.VISIBLE);
+ mAnimator = null;
+ ContextThemeWrapper ctw = new ContextThemeWrapper(getContext(), R.style.NumPadKey);
+ setBackground(getContext().getResources().getDrawable(
+ R.drawable.ripple_drawable_pin, ctw.getTheme()));
+ }
+
+ /**
* Reload colors from resources.
**/
public void reloadColors() {
@@ -141,7 +153,7 @@ public class NumPadKey extends ViewGroup {
mDigitText.setTextColor(textColor);
mKlondikeText.setTextColor(klondikeColor);
- mAnimator.reloadColors(getContext());
+ if (mAnimator != null) mAnimator.reloadColors(getContext());
}
@Override
@@ -150,14 +162,14 @@ public class NumPadKey extends ViewGroup {
doHapticKeyClick();
}
- mAnimator.start();
+ if (mAnimator != null) mAnimator.start();
return super.onTouchEvent(event);
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
- mAnimator.updateMargin((ViewGroup.MarginLayoutParams) params);
+ if (mAnimator != null) mAnimator.updateMargin((ViewGroup.MarginLayoutParams) params);
super.setLayoutParams(params);
}
@@ -167,8 +179,12 @@ public class NumPadKey extends ViewGroup {
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());
+ // Set width/height to the same value to ensure a smooth circle for the bg, but shrink
+ // the height to match the old pin bouncer
+ int width = getMeasuredWidth();
+ int height = mAnimator == null ? (int) (width * .75f) : width;
+
+ setMeasuredDimension(getMeasuredWidth(), height);
}
@Override
@@ -187,7 +203,7 @@ public class NumPadKey extends ViewGroup {
left = centerX - mKlondikeText.getMeasuredWidth() / 2;
mKlondikeText.layout(left, top, left + mKlondikeText.getMeasuredWidth(), bottom);
- mAnimator.onLayout(b - t);
+ if (mAnimator != null) mAnimator.onLayout(b - t);
}
@Override