Merge "Improve wallpaper full preview page TB UX" into ub-launcher3-master
diff --git a/src/com/android/wallpaper/picker/CategoryFragment.java b/src/com/android/wallpaper/picker/CategoryFragment.java
index 564d939..a172c01 100755
--- a/src/com/android/wallpaper/picker/CategoryFragment.java
+++ b/src/com/android/wallpaper/picker/CategoryFragment.java
@@ -143,7 +143,8 @@
private IndividualPickerFragment mIndividualPickerFragment;
private boolean mShowSelectedWallpaper;
private BottomSheetBehavior<View> mBottomSheetBehavior;
- private int mSelectedPreviewPage;
+ // The index of Destination#DEST_HOME_SCREEN or Destination#DEST_LOCK_SCREEN
+ private int mWallpaperIndex;
// The wallpaper information which is currently shown on the home preview.
private WallpaperInfo mHomePreviewWallpaperInfo;
@@ -228,7 +229,9 @@
@Override
public void onPageSelected(int i) {
- mSelectedPreviewPage = i;
+ mWallpaperIndex = mPreviewPager.isRtl()
+ ? (mWallPaperPreviews.size() - 1) - i
+ : i;
if (mIndividualPickerFragment != null && mIndividualPickerFragment.isVisible()) {
mIndividualPickerFragment.highlightAppliedWallpaper(i);
}
@@ -397,7 +400,7 @@
}
mIndividualPickerFragment = InjectorProvider.getInjector()
.getIndividualPickerFragment(category.getCollectionId());
- mIndividualPickerFragment.highlightAppliedWallpaper(mSelectedPreviewPage);
+ mIndividualPickerFragment.highlightAppliedWallpaper(mWallpaperIndex);
mIndividualPickerFragment.setOnWallpaperSelectedListener(position -> {
// Scroll to the selected wallpaper and collapse the sheet if needed.
// Resize and scroll here because we want to let the RecyclerView's scrolling and
@@ -644,7 +647,7 @@
if (mWallpaperConnection != null) {
mWallpaperConnection.disconnect();
}
- ImageView previewView = mSelectedPreviewPage == 0 ? mHomePreview : mLockscreenPreview;
+ ImageView previewView = mWallpaperIndex == 0 ? mHomePreview : mLockscreenPreview;
previewView.getLocationOnScreen(mLivePreviewLocation);
mPreviewGlobalRect.set(0, 0, previewView.getMeasuredWidth(),
previewView.getMeasuredHeight());
diff --git a/src/com/android/wallpaper/picker/LivePreviewFragment.java b/src/com/android/wallpaper/picker/LivePreviewFragment.java
index b0449f7..1525760 100644
--- a/src/com/android/wallpaper/picker/LivePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/LivePreviewFragment.java
@@ -405,6 +405,9 @@
@Override
public void onEngineShown() {
Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
mLoadingScrim.post(() -> mLoadingScrim.animate()
.alpha(0f)