Remove larger preview support for grid preview

Because the preview card in grid home page is clear enough.

Also remove the unused ViewOnlyFullPreviewActivity.

Fixes: 189384424
Test: Manually
Change-Id: I88cb36f7e167adc9a5b1042c1ef05223422e2fc5
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bae1cb3..90e05cb 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -66,9 +66,5 @@
              </intent-filter>
         </activity-alias>
 
-        <activity android:name="com.android.customization.picker.ViewOnlyFullPreviewActivity"
-            android:resizeableActivity="false"
-            android:theme="@style/CustomizationTheme.NoActionBar"/>
     </application>
-
 </manifest>
diff --git a/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java b/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java
deleted file mode 100644
index 44c6835..0000000
--- a/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2020 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.customization.picker;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.text.TextUtils;
-
-import androidx.annotation.IntDef;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
-
-import com.android.customization.picker.grid.GridFullPreviewFragment;
-import com.android.wallpaper.R;
-import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/** Activity for full preview. */
-public class ViewOnlyFullPreviewActivity extends FragmentActivity implements AppbarFragmentHost,
-        BottomActionBarHost {
-
-    private static final String EXTRA_PREVIEW_SECTION = "preview_section";
-    private static final String EXTRA_PREVIEW_BUNDLE = "preview_bundle";
-
-    public static final int SECTION_STYLE = 0;
-    public static final int SECTION_GRID = 1;
-    public static final int SECTION_CLOCK = 2;
-
-    @Override
-    public void onUpArrowPressed() {
-        onBackPressed();
-    }
-
-    @Override
-    public boolean isUpArrowSupported() {
-        return true;
-    }
-
-    @IntDef({SECTION_STYLE, SECTION_GRID, SECTION_CLOCK})
-    @Retention(RetentionPolicy.SOURCE)
-    private @interface Section {}
-
-    /** Returns a new Intent with the provided data in the extra. */
-    public static Intent newIntent(Context packageContext, @Section int section, Bundle bundle) {
-        Intent intent = new Intent(packageContext, ViewOnlyFullPreviewActivity.class);
-        intent.putExtra(EXTRA_PREVIEW_SECTION, section);
-        intent.putExtra(EXTRA_PREVIEW_BUNDLE, bundle);
-        return intent;
-    }
-
-    @Override
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_full_preview);
-
-        final Intent intent = getIntent();
-        @Section final int section = intent.getIntExtra(EXTRA_PREVIEW_SECTION, 0);
-        final Bundle bundle = intent.getBundleExtra(EXTRA_PREVIEW_BUNDLE);
-        if (section == SECTION_GRID) {
-            showFragment(GridFullPreviewFragment.newInstance(
-                    getString(R.string.grid_title), bundle));
-        }
-    }
-
-    @Override
-    public BottomActionBar getBottomActionBar() {
-        return findViewById(R.id.bottom_actionbar);
-    }
-
-    private void showFragment(Fragment fragment) {
-        getSupportFragmentManager()
-                .beginTransaction()
-                .replace(R.id.preview_fragment_container, fragment)
-                .commitNow();
-    }
-}
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 45cc18d..bb29d55 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -15,14 +15,8 @@
  */
 package com.android.customization.picker.grid;
 
-import static android.app.Activity.RESULT_OK;
-
-import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_GRID;
-import static com.android.customization.picker.grid.GridFullPreviewFragment.EXTRA_GRID_OPTION;
-import static com.android.customization.picker.grid.GridFullPreviewFragment.EXTRA_WALLPAPER_INFO;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY_TEXT;
 
-import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -42,7 +36,6 @@
 import com.android.customization.model.grid.GridOption;
 import com.android.customization.model.grid.GridOptionsManager;
 import com.android.customization.module.ThemesUserEventLogger;
-import com.android.customization.picker.ViewOnlyFullPreviewActivity;
 import com.android.customization.picker.WallpaperPreviewer;
 import com.android.customization.widget.OptionSelectorController;
 import com.android.customization.widget.OptionSelectorController.CheckmarkStyle;
@@ -63,13 +56,11 @@
  */
 public class GridFragment extends AppbarFragment {
 
-    private static final int FULL_PREVIEW_REQUEST_CODE = 1000;
+    private static final String TAG = "GridFragment";
     private static final String KEY_STATE_SELECTED_OPTION = "GridFragment.selectedOption";
     private static final String KEY_STATE_BOTTOM_ACTION_BAR_VISIBLE =
             "GridFragment.bottomActionBarVisible";
 
-    private static final String TAG = "GridFragment";
-
     public static GridFragment newInstance(CharSequence title) {
         GridFragment fragment = new GridFragment();
         fragment.setArguments(AppbarFragment.createArguments(title));
@@ -86,7 +77,6 @@
     private View mError;
     private BottomActionBar mBottomActionBar;
     private ThemesUserEventLogger mEventLogger;
-
     private GridOptionPreviewer mGridOptionPreviewer;
 
     private final Callback mApplyGridCallback = new Callback() {
@@ -153,7 +143,6 @@
         mGridOptionPreviewer = new GridOptionPreviewer(mGridManager,
                 view.findViewById(R.id.grid_preview_container));
 
-        view.findViewById(R.id.grid_preview_card).setOnClickListener(v -> showFullPreview());
         return view;
     }
 
@@ -177,15 +166,6 @@
     }
 
     @Override
-    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-        if (requestCode == FULL_PREVIEW_REQUEST_CODE && resultCode == RESULT_OK) {
-            applyGridOption(data.getParcelableExtra(EXTRA_GRID_OPTION));
-        }
-    }
-
-
-    @Override
     protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
         super.onBottomActionBarReady(bottomActionBar);
         mBottomActionBar = bottomActionBar;
