Fix wallpaper preview crashes
- Launch from picker home page.
- Launch from Photos.
Fixes: 188147553
Test: Manually
Change-Id: I64ccb33b574ccd0b5d48c0eef672bcbb4308d20e
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index 5088608..0795811 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -305,6 +305,10 @@
* initializing a zoom-scroll observer and click listener.
*/
private void initFullResView() {
+ if (mRawWallpaperSize == null || mFullResImageView == null) {
+ return;
+ }
+
// Minimum scale will only be respected under this scale type.
mFullResImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM);
// When we set a minimum scale bigger than the scale with which the full image is shown,
@@ -539,6 +543,7 @@
R.layout.fullscreen_wallpaper_preview, null);
mFullResImageView = wallpaperPreviewContainer.findViewById(R.id.full_res_image);
mLowResImageView = wallpaperPreviewContainer.findViewById(R.id.low_res_image);
+ initFullResView();
// Scale the mWallpaperSurface based on system zoom's scale so that the wallpaper is
// rendered in a larger surface than what preview shows, simulating the behavior of
// the actual wallpaper surface.
diff --git a/src/com/android/wallpaper/util/FullScreenAnimation.java b/src/com/android/wallpaper/util/FullScreenAnimation.java
index 587464e..da86636 100644
--- a/src/com/android/wallpaper/util/FullScreenAnimation.java
+++ b/src/com/android/wallpaper/util/FullScreenAnimation.java
@@ -228,11 +228,15 @@
*/
public void ensureToolbarIsCorrectlyColored() {
TextView textView = mView.findViewById(R.id.custom_toolbar_title);
- Toolbar toolbar = mView.findViewById(R.id.toolbar);
- ImageButton button = (ImageButton) toolbar.getNavigationView();
-
textView.setTextColor(mCurrentTextColor);
- button.setColorFilter(mCurrentTextColor);
+
+ Toolbar toolbar = mView.findViewById(R.id.toolbar);
+ // It may be null because there's no back arrow in some cases. For example: no back arrow
+ // for Photos launching case.
+ ImageButton button = (ImageButton) toolbar.getNavigationView();
+ if (button != null) {
+ button.setColorFilter(mCurrentTextColor);
+ }
}
/**
@@ -313,7 +317,11 @@
colorAnimator.addUpdateListener(animation -> {
int color = (int) animation.getAnimatedValue();
textView.setTextColor(color);
- button.setColorFilter(color);
+ // It may be null because there's no back arrow in some cases. For example: no back
+ // arrow for Photos launching case.
+ if (button != null) {
+ button.setColorFilter(color);
+ }
});
colorAnimator.start();