Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9161f33 authored by Chris Poultney's avatar Chris Poultney Committed by Automerger Merge Worker
Browse files

Merge "Fades in preview of feathers to avoid flicker" into tm-qpr-dev am: 33245ad3

parents 21786128 33245ad3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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>
+24 −0
Original line number Diff line number Diff line
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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());