Merge "Respect accessibility animation guidelines in AllSetActivity" into main

This commit is contained in:
Schneider Victor-tulias
2025-02-24 13:30:10 -08:00
committed by Android (Google) Code Review
5 changed files with 31 additions and 9 deletions
+2 -4
View File
@@ -29,7 +29,6 @@
android:layout_height="match_parent"
android:gravity="center"
android:scaleType="centerCrop"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:layout_constraintTop_toTopOf="parent"
@@ -49,11 +48,10 @@
app:layout_constraintEnd_toEndOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/text_content_view"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/allset_page_margin_horizontal"
android:layout_marginEnd="@dimen/allset_page_margin_horizontal"
android:paddingHorizontal="@dimen/allset_page_padding_horizontal"
android:layoutDirection="locale"
android:textDirection="locale"
android:forceHasOverlappingRendering="false"
+1 -1
View File
@@ -16,7 +16,7 @@
-->
<resources>
<!-- All Set page -->
<dimen name="allset_page_margin_horizontal">48dp</dimen>
<dimen name="allset_page_padding_horizontal">48dp</dimen>
<!-- Gesture Tutorial menu page -->
<dimen name="gesture_tutorial_menu_padding_horizontal">48dp</dimen>
+1 -1
View File
@@ -37,7 +37,7 @@
<dimen name="overview_actions_top_margin">24dp</dimen>
<!-- All Set page -->
<dimen name="allset_page_margin_horizontal">120dp</dimen>
<dimen name="allset_page_padding_horizontal">120dp</dimen>
<dimen name="allset_page_allset_text_size">38sp</dimen>
<dimen name="allset_page_swipe_up_text_size">15sp</dimen>
</resources>
+1 -1
View File
@@ -277,7 +277,7 @@
<dimen name="gesture_tutorial_taskbar_margin_bottom">24dp</dimen>
<!-- All Set page -->
<dimen name="allset_page_margin_horizontal">40dp</dimen>
<dimen name="allset_page_padding_horizontal">40dp</dimen>
<dimen name="allset_page_allset_text_size">36sp</dimen>
<dimen name="allset_page_swipe_up_text_size">14sp</dimen>
@@ -64,6 +64,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.RemoveAnimationSettingsTracker;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -107,6 +108,9 @@ public class AllSetActivity extends Activity {
private static final float ANIMATION_PAUSE_ALPHA_THRESHOLD = 0.1f;
private static final String KEY_BACKGROUND_ANIMATION_TOGGLED_ON =
"background_animation_toggled_on";
private final AnimatedFloat mSwipeProgress = new AnimatedFloat(this::onSwipeProgressUpdate);
private final InvariantDeviceProfile.OnIDPChangeListener mOnIDPChangeListener =
@@ -124,6 +128,9 @@ public class AllSetActivity extends Activity {
private AnimatorPlaybackController mLauncherStartAnim = null;
// Auto play background animation by default
private boolean mBackgroundAnimationToggledOn = true;
private TextView mHintView;
private final OverviewChangeListener mOverviewChangeListener = this::onOverviewTargetChange;
@@ -200,6 +207,15 @@ public class AllSetActivity extends Activity {
LOTTIE_TERTIARY_COLOR_TOKEN, R.color.all_set_bg_tertiary),
getTheme());
mBackgroundAnimationToggledOn = savedInstanceState == null
|| savedInstanceState.getBoolean(KEY_BACKGROUND_ANIMATION_TOGGLED_ON, true);
// The animated background is behind a scroll view, which intercepts all input.
// However, the content view also covers the full screen
requireViewById(R.id.content).setOnClickListener(v -> {
mBackgroundAnimationToggledOn = !mBackgroundAnimationToggledOn;
maybeResumeOrPauseBackgroundAnimation();
});
setUpBackgroundAnimation(getDP().isTablet);
getIDP().addOnChangeListener(mOnIDPChangeListener);
@@ -208,6 +224,12 @@ public class AllSetActivity extends Activity {
ActivityPreloadUtil.preloadOverviewForSUWAllSet(this);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_BACKGROUND_ANIMATION_TOGGLED_ON, mBackgroundAnimationToggledOn);
}
private InvariantDeviceProfile getIDP() {
return LauncherAppState.getInstance(this).getInvariantDeviceProfile();
}
@@ -368,8 +390,10 @@ public class AllSetActivity extends Activity {
private void maybeResumeOrPauseBackgroundAnimation() {
boolean shouldPlayAnimation =
getContentViewAlphaForSwipeProgress() > ANIMATION_PAUSE_ALPHA_THRESHOLD
&& isResumed();
!RemoveAnimationSettingsTracker.INSTANCE.get(this).isRemoveAnimationEnabled()
&& getContentViewAlphaForSwipeProgress() > ANIMATION_PAUSE_ALPHA_THRESHOLD
&& isResumed()
&& mBackgroundAnimationToggledOn;
if (mAnimatedBackground.isAnimating() && !shouldPlayAnimation) {
mAnimatedBackground.pauseAnimation();
} else if (!mAnimatedBackground.isAnimating() && shouldPlayAnimation) {