summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/wallpaper_preview_card.xml10
-rw-r--r--src/com/android/wallpaper/model/WallpaperSectionController.java41
-rw-r--r--src/com/android/wallpaper/util/VideoWallpaperUtils.java40
3 files changed, 89 insertions, 2 deletions
diff --git a/res/layout/wallpaper_preview_card.xml b/res/layout/wallpaper_preview_card.xml
index 3cce1262..085695e6 100644
--- a/res/layout/wallpaper_preview_card.xml
+++ b/res/layout/wallpaper_preview_card.xml
@@ -60,4 +60,14 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
+
+ <View
+ android:id="@+id/wallpaper_fadein_scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/color_surface"
+ android:forceHasOverlappingRendering="false"
+ android:importantForAccessibility="no"
+ android:visibility="invisible" />
+
</androidx.cardview.widget.CardView>
diff --git a/src/com/android/wallpaper/model/WallpaperSectionController.java b/src/com/android/wallpaper/model/WallpaperSectionController.java
index 4fd824bc..c9e867e6 100644
--- a/src/com/android/wallpaper/model/WallpaperSectionController.java
+++ b/src/com/android/wallpaper/model/WallpaperSectionController.java
@@ -64,6 +64,7 @@ import com.android.wallpaper.picker.WorkspaceSurfaceHolderCallback;
import com.android.wallpaper.util.DisplayUtils;
import com.android.wallpaper.util.PreviewUtils;
import com.android.wallpaper.util.ResourceUtils;
+import com.android.wallpaper.util.VideoWallpaperUtils;
import com.android.wallpaper.util.WallpaperConnection;
import com.android.wallpaper.util.WallpaperSurfaceCallback;
import com.android.wallpaper.widget.LockScreenPreviewer;
@@ -71,7 +72,9 @@ import com.android.wallpaper.widget.LockScreenPreviewer;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
-/** The class to control the wallpaper section view. */
+/**
+ * The class to control the wallpaper section view.
+ */
public class WallpaperSectionController implements
CustomizationSectionController<WallpaperSectionView>,
LifecycleObserver {
@@ -86,10 +89,12 @@ public class WallpaperSectionController implements
private WorkspaceSurfaceHolderCallback mWorkspaceSurfaceCallback;
private SurfaceView mHomeWallpaperSurface;
private WallpaperSurfaceCallback mHomeWallpaperSurfaceCallback;
+ private View mHomeFadeInScrim;
private SurfaceView mLockWallpaperSurface;
private WallpaperSurfaceCallback mLockWallpaperSurfaceCallback;
private CardView mLockscreenPreviewCard;
private ViewGroup mLockPreviewContainer;
+ private View mLockFadeInScrim;
private ContentLoadingProgressBar mLockscreenPreviewProgress;
private WallpaperConnection mHomeWallpaperConnection;
private WallpaperConnection mLockWallpaperConnection;
@@ -106,7 +111,8 @@ public class WallpaperSectionController implements
private final LifecycleOwner mLifecycleOwner;
private final PermissionRequester mPermissionRequester;
private final WallpaperColorsViewModel mWallpaperColorsViewModel;
- @Nullable private final LiveData<Boolean> mOnThemingChanged;
+ @Nullable
+ private final LiveData<Boolean> mOnThemingChanged;
private final CustomizationSectionNavigationController mSectionNavigationController;
private final WallpaperPreviewNavigator mWallpaperPreviewNavigator;
private final Bundle mSavedInstanceState;
@@ -175,6 +181,7 @@ public class WallpaperSectionController implements
new PreviewUtils(
mAppContext, mAppContext.getString(R.string.grid_control_metadata_name)));
mHomeWallpaperSurface = mHomePreviewCard.findViewById(R.id.wallpaper_surface);
+ mHomeFadeInScrim = mHomePreviewCard.findViewById(R.id.wallpaper_fadein_scrim);
Future<ColorInfo> colorFuture = CompletableFuture.completedFuture(
new ColorInfo(/* wallpaperColors= */ null,
@@ -195,6 +202,7 @@ public class WallpaperSectionController implements
R.id.wallpaper_preview_spinner);
mLockscreenPreviewCard.findViewById(R.id.workspace_surface).setVisibility(View.GONE);
mLockWallpaperSurface = mLockscreenPreviewCard.findViewById(R.id.wallpaper_surface);
+ mLockFadeInScrim = mLockscreenPreviewCard.findViewById(R.id.wallpaper_fadein_scrim);
mLockWallpaperSurfaceCallback = new WallpaperSurfaceCallback(mActivity,
mLockscreenPreviewCard, mLockWallpaperSurface, colorFuture, () -> {
if (mLockPreviewWallpaperInfo != null) {
@@ -402,6 +410,18 @@ public class WallpaperSectionController implements
}
onLockWallpaperColorsChanged(lockColors);
+
+ // If we need to do the scrim fade, show the scrim first.
+ if (VideoWallpaperUtils.needsFadeIn(mHomePreviewWallpaperInfo)) {
+ mHomeFadeInScrim.animate().cancel();
+ mHomeFadeInScrim.setAlpha(1f);
+ mHomeFadeInScrim.setVisibility(View.VISIBLE);
+ }
+ if (VideoWallpaperUtils.needsFadeIn(mLockPreviewWallpaperInfo)) {
+ mLockFadeInScrim.animate().cancel();
+ mLockFadeInScrim.setAlpha(1f);
+ mLockFadeInScrim.setVisibility(View.VISIBLE);
+ }
}, forceRefresh);
}
@@ -553,6 +573,22 @@ public class WallpaperSectionController implements
}
onHomeWallpaperColorsChanged(colors);
}
+
+ @Override
+ public void onEngineShown() {
+ if (VideoWallpaperUtils.needsFadeIn(homeWallpaper)) {
+ mHomeFadeInScrim.animate().alpha(0.0f)
+ .setDuration(VideoWallpaperUtils.TRANSITION_MILLIS)
+ .withEndAction(() -> mHomeFadeInScrim.setVisibility(
+ View.INVISIBLE));
+ if (isLockLive) {
+ mLockFadeInScrim.animate().alpha(0.0f)
+ .setDuration(VideoWallpaperUtils.TRANSITION_MILLIS)
+ .withEndAction(() -> mLockFadeInScrim.setVisibility(
+ View.INVISIBLE));
+ }
+ }
+ }
},
mHomeWallpaperSurface, isLockLive ? mLockWallpaperSurface : null);
@@ -586,6 +622,7 @@ public class WallpaperSectionController implements
return !mActivity.isDestroyed() && !mActivity.isFinishing();
}
+ // TODO(b/276439056) Remove these animations as they have no effect
private void fadeWallpaperPreview(boolean isFadeIn, int duration) {
setupFade(mHomePreviewCard, mHomePreviewProgress, duration, isFadeIn);
setupFade(mLockscreenPreviewCard, mLockscreenPreviewProgress, duration, isFadeIn);
diff --git a/src/com/android/wallpaper/util/VideoWallpaperUtils.java b/src/com/android/wallpaper/util/VideoWallpaperUtils.java
new file mode 100644
index 00000000..7acffda7
--- /dev/null
+++ b/src/com/android/wallpaper/util/VideoWallpaperUtils.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.wallpaper.util;
+
+import com.android.wallpaper.model.LiveWallpaperInfo;
+import com.android.wallpaper.model.WallpaperInfo;
+
+/**
+ * Workarounds for dealing with issues displaying video wallpaper previews until better solutions
+ * are found.
+ *
+ * See b/268066031.
+ */
+public class VideoWallpaperUtils {
+
+ /**
+ * Transition time for fade-in animation.
+ */
+ public static final int TRANSITION_MILLIS = 175;
+
+ /**
+ * Returns true if the is a video wallpaper that requires the fade-in workaround.
+ */
+ public static boolean needsFadeIn(WallpaperInfo info) {
+ return info instanceof LiveWallpaperInfo;
+ }
+}