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

Commit e0abb501 authored by Austin Wang's avatar Austin Wang
Browse files

Offset preview to start if on wallpaper display

For static wallpaper preview, offset the preview to the start of the
wallpaper if the current display is the largest display(wallpaper
display) on multi-display devices. Other wallpaper remains the same.

Test: set multiple wallpapers w/wo fullscreen preview
Bug: 259745033
Change-Id: I34b593e706f2d60d7f213f229bc525214bdcca0d
parent 3d4f38ff
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.wallpaper.model.WorkspaceViewModel;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.CustomizationSections;
import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController;
import com.android.wallpaper.util.DisplayUtils;

import java.util.ArrayList;
import java.util.List;
@@ -57,7 +58,8 @@ public final class DefaultCustomizationSections implements CustomizationSections
            WallpaperPreviewNavigator wallpaperPreviewNavigator,
            CustomizationSectionNavigationController sectionNavigationController,
            @Nullable Bundle savedInstanceState,
            CurrentWallpaperInfoFactory wallpaperInfoFactory) {
            CurrentWallpaperInfoFactory wallpaperInfoFactory,
            DisplayUtils displayUtils) {
        List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();

        // Wallpaper section.
@@ -67,7 +69,8 @@ public final class DefaultCustomizationSections implements CustomizationSections
                        lifecycleOwner,
                        screen,
                        wallpaperInfoFactory,
                        wallpaperColorsViewModel));
                        wallpaperColorsViewModel,
                        displayUtils));

        // Theme color section.
        sectionControllers.add(new ColorSectionController(
@@ -115,14 +118,15 @@ public final class DefaultCustomizationSections implements CustomizationSections
            PermissionRequester permissionRequester,
            WallpaperPreviewNavigator wallpaperPreviewNavigator,
            CustomizationSectionNavigationController sectionNavigationController,
            @Nullable Bundle savedInstanceState) {
            @Nullable Bundle savedInstanceState,
            DisplayUtils displayUtils) {
        List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();

        // Wallpaper section.
        sectionControllers.add(new WallpaperSectionController(
                activity, lifecycleOwner, permissionRequester, wallpaperColorsViewModel,
                workspaceViewModel, sectionNavigationController, wallpaperPreviewNavigator,
                savedInstanceState));
                savedInstanceState, displayUtils));

        // Theme color section.
        sectionControllers.add(new ColorSectionController(
+4 −2
Original line number Diff line number Diff line
@@ -154,14 +154,16 @@ public class WallpaperPreviewer implements LifecycleObserver {
                        .loadPreviewImage(mActivity,
                                renderInImageWallpaperSurface ? homeImageWallpaper : mHomePreview,
                                ResourceUtils.getColorAttr(
                                        mActivity, android.R.attr.colorSecondary));
                                        mActivity, android.R.attr.colorSecondary),
                                /* offsetToStart= */ true);
                if (mWallpaper instanceof LiveWallpaperInfo) {
                    mWallpaper.getThumbAsset(mActivity.getApplicationContext())
                            .loadPreviewImage(
                                    mActivity,
                                    homeImageWallpaper,
                                    ResourceUtils.getColorAttr(
                                            mActivity, android.R.attr.colorSecondary));
                                            mActivity, android.R.attr.colorSecondary),
                                    /* offsetToStart= */ true);
                    setUpLiveWallpaperPreview(mWallpaper);
                } else {
                    // Ensure live wallpaper connection is disconnected.
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ object KeyguardQuickAffordancePreviewBinder {
        previewView: CardView,
        viewModel: KeyguardQuickAffordancePickerViewModel,
        lifecycleOwner: LifecycleOwner,
        offsetToStart: Boolean,
    ) {
        val binding =
            ScreenPreviewBinder.bind(
@@ -46,6 +47,7 @@ object KeyguardQuickAffordancePreviewBinder {
                previewView = previewView,
                viewModel = viewModel.preview,
                lifecycleOwner = lifecycleOwner,
                offsetToStart = offsetToStart,
            )

        previewView.contentDescription =
+2 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ class KeyguardQuickAffordancePickerFragment : AppbarFragment() {
            previewView = view.requireViewById(R.id.preview),
            viewModel = viewModel,
            lifecycleOwner = this,
            offsetToStart =
                injector.getDisplayUtils(requireActivity()).isOnWallpaperDisplay(requireActivity())
        )
        KeyguardQuickAffordancePickerBinder.bind(
            view = view,