summaryrefslogtreecommitdiff
path: root/src/com/android/customization/picker/theme
diff options
context:
space:
mode:
authorchihhangchuang <chihhangchuang@google.com>2020-05-25 19:35:07 +0800
committerchihhangchuang <chihhangchuang@google.com>2020-05-27 10:09:37 +0800
commit8fa29f01a5f516cb997522595f99ba23a4d8ccbd (patch)
tree4b34281556288a8c42b20a5c240381e2bbca4b7a /src/com/android/customization/picker/theme
parentaaa81e46f071d64eacd1ceb40e3d8fbd623126a1 (diff)
downloadThemePicker-8fa29f01a5f516cb997522595f99ba23a4d8ccbd.tar.gz
Add full preview for the custom theme page
To have a consistent custom theme experience, I think user had to finish the custom theme flow(click the apply button in the naming page), so we don't support apply button for a undefined theme in the custom theme *full preview* page. Video: https://drive.google.com/file/d/1oIGb5QTliCJYNEW6b6b9IttD8Mc8QJdE/view?usp=sharing Test: Manually Bug: 151285476 Change-Id: I1cad75f78b02c1dc87b55488b15ebdfbe85570a1
Diffstat (limited to 'src/com/android/customization/picker/theme')
-rw-r--r--src/com/android/customization/picker/theme/CustomThemeNameFragment.java27
-rw-r--r--src/com/android/customization/picker/theme/ThemeFragment.java2
-rw-r--r--src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java11
3 files changed, 34 insertions, 6 deletions
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index 1a702456..34115422 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -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);
+ }
}
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 32bab206..1f4917ed 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -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);
}
diff --git a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
index 77642d53..473f480a 100644
--- a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
@@ -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) {
- bottomActionBar.showActionsOnly(INFORMATION, APPLY);
- bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
+ 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);