Remove obsolete classes

Remove below classes
- CategoryFragment
- TopLevelPickerActivity
- IndividualPickerActivity

Bug: 198711415
Test: Build and run standalone WallpaperPicker2 project
Change-Id: I087d7fc28617b284b9b2a8e66823529d8cc8856f
diff --git a/src/com/android/wallpaper/compat/ButtonDrawableSetterCompat.java b/src/com/android/wallpaper/compat/ButtonDrawableSetterCompat.java
deleted file mode 100755
index 77bbfbe..0000000
--- a/src/com/android/wallpaper/compat/ButtonDrawableSetterCompat.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2017 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.compat;
-
-import android.graphics.drawable.Drawable;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.widget.Button;
-
-/**
- * Compatibility class for adding Drawables to Buttons.
- */
-public class ButtonDrawableSetterCompat {
-
-    /**
-     * Sets a Drawable to the start of a Button on API 17+ and to the left of a Button on older
-     * versions where RTL is not supported.
-     */
-    public static void setDrawableToButtonStart(Button button, Drawable icon) {
-        // RTL method support was added in API 17.
-        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
-            button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
-        } else {
-            // Fall back to "left" icon placement if RTL is not supported.
-            button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
-        }
-    }
-}
diff --git a/src/com/android/wallpaper/model/Category.java b/src/com/android/wallpaper/model/Category.java
index 99d7500..a182ea4 100755
--- a/src/com/android/wallpaper/model/Category.java
+++ b/src/com/android/wallpaper/model/Category.java
@@ -49,12 +49,9 @@
      * Shows the UI for picking wallpapers within this category.
      *
      * @param srcActivity
-     * @param factory     A factory for showing the picker activity for within this app. Only used for
-     *                    certain Category implementations that show a picker in-app (as opposed to launching an
-     *                    external intent).
      * @param requestCode Request code to pass in when starting the picker activity.
      */
