summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Poultney <poultney@google.com>2023-03-28 18:37:22 +0000
committerChris Poultney <poultney@google.com>2023-03-31 18:15:46 +0000
commit64c480f6e0c09d22cb9acfab0f1761da42b4caf0 (patch)
tree26f577962a46d11a7a0532848edf990783f449a4
parente4e1bfa5239033206f049934984dcb5412ac1949 (diff)
Fades in preview of feathers to avoid flicker
Bug: 268066031 Test: manually verified that fade has replace flicker for feather videos Test: manually verified that static wallpaper previews are unchanged Test: manually verified that other live wallpaper previews are unchanged Change-Id: I420ee05e631bba19453ed24671c504e31e8c5e60
-rw-r--r--res/layout/grid_preview_card.xml9
-rw-r--r--src/com/android/customization/picker/WallpaperPreviewer.java24
-rw-r--r--src/com/android/customization/picker/grid/GridFragment.java3
3 files changed, 35 insertions, 1 deletions
diff --git a/res/layout/grid_preview_card.xml b/res/layout/grid_preview_card.xml
index e333ca7b..6df8508a 100644
--- a/res/layout/grid_preview_card.xml
+++ b/res/layout/grid_preview_card.xml
@@ -38,4 +38,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAccessibility="noHideDescendants" />
+
+ <View
+ android:id="@+id/grid_fadein_scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:colorSecondary"
+ android:forceHasOverlappingRendering="false"
+ android:importantForAccessibility="no"
+ android:visibility="invisible" />
</androidx.cardview.widget.CardView>
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java
index 354eec26..ef16895c 100644
--- a/src/com/android/customization/picker/WallpaperPreviewer.java
+++ b/src/com/android/customization/picker/WallpaperPreviewer.java
@@ -38,6 +38,7 @@ import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.util.ResourceUtils;
import com.android.wallpaper.util.ScreenSizeCalculator;
import com.android.wallpaper.util.SizeCalculator;
+import com.android.wallpaper.util.VideoWallpaperUtils;
import com.android.wallpaper.util.WallpaperConnection;
import com.android.wallpaper.util.WallpaperConnection.WallpaperConnectionListener;
import com.android.wallpaper.util.WallpaperSurfaceCallback;
@@ -53,6 +54,7 @@ public class WallpaperPreviewer implements LifecycleObserver {
private final Activity mActivity;
private final ImageView mHomePreview;
private final SurfaceView mWallpaperSurface;
+ @Nullable private final View mFadeInScrim;
private WallpaperSurfaceCallback mWallpaperSurfaceCallback;
private WallpaperInfo mWallpaper;
@@ -67,11 +69,17 @@ public class WallpaperPreviewer implements LifecycleObserver {
public WallpaperPreviewer(Lifecycle lifecycle, Activity activity, ImageView homePreview,
SurfaceView wallpaperSurface) {
+ this(lifecycle, activity, homePreview, wallpaperSurface, null);
+ }
+
+ public WallpaperPreviewer(Lifecycle lifecycle, Activity activity, ImageView homePreview,
+ SurfaceView wallpaperSurface, @Nullable View fadeInScrim) {
lifecycle.addObserver(this);
mActivity = activity;
mHomePreview = homePreview;
mWallpaperSurface = wallpaperSurface;
+ mFadeInScrim = fadeInScrim;
mWallpaperSurfaceCallback = new WallpaperSurfaceCallback(activity, mHomePreview,
mWallpaperSurface, this::setUpWallpaperPreview);
mWallpaperSurface.setZOrderMediaOverlay(true);
@@ -139,6 +147,11 @@ public class WallpaperPreviewer implements LifecycleObserver {
@Nullable WallpaperColorsListener listener) {
mWallpaper = wallpaperInfo;
mWallpaperColorsListener = listener;
+ if (mFadeInScrim != null && VideoWallpaperUtils.needsFadeIn(wallpaperInfo)) {
+ mFadeInScrim.animate().cancel();
+ mFadeInScrim.setAlpha(1f);
+ mFadeInScrim.setVisibility(View.VISIBLE);
+ }
setUpWallpaperPreview();
}
@@ -209,6 +222,17 @@ public class WallpaperPreviewer implements LifecycleObserver {
mWallpaperColorsListener.onWallpaperColorsChanged(colors);
}
}
+
+ @Override
+ public void onEngineShown() {
+ if (mFadeInScrim != null && VideoWallpaperUtils.needsFadeIn(
+ homeWallpaper)) {
+ mFadeInScrim.animate().alpha(0.0f)
+ .setDuration(VideoWallpaperUtils.TRANSITION_MILLIS)
+ .withEndAction(
+ () -> mFadeInScrim.setVisibility(View.INVISIBLE));
+ }
+ }
}, mWallpaperSurface);
mWallpaperConnection.setVisibility(true);
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index b5ed7ee8..4de1dab7 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -158,7 +158,8 @@ public class GridFragment extends AppbarFragment {
SurfaceView wallpaperSurface = view.findViewById(R.id.wallpaper_preview_surface);
WallpaperPreviewer wallpaperPreviewer = new WallpaperPreviewer(getLifecycle(),
- getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperSurface);
+ getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperSurface,
+ view.findViewById(R.id.grid_fadein_scrim));
// Loads current Wallpaper.
CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
.getCurrentWallpaperInfoFactory(getContext().getApplicationContext());