@@ -281,12 +261,4 @@
             mBottomActionBar.hide();
         }
     }
-
-    private void showFullPreview() {
-        Bundle bundle = new Bundle();
-        bundle.putParcelable(EXTRA_WALLPAPER_INFO, mHomeWallpaper);
-        bundle.putParcelable(EXTRA_GRID_OPTION, mSelectedOption);
-        Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_GRID, bundle);
-        startActivityForResult(intent, FULL_PREVIEW_REQUEST_CODE);
-    }
 }
diff --git a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
deleted file mode 100644
index f4b0219..0000000
--- a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2020 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.customization.picker.grid;
-
-import static android.app.Activity.RESULT_OK;
-
-import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY_TEXT;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.android.customization.model.grid.GridOption;
-import com.android.customization.model.grid.GridOptionsManager;
-import com.android.customization.picker.WallpaperPreviewer;
-import com.android.wallpaper.R;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.picker.AppbarFragment;
-import com.android.wallpaper.widget.BottomActionBar;
-
-import com.bumptech.glide.Glide;
-
-
-/** A Fragment for grid full preview page. */
-public class GridFullPreviewFragment extends AppbarFragment {
-
-    static final String EXTRA_WALLPAPER_INFO = "wallpaper_info";
-    static final String EXTRA_GRID_OPTION = "grid_option";
-
-    private WallpaperInfo mWallpaper;
-    private GridOption mGridOption;
-
-    private WallpaperPreviewer mWallpaperPreviewer;
-    private GridOptionPreviewer mGridOptionPreviewer;
-
-    /**
-     * Returns a new {@link GridFullPreviewFragment} with the provided title and bundle arguments
-     * set.
-     */
-    public static GridFullPreviewFragment newInstance(CharSequence title, Bundle intentBundle) {
-        GridFullPreviewFragment fragment = new GridFullPreviewFragment();
-        Bundle bundle = new Bundle();
-        bundle.putAll(AppbarFragment.createArguments(title));
-        bundle.putAll(intentBundle);
-        fragment.setArguments(bundle);
-        return fragment;
-    }
-
-    @Override
-    public void onCreate(@Nullable Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        mWallpaper = getArguments().getParcelable(EXTRA_WALLPAPER_INFO);
-        mGridOption = getArguments().getParcelable(EXTRA_GRID_OPTION);
-    }
-
-    @Nullable
-    @Override
-    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
-                             @Nullable Bundle savedInstanceState) {
-        View view = inflater.inflate(
-                R.layout.fragment_grid_full_preview, container, /* attachToRoot */ false);
-        setUpToolbar(view);
-
-        // Clear memory cache whenever grid fragment view is being loaded.
-        Glide.get(getContext()).clearMemory();
-
-        ImageView wallpaperPreviewImage = view.findViewById(R.id.wallpaper_preview_image);
-        SurfaceView wallpaperSurface = view.findViewById(R.id.wallpaper_preview_surface);
-        mWallpaperPreviewer = new WallpaperPreviewer(
-                getLifecycle(), getActivity(), wallpaperPreviewImage, wallpaperSurface);
-        mGridOptionPreviewer = new GridOptionPreviewer(GridOptionsManager.getInstance(getContext()),
-                view.findViewById(R.id.grid_preview_container));
-        return view;
-    }
-
-    @Override
-    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
-        mWallpaperPreviewer.setWallpaper(mWallpaper, /* listener= */ null);
-        mGridOptionPreviewer.setGridOption(mGridOption);
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        if (mGridOptionPreviewer != null) {
-            mGridOptionPreviewer.release();
-        }
-    }
-
-    @Override
-    protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
-        super.onBottomActionBarReady(bottomActionBar);
-        bottomActionBar.showActionsOnly(APPLY_TEXT);
-        bottomActionBar.setActionClickListener(APPLY_TEXT, v -> finishActivityWithResultOk());
-        bottomActionBar.show();
-    }
-
-    private void finishActivityWithResultOk() {
-        Activity activity = requireActivity();
-        activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
-        Intent intent = new Intent();
-        intent.putExtra(EXTRA_GRID_OPTION, mGridOption);
-        activity.setResult(RESULT_OK, intent);
-        activity.finish();
-    }
-}
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index 067dfbc..6f20a1a 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -15,12 +15,6 @@
  */
 package com.android.customization.picker.theme;
 
