Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d4c83a5 authored by chihhangchuang's avatar chihhangchuang Committed by Automerger Merge Worker
Browse files

Add full preview for the custom theme page am: 8fa29f01

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/11587713

Change-Id: I38188376598ef156d3adedca966cdc9291b0afd6
parents 444414ff 8fa29f01
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -15,6 +15,12 @@
 */
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;
@@ -28,8 +34,10 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
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;
@@ -91,10 +99,10 @@ public class CustomThemeNameFragment extends CustomThemeStepFragment {
                }, false);

        // Set theme option.
        mThemeOptionPreviewer = new ThemeOptionPreviewer(
                getLifecycle(),
                getContext(),
                view.findViewById(R.id.theme_preview_container));
        ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container);
        previewContainer.setOnClickListener(v -> showFullPreview());
        mThemeOptionPreviewer = new ThemeOptionPreviewer(getLifecycle(), getContext(),
                previewContainer);
        PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(getContext());
        mThemeOptionPreviewer.setPreviewInfo(previewInfo);

@@ -157,4 +165,15 @@ public class CustomThemeNameFragment extends CustomThemeStepFragment {
    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);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.customization.picker.theme;
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;
@@ -371,6 +372,7 @@ public class ThemeFragment extends AppbarFragment {
        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);
    }
+9 −2
Original line number Diff line number Diff line
@@ -56,9 +56,11 @@ public class ThemeFullPreviewFragment extends AppbarFragment {
    public static final String EXTRA_THEME_OPTION_TITLE = "theme_option_title";
    protected static final String EXTRA_THEME_OPTION = "theme_option";
    protected static final String EXTRA_WALLPAPER_INFO = "wallpaper_info";
    protected static final String EXTRA_CAN_APPLY_FROM_FULL_PREVIEW = "can_apply";

    private WallpaperInfo mWallpaper;
    private ThemeBundle mThemeBundle;
    private boolean mCanApplyFromFullPreview;

    /**
     * Returns a new {@link ThemeFullPreviewFragment} with the provided title and bundle arguments
@@ -77,6 +79,7 @@ public class ThemeFullPreviewFragment extends AppbarFragment {
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mWallpaper = getArguments().getParcelable(EXTRA_WALLPAPER_INFO);
        mCanApplyFromFullPreview = getArguments().getBoolean(EXTRA_CAN_APPLY_FROM_FULL_PREVIEW);
        CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
        ThemeBundleProvider themeProvider = new DefaultThemeProvider(
                getContext(), injector.getCustomizationPreferences(getContext()));
@@ -136,8 +139,12 @@ public class ThemeFullPreviewFragment extends AppbarFragment {

    @Override
    protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
        if (mCanApplyFromFullPreview) {
            bottomActionBar.showActionsOnly(INFORMATION, APPLY);
            bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
        } else {
            bottomActionBar.showActionsOnly(INFORMATION);
        }
        ThemeInfoView themeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate(
                R.layout.theme_info_view, /* root= */ null);
        themeInfoView.populateThemeInfo(mThemeBundle);