Merge "Animations/success state for external confirm device credentials (1/2)" into mnc-dev

This commit is contained in:
Jorim Jaggi
2015-06-10 23:10:06 +00:00
committed by Android (Google) Code Review
7 changed files with 78 additions and 24 deletions

View File

@@ -22,6 +22,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
/**
* Displays a PIN pad for unlocking.
*/
@@ -115,7 +118,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
.setDuration(500)
.setInterpolator(mAppearAnimationUtils.getInterpolator())
.translationY(0);
mAppearAnimationUtils.startAnimation(mViews,
mAppearAnimationUtils.startAnimation2d(mViews,
new Runnable() {
@Override
public void run() {
@@ -132,7 +135,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
.setDuration(280)
.setInterpolator(mDisappearAnimationUtils.getInterpolator())
.translationY(mDisappearYTranslation);
mDisappearAnimationUtils.startAnimation(mViews,
mDisappearAnimationUtils.startAnimation2d(mViews,
new Runnable() {
@Override
public void run() {

View File

@@ -36,6 +36,9 @@ import android.widget.LinearLayout;
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import com.android.settingslib.animation.AppearAnimationCreator;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
import java.util.List;
@@ -325,7 +328,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
.setDuration(500)
.setInterpolator(mAppearAnimationUtils.getInterpolator())
.translationY(0);
mAppearAnimationUtils.startAnimation(
mAppearAnimationUtils.startAnimation2d(
mLockPatternView.getCellStates(),
new Runnable() {
@Override
@@ -353,7 +356,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
.setDuration(300)
.setInterpolator(mDisappearAnimationUtils.getInterpolator())
.translationY(-mDisappearAnimationUtils.getStartTranslation());
mDisappearAnimationUtils.startAnimation(mLockPatternView.getCellStates(),
mDisappearAnimationUtils.startAnimation2d(mLockPatternView.getCellStates(),
new Runnable() {
@Override
public void run() {

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 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
-->
<resources>
<!-- The y translation to apply at the start in appear animations. -->
<dimen name="appear_y_translation_start">32dp</dimen>
<!-- The translation for disappearing security views after having solved them. -->
<dimen name="disappear_y_translation">-32dp</dimen>
</resources>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* Copyright (C) 2015 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.
@@ -14,13 +14,13 @@
* limitations under the License
*/
package com.android.keyguard;
package com.android.settingslib.animation;
import android.view.animation.Interpolator;
/**
* An interface which can create animations when starting an appear animation with
* {@link com.android.keyguard.AppearAnimationUtils}
* {@link AppearAnimationUtils}
*/
public interface AppearAnimationCreator<T> {
void createAnimation(T animatedObject, long delay, long duration,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* Copyright (C) 2015 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.
@@ -14,13 +14,15 @@
* limitations under the License
*/
package com.android.keyguard;
package com.android.settingslib.animation;
import android.content.Context;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import com.android.settingslib.R;
/**
* A class to make nice appear transitions for views in a tabular layout.
*/
@@ -33,7 +35,7 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
private final AppearAnimationProperties mProperties = new AppearAnimationProperties();
protected final float mDelayScale;
private final long mDuration;
protected boolean mScaleTranslationWithRow;
protected RowTranslationScaler mRowTranslationScaler;
protected boolean mAppearing;
public AppearAnimationUtils(Context ctx) {
@@ -49,19 +51,18 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
R.dimen.appear_y_translation_start) * translationScaleFactor;
mDelayScale = delayScaleFactor;
mDuration = duration;
mScaleTranslationWithRow = false;
mAppearing = true;
}
public void startAnimation(View[][] objects, final Runnable finishListener) {
startAnimation(objects, finishListener, this);
public void startAnimation2d(View[][] objects, final Runnable finishListener) {
startAnimation2d(objects, finishListener, this);
}
public void startAnimation(View[] objects, final Runnable finishListener) {
startAnimation(objects, finishListener, this);
}
public <T> void startAnimation(T[][] objects, final Runnable finishListener,
public <T> void startAnimation2d(T[][] objects, final Runnable finishListener,
AppearAnimationCreator<T> creator) {
AppearAnimationProperties properties = getDelays(objects);
startAnimations(properties, objects, finishListener, creator);
@@ -86,8 +87,13 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
if (properties.maxDelayRowIndex == row && properties.maxDelayColIndex == 0) {
endRunnable = finishListener;
}
float translationScale = mRowTranslationScaler != null
? mRowTranslationScaler.getRowTranslationScale(row, properties.delays.length)
: 1f;
float translation = translationScale * mStartTranslation;
creator.createAnimation(objects[row], delay, mDuration,
mStartTranslation, true /* appearing */, mInterpolator, endRunnable);
mAppearing ? translation : -translation,
mAppearing, mInterpolator, endRunnable);
}
}
@@ -99,10 +105,10 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
}
for (int row = 0; row < properties.delays.length; row++) {
long[] columns = properties.delays[row];
float translation = mScaleTranslationWithRow
? (float) (Math.pow((properties.delays.length - row), 2)
/ properties.delays.length * mStartTranslation)
: mStartTranslation;
float translationScale = mRowTranslationScaler != null
? mRowTranslationScaler.getRowTranslationScale(row, properties.delays.length)
: 1f;
float translation = translationScale * mStartTranslation;
for (int col = 0; col < columns.length; col++) {
long delay = columns[col];
Runnable endRunnable = null;
@@ -193,4 +199,8 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> {
public int maxDelayRowIndex;
public int maxDelayColIndex;
}
public interface RowTranslationScaler {
float getRowTranslationScale(int row, int numRows);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* Copyright (C) 2015 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.
@@ -14,7 +14,7 @@
* limitations under the License
*/
package com.android.keyguard;
package com.android.settingslib.animation;
import android.content.Context;
import android.view.animation.AnimationUtils;
@@ -28,17 +28,31 @@ public class DisappearAnimationUtils extends AppearAnimationUtils {
public DisappearAnimationUtils(Context ctx) {
this(ctx, DEFAULT_APPEAR_DURATION,
1.0f, 1.0f,
AnimationUtils.loadInterpolator(ctx, android.R.interpolator.linear_out_slow_in));
AnimationUtils.loadInterpolator(ctx, android.R.interpolator.fast_out_linear_in));
}
public DisappearAnimationUtils(Context ctx, long duration, float translationScaleFactor,
float delayScaleFactor, Interpolator interpolator) {
this(ctx, duration, translationScaleFactor, delayScaleFactor, interpolator,
ROW_TRANSLATION_SCALER);
}
public DisappearAnimationUtils(Context ctx, long duration, float translationScaleFactor,
float delayScaleFactor, Interpolator interpolator, RowTranslationScaler rowScaler) {
super(ctx, duration, translationScaleFactor, delayScaleFactor, interpolator);
mScaleTranslationWithRow = true;
mRowTranslationScaler = rowScaler;
mAppearing = false;
}
protected long calculateDelay(int row, int col) {
return (long) ((row * 60 + col * (Math.pow(row, 0.4) + 0.4) * 10) * mDelayScale);
}
private static final RowTranslationScaler ROW_TRANSLATION_SCALER = new RowTranslationScaler() {
@Override
public float getRowTranslationScale(int row, int numRows) {
return (float) (Math.pow((numRows - row), 2) / numRows);
}
};
}

View File

@@ -30,7 +30,7 @@ import android.view.ViewStub;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import com.android.keyguard.AppearAnimationUtils;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.systemui.R;
import com.android.systemui.qs.tiles.UserDetailItemView;
import com.android.systemui.statusbar.phone.KeyguardStatusBarView;