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

Commit a8f0930e authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

Add info sheet to the style picker

video: https://drive.google.com/file/d/1JuSHqEWGI0odruk8ihgXHQu75zaEeyJH/view?usp=sharing

Bug: 151285401
Test: manually
Change-Id: I2d69a938d4d515b97416fdc4f2cf0fa1afa997df
parent f3b04d68
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
<?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
+7 −0
Original line number Diff line number Diff line
@@ -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>
+4 −0
Original line number Diff line number Diff line
@@ -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>
+10 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EX
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.WallpaperPreviewer;
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 @@ public class ThemeFragment extends AppbarFragment {
    private BottomActionBar mBottomActionBar;
    private WallpaperPreviewer mWallpaperPreviewer;
    private ThemeOptionPreviewer mThemeOptionPreviewer;
    private ThemeInfoView mThemeInfoView;

    @Override
    public void onAttach(Context context) {
@@ -182,11 +185,14 @@ public class ThemeFragment extends AppbarFragment {
    @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 @@ public class ThemeFragment extends AppbarFragment {
                        } else {
                            createAdapter(options);
                        }
                        if (mThemeInfoView != null && mSelectedTheme != null) {
                            mThemeInfoView.populateThemeInfo(mSelectedTheme);
                        }
                        mBottomActionBar.show();
                    }
                });
+82 −0
Original line number Diff line number Diff line
/*
 * 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.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);
            }
        }
    }
}