Loading res/layout/grid_preview_card.xml +9 −0 Original line number Diff line number Diff line Loading @@ -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> src/com/android/customization/picker/WallpaperPreviewer.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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); Loading Loading @@ -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(); } Loading Loading @@ -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); Loading src/com/android/customization/picker/grid/GridFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading Loading
res/layout/grid_preview_card.xml +9 −0 Original line number Diff line number Diff line Loading @@ -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>
src/com/android/customization/picker/WallpaperPreviewer.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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); Loading Loading @@ -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(); } Loading Loading @@ -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); Loading
src/com/android/customization/picker/grid/GridFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading