diff options
| author | George Zacharia <george.zcharia@gmail.com> | 2023-07-02 14:33:47 +0530 |
|---|---|---|
| committer | George Zacharia <george.zcharia@gmail.com> | 2023-07-02 14:33:47 +0530 |
| commit | 913b11dfd2b52e445c773838c766f0d4f8ba0d05 (patch) | |
| tree | adb07f584833593bad6fca5495927c276ceef531 /src/com/android/customization/picker/WallpaperPreviewer.java | |
| parent | b2d9a4961b3804f79c151630421d480846fd0176 (diff) | |
| parent | cc6f666d7c0bc3b6927f6e9e3c7e46123be6263d (diff) | |
Merge tag 'android-13.0.0_r52' of https://android.googlesource.com/platform/packages/apps/ThemePicker into HEADHEADt13.0
Android 13.0.0 Release 52 (TQ3A.230605.012)
Change-Id: I2cea11fa2f1f02fbd3c9d21cfc1697a79d42a5b7
Diffstat (limited to 'src/com/android/customization/picker/WallpaperPreviewer.java')
| -rw-r--r-- | src/com/android/customization/picker/WallpaperPreviewer.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java index 354eec26..1b9ea9fc 100644 --- a/src/com/android/customization/picker/WallpaperPreviewer.java +++ b/src/com/android/customization/picker/WallpaperPreviewer.java @@ -19,6 +19,8 @@ import android.app.Activity; import android.app.WallpaperColors; import android.content.Intent; import android.graphics.Rect; +import android.graphics.RenderEffect; +import android.graphics.Shader.TileMode; import android.service.wallpaper.WallpaperService; import android.view.Surface; import android.view.SurfaceView; @@ -38,6 +40,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 +56,7 @@ public class WallpaperPreviewer implements LifecycleObserver { private final Activity mActivity; private final ImageView mHomePreview; private final SurfaceView mWallpaperSurface; + @Nullable private final ImageView mFadeInScrim; private WallpaperSurfaceCallback mWallpaperSurfaceCallback; private WallpaperInfo mWallpaper; @@ -67,11 +71,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 ImageView 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 +149,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(); } @@ -157,10 +172,16 @@ public class WallpaperPreviewer implements LifecycleObserver { mActivity, android.R.attr.colorSecondary), /* offsetToStart= */ true); if (mWallpaper instanceof LiveWallpaperInfo) { + ImageView preview = homeImageWallpaper; + if (VideoWallpaperUtils.needsFadeIn(mWallpaper) && mFadeInScrim != null) { + preview = mFadeInScrim; + preview.setRenderEffect( + RenderEffect.createBlurEffect(150f, 150f, TileMode.CLAMP)); + } mWallpaper.getThumbAsset(mActivity.getApplicationContext()) .loadPreviewImage( mActivity, - homeImageWallpaper, + preview, ResourceUtils.getColorAttr( mActivity, android.R.attr.colorSecondary), /* offsetToStart= */ true); @@ -209,6 +230,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); |
