Use the crop wallpaper's color rather than thumbnail's
Some image is large that thumbnail's color is different from preview
screen's. System would use the crop one (preview screen).
Bug: 185198554
Test: manual
Change-Id: Ib2a893525744c49996082adf45da91cde6ab1d28
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index 86db97e..313d215 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -67,7 +67,6 @@
import com.android.wallpaper.widget.BottomActionBar;
import com.android.wallpaper.widget.BottomActionBar.AccessibilityCallback;
import com.android.wallpaper.widget.LockScreenPreviewer2;
-import com.android.wallpaper.widget.WallpaperColorsLoader;
import com.android.wallpaper.widget.WallpaperInfoView;
import com.bumptech.glide.Glide;
@@ -84,7 +83,7 @@
* Fragment which displays the UI for previewing an individual static wallpaper and its attribution
* information.
*/
-public class ImagePreviewFragment extends PreviewFragment implements WallpaperColorsLoader.Callback{
+public class ImagePreviewFragment extends PreviewFragment {
private static final String TAG = "ImagePreviewFragment";
private static final float DEFAULT_WALLPAPER_MAX_ZOOM = 8f;
@@ -175,9 +174,6 @@
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- WallpaperColorsLoader.getWallpaperColors(getContext(),
- mWallpaper.getThumbAsset(getContext()), this);
-
mWallpaperAsset.decodeRawDimensions(getActivity(), dimensions -> {
// Don't continue loading the wallpaper if the Fragment is detached.
if (getActivity() == null) {
@@ -201,8 +197,7 @@
});
}
- @Override
- public void onLoaded(@Nullable WallpaperColors colors) {
+ protected void onWallpaperColorsChanged(@Nullable WallpaperColors colors) {
mLockScreenPreviewer.setColor(colors);
}
@@ -361,6 +356,7 @@
}, /* delayMillis= */ 100);
}
});
+ mFullResImageView.post(this::recalculateColors);
}
getActivity().invalidateOptionsMenu();
});
@@ -372,7 +368,7 @@
calculateCropRect(), /* adjustForRtl= */ false, new BitmapCropper.Callback() {
@Override
public void onBitmapCropped(Bitmap croppedBitmap) {
- onLoaded(WallpaperColors.fromBitmap(croppedBitmap));
+ onWallpaperColorsChanged(WallpaperColors.fromBitmap(croppedBitmap));
}
@Override