-    public abstract void show(Activity srcActivity, PickerIntentFactory factory, int requestCode);
+    public abstract void show(Activity srcActivity, int requestCode);
 
     /**
      * Returns true if this Category contains an enumerable set of wallpapers which can be presented
diff --git a/src/com/android/wallpaper/model/DesktopCustomCategory.java b/src/com/android/wallpaper/model/DesktopCustomCategory.java
index e6cc694..61b5c12 100755
--- a/src/com/android/wallpaper/model/DesktopCustomCategory.java
+++ b/src/com/android/wallpaper/model/DesktopCustomCategory.java
@@ -39,7 +39,7 @@
     }
 
     @Override
-    public void show(Activity srcActivity, PickerIntentFactory factory, int requestCode) {
+    public void show(Activity srcActivity, int requestCode) {
         // no op
     }
 
diff --git a/src/com/android/wallpaper/model/ImageCategory.java b/src/com/android/wallpaper/model/ImageCategory.java
index b5257f7..411fd63 100755
--- a/src/com/android/wallpaper/model/ImageCategory.java
+++ b/src/com/android/wallpaper/model/ImageCategory.java
@@ -51,7 +51,7 @@
     }
 
     @Override
-    public void show(Activity srcActivity, PickerIntentFactory factory, int requestCode) {
+    public void show(Activity srcActivity, int requestCode) {
         Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
         intent.setType("image/*");
         srcActivity.startActivityForResult(intent, requestCode);
diff --git a/src/com/android/wallpaper/model/PlaceholderCategory.java b/src/com/android/wallpaper/model/PlaceholderCategory.java
index 55186ea..76070d0 100644
--- a/src/com/android/wallpaper/model/PlaceholderCategory.java
+++ b/src/com/android/wallpaper/model/PlaceholderCategory.java
@@ -36,7 +36,7 @@
     }
 
     @Override
-    public void show(Activity srcActivity, PickerIntentFactory factory, int requestCode) {
+    public void show(Activity srcActivity, int requestCode) {
 
     }
 
diff --git a/src/com/android/wallpaper/model/ThirdPartyAppCategory.java b/src/com/android/wallpaper/model/ThirdPartyAppCategory.java
index a10ab6a..ddc12a7 100755
--- a/src/com/android/wallpaper/model/ThirdPartyAppCategory.java
+++ b/src/com/android/wallpaper/model/ThirdPartyAppCategory.java
@@ -96,7 +96,7 @@
     }
 
     @Override
-    public void show(Activity srcActivity, PickerIntentFactory unused, int requestCode) {
+    public void show(Activity srcActivity, int requestCode) {
         final ComponentName itemComponentName = new ComponentName(
                 mResolveInfo.activityInfo.packageName,
                 mResolveInfo.activityInfo.name);
diff --git a/src/com/android/wallpaper/model/WallpaperCategory.java b/src/com/android/wallpaper/model/WallpaperCategory.java
index 0393a48..4cadb84 100755
--- a/src/com/android/wallpaper/model/WallpaperCategory.java
+++ b/src/com/android/wallpaper/model/WallpaperCategory.java
@@ -74,9 +74,8 @@
     }
 
     @Override
-    public void show(Activity srcActivity, PickerIntentFactory factory, int requestCode) {
-        srcActivity.startActivityForResult(
-                factory.newIntent(srcActivity, getCollectionId()), requestCode);
+    public void show(Activity srcActivity, int requestCode) {
+        // No op
     }
 
     @Override
diff --git a/src/com/android/wallpaper/picker/CategoryFragment.java b/src/com/android/wallpaper/picker/CategoryFragment.java
deleted file mode 100755
index 4cbde9d..0000000
--- a/src/com/android/wallpaper/picker/CategoryFragment.java
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
- * Copyright (C) 2017 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.picker;
-
-import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED;
-import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.WallpaperColors;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.graphics.Rect;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.service.wallpaper.WallpaperService;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.cardview.widget.CardView;
-import androidx.viewpager.widget.PagerAdapter;
-import androidx.viewpager.widget.ViewPager;
-
-import com.android.wallpaper.R;
-import com.android.wallpaper.model.Category;
-import com.android.wallpaper.model.LiveWallpaperInfo;
-import com.android.wallpaper.model.WallpaperCategory;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
-import com.android.wallpaper.module.CurrentWallpaperInfoFactory.WallpaperInfoCallback;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperPersister;
-import com.android.wallpaper.module.WallpaperPreferences;
-import com.android.wallpaper.module.WallpaperPreferences.PresentationMode;
-import com.android.wallpaper.picker.CategorySelectorFragment.CategorySelectorFragmentHost;
-import com.android.wallpaper.picker.MyPhotosStarter.MyPhotosStarterProvider;
-import com.android.wallpaper.picker.MyPhotosStarter.PermissionChangedListener;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment.ThumbnailUpdater;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment.WallpaperDestinationCallback;
-import com.android.wallpaper.util.DeepLinkUtils;
-import com.android.wallpaper.util.ResourceUtils;
-import com.android.wallpaper.util.SizeCalculator;
-import com.android.wallpaper.util.WallpaperConnection;
-import com.android.wallpaper.util.WallpaperConnection.WallpaperConnectionListener;
-import com.android.wallpaper.util.WallpaperSurfaceCallback;
-import com.android.wallpaper.widget.LockScreenPreviewer;
-import com.android.wallpaper.widget.PreviewPager;
-import com.android.wallpaper.widget.WallpaperColorsLoader;
-import com.android.wallpaper.widget.WallpaperPickerRecyclerViewAccessibilityDelegate;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.MemoryCategory;
-import com.google.android.material.bottomsheet.BottomSheetBehavior;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Displays the Main UI for picking a category of wallpapers to choose from.
- */
-public class CategoryFragment extends AppbarFragment
-        implements CategorySelectorFragmentHost, ThumbnailUpdater, WallpaperDestinationCallback,
-        WallpaperPickerRecyclerViewAccessibilityDelegate.BottomSheetHost,
-        IndividualPickerFragment.IndividualPickerFragmentHost {
-
-    /**
-     * Interface to be implemented by an Activity hosting a {@link CategoryFragment}
-     */
-    public interface CategoryFragmentHost extends MyPhotosStarterProvider {
-
-        void requestExternalStoragePermission(PermissionChangedListener listener);
-
-        boolean isReadExternalStoragePermissionGranted();
-
-        void showViewOnlyPreview(WallpaperInfo wallpaperInfo, boolean isViewAsHome);
-
-        void show(String collectionId);
-
-        void fetchCategories();
-
-        void cleanUp();
-    }
-
-    public static CategoryFragment newInstance(CharSequence title) {
-        CategoryFragment fragment = new CategoryFragment();
-        fragment.setArguments(AppbarFragment.createArguments(title));
-        return fragment;
-    }
-
-    private static final String TAG = "CategoryFragment";
-
-    private static final int SETTINGS_APP_INFO_REQUEST_CODE = 1;
-
-    private static final String PERMISSION_READ_WALLPAPER_INTERNAL =
-            "android.permission.READ_WALLPAPER_INTERNAL";
-
-    private SurfaceView mWorkspaceSurface;
-    private WorkspaceSurfaceHolderCallback mWorkspaceSurfaceCallback;
-    private SurfaceView mWallpaperSurface;
-    private WallpaperSurfaceCallback mWallpaperSurfaceCallback;
-    private PreviewPager mPreviewPager;
-    private List<View> mWallPaperPreviews;
-    private WallpaperConnection mWallpaperConnection;
-    private CategorySelectorFragment mCategorySelectorFragment;
-    private IndividualPickerFragment mIndividualPickerFragment;
-    private boolean mShowSelectedWallpaper;
-    private BottomSheetBehavior<View> mBottomSheetBehavior;
-    // 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;
-    // The wallpaper information which is currently shown on the lock preview.
-    private WallpaperInfo mLockPreviewWallpaperInfo;
-
-    private LockScreenPreviewer mLockScreenPreviewer;
-    private View mRootContainer;
-
-    private final Rect mPreviewLocalRect = new Rect();
-    private final Rect mPreviewGlobalRect = new Rect();
-    private final int[] mLivePreviewLocation = new int[2];
-
-    public CategoryFragment() {
-        mCategorySelectorFragment = new CategorySelectorFragment();
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                             Bundle savedInstanceState) {
-        View view = inflater.inflate(
-                R.layout.fragment_category_picker, container, /* attachToRoot= */ false);
-
-        mWallPaperPreviews = new ArrayList<>();
-        CardView homePreviewCard = (CardView) inflater.inflate(
-                R.layout.wallpaper_preview_card, null);
-        mWorkspaceSurface = homePreviewCard.findViewById(R.id.workspace_surface);
-        mWorkspaceSurfaceCallback = new WorkspaceSurfaceHolderCallback(
-                mWorkspaceSurface, getContext());
-        mWallpaperSurface = homePreviewCard.findViewById(R.id.wallpaper_surface);
-        mWallpaperSurfaceCallback = new WallpaperSurfaceCallback(getContext(), homePreviewCard,
-                mWallpaperSurface);
-        mWallPaperPreviews.add(homePreviewCard);
-
-        CardView lockscreenPreviewCard = (CardView) inflater.inflate(
-                R.layout.wallpaper_preview_card, null);
-        lockscreenPreviewCard.findViewById(R.id.workspace_surface).setVisibility(View.GONE);
-        lockscreenPreviewCard.findViewById(R.id.wallpaper_surface).setVisibility(View.GONE);
-        ViewGroup lockPreviewContainer = lockscreenPreviewCard.findViewById(
-                R.id.lock_screen_preview_container);
-        lockPreviewContainer.setVisibility(View.VISIBLE);
-        mLockScreenPreviewer = new LockScreenPreviewer(getLifecycle(), getContext(),
-                lockPreviewContainer);
-        mWallPaperPreviews.add(lockscreenPreviewCard);
-
-        mPreviewPager = view.findViewById(R.id.wallpaper_preview_pager);
-        if (mPreviewPager.isRtl()) {
-            Collections.reverse(mWallPaperPreviews);
-        }
-        mPreviewPager.setAdapter(new PreviewPagerAdapter(mWallPaperPreviews));
-        mPreviewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
-            @Override
-            public void onPageScrolled(int position, float positionOffset,
-                    int positionOffsetPixels) {
-                // For live wallpaper, show its thumbnail when scrolling.
-                if (mWallpaperConnection != null && mWallpaperConnection.isEngineReady()
-                        && mHomePreviewWallpaperInfo instanceof LiveWallpaperInfo) {
-                    if (positionOffset == 0.0f || positionOffset == 1.0f
-                            || positionOffsetPixels == 0) {
-                        // The page is not moved. Show live wallpaper.
-                        mWallpaperSurface.setZOrderMediaOverlay(false);
-                    } else {
-                        // The page is moving. Show live wallpaper's thumbnail.
-                        mWallpaperSurface.setZOrderMediaOverlay(true);
-                    }
-                }
-            }
-
-            @Override
-            public void onPageSelected(int i) {
-                mWallpaperIndex = mPreviewPager.isRtl()
-                        ? (mWallPaperPreviews.size() - 1) - i
-                        : i;
-                if (mIndividualPickerFragment != null && mIndividualPickerFragment.isVisible()) {
-                    mIndividualPickerFragment.highlightAppliedWallpaper(mWallpaperIndex);
-                }
-            }
-
-            @Override
-            public void onPageScrollStateChanged(int i) {
-            }
-        });
-        setupCurrentWallpaperPreview(view);
-
-        ViewGroup fragmentContainer = view.findViewById(R.id.category_fragment_container);
-        mBottomSheetBehavior = BottomSheetBehavior.from(fragmentContainer);
-        mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
-            @Override
-            public void onStateChanged(@NonNull View bottomSheet, int newState) {
-                // Update preview pager's accessibility param since it will be blocked by the
-                // bottom sheet when expanded.
-                mPreviewPager.setImportantForAccessibility(newState == STATE_EXPANDED
-                        ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
-                        : View.IMPORTANT_FOR_ACCESSIBILITY_YES);
-            }
-
-            @Override
-            public void onSlide(@NonNull View bottomSheet, float slideOffset) {}
-        });
-        mRootContainer = view.findViewById(R.id.root_container);
-        fragmentContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
-            @Override
-            public void onLayoutChange(View containerView, int left, int top, int right,
-                    int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
-                int minimumHeight = mRootContainer.getHeight() - mPreviewPager.getMeasuredHeight();
-                mBottomSheetBehavior.setPeekHeight(minimumHeight);
-                containerView.setMinimumHeight(minimumHeight);
-                homePreviewCard.setRadius(SizeCalculator.getPreviewCornerRadius(
-                                getActivity(), homePreviewCard.getMeasuredWidth()));
-                if (lockscreenPreviewCard != null) {
-                    lockscreenPreviewCard
-                            .setRadius(SizeCalculator.getPreviewCornerRadius(
-                                    getActivity(), lockPreviewContainer.getMeasuredWidth()));
-                }
-            }});
-        fragmentContainer.setOnApplyWindowInsetsListener((v, windowInsets) -> {
-            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
-                    windowInsets.getSystemWindowInsetBottom());
-            return windowInsets;
-        });
-
-        setUpToolbar(view);
-
-        getChildFragmentManager()
-                .beginTransaction()
-                .replace(R.id.category_fragment_container, mCategorySelectorFragment)
-                .commitNow();
-
-        // Deep link case
-        Intent intent = getActivity().getIntent();
-        String deepLinkCollectionId = DeepLinkUtils.getCollectionId(intent);
-        if (!TextUtils.isEmpty(deepLinkCollectionId)) {
-            mIndividualPickerFragment = InjectorProvider.getInjector()
-                    .getIndividualPickerFragment(deepLinkCollectionId);
-            mIndividualPickerFragment.highlightAppliedWallpaper(mWallpaperIndex);
-            getChildFragmentManager()
-                    .beginTransaction()
-                    .replace(R.id.category_fragment_container, mIndividualPickerFragment)
-                    .addToBackStack(null)
-                    .commit();
-            getChildFragmentManager().executePendingTransactions();
-            intent.setData(null);
-        }
-        return view;
-    }
-
-    @Override
-    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
-        updateWallpaperSurface();
-        updateWorkspaceSurface();
-    }
-
-    @Override
-    public CharSequence getDefaultTitle() {
-        return getContext().getString(R.string.app_name);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        WallpaperPreferences preferences = InjectorProvider.getInjector().getPreferences(getActivity());
-        preferences.setLastAppActiveTimestamp(new Date().getTime());
-
-        // Reset Glide memory settings to a "normal" level of usage since it may have been lowered in
-        // PreviewFragment.
-        Glide.get(getActivity()).setMemoryCategory(MemoryCategory.NORMAL);
-
-        // The wallpaper may have been set while this fragment was paused, so force refresh the current
-        // wallpapers and presentation mode.
-        if (!mShowSelectedWallpaper) {
-            refreshCurrentWallpapers(/* forceRefresh= */ true);
-        }
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.setVisibility(true);
-        }
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.setVisibility(false);
-        }
-    }
-
-    @Override
-    public void onStop() {
-        super.onStop();
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.disconnect();
-            mWallpaperConnection = null;
-        }
-    }
-
-    @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-        mWallpaperSurfaceCallback.cleanUp();
-        mWorkspaceSurfaceCallback.cleanUp();
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.disconnect();
-            mWallpaperConnection = null;
-        }
-        mPreviewPager.setAdapter(null);
-        mWallPaperPreviews.forEach(view -> ((ViewGroup) view).removeAllViews());
-        mWallPaperPreviews.clear();
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.disconnect();
-            mWallpaperConnection = null;
-        }
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == SETTINGS_APP_INFO_REQUEST_CODE) {
-            mCategorySelectorFragment.notifyDataSetChanged();
-        }
-    }
-
-    @Override
-    public void requestCustomPhotoPicker(PermissionChangedListener listener) {
-        getFragmentHost().getMyPhotosStarter().requestCustomPhotoPicker(listener);
-    }
-
-    @Override
-    public void show(Category category) {
-        if (!(category instanceof WallpaperCategory)) {
-            getFragmentHost().show(category.getCollectionId());
-            return;
-        }
-        mIndividualPickerFragment = InjectorProvider.getInjector()
-                .getIndividualPickerFragment(category.getCollectionId());
-        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
-            // BottomSheet's collapsing can be executed together instead of scrolling
-            // the RecyclerView after the BottomSheet is collapsed.
-            mIndividualPickerFragment.resizeLayout(mBottomSheetBehavior.getPeekHeight());
-            mIndividualPickerFragment.scrollToPosition(position);
-            if (mBottomSheetBehavior.getState() != STATE_COLLAPSED) {
-                mBottomSheetBehavior.setState(STATE_COLLAPSED);
-            }
-        });
-        getChildFragmentManager()
-                .beginTransaction()
-                .replace(R.id.category_fragment_container, mIndividualPickerFragment)
-                .addToBackStack(null)
-                .commit();
-        getChildFragmentManager().executePendingTransactions();
-    }
-
-    @Override
-    public boolean isHostToolbarShown() {
-        return true;
-    }
-
-    @Override
-    public void setToolbarTitle(CharSequence title) {
-        setTitle(title);
-    }
-
-    @Override
-    public void setToolbarMenu(int menuResId) {
-        setUpToolbarMenu(menuResId);
-    }
-
-    @Override
-    public void removeToolbarMenu() {
-        mToolbar.getMenu().clear();
-    }
-
-    @Override
-    public void moveToPreviousFragment() {
-        getChildFragmentManager().popBackStack();
-    }
-
-    @Override
-    public void fetchCategories() {
-        getFragmentHost().fetchCategories();
-    }
-
-    @Override
-    public void cleanUp() {
-        getFragmentHost().cleanUp();
-    }
-
-    @Override
-    public void expandBottomSheet() {
-        if (mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
-            mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
-        }
-    }
-
-    @Override
-    public int getBottomSheetState() {
-        return mBottomSheetBehavior.getState();
-    }
-
-    @Override
-    public void updateThumbnail(WallpaperInfo wallpaperInfo) {
-        new android.os.Handler().post(() -> {
-            // A config change may have destroyed the activity since the refresh started, so check
-            // for that.
-            if (getActivity() == null) {
-                return;
-            }
-
-            mHomePreviewWallpaperInfo = wallpaperInfo;
-            mLockPreviewWallpaperInfo = wallpaperInfo;
-            updateThumbnail(mHomePreviewWallpaperInfo,
-                    mWallpaperSurfaceCallback.getHomeImageWallpaper(), true);
-            mShowSelectedWallpaper = true;
-        });
-    }
-
-    @Override
-    public void restoreThumbnails() {
-        refreshCurrentWallpapers(/* forceRefresh= */ true);
-        mShowSelectedWallpaper = false;
-    }
-
-    @Override
-    public void onDestinationSet(@WallpaperPersister.Destination int destination) {
-        if (destination == WallpaperPersister.DEST_BOTH) {
-            return;
-        }
-        mPreviewPager.switchPreviewPage(destination);
-    }
-
-    @Override
-    public boolean onMenuItemClick(MenuItem item) {
-        if (item.getItemId() == R.id.daily_rotation) {
-            if (mIndividualPickerFragment != null && mIndividualPickerFragment.isVisible()) {
-                mIndividualPickerFragment.showRotationDialog();
-            }
-            return true;
-        }
-        return super.onMenuItemClick(item);
-    }
-
-    /**
-     * Gets the {@link CategorySelectorFragment} which is attached to {@link CategoryFragment}.
-     */
-    public CategorySelectorFragment getCategorySelectorFragment() {
-        return mCategorySelectorFragment;
-    }
-
-    /**
-     * Pops the child fragment from the stack if {@link CategoryFragment} is visible to the users.
-     *
-     * @return {@code true} if the child fragment is popped, {@code false} otherwise.
-     */
-    public boolean popChildFragment() {
-        return isVisible() && getChildFragmentManager().popBackStackImmediate();
-    }
-
-    private boolean canShowCurrentWallpaper() {
-        Activity activity = getActivity();
-        CategoryFragmentHost host = getFragmentHost();
-        PackageManager packageManager = activity.getPackageManager();
-        String packageName = activity.getPackageName();
-
-        boolean hasReadWallpaperInternal = packageManager.checkPermission(
-                PERMISSION_READ_WALLPAPER_INTERNAL, packageName) == PackageManager.PERMISSION_GRANTED;
-        return hasReadWallpaperInternal || host.isReadExternalStoragePermissionGranted();
-    }
-
-    private void showCurrentWallpaper(View rootView, boolean show) {
-        // The category/wallpaper tiles page depends on the height of the preview pager.
-        // So if we want to hide the preview pager, we should use INVISIBLE instead of GONE.
-        rootView.findViewById(R.id.wallpaper_preview_pager)
-                .setVisibility(show ? View.VISIBLE : View.INVISIBLE);
-        rootView.findViewById(R.id.permission_needed)
-                .setVisibility(show ? View.GONE : View.VISIBLE);
-    }
-
-    private void setupCurrentWallpaperPreview(View rootView) {
-        if (canShowCurrentWallpaper()) {
-            showCurrentWallpaper(rootView, true);
-        } else {
-            showCurrentWallpaper(rootView, false);
-
-            Button mAllowAccessButton = rootView
-                    .findViewById(R.id.permission_needed_allow_access_button);
-            mAllowAccessButton.setOnClickListener(view ->
-                    getFragmentHost().requestExternalStoragePermission(
-                            new PermissionChangedListener() {
-
-                                @Override
-                                public void onPermissionsGranted() {
-                                    showCurrentWallpaper(rootView, true);
-                                    mCategorySelectorFragment.notifyDataSetChanged();
-                                }
-
-                                @Override
-                                public void onPermissionsDenied(boolean dontAskAgain) {
-                                    if (!dontAskAgain) {
-                                        return;
-                                    }
-                                    showPermissionNeededDialog();
-                                }
-                            })
-            );
-
-            // Replace explanation text with text containing the Wallpapers app name which replaces
-            // the placeholder.
-            String appName = getString(R.string.app_name);
-            String explanation = getString(R.string.permission_needed_explanation, appName);
-            TextView explanationView = rootView.findViewById(R.id.permission_needed_explanation);
-            explanationView.setText(explanation);
-        }
-    }
-
-    private void showPermissionNeededDialog() {
-        String permissionNeededMessage = getString(
-                R.string.permission_needed_explanation_go_to_settings);
-        AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.LightDialogTheme)
-                .setMessage(permissionNeededMessage)
-                .setPositiveButton(android.R.string.ok, /* onClickListener= */ null)
-                .setNegativeButton(
-                        R.string.settings_button_label,
-                        (dialogInterface, i) -> {
-                            Intent appInfoIntent = new Intent();
-                            appInfoIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
-                            Uri uri = Uri.fromParts("package",
-                                    getActivity().getPackageName(), /* fragment= */ null);
-                            appInfoIntent.setData(uri);
-                            startActivityForResult(appInfoIntent, SETTINGS_APP_INFO_REQUEST_CODE);
-                        })
-                .create();
-        dialog.show();
-    }
-
-    private CategoryFragmentHost getFragmentHost() {
-        return (CategoryFragmentHost) getActivity();
-    }
-
-    private Intent getWallpaperIntent(android.app.WallpaperInfo info) {
-        return new Intent(WallpaperService.SERVICE_INTERFACE)
-                .setClassName(info.getPackageName(), info.getServiceName());
-    }
-
-    /**
-     * Obtains the {@link WallpaperInfo} object(s) representing the wallpaper(s) currently set to
-     * the device from the {@link CurrentWallpaperInfoFactory}.
-     */
-    private void refreshCurrentWallpapers(boolean forceRefresh) {
-        CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
-                .getCurrentWallpaperFactory(getActivity().getApplicationContext());
-
-        factory.createCurrentWallpaperInfos(new WallpaperInfoCallback() {
-            @Override
-            public void onWallpaperInfoCreated(
-                    final WallpaperInfo homeWallpaper,
-                    @Nullable final WallpaperInfo lockWallpaper,
-                    @PresentationMode final int presentationMode) {
-
-                // Update the metadata displayed on screen. Do this in a Handler so it is scheduled at the
-                // end of the message queue. This is necessary to ensure we do not remove or add data from
-                // the adapter while the layout is being computed. RecyclerView documentation therefore
-                // recommends performing such changes in a Handler.
-                new android.os.Handler().post(new Runnable() {
-                    @Override
-                    public void run() {
-                        final Activity activity = getActivity();
-                        // A config change may have destroyed the activity since the refresh
-                        // started, so check for that.
-                        if (activity == null) {
-                            return;
-                        }
-
-                        mHomePreviewWallpaperInfo = homeWallpaper;
-                        mLockPreviewWallpaperInfo =
-                                lockWallpaper == null ? homeWallpaper : lockWallpaper;
-                        updateThumbnail(mHomePreviewWallpaperInfo,
-                                mWallpaperSurfaceCallback.getHomeImageWallpaper(), true);
-                    }
-                });
-            }
-        }, forceRefresh);
-    }
-
-    private void setUpLiveWallpaperPreview(WallpaperInfo homeWallpaper) {
-        Activity activity = getActivity();
-        if (activity == null) {
-            return;
-        }
-        if (mWallpaperConnection != null) {
-            mWallpaperConnection.disconnect();
-        }
-
-        if (WallpaperConnection.isPreviewAvailable()) {
-            ImageView previewView = mWallpaperSurfaceCallback.getHomeImageWallpaper();
-            mWallpaperConnection = new WallpaperConnection(
-                    getWallpaperIntent(homeWallpaper.getWallpaperComponent()), activity,
-                    new WallpaperConnectionListener() {
-                        @Override
-                        public void onWallpaperColorsChanged(WallpaperColors colors,
-                                int displayId) {
-                            if (mLockPreviewWallpaperInfo instanceof LiveWallpaperInfo) {
-                                mLockScreenPreviewer.setColor(colors);
-                            }
-                        }
-                    }, mWallpaperSurface);
-
-
-            mWallpaperConnection.setVisibility(true);
-            previewView.post(() -> {
-                if (mWallpaperConnection != null && !mWallpaperConnection.connect()) {
-                    mWallpaperConnection = null;
-                }
-            });
-        }
-    }
-
-    private void updateThumbnail(WallpaperInfo wallpaperInfo, ImageView thumbnailView,
-                                 boolean isHomeWallpaper) {
-        if (wallpaperInfo == null) {
-            return;
-        }
-
-        if (thumbnailView == null) {
-            return;
-        }
-
-        Activity activity = getActivity();
-        if (activity == null) {
-            return;
-        }
-
-        UserEventLogger eventLogger = InjectorProvider.getInjector().getUserEventLogger(activity);
-
-        boolean renderInImageWallpaperSurface =
-                !(wallpaperInfo instanceof LiveWallpaperInfo) && isHomeWallpaper;
-        ImageView imageView = renderInImageWallpaperSurface
-                ? mWallpaperSurfaceCallback.getHomeImageWallpaper() : thumbnailView;
-        if (imageView != null) {
-            wallpaperInfo.getThumbAsset(activity.getApplicationContext())
-                    .loadPreviewImage(activity, imageView,
-                            ResourceUtils.getColorAttr(
-                                    getActivity(), android.R.attr.colorSecondary));
-        }
-
-        if (isHomeWallpaper) {
-            if (wallpaperInfo instanceof LiveWallpaperInfo) {
-                if (mWallpaperSurfaceCallback.getHomeImageWallpaper() != null) {
-                    wallpaperInfo.getThumbAsset(activity.getApplicationContext()).loadPreviewImage(
-                            activity, mWallpaperSurfaceCallback.getHomeImageWallpaper(),
-                            ResourceUtils.getColorAttr(
-                                    getActivity(), android.R.attr.colorSecondary));
-                }
-                setUpLiveWallpaperPreview(wallpaperInfo);
-            } else {
-                if (mWallpaperConnection != null) {
-                    mWallpaperConnection.disconnect();
-                    mWallpaperConnection = null;
-                }
-            }
-        } else {
-            // lock screen wallpaper
-            if (!(wallpaperInfo instanceof LiveWallpaperInfo)
-                    || !WallpaperConnection.isPreviewAvailable()) {
-                // Load wallpaper color from thumbnail for static wallpaper.
-                WallpaperColorsLoader.getWallpaperColors(
-                        activity,
-                        wallpaperInfo.getThumbAsset(activity),
-                        mLockScreenPreviewer::setColor);
-            }
-        }
-
-        ((View) thumbnailView.getParent()).setOnClickListener(view -> {
-            getFragmentHost().showViewOnlyPreview(wallpaperInfo, isHomeWallpaper);
-            eventLogger.logCurrentWallpaperPreviewed();
-        });
-    }
-
-    private void updateWallpaperSurface() {
-        mWallpaperSurface.getHolder().addCallback(mWallpaperSurfaceCallback);
-        mWallpaperSurface.setZOrderMediaOverlay(true);
-    }
-
-    private void updateWorkspaceSurface() {
-        mWorkspaceSurface.setZOrderMediaOverlay(true);
-        mWorkspaceSurface.getHolder().addCallback(mWorkspaceSurfaceCallback);
-    }
-
-    private static class PreviewPagerAdapter extends PagerAdapter {
-
-        private List<View> mPages;
-
-        PreviewPagerAdapter(List<View> pages) {
-            mPages = pages;
-        }
-
-        @Override
-        public void destroyItem(@NonNull ViewGroup container, int position,
-                                @NonNull Object object) {
-            container.removeView((View) object);
-        }
-
-        @NonNull
-        @Override
-        public Object instantiateItem(@NonNull ViewGroup container, int position) {
-            View view = mPages.get(position);
-            container.addView(view);
-            return view;
-        }
-
-        @Override
-        public int getCount() {
-            return mPages.size();
-        }
-
-        @Override
-        public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
-            return view == o;
-        }
-    }
-}
diff --git a/src/com/android/wallpaper/picker/CategorySelectorFragment.java b/src/com/android/wallpaper/picker/CategorySelectorFragment.java
index a611d48..f2b1157 100644
--- a/src/com/android/wallpaper/picker/CategorySelectorFragment.java
+++ b/src/com/android/wallpaper/picker/CategorySelectorFragment.java
@@ -243,8 +243,7 @@
     }
 
     /**
-     * Notifies the CategoryFragment that no further categories are expected so it may hide
-     * the loading indicator.
+     * Notifies that no further categories are expected so it may hide the loading indicator.
      */
     void doneFetchingCategories() {
         if (mAwaitingCategories) {
diff --git a/src/com/android/wallpaper/picker/CustomizationPickerActivity.java b/src/com/android/wallpaper/picker/CustomizationPickerActivity.java
index f9ceed0..f76c09b 100644
--- a/src/com/android/wallpaper/picker/CustomizationPickerActivity.java
+++ b/src/com/android/wallpaper/picker/CustomizationPickerActivity.java
@@ -48,7 +48,6 @@
 import com.android.wallpaper.module.NetworkStatusNotifier.NetworkStatus;
 import com.android.wallpaper.module.UserEventLogger;
 import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
-import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
 import com.android.wallpaper.picker.CategorySelectorFragment.CategorySelectorFragmentHost;
 import com.android.wallpaper.picker.MyPhotosStarter.PermissionChangedListener;
 import com.android.wallpaper.picker.individual.IndividualPickerFragment.IndividualPickerFragmentHost;
@@ -63,9 +62,9 @@
  *  Fragments providing customization options.
  */
 public class CustomizationPickerActivity extends FragmentActivity implements AppbarFragmentHost,
-        WallpapersUiContainer, CategoryFragmentHost, BottomActionBarHost,
-        FragmentTransactionChecker, PermissionRequester, CategorySelectorFragmentHost,
-        IndividualPickerFragmentHost, WallpaperPreviewNavigator {
+        WallpapersUiContainer, BottomActionBarHost, FragmentTransactionChecker,
+        PermissionRequester, CategorySelectorFragmentHost, IndividualPickerFragmentHost,
+        WallpaperPreviewNavigator {
 
     private static final String TAG = "CustomizationPickerActivity";
 
@@ -218,21 +217,11 @@
     }
 
     @Override
-    public boolean isReadExternalStoragePermissionGranted() {
-        return mDelegate.isReadExternalStoragePermissionGranted();
-    }
-
-    @Override
     public void showViewOnlyPreview(WallpaperInfo wallpaperInfo, boolean isViewAsHome) {
         mDelegate.showViewOnlyPreview(wallpaperInfo, isViewAsHome);
     }
 
     @Override
-    public void show(String collectionId) {
-        mDelegate.show(collectionId);
-    }
-
-    @Override
     public void requestCustomPhotoPicker(PermissionChangedListener listener) {
         mDelegate.requestCustomPhotoPicker(listener);
     }
@@ -240,7 +229,7 @@
     @Override
     public void show(Category category) {
         if (!(category instanceof WallpaperCategory)) {
-            show(category.getCollectionId());
+            mDelegate.show(category.getCollectionId());
             return;
         }
         switchFragmentWithBackStack(InjectorProvider.getInjector().getIndividualPickerFragment(
@@ -316,11 +305,6 @@
     }
 
     @Override
-    public MyPhotosStarter getMyPhotosStarter() {
-        return mDelegate;
-    }
-
-    @Override
     protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         if (mDelegate.handleActivityResult(requestCode, resultCode, data)) {
diff --git a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
deleted file mode 100755
index 191a39f..0000000
--- a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
+++ /dev/null
@@ -1,1168 +0,0 @@
-/*
- * Copyright (C) 2017 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.picker;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Color;
-import android.graphics.Insets;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.WindowInsets;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.android.wallpaper.R;
-import com.android.wallpaper.asset.Asset;
-import com.android.wallpaper.compat.ButtonDrawableSetterCompat;
-import com.android.wallpaper.config.Flags;
-import com.android.wallpaper.model.Category;
-import com.android.wallpaper.model.ImageWallpaperInfo;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
-import com.android.wallpaper.module.CurrentWallpaperInfoFactory.WallpaperInfoCallback;
-import com.android.wallpaper.module.DailyLoggingAlarmScheduler;
-import com.android.wallpaper.module.ExploreIntentChecker;
-import com.android.wallpaper.module.FormFactorChecker;
-import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.NetworkStatusNotifier;
-import com.android.wallpaper.module.NetworkStatusNotifier.NetworkStatus;
-import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.UserEventLogger.WallpaperSetFailureReason;
-import com.android.wallpaper.module.WallpaperPersister;
-import com.android.wallpaper.module.WallpaperPersister.Destination;
-import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback;
-import com.android.wallpaper.module.WallpaperPersister.WallpaperPosition;
-import com.android.wallpaper.module.WallpaperPreferences;
-import com.android.wallpaper.module.WallpaperPreferences.PresentationMode;
-import com.android.wallpaper.module.WallpaperRotationRefresher;
-import com.android.wallpaper.module.WallpaperRotationRefresher.Listener;
-import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
-import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
-import com.android.wallpaper.picker.WallpaperDisabledFragment.WallpaperSupportLevel;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment;
-import com.android.wallpaper.util.ActivityUtils;
-import com.android.wallpaper.util.ResourceUtils;
-import com.android.wallpaper.util.ScreenSizeCalculator;
-import com.android.wallpaper.util.ThrowableAnalyzer;
-
-import com.google.android.material.bottomsheet.BottomSheetBehavior;
-import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback;
-import com.google.android.material.tabs.TabLayout;
-import com.google.android.material.tabs.TabLayout.OnTabSelectedListener;
-import com.google.android.material.tabs.TabLayout.Tab;
-
-import java.util.List;
-
-/**
- * Activity allowing users to select a category of wallpapers to choose from.
- */
-public class TopLevelPickerActivity extends BaseActivity implements WallpapersUiContainer,
-        CurrentWallpaperBottomSheetPresenter, SetWallpaperErrorDialogFragment.Listener,
-        MyPhotosStarter, AppbarFragmentHost, CategoryFragmentHost {
-
-    private static final String TAG_SET_WALLPAPER_ERROR_DIALOG_FRAGMENT =
-            "toplevel_set_wallpaper_error_dialog";
-
-    private static final String TAG = "TopLevelPicker";
-    private static final String KEY_SELECTED_CATEGORY_TAB = "selected_category_tab";
-
-    private WallpaperPickerDelegate mDelegate;
-    private int mLastSelectedCategoryTabIndex;
-    private UserEventLogger mUserEventLogger;
-    private NetworkStatusNotifier mNetworkStatusNotifier;
-    private NetworkStatusNotifier.Listener mNetworkStatusListener;
-    private WallpaperPersister mWallpaperPersister;
-    private WallpaperPreferences mWallpaperPreferences;
-    private boolean mWasCustomPhotoWallpaperSet;
-    @WallpaperPosition
-    private int mCustomPhotoWallpaperPosition;
-
-    /**
-     * Progress dialogs for "refresh daily wallpaper" and "set wallpaper" operations.
-     */
-    private ProgressDialog mRefreshWallpaperProgressDialog;
-    private ProgressDialog mSetWallpaperProgressDialog;
-
-    /**
-     * Designates a test mode of operation -- in which certain UI features are disabled to allow for
-     * UI tests to run correctly.
-     */
-    private boolean mTestingMode;
-
-    /**
-     * UI for the "currently set wallpaper" BottomSheet.
-     */
-    private LinearLayout mBottomSheet;
-    private ImageView mCurrentWallpaperImage;
-    private TextView mCurrentWallpaperPresentationMode;
-    private TextView mCurrentWallpaperTitle;
-    private TextView mCurrentWallpaperSubtitle;
-    private Button mCurrentWallpaperExploreButton;
-    private Button mCurrentWallpaperSkipWallpaperButton;
-    private FrameLayout mFragmentContainer;
-    private FrameLayout mLoadingIndicatorContainer;
-    private LinearLayout mWallpaperPositionOptions;
-
-    /**
-     * Staged error dialog fragments that were unable to be shown when the activity didn't allow
-     * committing fragment transactions.
-     */
-    private SetWallpaperErrorDialogFragment mStagedSetWallpaperErrorDialogFragment;
-
-    /**
-     * A wallpaper pending set to the device--we retain a reference to this in order to facilitate
-     * retry or re-crop operations.
-     */
-    private WallpaperInfo mPendingSetWallpaperInfo;
-
-    private int getTextColorForWallpaperPositionButton(boolean isSelected) {
-        int textColorId = isSelected
-                ? android.R.attr.colorAccent
-                : android.R.attr.textColorTertiary;
-        return ResourceUtils.getColorAttr(this, textColorId);
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        mLastSelectedCategoryTabIndex = -1;
-
-        Injector injector = InjectorProvider.getInjector();
-        mDelegate = new WallpaperPickerDelegate(this, this, injector);
-        mUserEventLogger = injector.getUserEventLogger(this);
-        mNetworkStatusNotifier = injector.getNetworkStatusNotifier(this);
-        mWallpaperPersister = injector.getWallpaperPersister(this);
-        mWallpaperPreferences = injector.getPreferences(this);
-        mWasCustomPhotoWallpaperSet = false;
-
-        mDelegate.getCategoryProvider().resetIfNeeded();
-
-        @WallpaperSupportLevel int wallpaperSupportLevel = mDelegate.getWallpaperSupportLevel();
-        if (wallpaperSupportLevel != WallpaperDisabledFragment.SUPPORTED_CAN_SET) {
-            setContentView(R.layout.activity_top_level_picker);
-
-            FragmentManager fm = getSupportFragmentManager();
-            WallpaperDisabledFragment wallpaperDisabledFragment =
-                    WallpaperDisabledFragment.newInstance(wallpaperSupportLevel);
-            fm.beginTransaction()
-                    .add(R.id.fragment_container, wallpaperDisabledFragment)
-                    .commit();
-            return;
-        }
-
-        if (mDelegate.getFormFactor() == FormFactorChecker.FORM_FACTOR_MOBILE) {
-            initializeMobile(true /* shouldForceRefresh */);
-        } else { // DESKTOP
-            initializeDesktop(savedInstanceState);
-        }
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        boolean provisioned = Settings.Global.getInt(getContentResolver(),
-                Settings.Global.DEVICE_PROVISIONED, 0) != 0;
-
-        mUserEventLogger.logResumed(provisioned, true);
-        // Show the staged 'load wallpaper' or 'set wallpaper' error dialog fragments if there is one
-        // that was unable to be shown earlier when this fragment's hosting activity didn't allow
-        // committing fragment transactions.
-        if (mStagedSetWallpaperErrorDialogFragment != null) {
-            mStagedSetWallpaperErrorDialogFragment.show(
-                    getSupportFragmentManager(), TAG_SET_WALLPAPER_ERROR_DIALOG_FRAGMENT);
-            mStagedSetWallpaperErrorDialogFragment = null;
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        mUserEventLogger.logStopped();
-        super.onStop();
-    }
-
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        mDelegate.cleanUp();
-        if (mNetworkStatusListener != null) {
-            mNetworkStatusNotifier.unregisterListener(mNetworkStatusListener);
-        }
-
-        if (mRefreshWallpaperProgressDialog != null) {
-            mRefreshWallpaperProgressDialog.dismiss();
-        }
-        if (mSetWallpaperProgressDialog != null) {
-            mSetWallpaperProgressDialog.dismiss();
-        }
-    }
-
-    @Override
-    public void onBackPressed() {
-        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
-        if (fragment != null && fragment.getChildFragmentManager().popBackStackImmediate()) {
-            return;
-        }
-        super.onBackPressed();
-    }
-
-    @Override
-    public void requestCustomPhotoPicker(PermissionChangedListener listener) {
-        mDelegate.requestCustomPhotoPicker(listener);
-    }
-
-    @Override
-    public void requestExternalStoragePermission(PermissionChangedListener listener) {
-        mDelegate.requestExternalStoragePermission(listener);
-    }
-
-    /**
-     * Returns whether READ_EXTERNAL_STORAGE has been granted for the application.
-     */
-    public boolean isReadExternalStoragePermissionGranted() {
-        return mDelegate.isReadExternalStoragePermissionGranted();
-    }
-
-    private void initializeMobile(boolean shouldForceRefresh) {
-        setContentView(R.layout.activity_top_level_picker);
-        if (ActivityUtils.isSUWMode(getBaseContext())) {
-            findViewById(R.id.fragment_main).setFitsSystemWindows(/* fitSystemWindows= */ true);
-        }
-        getWindow().getDecorView().setSystemUiVisibility(
-                getWindow().getDecorView().getSystemUiVisibility()
-                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
-                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
-        View fragmentContainer = findViewById(R.id.fragment_container);
-        fragmentContainer.setOnApplyWindowInsetsListener((view, windowInsets) -> {
-            view.setPadding(view.getPaddingLeft(), windowInsets.getSystemWindowInsetTop(),
-                    view.getPaddingRight(), view.getPaddingBottom());
-            // Consume only the top inset (status bar), to let other content in the Activity consume
-            // the nav bar (ie, by using "fitSystemWindows")
-            if (VERSION.SDK_INT >= VERSION_CODES.Q) {
-                WindowInsets.Builder builder = new WindowInsets.Builder(windowInsets);
-                builder.setSystemWindowInsets(Insets.of(windowInsets.getSystemWindowInsetLeft(),
-                        0, windowInsets.getStableInsetRight(),
-                        windowInsets.getSystemWindowInsetBottom()));
-                return builder.build();
-            } else {
-                return windowInsets.replaceSystemWindowInsets(
-                        windowInsets.getSystemWindowInsetLeft(),
-                        0, windowInsets.getStableInsetRight(),
-                        windowInsets.getSystemWindowInsetBottom());
-            }
-        });
-
-        // Set toolbar as the action bar.
-        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
-        setSupportActionBar(toolbar);
-
-        FragmentManager fm = getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
-        if (fragment == null) {
-            // App launch specific logic: log the "app launch source" event.
-            mUserEventLogger.logAppLaunched(getIntent());
-            mWallpaperPreferences.incrementAppLaunched();
-            DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
-
-            CategoryFragment newFragment = CategoryFragment.newInstance(
-                    getString(R.string.wallpaper_app_name));
-            fm.beginTransaction()
-                    .add(R.id.fragment_container, newFragment)
-                    .commit();
-        }
-    }
-
-    private void initializeDesktop(Bundle savedInstanceState) {
-        setContentView(R.layout.activity_top_level_desktop);
-
-        mBottomSheet = (LinearLayout) findViewById(R.id.bottom_sheet);
-        mCurrentWallpaperImage = (ImageView) mBottomSheet.findViewById(R.id.current_wallpaper_image);
-        mCurrentWallpaperImage.getLayoutParams().width = getSingleWallpaperImageWidthPx();
-
-        mCurrentWallpaperPresentationMode =
-                (TextView) mBottomSheet.findViewById(R.id.current_wallpaper_presentation_mode);
-        mCurrentWallpaperTitle = (TextView) findViewById(R.id.current_wallpaper_title);
-        mCurrentWallpaperSubtitle = (TextView) findViewById(R.id.current_wallpaper_subtitle);
-        mCurrentWallpaperExploreButton = (Button) findViewById(
-                R.id.current_wallpaper_explore_button);
-        mCurrentWallpaperSkipWallpaperButton = (Button) findViewById(
-                R.id.current_wallpaper_skip_wallpaper_button);
-        mFragmentContainer = (FrameLayout) findViewById(R.id.fragment_container);
-        mLoadingIndicatorContainer = (FrameLayout) findViewById(R.id.loading_indicator_container);
-        mWallpaperPositionOptions = (LinearLayout) findViewById(
-                R.id.desktop_wallpaper_position_options);
-
-        final TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
-        tabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {
-            @Override
-            public void onTabSelected(Tab tab) {
-                Category category = (Category) tab.getTag();
-                showCategoryDesktop(category.getCollectionId());
-                mLastSelectedCategoryTabIndex = tabLayout.getSelectedTabPosition();
-            }
-
-            @Override
-            public void onTabUnselected(Tab tab) {
-            }
-
-            @Override
-            public void onTabReselected(Tab tab) {
-                Category category = (Category) tab.getTag();
-                // If offline, "My photos" may be the only visible category. In this case we want to allow
-                // re-selection so user can still select a photo as wallpaper while offline.
-                if (!category.isEnumerable()) {
-                    onTabSelected(tab);
-                }
-            }
-        });
-
-        FragmentManager fm = getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
-        if (fragment == null) {
-            // App launch specific logic: log the "app launch source" event.
-            mUserEventLogger.logAppLaunched(getIntent());
-            mWallpaperPreferences.incrementAppLaunched();
-            DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
-        }
-
-        mNetworkStatusListener = new NetworkStatusNotifier.Listener() {
-            @Override
-            public void onNetworkChanged(@NetworkStatus int networkStatus) {
-                initializeDesktopBasedOnNetwork(networkStatus, savedInstanceState);
-            }
-        };
-        // Upon registering a listener, the onNetworkChanged method is immediately called with the
-        // initial network status.
-        mNetworkStatusNotifier.registerListener(mNetworkStatusListener);
-    }
-
-    private void initializeDesktopBasedOnNetwork(@NetworkStatus int networkStatus,
-                                                 Bundle savedInstanceState) {
-        if (networkStatus == NetworkStatusNotifier.NETWORK_CONNECTED) {
-            initializeDesktopOnline(savedInstanceState);
-        } else {
-            initializeDesktopOffline();
-        }
-    }
-
-    private void initializeDesktopOnline(Bundle savedInstanceState) {
-        FragmentManager fm = getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
-        // Require a category refresh if this is the first load of the app or if the app is now
-        // returning online after having been offline.
-        boolean forceCategoryRefresh = fragment == null || fragment instanceof OfflineDesktopFragment;
-
-        if (fragment != null) {
-            fm.beginTransaction()
-                    .remove(fragment)
-                    .commit();
-        }
-
-        mLastSelectedCategoryTabIndex = savedInstanceState != null
-                ? savedInstanceState.getInt(KEY_SELECTED_CATEGORY_TAB) : -1;
-        mDelegate.populateCategories(forceCategoryRefresh);
-
-        setDesktopLoading(true);
-        setUpBottomSheet();
-        refreshCurrentWallpapers(null /* refreshListener */);
-    }
-
-    private void initializeDesktopOffline() {
-        FragmentManager fm = getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
-        if (fragment != null) {
-            fm.beginTransaction()
-                    .remove(fragment)
-                    .commit();
-        }
-        OfflineDesktopFragment newFragment = new OfflineDesktopFragment();
-        fm.beginTransaction()
-                .add(R.id.fragment_container, newFragment)
-                .commit();
-
-        // Reset the last selected category tab index to ensure the app doesn't try to reselect a
-        // tab for a category not yet repopulated.
-        mLastSelectedCategoryTabIndex = -1;
-
-        mDelegate.populateCategories(/* forceRefresh= */ true);
-
-        setDesktopLoading(false);
-        setCurrentWallpapersExpanded(false);
-    }
-
-    /**
-     * Sets the status of the loading indicator overlay in desktop mode.
-     *
-     * @param loading Whether an indeterminate loading indicator is displayed in place of the main
-     *                fragment.
-     */
-    private void setDesktopLoading(boolean loading) {
-        if (loading) {
-            mLoadingIndicatorContainer.setVisibility(View.VISIBLE);
-            mFragmentContainer.setVisibility(View.GONE);
-        } else {
-            mLoadingIndicatorContainer.setVisibility(View.GONE);
-            mFragmentContainer.setVisibility(View.VISIBLE);
-        }
-    }
-
-    /**
-     * Returns the width (in physical px) to use for the "currently set wallpaper" thumbnail.
-     */
-    private int getSingleWallpaperImageWidthPx() {
-        final float screenAspectRatio =
-                ScreenSizeCalculator.getInstance().getScreenAspectRatio(this);
-
-        int height = getResources().getDimensionPixelSize(
-                R.dimen.current_wallpaper_bottom_sheet_thumb_height);
-        return (int) (height / screenAspectRatio);
-    }
-
-    /**
-     * Enables and populates the "Currently set" wallpaper BottomSheet.
-     */
-    private void setUpBottomSheet() {
-        mBottomSheet.setVisibility(View.VISIBLE);
-
-        if (Flags.skipDailyWallpaperButtonEnabled) {
-            // Add "next" icon to the Next Wallpaper button
-            Drawable nextWallpaperButtonDrawable = getResources().getDrawable(
-                    R.drawable.ic_refresh_18px);
-
-            // This Drawable's state is shared across the app, so make a copy of it before applying a
-            // color tint as not to affect other clients elsewhere in the app.
-            nextWallpaperButtonDrawable =
-                    nextWallpaperButtonDrawable.getConstantState().newDrawable().mutate();
-            // Color the "compass" icon with the accent color.
-            nextWallpaperButtonDrawable.setColorFilter(
-                    ResourceUtils.getColorAttr(this,
-                            android.R.attr.colorAccent), Mode.SRC_IN);
-            ButtonDrawableSetterCompat.setDrawableToButtonStart(
-                    mCurrentWallpaperSkipWallpaperButton, nextWallpaperButtonDrawable);
-        }
-
-        final BottomSheetBehavior<LinearLayout> bottomSheetBehavior =
-                BottomSheetBehavior.from(mBottomSheet);
-        bottomSheetBehavior.setBottomSheetCallback(new BottomSheetCallback() {
-            @Override
-            public void onStateChanged(@NonNull View view, int i) {
-            }
-
-            @Override
-            public void onSlide(@NonNull View view, float slideOffset) {
-                float alpha;
-                if (slideOffset >= 0) {
-                    alpha = slideOffset;
-                } else {
-                    alpha = 1f - slideOffset;
-                }
-                LinearLayout bottomSheetContents = findViewById(R.id.bottom_sheet_contents);
-                bottomSheetContents.setAlpha(alpha);
-            }
-        });
-    }
-
-    /**
-     * Enables a test mode of operation -- in which certain UI features are disabled to allow for
-     * UI tests to run correctly. Works around issue in ProgressDialog currently where the dialog
-     * constantly keeps the UI thread alive and blocks a test forever.
-     */
-    void setTestingMode(boolean testingMode) {
-        mTestingMode = testingMode;
-    }
-
-    /**
-     * Obtains the {@link WallpaperInfo} object(s) representing the wallpaper(s) currently set to the
-     * device from the {@link CurrentWallpaperInfoFactory} and displays them in the BottomSheet.
-     */
-    @Override
-    public void refreshCurrentWallpapers(@Nullable RefreshListener refreshListener) {
-        final Injector injector = InjectorProvider.getInjector();
-        final Context appContext = getApplicationContext();
-
-        CurrentWallpaperInfoFactory factory = injector.getCurrentWallpaperFactory(this);
-        factory.createCurrentWallpaperInfos(new WallpaperInfoCallback() {
-            @Override
-            public void onWallpaperInfoCreated(
-                    final WallpaperInfo homeWallpaper,
-                    @Nullable final WallpaperInfo lockWallpaper,
-                    @PresentationMode final int presentationMode) {
-
-                if (isDestroyed()) {
-                    return;
-                }
-
-                // Fetch the home wallpaper's thumbnail asset asynchronously to work around expensive
-                // method call to WallpaperManager#getWallpaperFile made from the CurrentWallpaperInfoVN
-                // getAsset() method.
-                AssetReceiver assetReceiver = (Asset thumbAsset) -> {
-                    if (isDestroyed()) {
-                        return;
-                    }
-
-                    homeWallpaper.getThumbAsset(appContext).loadDrawableWithTransition(
-                            TopLevelPickerActivity.this,
-                            mCurrentWallpaperImage,
-                            200 /* transitionDurationMillis */,
-                            () -> {
-                                if (refreshListener != null) {
-                                    refreshListener.onCurrentWallpaperRefreshed();
-                                }
-                            },
-                            Color.TRANSPARENT);
-                };
-                new FetchThumbAssetTask(appContext, homeWallpaper, assetReceiver).executeOnExecutor(
-                        AsyncTask.THREAD_POOL_EXECUTOR);
-
-                mCurrentWallpaperPresentationMode.setText(
-                        AttributionFormatter.getHumanReadableWallpaperPresentationMode(
-                                TopLevelPickerActivity.this, presentationMode));
-
-                List<String> attributions = homeWallpaper.getAttributions(appContext);
-                if (attributions.size() > 0 && attributions.get(0) != null) {
-                    mCurrentWallpaperTitle.setText(attributions.get(0));
-                }
-
-                mCurrentWallpaperSubtitle.setText(
-                        AttributionFormatter.formatWallpaperSubtitle(appContext, homeWallpaper));
-
-                final String actionUrl = homeWallpaper.getActionUrl(appContext);
-                if (actionUrl != null && !actionUrl.isEmpty()) {
-                    Uri exploreUri = Uri.parse(actionUrl);
-
-                    ExploreIntentChecker intentChecker = injector.getExploreIntentChecker(appContext);
-                    intentChecker.fetchValidActionViewIntent(exploreUri, (@Nullable Intent exploreIntent) -> {
-                        if (exploreIntent != null && !isDestroyed()) {
-                            // Set the icon for the button
-                            Drawable exploreButtonDrawable = getResources().getDrawable(
-                                    homeWallpaper.getActionIconRes(appContext));
-
-                            // This Drawable's state is shared across the app, so make a copy of it
-                            // before applying a color tint as not to affect other clients elsewhere
-                            // in the app.
-                            exploreButtonDrawable = exploreButtonDrawable.getConstantState()
-                                    .newDrawable().mutate();
-                            // Color the "compass" icon with the accent color.
-                            exploreButtonDrawable.setColorFilter(
-                                    ResourceUtils.getColorAttr(TopLevelPickerActivity.this,
-                                            android.R.attr.colorAccent), Mode.SRC_IN);
-
-                            ButtonDrawableSetterCompat.setDrawableToButtonStart(
-                                    mCurrentWallpaperExploreButton, exploreButtonDrawable);
-                            mCurrentWallpaperExploreButton.setText(getString(
-                                    homeWallpaper.getActionLabelRes(appContext)));
-                            mCurrentWallpaperExploreButton.setVisibility(View.VISIBLE);
-                            mCurrentWallpaperExploreButton.setOnClickListener(new OnClickListener() {
-                                @Override
-                                public void onClick(View v) {
-                                    mUserEventLogger.logActionClicked(
-                                            homeWallpaper.getCollectionId(appContext),
-                                            homeWallpaper.getActionLabelRes(appContext));
-                                    startActivity(exploreIntent);
-                                }
-                            });
-                        }
-                    });
-                } else {
-                    mCurrentWallpaperExploreButton.setVisibility(View.GONE);
-                }
-
-                // Hide the wallpaper position options UI if the current home wallpaper is not from
-                // "my photos".
-                String homeCollectionId = homeWallpaper.getCollectionId(TopLevelPickerActivity.this);
-                if (mWallpaperPositionOptions != null
-                        && homeCollectionId != null // May be null if app is being used for the first time.
-                        && !homeCollectionId.equals(getString(R.string.image_wallpaper_collection_id))) {
-                    mWallpaperPositionOptions.setVisibility(View.GONE);
-                }
-
-                boolean showSkipWallpaperButton = Flags.skipDailyWallpaperButtonEnabled
-                        && presentationMode == WallpaperPreferences.PRESENTATION_MODE_ROTATING;
-                if (showSkipWallpaperButton) {
-                    mCurrentWallpaperSkipWallpaperButton.setVisibility(View.VISIBLE);
-                    mCurrentWallpaperSkipWallpaperButton.setOnClickListener(
-                            v -> refreshDailyWallpaper());
-                } else {
-                    mCurrentWallpaperSkipWallpaperButton.setVisibility(View.GONE);
-                }
-
-                if (refreshListener != null) {
-                    refreshListener.onCurrentWallpaperRefreshed();
-                }
-            }
-        }, true /* forceRefresh */);
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle savedInstanceState) {
-        FormFactorChecker formFactorChecker = InjectorProvider.getInjector().getFormFactorChecker(this);
-        if (formFactorChecker.getFormFactor() == FormFactorChecker.FORM_FACTOR_DESKTOP) {
-            TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
-
-            // tabLayout is only present when the main IndividualPickerFragment is present (as
-            // opposed to
-            // the WallpaperDisabledFragment), so need this null check.
-            if (tabLayout != null) {
-                savedInstanceState.putInt(KEY_SELECTED_CATEGORY_TAB, tabLayout.getSelectedTabPosition());
-            }
-        }
-
-        super.onSaveInstanceState(savedInstanceState);
-    }
-
-    @Override
-    @Nullable
-    public CategorySelectorFragment getCategorySelectorFragment() {
-        if (mDelegate.getFormFactor() != FormFactorChecker.FORM_FACTOR_MOBILE) {
-            return null;
-        }
-        FragmentManager fm = getSupportFragmentManager();
-        return ((CategoryFragment) fm.findFragmentById(
-                R.id.fragment_container)).getCategorySelectorFragment();
-    }
-
-    /**
-     * Populates the category tabs on DESKTOP form factor.
-     *
-     * @param selectedTabPosition The position of the tab to show as selected, or -1 if no particular
-     *                            tab should be selected (in which case: the tab of the category for the currently set
-     *                            wallpaper will be selected if enumerable; if not, the first enumerable category's tab will
-     *                            be selected).
-     */
-    private void populateCategoryTabs(int selectedTabPosition) {
-        final TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
-        tabLayout.removeAllTabs();
-
-        String currentlySetCollectionId = mDelegate.getPreferences().getHomeWallpaperCollectionId();
-
-        Tab tabToSelect = null;
-        Tab firstEnumerableCategoryTab = null;
-        for (int i = 0; i < mDelegate.getCategoryProvider().getSize(); i++) {
-            Category category = mDelegate.getCategoryProvider().getCategory(i);
-
-            Tab tab = tabLayout.newTab();
-            tab.setText(category.getTitle());
-            tab.setTag(category);
-            tabLayout.addTab(tab, false /* setSelected */);
-
-            if (firstEnumerableCategoryTab == null && category.isEnumerable()) {
-                firstEnumerableCategoryTab = tab;
-            }
-
-            boolean shouldSelectTab = (i == selectedTabPosition)
-                    || (selectedTabPosition == -1
-                    && tabToSelect == null
-                    && category.isEnumerable()
-                    && currentlySetCollectionId != null
-                    && currentlySetCollectionId.equals(category.getCollectionId()));
-
-            if (shouldSelectTab) {
-                tabToSelect = tab;
-            }
-        }
-
-        // If the above loop did not identify a specific tab to select, then just select the tab for
-        // the first enumerable category.
-        if (tabToSelect == null) {
-            tabToSelect = firstEnumerableCategoryTab;
-        }
-
-        // There may be no enumerable tabs (e.g., offline case), so we need to null-check again.
-        if (tabToSelect != null) {
-            tabToSelect.select();
-        }
-    }
-
-    /**
-     * Refreshes the current wallpaper in a daily wallpaper rotation.
-     */
-    private void refreshDailyWallpaper() {
-        // ProgressDialog endlessly updates the UI thread, keeping it from going idle which therefore
-        // causes Espresso to hang once the dialog is shown.
-        if (!mTestingMode) {
-            int themeResId;
-            if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) {
-                themeResId = R.style.ProgressDialogThemePreL;
-            } else {
-                themeResId = R.style.LightDialogTheme;
-            }
-            mRefreshWallpaperProgressDialog = new ProgressDialog(this, themeResId);
-            mRefreshWallpaperProgressDialog.setTitle(null);
-            mRefreshWallpaperProgressDialog.setMessage(
-                    getResources().getString(R.string.refreshing_daily_wallpaper_dialog_message));
-            mRefreshWallpaperProgressDialog.setIndeterminate(true);
-            mRefreshWallpaperProgressDialog.show();
-        }
-
-        WallpaperRotationRefresher wallpaperRotationRefresher =
-                InjectorProvider.getInjector().getWallpaperRotationRefresher();
-        wallpaperRotationRefresher.refreshWallpaper(this, new Listener() {
-            @Override
-            public void onRefreshed() {
-                if (isDestroyed()) {
-                    return;
-                }
-
-                if (mRefreshWallpaperProgressDialog != null) {
-                    mRefreshWallpaperProgressDialog.dismiss();
-                }
-
-                refreshCurrentWallpapers(null /* refreshListener */);
-            }
-
-            @Override
-            public void onError() {
-                if (mRefreshWallpaperProgressDialog != null) {
-                    mRefreshWallpaperProgressDialog.dismiss();
-                }
-
-                AlertDialog errorDialog = new AlertDialog.Builder(
-                        TopLevelPickerActivity.this, R.style.LightDialogTheme)
-                        .setMessage(R.string.refresh_daily_wallpaper_failed_message)
-                        .setPositiveButton(android.R.string.ok, null /* onClickListener */)
-                        .create();
-                errorDialog.show();
-            }
-        });
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        if (requestCode == WallpaperPickerDelegate.SHOW_CATEGORY_REQUEST_CODE
-                && resultCode == Activity.RESULT_OK) {
-            if (mDelegate.getFormFactor() == FormFactorChecker.FORM_FACTOR_DESKTOP) {
-                Uri imageUri = (data == null) ? null : data.getData();
-                if (imageUri != null) {
-                    // User selected an image from the system picker, so launch the preview for that
-                    // image.
-                    ImageWallpaperInfo imageWallpaper = new ImageWallpaperInfo(imageUri);
-                    setCustomPhotoWallpaper(imageWallpaper);
-                    return;
-                }
-            }
-        }
-        if (mDelegate.handleActivityResult(requestCode, resultCode, data)) {
-            finishActivityWithResultOk();
-        }
-    }
-
-    /**
-     * Shows the view-only preview activity for the given wallpaper.
-     */
-    public void showViewOnlyPreview(WallpaperInfo wallpaperInfo, boolean isViewAsHome) {
-        mDelegate.showViewOnlyPreview(wallpaperInfo, isViewAsHome);
-    }
-
-    @Override
-    public void show(String collectionId) {
-        mDelegate.show(collectionId);
-    }
-
-    @Override
-    public void fetchCategories() {
-        mDelegate.initialize(!mDelegate.getCategoryProvider().isCategoriesFetched());
-    }
-
-    @Override
-    public void cleanUp() {
-        mDelegate.cleanUp();
-    }
-
-    @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
-                                           @NonNull int[] grantResults) {
-        mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
-    }
-
-    private void reselectLastTab() {
-        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
-
-        // In the offline case, "My photos" could be the only category. Thus we need this check --
-        // to ensure that we don't try to select the "previously selected" category which was -1.
-        if (mLastSelectedCategoryTabIndex > -1) {
-            Tab tabToSelect = tabLayout.getTabAt(
-                    mLastSelectedCategoryTabIndex);
-            if (((Category) tabToSelect.getTag()).isEnumerable()) {
-                tabToSelect.select();
-            }
-        }
-    }
-
-    private void showCategoryDesktop(String collectionId) {
-        Category category = mDelegate.findCategoryForCollectionId(collectionId);
-        if (category == null) {
-            return;
-        }
-
-        if (category.isEnumerable()) {
-            // Replace contained IndividualPickerFragment with a new instance for the given category.
-            final FragmentManager fm = getSupportFragmentManager();
-            Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-            if (fragment != null) {
-                fm.beginTransaction()
-                        .remove(fragment)
-                        .commit();
-            }
-            Injector injector = InjectorProvider.getInjector();
-            IndividualPickerFragment newFragment = injector.getIndividualPickerFragment(
-                    collectionId);
-            fm.beginTransaction()
-                    .add(R.id.fragment_container, newFragment)
-                    .commit();
-            newFragment.setCurrentWallpaperBottomSheetPresenter(this);
-            newFragment.setWallpapersUiContainer(this);
-        } else {
-            category.show(this, mDelegate.getPickerIntentFactory(),
-                    WallpaperPickerDelegate.SHOW_CATEGORY_REQUEST_CODE);
-
-            // Need to select the tab here in case we are coming back from a "My photos" in which case
-            // the tab would have been set to "My photos" while viewing a regular image category.
-            reselectLastTab();
-        }
-    }
-
-    private void finishActivityWithResultOk() {
-        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
-        setResult(Activity.RESULT_OK);
-        finish();
-    }
-
-    @Override
-    public void setCurrentWallpapersExpanded(boolean expanded) {
-        final BottomSheetBehavior<LinearLayout> bottomSheetBehavior =
-                BottomSheetBehavior.from(mBottomSheet);
-        bottomSheetBehavior.setState(
-                expanded ? BottomSheetBehavior.STATE_EXPANDED
-                        : BottomSheetBehavior.STATE_COLLAPSED);
-    }
-
-    @Override
-    public void doneFetchingCategories() {
-        populateCategoryTabs(mLastSelectedCategoryTabIndex);
-    }
-
-    @Override
-    public void onWallpapersReady() {
-        setDesktopLoading(false);
-        setCurrentWallpapersExpanded(true);
-    }
-
-    @Override
-    public MyPhotosStarter getMyPhotosStarter() {
-        return this;
-    }
-
-    @Override
-    public void onClickTryAgain(@Destination int unused) {
-        // Retry the set wallpaper operation with the default center-crop setting.
-        if (mPendingSetWallpaperInfo != null) {
-            setCustomPhotoWallpaper(mPendingSetWallpaperInfo);
-        }
-    }
-
-    /**
-     * Sets the provides wallpaper to the device with center-cropped and scaled to fit the device's
-     * default display.
-     */
-    private void setCustomPhotoWallpaper(final WallpaperInfo wallpaper) {
-        // Save this WallpaperInfo so we can retry this operation later if it fails.
-        mPendingSetWallpaperInfo = wallpaper;
-
-        showSettingWallpaperProgressDialog();
-
-        mWallpaperPersister.setIndividualWallpaperWithPosition(this, wallpaper,
-                WallpaperPersister.WALLPAPER_POSITION_CENTER_CROP, new SetWallpaperCallback() {
-                    @Override
-                    public void onSuccess(WallpaperInfo wallpaperInfo) {
-                        dismissSettingWallpaperProgressDialog();
-                        refreshCurrentWallpapers(null /* refreshListener */);
-
-                        mDelegate.getPreferences().setPendingWallpaperSetStatus(
-                                WallpaperPreferences.WALLPAPER_SET_NOT_PENDING);
-                        mUserEventLogger.logWallpaperSet(
-                                wallpaper.getCollectionId(getApplicationContext()),
-                                wallpaper.getWallpaperId());
-                        mUserEventLogger.logWallpaperSetResult(UserEventLogger.WALLPAPER_SET_RESULT_SUCCESS);
-
-                        // The user may have closed the activity before the set wallpaper operation completed.
-                        if (isDestroyed()) {
-                            return;
-                        }
-
-                        // Show the wallpaper crop option selector and bind click event handlers.
-                        mWallpaperPositionOptions.setVisibility(View.VISIBLE);
-
-                        mWasCustomPhotoWallpaperSet = true;
-                        mCustomPhotoWallpaperPosition = WallpaperPersister.WALLPAPER_POSITION_CENTER_CROP;
-
-                        initializeWallpaperPositionOptionClickHandlers(wallpaper);
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
-                        dismissSettingWallpaperProgressDialog();
-                        showSetWallpaperErrorDialog();
-
-                        mDelegate.getPreferences().setPendingWallpaperSetStatus(
-                                WallpaperPreferences.WALLPAPER_SET_NOT_PENDING);
-                        mUserEventLogger.logWallpaperSetResult(
-                                UserEventLogger.WALLPAPER_SET_RESULT_FAILURE);
-                        @WallpaperSetFailureReason int failureReason = ThrowableAnalyzer.isOOM(throwable)
-                                ? UserEventLogger.WALLPAPER_SET_FAILURE_REASON_OOM
-                                : UserEventLogger.WALLPAPER_SET_FAILURE_REASON_OTHER;
-                        mUserEventLogger.logWallpaperSetFailureReason(failureReason);
-                        Log.e(TAG, "Unable to set wallpaper from 'my photos'.");
-                    }
-                });
-    }
-
-    /**
-     * Initializes the wallpaper position button click handlers to change the way the provided
-     * wallpaper is set to the device.
-     */
-    private void initializeWallpaperPositionOptionClickHandlers(final WallpaperInfo wallpaperInfo) {
-        Button centerCropOptionBtn = (Button) findViewById(R.id.wallpaper_position_option_center_crop);
-        Button stretchOptionBtn = (Button) findViewById(R.id.wallpaper_position_option_stretched);
-        Button centerOptionBtn = (Button) findViewById(R.id.wallpaper_position_option_center);
-
-        // The "center crop" wallpaper position button is selected by default.
-        setCenterCropWallpaperPositionButtonSelected(centerCropOptionBtn, true /* isSelected */);
-        centerCropOptionBtn.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                mWallpaperPersister.setIndividualWallpaperWithPosition(TopLevelPickerActivity.this,
-                        wallpaperInfo, WallpaperPersister.WALLPAPER_POSITION_CENTER_CROP,
-                        new SetWallpaperCallback() {
-                            @Override
-                            public void onSuccess(WallpaperInfo wallpaperInfo) {
-                                // The user may have closed the activity before the set wallpaper operation
-                                // completed.
-                                if (isDestroyed()) {
-                                    return;
-                                }
-
-                                refreshCurrentWallpapers(null /* refreshListener */);
-
-                                setCenterCropWallpaperPositionButtonSelected(
-                                        centerCropOptionBtn, true /* isSelected */);
-                                setCenterWallpaperPositionButtonSelected(centerOptionBtn, false /* isSelected */);
-                                setStretchWallpaperPositionButtonSelected(stretchOptionBtn, false /* isSelected */);
-
-                                mCustomPhotoWallpaperPosition = WallpaperPersister.WALLPAPER_POSITION_CENTER_CROP;
-                            }
-
-                            @Override
-                            public void onError(@Nullable Throwable throwable) {
-                                // no-op
-                            }
-                        });
-            }
-        });
-
-        // "Stretch" is not selected by default.
-        setStretchWallpaperPositionButtonSelected(stretchOptionBtn, false /* isSelected */);
-        stretchOptionBtn.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                mWallpaperPersister.setIndividualWallpaperWithPosition(TopLevelPickerActivity.this,
-                        wallpaperInfo, WallpaperPersister.WALLPAPER_POSITION_STRETCH,
-                        new SetWallpaperCallback() {
-                            @Override
-                            public void onSuccess(WallpaperInfo wallpaperInfo) {
-                                // The user may have closed the activity before the set wallpaper operation
-                                // completed.
-                                if (isDestroyed()) {
-                                    return;
-                                }
-
-                                refreshCurrentWallpapers(null /* refreshListener */);
-
-                                setStretchWallpaperPositionButtonSelected(stretchOptionBtn, true /* isSelected */);
-                                setCenterCropWallpaperPositionButtonSelected(
-                                        centerCropOptionBtn, false /* isSelected */);
-                                setCenterWallpaperPositionButtonSelected(centerOptionBtn, false /* isSelected */);
-
-                                mCustomPhotoWallpaperPosition = WallpaperPersister.WALLPAPER_POSITION_STRETCH;
-                            }
-
-                            @Override
-                            public void onError(@Nullable Throwable throwable) {
-                                // no-op
-                            }
-                        });
-            }
-        });
-
-        // "Center" is not selected by default.
-        setCenterWallpaperPositionButtonSelected(centerOptionBtn, false /* isSelected */);
-        centerOptionBtn.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                mWallpaperPersister.setIndividualWallpaperWithPosition(TopLevelPickerActivity.this,
-                        wallpaperInfo, WallpaperPersister.WALLPAPER_POSITION_CENTER,
-                        new SetWallpaperCallback() {
-                            @Override
-                            public void onSuccess(WallpaperInfo wallpaperInfo) {
-                                // The user may have closed the activity before the set wallpaper operation
-                                // completed.
-                                if (isDestroyed()) {
-                                    return;
-                                }
-
-                                refreshCurrentWallpapers(null /* refreshListener */);
-
-                                setCenterWallpaperPositionButtonSelected(centerOptionBtn, true /* isSelected */);
-                                setCenterCropWallpaperPositionButtonSelected(
-                                        centerCropOptionBtn, false /* isSelected */);
-                                setStretchWallpaperPositionButtonSelected(stretchOptionBtn, false /* isSelected */);
-
-                                mCustomPhotoWallpaperPosition = WallpaperPersister.WALLPAPER_POSITION_CENTER;
-                            }
-
-                            @Override
-                            public void onError(@Nullable Throwable throwable) {
-                                // no-op
-                            }
-                        });
-            }
-        });
-    }
-
-    private void setCenterWallpaperPositionButtonSelected(Button button, boolean isSelected) {
-        int drawableId = isSelected ? R.drawable.center_blue : R.drawable.center_grey;
-        ButtonDrawableSetterCompat.setDrawableToButtonStart(button, getDrawable(drawableId));
-        button.setTextColor(getTextColorForWallpaperPositionButton(isSelected));
-    }
-
-    private void setCenterCropWallpaperPositionButtonSelected(Button button, boolean isSelected) {
-        int drawableId = isSelected ? R.drawable.center_crop_blue : R.drawable.center_crop_grey;
-        ButtonDrawableSetterCompat.setDrawableToButtonStart(button, getDrawable(drawableId));
-        button.setTextColor(getTextColorForWallpaperPositionButton(isSelected));
-    }
-
-    private void setStretchWallpaperPositionButtonSelected(Button button, boolean isSelected) {
-        int drawableId = isSelected ? R.drawable.stretch_blue : R.drawable.stretch_grey;
-        ButtonDrawableSetterCompat.setDrawableToButtonStart(button, getDrawable(drawableId));
-        button.setTextColor(getTextColorForWallpaperPositionButton(isSelected));
-    }
-
-    private void showSettingWallpaperProgressDialog() {
-        // ProgressDialog endlessly updates the UI thread, keeping it from going idle which
-        // therefore causes Espresso to hang once the dialog is shown.
-        if (!mTestingMode) {
-            int themeResId;
-            if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) {
-                themeResId = R.style.ProgressDialogThemePreL;
-            } else {
-                themeResId = R.style.LightDialogTheme;
-            }
-            mSetWallpaperProgressDialog = new ProgressDialog(this, themeResId);
-            mSetWallpaperProgressDialog.setTitle(null);
-            mSetWallpaperProgressDialog.setMessage(
-                    getResources().getString(R.string.set_wallpaper_progress_message));
-            mSetWallpaperProgressDialog.setIndeterminate(true);
-            mSetWallpaperProgressDialog.show();
-        }
-    }
-
-    private void dismissSettingWallpaperProgressDialog() {
-        if (mSetWallpaperProgressDialog != null) {
-            mSetWallpaperProgressDialog.dismiss();
-        }
-    }
-
-    private void showSetWallpaperErrorDialog() {
-        SetWallpaperErrorDialogFragment dialogFragment = SetWallpaperErrorDialogFragment.newInstance(
-                R.string.set_wallpaper_error_message, WallpaperPersister.DEST_BOTH);
-
-        if (isSafeToCommitFragmentTransaction()) {
-            dialogFragment.show(getSupportFragmentManager(), TAG_SET_WALLPAPER_ERROR_DIALOG_FRAGMENT);
-        } else {
-            mStagedSetWallpaperErrorDialogFragment = dialogFragment;
-        }
-    }
-
-    @Override
-    public void onUpArrowPressed() {
-        onBackPressed();
-    }
-
-    @Override
-    public boolean isUpArrowSupported() {
-        return !ActivityUtils.isSUWMode(getBaseContext());
-    }
-
-    private interface AssetReceiver {
-        void onAssetReceived(Asset asset);
-    }
-
-    /**
-     * An AsyncTask for asynchronously fetching the thumbnail asset for a given WallpaperInfo.
-     * Used to work around expensive method call to WallpaperManager#getWallpaperFile made from the
-     * CurrentWallpaperInfoVN getAsset() method.
-     */
-    private static class FetchThumbAssetTask extends AsyncTask<Void, Void, Asset> {
-        private Context mAppContext;
-        private WallpaperInfo mWallpaperInfo;
-        private AssetReceiver mReceiver;
-
-        public FetchThumbAssetTask(Context appContext, WallpaperInfo wallpaperInfo,
-                                   AssetReceiver receiver) {
-            mAppContext = appContext;
-            mWallpaperInfo = wallpaperInfo;
-            mReceiver = receiver;
-        }
-
-        @Override
-        protected Asset doInBackground(Void... params) {
-            return mWallpaperInfo.getThumbAsset(mAppContext);
-        }
-
-        @Override
-        protected void onPostExecute(Asset thumbAsset) {
-            mReceiver.onAssetReceived(thumbAsset);
-        }
-    }
-}
diff --git a/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java b/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
index adb9e54..06591ad 100644
--- a/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
+++ b/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
@@ -48,14 +48,13 @@
 import com.android.wallpaper.picker.PreviewActivity.PreviewActivityIntentFactory;
 import com.android.wallpaper.picker.ViewOnlyPreviewActivity.ViewOnlyPreviewActivityIntentFactory;
 import com.android.wallpaper.picker.WallpaperDisabledFragment.WallpaperSupportLevel;
