Add animated background to the suw all set page.
Test: Ran all set page in landscape/portrait, dark/light mode Fixes: 190828563 Change-Id: Ie7fbc6ce6777e9cec8d4dcb5dff3090dc167a161
This commit is contained in:
parent
bc1b36344f
commit
d0865f8219
|
@ -204,6 +204,7 @@ android_library {
|
|||
],
|
||||
static_libs: [
|
||||
"Launcher3ResLib",
|
||||
"lottie",
|
||||
"SystemUISharedLib",
|
||||
"SystemUI-statsd",
|
||||
],
|
||||
|
|
|
@ -163,6 +163,8 @@ dependencies {
|
|||
androidTestImplementation 'com.android.support.test:rules:1.0.0'
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
|
||||
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
|
||||
|
||||
api 'com.airbnb.android:lottie:3.3.0'
|
||||
}
|
||||
|
||||
protobuf {
|
||||
|
|
|
@ -22,6 +22,23 @@
|
|||
android:id="@+id/root_view"
|
||||
android:background="@color/all_set_page_background" >
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/content_view"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
android:id="@+id/animated_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerCrop"
|
||||
|
||||
app:lottie_rawRes="@raw/all_set_page_bg"
|
||||
app:lottie_autoPlay="true"
|
||||
app:lottie_loop="true" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -29,7 +46,6 @@
|
|||
android:layout_marginEnd="@dimen/allset_page_margin_horizontal"
|
||||
android:layoutDirection="locale"
|
||||
android:textDirection="locale"
|
||||
android:id="@+id/content_view"
|
||||
android:forceHasOverlappingRendering="false"
|
||||
android:fitsSystemWindows="true" >
|
||||
|
||||
|
@ -103,4 +119,6 @@
|
|||
android:text="@string/allset_hint"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -19,6 +19,7 @@ import static com.android.launcher3.Utilities.mapBoundToRange;
|
|||
import static com.android.launcher3.Utilities.mapRange;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.content.Context;
|
||||
|
@ -38,6 +39,8 @@ import android.graphics.Rect;
|
|||
import android.graphics.Shader.TileMode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
|
@ -56,6 +59,8 @@ import com.android.quickstep.GestureState;
|
|||
import com.android.quickstep.TouchInteractionService.TISBinder;
|
||||
import com.android.quickstep.util.TISBindHelper;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
|
@ -80,6 +85,10 @@ public class AllSetActivity extends Activity {
|
|||
private View mContentView;
|
||||
private float mSwipeUpShift;
|
||||
|
||||
@Nullable private Vibrator mVibrator;
|
||||
private LottieAnimationView mAnimatedBackground;
|
||||
private Animator.AnimatorListener mBackgroundAnimatorListener;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -115,6 +124,52 @@ public class AllSetActivity extends Activity {
|
|||
|
||||
findViewById(R.id.hint).setAccessibilityDelegate(new SkipButtonAccessibilityDelegate());
|
||||
mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
|
||||
|
||||
mVibrator = getSystemService(Vibrator.class);
|
||||
mAnimatedBackground = findViewById(R.id.animated_background);
|
||||
startBackgroundAnimation();
|
||||
}
|
||||
|
||||
private void startBackgroundAnimation() {
|
||||
if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
|
||||
VibrationEffect.Composition.PRIMITIVE_THUD)) {
|
||||
if (mBackgroundAnimatorListener == null) {
|
||||
mBackgroundAnimatorListener =
|
||||
new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mVibrator.vibrate(getVibrationEffect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
mVibrator.vibrate(getVibrationEffect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mVibrator.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mVibrator.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
|
||||
}
|
||||
mAnimatedBackground.playAnimation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the vibration effect for the next round of animation. The parameters vary between
|
||||
* different illustrations.
|
||||
*/
|
||||
private VibrationEffect getVibrationEffect() {
|
||||
return VibrationEffect.startComposition()
|
||||
.addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)
|
||||
.compose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,6 +208,9 @@ public class AllSetActivity extends Activity {
|
|||
super.onDestroy();
|
||||
mTISBindHelper.onDestroy();
|
||||
clearBinderOverride();
|
||||
if (mBackgroundAnimatorListener != null) {
|
||||
mAnimatedBackground.removeAnimatorListener(mBackgroundAnimatorListener);
|
||||
}
|
||||
}
|
||||
|
||||
private AnimatedFloat createSwipeUpProxy(GestureState state) {
|
||||
|
@ -173,6 +231,12 @@ public class AllSetActivity extends Activity {
|
|||
1, 0, LINEAR);
|
||||
mContentView.setAlpha(alpha);
|
||||
mContentView.setTranslationY((alpha - 1) * mSwipeUpShift);
|
||||
|
||||
if (alpha == 0f) {
|
||||
mAnimatedBackground.pauseAnimation();
|
||||
} else if (!mAnimatedBackground.isAnimating()) {
|
||||
mAnimatedBackground.resumeAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue