diff options
| author | Adam Cohen <adamcohen@google.com> | 2012-09-30 12:21:21 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-30 12:21:55 -0700 |
| commit | 0a5bc22273fc274a0d4bd9aa4bc80ee5116e11ef (patch) | |
| tree | 0a9c08966a775fb56a831e510c8d491a0f1f8c96 /policy | |
| parent | b97a71e8bd9877f4d4e47ec41408079552ab165b (diff) | |
| parent | c1aa6a54a78972843899fd0d911f80a4aff4dd20 (diff) | |
| download | frameworks_base-0a5bc22273fc274a0d4bd9aa4bc80ee5116e11ef.zip frameworks_base-0a5bc22273fc274a0d4bd9aa4bc80ee5116e11ef.tar.gz frameworks_base-0a5bc22273fc274a0d4bd9aa4bc80ee5116e11ef.tar.bz2 | |
Merge "Integrate keyguard paging hint" into jb-mr1-dev
Diffstat (limited to 'policy')
6 files changed, 211 insertions, 5 deletions
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java b/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java index cbbc92c..97a3f26 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java @@ -33,7 +33,6 @@ import android.widget.TextView; import java.lang.ref.WeakReference; import java.text.DateFormatSymbols; import java.util.Calendar; - import com.android.internal.R; /** diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardGlowStripView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardGlowStripView.java new file mode 100644 index 0000000..e1c95f0 --- /dev/null +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardGlowStripView.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.internal.policy.impl.keyguard; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; +import android.widget.LinearLayout; + +import com.android.internal.R; + +/** + * A layout which animates a strip of horizontal, pulsing dots on request. This is used + * to indicate the presence of pages to the left / right. + */ +public class KeyguardGlowStripView extends LinearLayout { + private static final int DURATION = 500; + + private static final float SLIDING_WINDOW_SIZE = 0.4f; + private int mDotStripTop; + private int mHorizontalDotGap; + + private int mDotSize; + private int mNumDots; + private Drawable mDotDrawable; + private boolean mLeftToRight = true; + + private float mAnimationProgress = 0f; + private boolean mDrawDots = false; + private ValueAnimator mAnimator; + private Interpolator mDotAlphaInterpolator = new DecelerateInterpolator(0.5f); + + public KeyguardGlowStripView(Context context) { + this(context, null, 0); + } + + public KeyguardGlowStripView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public KeyguardGlowStripView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyguardGlowStripView); + mDotSize = a.getDimensionPixelSize(R.styleable.KeyguardGlowStripView_dotSize, mDotSize); + mNumDots = a.getInt(R.styleable.KeyguardGlowStripView_numDots, mNumDots); + mDotDrawable = a.getDrawable(R.styleable.KeyguardGlowStripView_glowDot); + mLeftToRight = a.getBoolean(R.styleable.KeyguardGlowStripView_leftToRight, mLeftToRight); + } + + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + int availableWidth = w - getPaddingLeft() - getPaddingRight(); + mHorizontalDotGap = (availableWidth - mDotSize * mNumDots) / (mNumDots - 1); + mDotStripTop = getPaddingTop(); + invalidate(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + super.dispatchDraw(canvas); + + if (!mDrawDots) return; + + int xOffset = getPaddingLeft(); + mDotDrawable.setBounds(0, 0, mDotSize, mDotSize); + + for (int i = 0; i < mNumDots; i++) { + // We fudge the relative position to provide a fade in of the first dot and a fade + // out of the final dot. + float relativeDotPosition = SLIDING_WINDOW_SIZE / 2 + ((1.0f * i) / (mNumDots - 1)) * + (1 - SLIDING_WINDOW_SIZE); + float distance = Math.abs(relativeDotPosition - mAnimationProgress); + float alpha = Math.max(0, 1 - distance / (SLIDING_WINDOW_SIZE / 2)); + + alpha = mDotAlphaInterpolator.getInterpolation(alpha); + + canvas.save(); + canvas.translate(xOffset, mDotStripTop); + mDotDrawable.setAlpha((int) (alpha * 255)); + mDotDrawable.draw(canvas); + canvas.restore(); + xOffset += mDotSize + mHorizontalDotGap; + } + } + + public void makeEmGo() { + if (mAnimator != null) { + mAnimator.cancel(); + } + float from = mLeftToRight ? 0f : 1f; + float to = mLeftToRight ? 1f : 0f; + mAnimator = ValueAnimator.ofFloat(from, to); + mAnimator.setDuration(DURATION); + mAnimator.setInterpolator(new LinearInterpolator()); + mAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mDrawDots = false; + // make sure we draw one frame at the end with everything gone. + invalidate(); + } + + @Override + public void onAnimationStart(Animator animation) { + mDrawDots = true; + } + }); + mAnimator.addUpdateListener(new AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + mAnimationProgress = (Float) animation.getAnimatedValue(); + invalidate(); + } + }); + mAnimator.start(); + } +} diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 1d1c7fc..14633c4 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -141,7 +141,8 @@ public class KeyguardHostView extends KeyguardViewBase { @Override protected void onFinishInflate() { mAppWidgetContainer = (KeyguardWidgetPager) findViewById(R.id.app_widget_container); - mAppWidgetContainer.setVisibility(VISIBLE); + KeyguardWidgetRegion kgwr = (KeyguardWidgetRegion) findViewById(R.id.kg_widget_region); + kgwr.setVisibility(VISIBLE); mSecurityViewContainer = (ViewFlipper) findViewById(R.id.view_flipper); // This code manages showing/hiding the transport control. We keep it around and only diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java index f99765d..8714276 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java @@ -26,15 +26,12 @@ import android.content.Intent; import android.os.RemoteException; import android.os.UserHandle; import android.provider.MediaStore; -import android.telephony.TelephonyManager; import android.util.AttributeSet; import android.util.Log; import android.util.Slog; import android.view.View; -import android.widget.Button; import android.widget.LinearLayout; -import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.multiwaveview.GlowPadView; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java index fd9362a..4af7a25 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java @@ -20,6 +20,7 @@ import android.appwidget.AppWidgetHostView; import android.content.Context; import android.util.AttributeSet; import android.view.Gravity; +import android.view.MotionEvent; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; @@ -63,6 +64,12 @@ public class KeyguardWidgetPager extends PagedView { addView(frame); } + protected void onUnhandledTap(MotionEvent ev) { + if (getParent() instanceof KeyguardWidgetRegion) { + ((KeyguardWidgetRegion) getParent()).showPagingFeedback(); + } + } + /* * This interpolator emulates the rate at which the perceived scale of an object changes * as its distance from a camera increases. When this interpolator is applied to a scale diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java new file mode 100644 index 0000000..34754e0 --- /dev/null +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.internal.policy.impl.keyguard; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.LinearLayout; + +import com.android.internal.R; + +public class KeyguardWidgetRegion extends LinearLayout { + KeyguardGlowStripView mLeftStrip; + KeyguardGlowStripView mRightStrip; + KeyguardWidgetPager mPager; + + public KeyguardWidgetRegion(Context context) { + this(context, null, 0); + } + + public KeyguardWidgetRegion(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public KeyguardWidgetRegion(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mLeftStrip = (KeyguardGlowStripView) findViewById(R.id.left_strip); + mRightStrip = (KeyguardGlowStripView) findViewById(R.id.right_strip); + mPager = (KeyguardWidgetPager) findViewById(R.id.app_widget_container); + + setSoundEffectsEnabled(false); + setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + showPagingFeedback(); + } + }); + } + + public void showPagingFeedback() { + mLeftStrip.makeEmGo(); + mRightStrip.makeEmGo(); + } +} |
