Merge "Scale the preview content from full preview size to match the container size" into ub-launcher3-master
diff --git a/res/layout/theme_info_view.xml b/res/layout/theme_info_view.xml
new file mode 100644
index 0000000..2bb8701
--- /dev/null
+++ b/res/layout/theme_info_view.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<com.android.customization.widget.ThemeInfoView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ android:paddingHorizontal="@dimen/wallpaper_info_pane_horizontal_padding"
+ android:paddingTop="@dimen/wallpaper_info_pane_top_padding"
+ android:paddingBottom="@dimen/wallpaper_info_pane_bottom_padding"
+ android:theme="@style/WallpaperPicker.BottomPaneStyle">
+
+ <TextView
+ android:id="@+id/style_info_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/theme_info_margin"
+ android:gravity="center"
+ android:lineHeight="24dp"
+ android:textAppearance="@style/SubtitleTextAppearance"
+ android:textColor="@color/action_bar_bottom_sheet_text_color"
+ android:textSize="16sp"
+ android:text="@string/style_info_description"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center">
+
+ <TextView
+ android:id="@+id/font_preview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginHorizontal="@dimen/theme_info_margin"
+ android:textSize="@dimen/theme_info_text_size"
+ android:textColor="?android:attr/colorForeground"
+ android:text="@string/font_component_option_thumbnail"/>
+
+ <ImageView
+ android:id="@+id/qs_preview_icon"
+ android:layout_width="@dimen/theme_info_icon_size"
+ android:layout_height="@dimen/theme_info_icon_size"
+ android:layout_marginHorizontal="@dimen/theme_info_margin"
+ android:tint="@color/theme_preview_icon_color"/>
+
+ <ImageView
+ android:id="@+id/app_preview_icon"
+ android:layout_width="@dimen/theme_info_icon_size"
+ android:layout_height="@dimen/theme_info_icon_size"
+ android:layout_marginHorizontal="@dimen/theme_info_margin"
+ android:layout_marginVertical="@dimen/theme_info_app_preview_icon_margin"
+ android:elevation="@dimen/theme_info_app_preview_icon_elevation"/>
+
+ <ImageView
+ android:id="@+id/shape_preview_icon"
+ android:layout_width="@dimen/theme_info_icon_size"
+ android:layout_height="@dimen/theme_info_icon_size"
+ android:layout_marginHorizontal="@dimen/theme_info_margin"/>
+ </LinearLayout>
+</com.android.customization.widget.ThemeInfoView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a565701..ec21329 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -117,4 +117,11 @@
<dimen name="min_taptarget_height">48dp</dimen>
+ <!-- For the style info preview sheet. -->
+ <dimen name="theme_info_margin">12dp</dimen>
+ <dimen name="theme_info_icon_size">24dp</dimen>
+ <dimen name="theme_info_app_preview_icon_margin">2dp</dimen>
+ <dimen name="theme_info_app_preview_icon_elevation">2dp</dimen>
+ <dimen name="theme_info_text_size">28sp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 238be06..f1cd169 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -195,4 +195,8 @@
<!-- Title for a section of a style preview screen that shows a preview of the style color and icons. [CHAR_LIMIT=30]-->
<string name="theme_preview_icons_section_title">Color / Icons</string>
+
+ <!-- Bottom sheet dialog which displaying different theme's info. [CHAR_LIMIT=30]
+ (eg, Fonts, icons, shape, color will change to the "Default" Style) -->
+ <string name="style_info_description">Fonts, icons, shape, color will change to the <xliff:g name="style_name">%1$s</xliff:g> Style</string>
</resources>
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 1ab3329..52814c5 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -22,6 +22,7 @@
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.INFORMATION;
import android.app.Activity;
import android.app.WallpaperColors;
@@ -67,6 +68,7 @@
import com.android.customization.picker.theme.ThemePreviewPage.ThemeCoverPage;
import com.android.customization.picker.theme.ThemePreviewPage.TimeContainer;
import com.android.customization.widget.OptionSelectorController;
+import com.android.customization.widget.ThemeInfoView;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.Asset.CenterCropBitmapTask;
@@ -121,6 +123,7 @@
private BottomActionBar mBottomActionBar;
private WallpaperPreviewer mWallpaperPreviewer;
private ThemeOptionPreviewer mThemeOptionPreviewer;
+ private ThemeInfoView mThemeInfoView;
@Override
public void onAttach(Context context) {
@@ -182,11 +185,14 @@
@Override
protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
mBottomActionBar = bottomActionBar;
- mBottomActionBar.showActionsOnly(APPLY);
+ mBottomActionBar.showActionsOnly(INFORMATION, APPLY);
mBottomActionBar.setActionClickListener(APPLY, v -> {
mBottomActionBar.disableActions();
applyTheme();
});
+ mThemeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate(
+ R.layout.theme_info_view, /* root= */ null);
+ mBottomActionBar.attachViewToBottomSheetAndBindAction(mThemeInfoView, INFORMATION);
}
@Override
@@ -338,6 +344,9 @@
} else {
createAdapter(options);
}
+ if (mThemeInfoView != null && mSelectedTheme != null) {
+ mThemeInfoView.populateThemeInfo(mSelectedTheme);
+ }
mBottomActionBar.show();
}
});
diff --git a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
index 9181daa..4f6faa6 100644
--- a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java
@@ -18,6 +18,7 @@
import static android.app.Activity.RESULT_OK;
import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION;
import android.app.Activity;
import android.content.Intent;
@@ -35,6 +36,7 @@
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.module.CustomizationInjector;
import com.android.customization.picker.WallpaperPreviewer;
+import com.android.customization.widget.ThemeInfoView;
import com.android.wallpaper.R;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.InjectorProvider;
@@ -125,8 +127,12 @@
@Override
protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
- bottomActionBar.showActionsOnly(APPLY);
+ bottomActionBar.showActionsOnly(INFORMATION, APPLY);
bottomActionBar.setActionClickListener(APPLY, v -> finishActivityWithResultOk());
+ ThemeInfoView themeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate(
+ R.layout.theme_info_view, /* root= */ null);
+ themeInfoView.populateThemeInfo(mThemeBundle);
+ bottomActionBar.attachViewToBottomSheetAndBindAction(themeInfoView, INFORMATION);
bottomActionBar.show();
}
diff --git a/src/com/android/customization/widget/ThemeInfoView.java b/src/com/android/customization/widget/ThemeInfoView.java
new file mode 100644
index 0000000..5b05484
--- /dev/null
+++ b/src/com/android/customization/widget/ThemeInfoView.java
@@ -0,0 +1,85 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.customization.model.theme.ThemeBundle;
+import com.android.wallpaper.R;
+
+/** A view for displaying style info. */
+public class ThemeInfoView extends LinearLayout {
+ private static final int WIFI_ICON_PREVIEW_INDEX = 0;
+ private static final int SHAPE_PREVIEW_INDEX = 0;
+
+ private TextView mTitle;
+ private TextView mFontPreviewTextView;
+ private ImageView mIconPreviewImageView;
+ private ImageView mAppPreviewImageView;
+ private ImageView mShapePreviewImageView;
+
+ public ThemeInfoView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mTitle = findViewById(R.id.style_info_title);
+ mFontPreviewTextView = findViewById(R.id.font_preview);
+ mIconPreviewImageView = findViewById(R.id.qs_preview_icon);
+ mAppPreviewImageView = findViewById(R.id.app_preview_icon);
+ mShapePreviewImageView = findViewById(R.id.shape_preview_icon);
+ }
+
+ /** Populates theme info. */
+ public void populateThemeInfo(@NonNull ThemeBundle selectedTheme) {
+ ThemeBundle.PreviewInfo previewInfo = selectedTheme.getPreviewInfo();
+
+ if (previewInfo != null) {
+ mTitle.setText(getContext().getString(
+ R.string.style_info_description, selectedTheme.getTitle()));
+ if (previewInfo.headlineFontFamily != null) {
+ mTitle.setTypeface(previewInfo.headlineFontFamily);
+ mFontPreviewTextView.setTypeface(previewInfo.headlineFontFamily);
+ }
+
+ if (previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX) != null) {
+ mIconPreviewImageView.setImageDrawable(
+ previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX));
+ }
+
+ if (previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX) != null) {
+ mAppPreviewImageView.setBackground(
+ previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX));
+ }
+
+ if (previewInfo.shapeDrawable != null) {
+ mShapePreviewImageView.setImageDrawable(previewInfo.shapeDrawable);
+ mShapePreviewImageView.setImageTintList(
+ ColorStateList.valueOf(previewInfo.resolveAccentColor(getResources())));
+ }
+ }
+ }
+}