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:
Schneider Victor-tulias 2021-11-09 13:19:21 -08:00
parent bc1b36344f
commit d0865f8219
5 changed files with 154 additions and 68 deletions

View File

@ -204,6 +204,7 @@ android_library {
],
static_libs: [
"Launcher3ResLib",
"lottie",
"SystemUISharedLib",
"SystemUI-statsd",
],

View File

@ -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 {

View File

@ -25,82 +25,100 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/allset_page_margin_horizontal"
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" >
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_title_icon_margin_top"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/ic_all_set"/>
<TextView
android:id="@+id/title"
style="@style/TextAppearance.GestureTutorial.Feedback.Title"
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animated_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_title_margin_top"
app:layout_constraintTop_toBottomOf="@id/icon"
app:layout_constraintStart_toStartOf="parent"
android:gravity="start"
android:text="@string/allset_title"/>
android:layout_height="match_parent"
android:gravity="center"
android:scaleType="centerCrop"
<TextView
android:id="@+id/subtitle"
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_subtitle_margin_top"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
android:gravity="start"
android:text="@string/allset_description"/>
app:lottie_rawRes="@raw/all_set_page_bg"
app:lottie_autoPlay="true"
app:lottie_loop="true" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/navigation_settings_guideline_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.83" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/allset_page_margin_horizontal"
android:layout_marginEnd="@dimen/allset_page_margin_horizontal"
android:layoutDirection="locale"
android:textDirection="locale"
android:forceHasOverlappingRendering="false"
android:fitsSystemWindows="true" >
<TextView
android:id="@+id/navigation_settings"
style="@style/TextAppearance.GestureTutorial.LinkText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/navigation_settings_guideline_bottom"
android:minHeight="48dp"
android:background="?android:attr/selectableItemBackground"
android:text="@string/allset_navigation_settings" />
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_title_icon_margin_top"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/ic_all_set"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/hint_guideline_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.94" />
<TextView
android:id="@+id/title"
style="@style/TextAppearance.GestureTutorial.Feedback.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_title_margin_top"
app:layout_constraintTop_toBottomOf="@id/icon"
app:layout_constraintStart_toStartOf="parent"
android:gravity="start"
android:text="@string/allset_title"/>
<TextView
android:id="@+id/subtitle"
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/allset_subtitle_margin_top"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
android:gravity="start"
android:text="@string/allset_description"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/navigation_settings_guideline_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.83" />
<TextView
android:id="@+id/navigation_settings"
style="@style/TextAppearance.GestureTutorial.LinkText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/navigation_settings_guideline_bottom"
android:minHeight="48dp"
android:background="?android:attr/selectableItemBackground"
android:text="@string/allset_navigation_settings" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/hint_guideline_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.94" />
<TextView
android:id="@+id/hint"
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/hint_guideline_bottom"
android:text="@string/allset_hint"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/hint"
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/hint_guideline_bottom"
android:text="@string/allset_hint"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

View File

@ -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