Update illustrations in private space setup and settings

Recording link : b/326391912#comment3
https://drive.google.com/file/d/1Rykqy8iugvVNiE8uW2tgAlFhAypGxhdN/view?usp=drive_link

Bug: 326391912
Test: Manual
Change-Id: Ic53c42ec87fde4f1b8c38634e1e2927b235ff2a3
This commit is contained in:
josephpv
2024-02-23 20:36:36 +00:00
committed by Joseph Vincent
parent c1fd5ad1ec
commit 0809d4dee7
21 changed files with 63 additions and 593 deletions

View File

@@ -35,7 +35,6 @@ import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.Nullable;
@@ -44,6 +43,7 @@ import androidx.navigation.fragment.NavHostFragment;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
import com.airbnb.lottie.LottieAnimationView;
import com.google.android.setupdesign.GlifLayout;
import com.google.common.collect.ImmutableList;
@@ -61,21 +61,21 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
private GlifLayout mRootView;
private Handler mHandler;
private int mScreenTitleIndex;
private static final List<Pair<Integer, Integer>> HEADER_IMAGE_PAIRS =
private static final List<Pair<Integer, Integer>> HEADER_ILLUSTRATION_PAIRS =
ImmutableList.of(
new Pair(R.string.private_space_notifications_hidden_title,
R.drawable.private_space_setup_notification_illustration),
R.raw.private_space_notifications_illustration),
new Pair(R.string.private_space_apps_installed_title,
R.drawable.private_space_setup_preinstalled_illustration),
R.raw.private_space_unlock_to_share_illustration),
new Pair(R.string.private_space_explore_settings_title,
R.drawable.private_space_setup_sharing_illustration));
R.raw.private_space_placeholder_illustration));
private Runnable mUpdateScreenResources =
new Runnable() {
@Override
public void run() {
if (getActivity() != null) {
if (++mScreenTitleIndex < HEADER_IMAGE_PAIRS.size()) {
if (++mScreenTitleIndex < HEADER_ILLUSTRATION_PAIRS.size()) {
startFadeOutAnimation();
mHandler.postDelayed(mUpdateScreenResources, DELAY_BETWEEN_SCREENS);
} else if (PrivateSpaceMaintainer.getInstance(getActivity())
@@ -120,7 +120,7 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
}
} else {
mScreenTitleIndex = savedInstanceState.getInt(TITLE_INDEX);
if (mScreenTitleIndex >= HEADER_IMAGE_PAIRS.size()) {
if (mScreenTitleIndex >= HEADER_ILLUSTRATION_PAIRS.size()) {
return super.onCreateView(inflater, container, savedInstanceState);
}
}
@@ -129,7 +129,7 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
inflater.inflate(R.layout.private_space_advancing_screen, container, false);
mRootView.getHeaderTextView().setMaxLines(HEADER_TEXT_MAX_LINES);
mRootView.getHeaderTextView().setBreakStrategy(BREAK_STRATEGY_SIMPLE);
updateHeaderAndImage();
updateHeaderAndIllustration();
mHandler = new Handler(Looper.getMainLooper());
mHandler.postDelayed(mUpdateScreenResources, DELAY_BETWEEN_SCREENS);
OnBackPressedCallback callback =
@@ -152,7 +152,9 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
@Override
public void onDestroy() {
mHandler.removeCallbacks(mUpdateScreenResources);
if (mHandler != null) {
mHandler.removeCallbacks(mUpdateScreenResources);
}
super.onDestroy();
}
@@ -166,20 +168,21 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
.navigate(R.id.action_advance_profile_error);
}
private void updateHeaderAndImage() {
mRootView.setHeaderText(HEADER_IMAGE_PAIRS.get(mScreenTitleIndex).first);
((ImageView) mRootView.findViewById(R.id.setup_advance_image))
.setImageResource(HEADER_IMAGE_PAIRS.get(mScreenTitleIndex).second);
private void updateHeaderAndIllustration() {
mRootView.setHeaderText(HEADER_ILLUSTRATION_PAIRS.get(mScreenTitleIndex).first);
LottieAnimationView animationView = mRootView.findViewById(R.id.lottie_animation);
animationView.setAnimation(HEADER_ILLUSTRATION_PAIRS.get(mScreenTitleIndex).second);
animationView.playAnimation();
startFadeInAnimation();
}
private void startFadeInAnimation() {
ValueAnimator textView = ObjectAnimator.ofFloat(
mRootView.getHeaderTextView(), View.ALPHA, 0f, 1f);
ValueAnimator imageView = ObjectAnimator.ofFloat(
mRootView.findViewById(R.id.setup_advance_image), View.ALPHA, 0, 1f);
ValueAnimator lottieView = ObjectAnimator.ofFloat(
mRootView.findViewById(R.id.lottie_animation), View.ALPHA, 0, 1f);
AnimatorSet fadeIn = new AnimatorSet();
fadeIn.playTogether(textView, imageView);
fadeIn.playTogether(textView, lottieView);
fadeIn.setDuration(ANIMATION_DURATION_MILLIS).start();
}
@@ -187,14 +190,14 @@ public class AutoAdvanceSetupFragment extends InstrumentedFragment {
AnimatorSet fadeOut = new AnimatorSet();
ValueAnimator textView = ObjectAnimator.ofFloat(
mRootView.getHeaderTextView(), View.ALPHA, 1f, 0f);
ValueAnimator imageView = ObjectAnimator.ofFloat(
mRootView.findViewById(R.id.setup_advance_image), View.ALPHA, 1f, 0f);
fadeOut.playTogether(textView, imageView);
ValueAnimator lottieView = ObjectAnimator.ofFloat(
mRootView.findViewById(R.id.lottie_animation), View.ALPHA, 1f, 0f);
fadeOut.playTogether(textView, lottieView);
fadeOut.setDuration(ANIMATION_DURATION_MILLIS).start();
fadeOut.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateHeaderAndImage();
updateHeaderAndIllustration();
}
});
}