Revamp outro animation

Use the wallpaper as part of the window background rather than trying
to replicate it with WallpaperManager. This allows us to perform a
circular hide to whatever the wallpaper currently looks like exactly,
rather than needing to obtain the wallpaper Bitmap or Drawable and
guess. Display the Finish activity edge-to-edge. Fade out rather
than slide out.

Change-Id: I1154043178a04ca0ced7e8365e338dc10f3377cb
This commit is contained in:
Tommy Webb
2023-12-20 22:58:35 -05:00
committed by Michael Bestas
parent 63bbec0258
commit ed1a968160
5 changed files with 58 additions and 41 deletions

View File

@@ -292,6 +292,7 @@
</activity>
<activity android:name=".FinishActivity"
android:theme="@style/EdgeToEdgeWallpaperBackground"
android:label="@string/activity_label_empty"
android:excludeFromRecents="true"
android:configChanges="mcc|mnc"

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The CyanogenMod Project
Copyright (C) 2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,5 +15,5 @@
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/page_background" />
<solid android:color="?android:attr/colorBackground" />
</shape>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The CyanogenMod Project
Copyright (C) 2017-2021 The LineageOS Project
Copyright (C) 2017-2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -25,7 +25,15 @@
android:fitsSystemWindows="true"
app:insetForeground="@android:color/transparent">
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:visibility="visible"/>
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -49,11 +57,4 @@
</LinearLayout>
<ImageView
android:id="@+id/reveal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/reveal"
android:visibility="invisible"/>
</android.widget.FrameLayout>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 The CyanogenMod Project
Copyright (C) 2017-2022 The LineageOS Project
Copyright (C) 2017-2024 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -62,4 +62,12 @@
<item name="android:paddingBottom">@dimen/welcome_title_padding_bottom</item>
<item name="android:lineHeight">@dimen/welcome_title_line_height</item>
</style>
<style name="EdgeToEdgeWallpaperBackground" parent="Theme.Setup">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">?attr/android:windowBackground</item>
<item name="android:navigationBarColor">?attr/android:windowBackground</item>
</style>
</resources>

View File

@@ -51,8 +51,14 @@ import android.os.UserHandle;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.Window;
import android.widget.ImageView;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import lineageos.providers.LineageSettings;
import org.lineageos.setupwizard.util.SetupWizardUtils;
@@ -61,7 +67,7 @@ public class FinishActivity extends BaseSetupWizardActivity {
public static final String TAG = FinishActivity.class.getSimpleName();
private ImageView mReveal;
private ImageView mBackground;
private SetupWizardApp mSetupWizardApp;
@@ -85,12 +91,34 @@ public class FinishActivity extends BaseSetupWizardActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
if (LOGV) {
logActivityState("onCreate savedInstanceState=" + savedInstanceState);
}
mSetupWizardApp = (SetupWizardApp) getApplication();
mReveal = (ImageView) findViewById(R.id.reveal);
mBackground = (ImageView) findViewById(R.id.background);
setNextText(R.string.start);
// Edge-to-edge. Needed for the background view to fill the full screen.
final Window window = getWindow();
window.setDecorFitsSystemWindows(false);
// Make sure 3-button navigation bar is the same color as the rest of the screen.
window.setNavigationBarContrastEnforced(false);
// Ensure the main layout (not including the background view) does not get obscured by bars.
final View rootView = findViewById(R.id.root);
ViewCompat.setOnApplyWindowInsetsListener(rootView, (view, windowInsets) -> {
final View linearLayout = findViewById(R.id.linear_layout);
final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
final MarginLayoutParams params = (MarginLayoutParams) linearLayout.getLayoutParams();
params.leftMargin = insets.left;
params.topMargin = insets.top;
params.rightMargin = insets.right;
params.bottomMargin = insets.bottom;
linearLayout.setLayoutParams(params);
return WindowInsetsCompat.CONSUMED;
});
}
@Override
@@ -122,47 +150,26 @@ public class FinishActivity extends BaseSetupWizardActivity {
hideNextButton();
// Begin outro animation.
setupRevealImage();
}
private void setupRevealImage() {
Rect rect = getWindowManager().getCurrentWindowMetrics().getBounds();
final Point p = new Point(rect.width(), rect.height());
final WallpaperManager wallpaperManager =
WallpaperManager.getInstance(this);
wallpaperManager.forgetLoadedWallpaper();
final Bitmap wallpaper = wallpaperManager.getBitmap();
Bitmap cropped = null;
if (wallpaper != null) {
cropped = Bitmap.createBitmap(wallpaper, 0,
0, Math.min(p.x, wallpaper.getWidth()),
Math.min(p.y, wallpaper.getHeight()));
}
if (cropped != null) {
mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
mReveal.setImageBitmap(cropped);
} else {
mReveal.setBackground(wallpaperManager
.getBuiltInDrawable(p.x, p.y, false, 0, 0));
}
animateOut();
}
private void animateOut() {
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
int cy = (mReveal.getTop() + mReveal.getBottom()) / 2;
int finalRadius = Math.max(mReveal.getWidth(), mReveal.getHeight());
final View rootView = findViewById(R.id.root);
final int cx = (rootView.getLeft() + rootView.getRight()) / 2;
final int cy = (rootView.getTop() + rootView.getBottom()) / 2;
final float fullRadius = (float) Math.hypot(cx, cy);
Animator anim =
ViewAnimationUtils.createCircularReveal(mReveal, cx, cy, 0, finalRadius);
ViewAnimationUtils.createCircularReveal(rootView, cx, cy, fullRadius, 0f);
anim.setDuration(900);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mReveal.setVisibility(View.VISIBLE);
rootView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
rootView.setVisibility(View.INVISIBLE);
mHandler.post(() -> {
if (LOGV) {
Log.v(TAG, "Animation ended");