Various theme picker fixes.
- Add Previous button to custom flow
- Seed custom flow with the currently applied bundled theme
- Use add drawable icon instead of text
- Add padding between checkbox and "Add current wallpaper"
- Show ripple background on "Tap to edit"
Fixes: 130763331
Fixes: 130753131
Fixes: 130761402
Fixes: 130759176
Bug: 130759508
Test: visual
Change-Id: Ia82344befe8ac45489646d840453a71e31c83eae
diff --git a/res/drawable/ic_add_24px.xml b/res/drawable/ic_add_24px.xml
new file mode 100644
index 0000000..50df565
--- /dev/null
+++ b/res/drawable/ic_add_24px.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M20,13h-7v7h-2v-7H4v-2h7V4h2v7h7V13z"/>
+</vector>
+
diff --git a/res/layout/activity_custom_theme.xml b/res/layout/activity_custom_theme.xml
index 82b7887..b2aaa73 100644
--- a/res/layout/activity_custom_theme.xml
+++ b/res/layout/activity_custom_theme.xml
@@ -35,6 +35,13 @@
android:layout_height="@dimen/custom_theme_nav_height"
android:layout_marginHorizontal="12dp">
<Button
+ android:id="@+id/previous_button"
+ style="@style/ActionSecondaryButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start|center_vertical"
+ android:text="@string/custom_theme_previous"/>
+ <Button
android:id="@+id/next_button"
style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
diff --git a/res/layout/custom_theme_option.xml b/res/layout/custom_theme_option.xml
index b249555..09bd58e 100644
--- a/res/layout/custom_theme_option.xml
+++ b/res/layout/custom_theme_option.xml
@@ -34,13 +34,11 @@
android:paddingHorizontal="@dimen/option_tile_padding_horizontal"
android:paddingVertical="@dimen/option_tile_padding_vertical"
android:background="@drawable/option_border">
- <TextView
+ <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:textSize="@dimen/theme_option_add_size"
- android:textAlignment="center"
- android:textColor="?android:colorAccent"
- android:text="@string/add_custom_theme"/>
+ android:src="@drawable/ic_add_24px"
+ android:tint="?android:attr/colorAccent" />
</FrameLayout>
</LinearLayout>
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index ffc2d7b..c73bf63 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -51,6 +51,7 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
+ android:paddingLeft="4dp"
android:minHeight="@dimen/min_taptarget_height"
android:text="@string/keep_my_wallpaper"/>
<Button
diff --git a/res/layout/theme_preview_card.xml b/res/layout/theme_preview_card.xml
index 277a739..deccd48 100644
--- a/res/layout/theme_preview_card.xml
+++ b/res/layout/theme_preview_card.xml
@@ -65,10 +65,9 @@
android:layout_gravity="center_horizontal"
android:drawableStart="@drawable/ic_tune_24px"
android:drawablePadding="8dp"
- android:drawableTint="?android:colorAccent"
android:gravity="center"
android:text="@string/edit_custom_theme_lbl"
- android:textAppearance="@style/EditLabelTextAppearance"
+ style="@style/EditLabelStyle"
android:visibility="invisible"/>
</LinearLayout>
</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0723542..75bd9a6 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -105,6 +105,10 @@
[CHAR LIMIT=20] -->
<string name="custom_theme_next">Next</string>
+ <!-- Label for a button that takes the user back to the previous step when configuring a custom theme.
+ [CHAR LIMIT=20] -->
+ <string name="custom_theme_previous">Previous</string>
+
<!-- Label for a system Style/Theme (combination of fonts/colors/icons) that is defined and
customized by the user [CHAR LIMIT=15] -->
<string name="custom_theme_title">Custom</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1b69e3d..dd44a91 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -58,6 +58,8 @@
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
+ <style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button.Borderless.Colored"/>
+
<style name="OptionTitleTextAppearance" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
<item name="android:textColor">@color/option_title_color</item>
<item name="android:textAlignment">center</item>
@@ -100,7 +102,7 @@
<style name="ComponentCounterTextAppearance" parent="@android:style/TextAppearance.DeviceDefault"/>
- <style name="EditLabelTextAppearance" parent="@android:style/TextAppearance.DeviceDefault">
- <item name="android:textColor">?android:colorAccent</item>
+ <style name="EditLabelStyle" parent="@style/ActionSecondaryButton">
+ <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault</item>
</style>
</resources>
diff --git a/src/com/android/customization/model/theme/custom/CustomThemeManager.java b/src/com/android/customization/model/theme/custom/CustomThemeManager.java
index 0ce5954..f8e5fbb 100644
--- a/src/com/android/customization/model/theme/custom/CustomThemeManager.java
+++ b/src/com/android/customization/model/theme/custom/CustomThemeManager.java
@@ -20,6 +20,7 @@
import androidx.annotation.Nullable;
import com.android.customization.model.CustomizationManager;
+import com.android.customization.model.theme.ThemeManager;
import com.android.wallpaper.R;
import java.util.HashMap;
@@ -27,16 +28,12 @@
public class CustomThemeManager implements CustomizationManager<ThemeComponentOption> {
- private final Map<String, String> overlayPackages = new HashMap<>();
+ private final Map<String, String> mOverlayPackages = new HashMap<>();
private final CustomTheme mOriginalTheme;
- public CustomThemeManager(@Nullable CustomTheme existingTheme) {
- if (existingTheme != null && existingTheme.isDefined()) {
- mOriginalTheme = existingTheme;
- overlayPackages.putAll(existingTheme.getPackagesByCategory());
- } else {
- mOriginalTheme = null;
- }
+ private CustomThemeManager(Map<String, String> overlayPackages, @Nullable CustomTheme originalTheme) {
+ mOverlayPackages.putAll(overlayPackages);
+ mOriginalTheme = originalTheme;
}
@Override
@@ -46,20 +43,20 @@
@Override
public void apply(ThemeComponentOption option, @Nullable Callback callback) {
- overlayPackages.putAll(option.getOverlayPackages());
+ mOverlayPackages.putAll(option.getOverlayPackages());
if (callback != null) {
callback.onSuccess();
}
}
public Map<String, String> getOverlayPackages() {
- return overlayPackages;
+ return mOverlayPackages;
}
public CustomTheme buildPartialCustomTheme(Context context) {
return new CustomTheme(mOriginalTheme != null
? mOriginalTheme.getTitle() : context.getString(R.string.custom_theme_title),
- overlayPackages, null);
+ mOverlayPackages, null);
}
@Override
@@ -70,4 +67,13 @@
public CustomTheme getOriginalTheme() {
return mOriginalTheme;
}
+
+ public static CustomThemeManager create(
+ @Nullable CustomTheme customTheme, ThemeManager themeManager) {
+ if (customTheme != null && customTheme.isDefined()) {
+ return new CustomThemeManager(customTheme.getPackagesByCategory(), customTheme);
+ }
+ // Seed the first custom theme with the currently applied theme.
+ return new CustomThemeManager(themeManager.getCurrentOverlays(), null);
+ }
}
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index f7603ad..df14c86 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -74,26 +74,26 @@
private int mCurrentStep;
private CustomThemeManager mCustomThemeManager;
private ThemeManager mThemeManager;
- private TextView mApplyButton;
+ private TextView mNextButton;
+ private TextView mPreviousButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
mUserEventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(this);
Intent intent = getIntent();
- Builder themeBuilder = null;
+ CustomTheme customTheme = null;
if (intent != null && intent.hasExtra(EXTRA_THEME_PACKAGES)
&& intent.hasExtra(EXTRA_THEME_TITLE)) {
ThemeBundleProvider themeProvider =
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this));
- themeBuilder = themeProvider.parseCustomTheme(
+ Builder themeBuilder = themeProvider.parseCustomTheme(
intent.getStringExtra(EXTRA_THEME_PACKAGES));
if (themeBuilder != null) {
themeBuilder.setTitle(intent.getStringExtra(EXTRA_THEME_TITLE));
}
+ customTheme = (CustomTheme) themeBuilder.build(this);
}
- mCustomThemeManager = new CustomThemeManager(themeBuilder == null ? null
- : (CustomTheme) themeBuilder.build(this));
mThemeManager = new ThemeManager(
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
@@ -103,6 +103,7 @@
new OverlayManagerCompat(this),
mUserEventLogger);
mThemeManager.fetchOptions(null, false);
+ mCustomThemeManager = CustomThemeManager.create(customTheme, mThemeManager);
int currentStep = 0;
if (savedInstanceState != null) {
@@ -112,8 +113,10 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_theme);
- mApplyButton = findViewById(R.id.next_button);
- mApplyButton.setOnClickListener(view -> onNextOrApply());
+ mNextButton = findViewById(R.id.next_button);
+ mNextButton.setOnClickListener(view -> onNextOrApply());
+ mPreviousButton = findViewById(R.id.previous_button);
+ mPreviousButton.setOnClickListener(view -> onBackPressed());
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.fragment_container);
@@ -234,7 +237,7 @@
}
private void updateApplyButtonLabel() {
- mApplyButton.setText((mCurrentStep < mSteps.size() -1) ? R.string.custom_theme_next
+ mNextButton.setText((mCurrentStep < mSteps.size() -1) ? R.string.custom_theme_next
: R.string.apply_btn);
}
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 3d135ed..4deb198 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -384,9 +384,13 @@
ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
inflater.inflate(contentLayoutRes, body, true);
bindBody(false);
- card.setOnClickListener(mEditClickListener);
- card.findViewById(R.id.edit_label).setVisibility(mEditClickListener != null
+ TextView editLabel = card.findViewById(R.id.edit_label);
+ editLabel.setOnClickListener(mEditClickListener);
+ editLabel.setVisibility(mEditClickListener != null
? View.VISIBLE : View.INVISIBLE);
+ ColorStateList themeAccentColor = ColorStateList.valueOf(accentColor);
+ editLabel.setTextColor(themeAccentColor);
+ editLabel.setCompoundDrawableTintList(themeAccentColor);
View qsb = card.findViewById(R.id.theme_qsb);
if (qsb != null && qsb.getVisibility() == View.VISIBLE) {
if (qsb.getBackground() instanceof GradientDrawable) {