2 * Copyright (C) 2012 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.keyguard;
19 import android.animation.Animator;
20 import android.animation.AnimatorListenerAdapter;
21 import android.animation.ObjectAnimator;
22 import android.graphics.drawable.Drawable;
23 import android.view.View;
26 * Some common functions that are useful for KeyguardSecurityViews.
28 public class KeyguardSecurityViewHelper {
30 public static void showBouncer(SecurityMessageDisplay securityMessageDisplay,
31 final View ecaView, Drawable bouncerFrame, int duration) {
32 if (securityMessageDisplay != null) {
33 securityMessageDisplay.showBouncer(duration);
35 if (ecaView != null) {
37 Animator anim = ObjectAnimator.ofFloat(ecaView, "alpha", 0f);
38 anim.setDuration(duration);
39 anim.addListener(new AnimatorListenerAdapter() {
40 private boolean mCanceled;
42 public void onAnimationCancel(Animator animation) {
43 // Fail safe and show the emergency button in onAnimationEnd()
48 public void onAnimationEnd(Animator animation) {
49 ecaView.setVisibility(mCanceled ? View.VISIBLE : View.INVISIBLE);
55 ecaView.setVisibility(View.INVISIBLE);
58 if (bouncerFrame != null) {
60 Animator anim = ObjectAnimator.ofInt(bouncerFrame, "alpha", 0, 255);
61 anim.setDuration(duration);
64 bouncerFrame.setAlpha(255);
69 public static void hideBouncer(SecurityMessageDisplay securityMessageDisplay,
70 View ecaView, Drawable bouncerFrame, int duration) {
71 if (securityMessageDisplay != null) {
72 securityMessageDisplay.hideBouncer(duration);
74 if (ecaView != null) {
75 ecaView.setVisibility(View.VISIBLE);
77 Animator anim = ObjectAnimator.ofFloat(ecaView, "alpha", 1f);
78 anim.setDuration(duration);
84 if (bouncerFrame != null) {
86 Animator anim = ObjectAnimator.ofInt(bouncerFrame, "alpha", 255, 0);
87 anim.setDuration(duration);
90 bouncerFrame.setAlpha(0);