-import com.android.wallpaper.picker.individual.IndividualPickerActivity.IndividualPickerActivityIntentFactory;
 
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * Implements all the logic for handling a WallpaperPicker container Activity.
- * @see TopLevelPickerActivity for usage details.
+ * @see CustomizationPickerActivity for usage details.
  */
 public class WallpaperPickerDelegate implements MyPhotosStarter {
 
@@ -67,8 +66,6 @@
     public static final int READ_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 3;
     public static final int PREVIEW_LIVE_WALLPAPER_REQUEST_CODE = 4;
 
-    private IndividualPickerActivityIntentFactory mPickerIntentFactory;
-
     private InlinePreviewIntentFactory mPreviewIntentFactory;
     private InlinePreviewIntentFactory mViewOnlyPreviewIntentFactory;
 
@@ -89,7 +86,6 @@
             Injector injector) {
         mContainer = container;
         mActivity = activity;
-        mPickerIntentFactory = new IndividualPickerActivityIntentFactory();
         mPreviewIntentFactory = new PreviewActivityIntentFactory();
         mViewOnlyPreviewIntentFactory =
                 new ViewOnlyPreviewActivityIntentFactory();
@@ -361,7 +357,7 @@
         if (category == null) {
             return;
         }
-        category.show(mActivity, mPickerIntentFactory, SHOW_CATEGORY_REQUEST_CODE);
+        category.show(mActivity, SHOW_CATEGORY_REQUEST_CODE);
     }
 
     @Nullable
