diff --git a/Android.bp b/Android.bp index 8b7eb54b9e..60ef5b1ab7 100644 --- a/Android.bp +++ b/Android.bp @@ -204,6 +204,7 @@ android_library { ], static_libs: [ "Launcher3ResLib", + "lottie", "SystemUISharedLib", "SystemUI-statsd", ], diff --git a/build.gradle b/build.gradle index 617738a5ed..683a4cfaf1 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/quickstep/res/layout/activity_allset.xml b/quickstep/res/layout/activity_allset.xml index b4ee4828a6..9ad10dc54e 100644 --- a/quickstep/res/layout/activity_allset.xml +++ b/quickstep/res/layout/activity_allset.xml @@ -25,82 +25,100 @@ + android:fitsSystemWindows="true"> - - - + 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" /> - + - + - + + + + + + + + + + + + - \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java index 965c1bcc32..1c3e784308 100644 --- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java +++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java @@ -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(); + } } /** diff --git a/res/raw/all_set_page_bg.json b/res/raw/all_set_page_bg.json new file mode 100644 index 0000000000..9705837912 --- /dev/null +++ b/res/raw/all_set_page_bg.json @@ -0,0 +1 @@ +{"v":"5.7.8","fr":24,"ip":0,"op":72,"w":2472,"h":5352,"nm":"3Second_MAIN_Welcome","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":3,"nm":"Null 60","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[1508,1364,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":240,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"PinkFlower","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":72,"s":[56]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.07,"y":0.986},"o":{"x":0.167,"y":0.167},"t":0,"s":[1505.832,1379.455,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.773,"y":0.01},"t":38,"s":[1505.832,575,0],"to":[0,0,0],"ti":[0,0,0]},{"t":72,"s":[1505.832,1379.455,0]}],"ix":2,"l":2},"a":{"a":0,"k":[-3514.717,-358.642,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[75.615,-96.908],[89.338,-70.276],[111.99,-50.668],[111.764,-20.709],[122.709,7.18],[108.586,33.602],[105.316,63.383],[80.533,80.216],[63.797,105.066],[34.03,108.453],[7.663,122.679],[-20.269,111.845],[-50.226,112.189],[-69.924,89.614],[-96.61,75.997],[-103.56,46.854],[-120.861,22.395],[-113.472,-6.639],[-117.425,-36.337],[-97.389,-58.612],[-87.087,-86.745],[-58.996,-97.158],[-36.8,-117.281],[-7.086,-113.445],[21.918,-120.948],[46.446,-103.744]],"o":[[-75.615,96.909],[-89.338,70.276],[-111.99,50.668],[-111.764,20.709],[-122.709,-7.18],[-108.586,-33.602],[-105.316,-63.383],[-80.533,-80.216],[-63.797,-105.066],[-34.03,-108.453],[-7.663,-122.679],[20.269,-111.845],[50.226,-112.188],[69.924,-89.614],[96.61,-75.997],[103.56,-46.854],[120.861,-22.395],[113.472,6.64],[117.425,36.337],[97.389,58.612],[87.088,86.745],[58.995,97.158],[36.8,117.281],[7.087,113.445],[-21.918,120.948],[-46.446,103.744]],"v":[[733.209,572.105],[531.711,675.932],[383.354,847.313],[156.685,845.606],[-54.323,928.412],[-254.235,821.562],[-479.555,796.823],[-606.913,609.309],[-794.927,482.691],[-820.554,257.47],[-928.191,57.981],[-846.217,-153.353],[-848.817,-380.013],[-678.021,-529.044],[-574.99,-730.949],[-354.499,-783.537],[-169.439,-914.435],[50.234,-858.532],[274.928,-888.434],[443.46,-736.847],[656.313,-658.903],[735.094,-446.359],[887.344,-278.426],[858.327,-53.616],[915.095,165.835],[784.928,351.409]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.839215686275,0.439215686275,0.388235294118,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.839215746113,0.439215716194,0.388235324037,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":true},{"ty":"tr","p":{"a":0,"k":[-3509.952,-363.731],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Polystar 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":288,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Ellipse_Bottom","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.248]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[-56]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.172]},"t":38,"s":[-38]},{"t":72,"s":[-56]}],"ix":10},"p":{"s":true,"x":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.032]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[1720]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.022]},"t":38,"s":[1544]},{"t":72,"s":[1720]}],"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.07],"y":[1.034]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[4069]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.719],"y":[0.024]},"t":38,"s":[3872]},{"t":72,"s":[4069]}],"ix":4}},"a":{"a":0,"k":[164.438,1433.781,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[3079.125,4685.989],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.305882352941,0.309803921569,0.321568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.882353001015,0.894118006089,0.886274988511,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":true},{"ty":"tr","p":{"a":0,"k":[164.438,1481.781],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":240,"st":0,"bm":0}],"markers":[]}