-import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_STYLE;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION_TITLE;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_WALLPAPER_INFO;
-
-import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
@@ -37,10 +31,8 @@
 import com.android.customization.model.theme.custom.CustomTheme;
 import com.android.customization.module.CustomizationInjector;
 import com.android.customization.module.CustomizationPreferences;
-import com.android.customization.picker.ViewOnlyFullPreviewActivity;
 import com.android.customization.picker.WallpaperPreviewer;
 import com.android.wallpaper.R;
-import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
 import com.android.wallpaper.module.InjectorProvider;
 import com.android.wallpaper.picker.AppbarFragment;
@@ -66,7 +58,6 @@
 
     private EditText mNameEditor;
     private ImageView mWallpaperImage;
-    private WallpaperInfo mCurrentHomeWallpaper;
     private ThemeOptionPreviewer mThemeOptionPreviewer;
     private CustomizationPreferences mCustomizationPreferences;
 
@@ -98,7 +89,6 @@
                 view.findViewById(R.id.wallpaper_preview_surface));
         currentWallpaperFactory.createCurrentWallpaperInfos(
                 (homeWallpaper, lockWallpaper, presentationMode) -> {
-                    mCurrentHomeWallpaper = homeWallpaper;
                     wallpaperPreviewer.setWallpaper(homeWallpaper,
                             mThemeOptionPreviewer::updateColorForLauncherWidgets);
                 }, false);
@@ -106,8 +96,6 @@
         // Set theme default name.
         mNameEditor = view.findViewById(R.id.custom_theme_name);
         mNameEditor.setText(getOriginalThemeName());
-
-        view.findViewById(R.id.theme_preview_card).setOnClickListener(v -> showFullPreview());
         return view;
     }
 
@@ -141,15 +129,4 @@
     public String getThemeName() {
         return mNameEditor.getText().toString();
     }
-
-    private void showFullPreview() {
-        CustomTheme themeToFullPreview = mCustomThemeManager.buildPartialCustomTheme(
-                getContext(), /* id= */ "", getThemeName());
-        Bundle bundle = new Bundle();
-        bundle.putParcelable(EXTRA_WALLPAPER_INFO, mCurrentHomeWallpaper);
-        bundle.putString(EXTRA_THEME_OPTION, themeToFullPreview.getSerializedPackages());
-        bundle.putString(EXTRA_THEME_OPTION_TITLE, themeToFullPreview.getTitle());
-        Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_STYLE, bundle);
-        startActivity(intent);
-    }
 }
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 965a2ad..3537c36 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -17,11 +17,6 @@
 
 import static android.app.Activity.RESULT_OK;
 
-import static com.android.customization.picker.ViewOnlyFullPreviewActivity.SECTION_STYLE;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_CAN_APPLY_FROM_FULL_PREVIEW;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION_TITLE;
-import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_WALLPAPER_INFO;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.CUSTOMIZE;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION;
@@ -48,7 +43,6 @@
 import com.android.customization.model.theme.ThemeManager;
 import com.android.customization.model.theme.custom.CustomTheme;
 import com.android.customization.module.ThemesUserEventLogger;
-import com.android.customization.picker.ViewOnlyFullPreviewActivity;
 import com.android.customization.picker.WallpaperPreviewer;
 import com.android.customization.widget.OptionSelectorController;
 import com.android.wallpaper.R;
@@ -141,8 +135,6 @@
                     mWallpaperPreviewer.setWallpaper(mCurrentHomeWallpaper,
                             mThemeOptionPreviewer::updateColorForLauncherWidgets);
                 }, false);
-
-        view.findViewById(R.id.theme_preview_card).setOnClickListener(v -> showFullPreview());
         return view;
     }
 
@@ -386,14 +378,4 @@
                 themeToEdit.getSerializedPackages());
         startActivityForResult(intent, CustomThemeActivity.REQUEST_CODE_CUSTOM_THEME);
     }
-
-    private void showFullPreview() {
-        Bundle bundle = new Bundle();
-        bundle.putParcelable(EXTRA_WALLPAPER_INFO, mCurrentHomeWallpaper);
-        bundle.putString(EXTRA_THEME_OPTION, mSelectedTheme.getSerializedPackages());
-        bundle.putString(EXTRA_THEME_OPTION_TITLE, mSelectedTheme.getTitle());
-        bundle.putBoolean(EXTRA_CAN_APPLY_FROM_FULL_PREVIEW, true);
-        Intent intent = ViewOnlyFullPreviewActivity.newIntent(getContext(), SECTION_STYLE, bundle);
-        startActivityForResult(intent, FULL_PREVIEW_REQUEST_CODE);
-    }
 }