@@ -395,10 +391,6 @@
         }
     }
 
-    public IndividualPickerActivityIntentFactory getPickerIntentFactory() {
-        return mPickerIntentFactory;
-    }
-
     public InlinePreviewIntentFactory getPreviewIntentFactory() {
         return mPreviewIntentFactory;
     }
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
deleted file mode 100755
index 9923066..0000000
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (C) 2017 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.picker.individual;
-
-import static com.android.wallpaper.picker.WallpaperPickerDelegate.PREVIEW_LIVE_WALLPAPER_REQUEST_CODE;
-import static com.android.wallpaper.picker.WallpaperPickerDelegate.PREVIEW_WALLPAPER_REQUEST_CODE;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources.NotFoundException;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.MenuItem;
-import android.widget.Toast;
-
-import androidx.appcompat.widget.Toolbar;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-
-import com.android.wallpaper.R;
-import com.android.wallpaper.model.Category;
-import com.android.wallpaper.model.CategoryProvider;
-import com.android.wallpaper.model.CategoryReceiver;
-import com.android.wallpaper.model.InlinePreviewIntentFactory;
-import com.android.wallpaper.model.LiveWallpaperInfo;
-import com.android.wallpaper.model.PickerIntentFactory;
-import com.android.wallpaper.model.WallpaperCategory;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.WallpaperPersister;
-import com.android.wallpaper.picker.BaseActivity;
-import com.android.wallpaper.picker.PreviewActivity.PreviewActivityIntentFactory;
-import com.android.wallpaper.util.DiskBasedLogger;
-import com.android.wallpaper.util.ResourceUtils;
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
-
-/**
- * Activity that can be launched from the Android wallpaper picker and allows users to pick from
- * various wallpapers and enter a preview mode for specific ones.
- */
-public class IndividualPickerActivity extends BaseActivity implements BottomActionBarHost,
-        IndividualPickerFragment.IndividualPickerFragmentHost {
-    private static final String TAG = "IndividualPickerAct";
-    private static final String EXTRA_CATEGORY_COLLECTION_ID =
-            "com.android.wallpaper.category_collection_id";
-    private static final String EXTRA_WALLPAPER_ID = "com.android.wallpaper.wallpaper_id";
-    private static final String KEY_CATEGORY_COLLECTION_ID = "key_category_collection_id";
-
-    private InlinePreviewIntentFactory mPreviewIntentFactory;
-    private WallpaperPersister mWallpaperPersister;
-    private Category mCategory;
-    private String mCategoryCollectionId;
-    private String mWallpaperId;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        mPreviewIntentFactory = new PreviewActivityIntentFactory();
-        Injector injector = InjectorProvider.getInjector();
-        mWallpaperPersister = injector.getWallpaperPersister(this);
-
-        mCategoryCollectionId = (savedInstanceState == null)
-                ? getIntent().getStringExtra(EXTRA_CATEGORY_COLLECTION_ID)
-                : savedInstanceState.getString(KEY_CATEGORY_COLLECTION_ID);
-        mWallpaperId = getIntent().getStringExtra(EXTRA_WALLPAPER_ID);
-
-        if (mWallpaperId == null) { // Normal case
-            initializeUI();
-        } else { // Deeplink to preview page case
-            setContentView(R.layout.activity_loading);
-        }
-
-        CategoryProvider categoryProvider = injector.getCategoryProvider(this);
-        categoryProvider.fetchCategories(new CategoryReceiver() {
-            @Override
-            public void onCategoryReceived(Category category) {
-                // Do nothing.
-            }
-
-            @Override
-            public void doneFetchingCategories() {
-                mCategory = categoryProvider.getCategory(mCategoryCollectionId);
-                if (mCategory == null) {
-                    DiskBasedLogger.e(TAG, "Failed to find the category: "
-                            + mCategoryCollectionId, IndividualPickerActivity.this);
-                    // We either were called with an invalid collection Id, or we're restarting
-                    // with no saved state, or with a collection id that doesn't exist anymore.
-                    // In those cases, we cannot continue, so let's just go back.
-                    finish();
-                    return;
-                }
-
-                // Show the preview of the specific wallpaper directly.
-                if (mWallpaperId != null) {
-                    ((WallpaperCategory) mCategory).fetchWallpapers(getApplicationContext(),
-                            wallpapers -> {
-                                for (WallpaperInfo wallpaper : wallpapers) {
-                                    if (wallpaper.getWallpaperId().equals(mWallpaperId)) {
-                                        showPreview(wallpaper);
-                                        return;
-                                    }
-                                }
-                                // No matched wallpaper, finish the activity.
-                                finish();
-                            }, false);
-                } else {
-                    onCategoryLoaded();
-                }
-            }
-        }, false);
-    }
-
-    private void onCategoryLoaded() {
-        setTitle(mCategory.getTitle());
-        getSupportActionBar().setTitle(mCategory.getTitle());
-    }
-
-    private void initializeUI() {
-        setContentView(R.layout.activity_individual_picker);
-
-        // Set toolbar as the action bar.
-        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
-        setSupportActionBar(toolbar);
-
-        FragmentManager fm = getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
-
-        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
-
-        toolbar.getNavigationIcon().setTint(
-                ResourceUtils.getColorAttr(this, android.R.attr.textColorPrimary)
-        );
-        toolbar.getNavigationIcon().setAutoMirrored(true);
-
-        if (fragment == null) {
-            fragment = InjectorProvider.getInjector()
-                    .getIndividualPickerFragment(mCategoryCollectionId);
-            fm.beginTransaction().add(R.id.fragment_container, fragment).commit();
-        }
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        int id = item.getItemId();
-        if (id == android.R.id.home) {
-            // Handle Up as a Global back since the only entry point to IndividualPickerActivity is
-            // from TopLevelPickerActivity.
-            onBackPressed();
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        boolean shouldShowMessage = false;
-        switch (requestCode) {
-            case PREVIEW_LIVE_WALLPAPER_REQUEST_CODE:
-                shouldShowMessage = true;
-            case PREVIEW_WALLPAPER_REQUEST_CODE:
-                if (resultCode == Activity.RESULT_OK) {
-                    mWallpaperPersister.onLiveWallpaperSet();
-
-                    // The wallpaper was set, so finish this activity with result OK.
-                    finishWithResultOk(shouldShowMessage);
-                }
-                break;
-            default:
-                Log.e(TAG, "Invalid request code: " + requestCode);
-        }
-
-        // In deeplink to preview page case, this activity is just a middle layer
-        // which redirects to preview activity. We should make sure this activity is finished
-        // after getting the result in this case. Otherwise it will show an empty activity.
-        if (mWallpaperId != null && !isFinishing()) {
-            setResult(resultCode);
-            finish();
-        }
-    }
-
-    /**
-     * Shows the preview activity for the given wallpaper.
-     */
-    public void showPreview(WallpaperInfo wallpaperInfo) {
-        mWallpaperPersister.setWallpaperInfoInPreview(wallpaperInfo);
-        wallpaperInfo.showPreview(this, mPreviewIntentFactory,
-                wallpaperInfo instanceof LiveWallpaperInfo ? PREVIEW_LIVE_WALLPAPER_REQUEST_CODE
-                        : PREVIEW_WALLPAPER_REQUEST_CODE);
-    }
-
-    private void finishWithResultOk(boolean shouldShowMessage) {
-        if (shouldShowMessage) {
-            try {
-                Toast.makeText(this, R.string.wallpaper_set_successfully_message,
-                        Toast.LENGTH_SHORT).show();
-            } catch (NotFoundException e) {
-                Log.e(TAG, "Could not show toast " + e);
-            }
-        }
-        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
-        setResult(Activity.RESULT_OK);
-        finish();
-    }
-
-    @Override
-    protected void onSaveInstanceState(Bundle bundle) {
-        super.onSaveInstanceState(bundle);
-
-        bundle.putString(KEY_CATEGORY_COLLECTION_ID, mCategoryCollectionId);
-    }
-
-    @Override
-    public BottomActionBar getBottomActionBar() {
-        return findViewById(R.id.bottom_actionbar);
-    }
-
-    @Override
-    public boolean isHostToolbarShown() {
-        return true;
-    }
-
-    @Override
-    public void setToolbarTitle(CharSequence title) {
-        setTitle(title);
-        getSupportActionBar().setTitle(title);
-    }
-
-    @Override
-    public void setToolbarMenu(int menuResId) {
-
-    }
-
-    @Override
-    public void removeToolbarMenu() {
-
-    }
-
-    @Override
-    public void moveToPreviousFragment() {
-        getSupportFragmentManager().popBackStack();
-    }
-
-    /**
-     * Default implementation of intent factory that provides an intent to start an
-     * IndividualPickerActivity.
-     */
-    public static class IndividualPickerActivityIntentFactory implements PickerIntentFactory {
-        @Override
-        public Intent newIntent(Context ctx, String collectionId) {
-            return new Intent(ctx, IndividualPickerActivity.class).putExtra(
-                    EXTRA_CATEGORY_COLLECTION_ID, collectionId);
-        }
-    }
-}