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

Commit c5805c3b authored by chihhangchuang's avatar chihhangchuang
Browse files

Add screen corner radius for the preview of Grid/Style/Clock

Before: https://screenshot.googleplex.com/LP9shBKk74N.png
After: https://screenshot.googleplex.com/r2YTE1uRJ6C.png

Test: Manually
Fixes: 155354505
Change-Id: I78924238a07cc3ae6dcdded09f5910d4fa80c8a4
parent d920969c
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.customization.picker;

import static androidx.core.view.ViewCompat.LAYOUT_DIRECTION_RTL;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,6 +30,7 @@ import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.PagerAdapter;

import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
import com.android.wallpaper.util.TileSizeCalculator;
import com.android.wallpaper.widget.PreviewPager;

import java.util.ArrayList;
@@ -103,12 +105,19 @@ public class BasePreviewAdapter<T extends PreviewPage> extends PagerAdapter {
        protected final String title;
        protected CardView card;

        protected PreviewPage(String title) {
        private Activity mActivity;

        protected PreviewPage(String title, Activity activity) {
            this.title = title;
            mActivity = activity;
        }

        public void setCard(CardView card) {
            this.card = card;
            this.card.addOnLayoutChangeListener(
                    (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
                            card.setRadius(TileSizeCalculator.getPreviewCornerRadius(
                                    mActivity, card.getMeasuredWidth())));
        }

        public abstract void bindPreviewContent();
+8 −6
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.customization.picker.clock;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
@@ -120,7 +121,7 @@ public class ClockFragment extends AppbarFragment {
    }

    private void createAdapter() {
        mPreviewPager.setAdapter(new ClockPreviewAdapter(getContext(), mSelectedOption));
        mPreviewPager.setAdapter(new ClockPreviewAdapter(getActivity(), mSelectedOption));
    }

    private void setUpOptions() {
@@ -174,8 +175,8 @@ public class ClockFragment extends AppbarFragment {

        private final Asset mPreviewAsset;

        public ClockfacePreviewPage(String title, Asset previewAsset) {
            super(title);
        public ClockfacePreviewPage(String title, Activity activity, Asset previewAsset) {
            super(title, activity);
            mPreviewAsset = previewAsset;
        }

@@ -199,9 +200,10 @@ public class ClockFragment extends AppbarFragment {
     * we don't want to just scroll)
     */
    private static class ClockPreviewAdapter extends BasePreviewAdapter<ClockfacePreviewPage> {
        ClockPreviewAdapter(Context context, Clockface clockface) {
            super(context, R.layout.clock_preview_card);
            addPage(new ClockfacePreviewPage(clockface.getTitle(), clockface.getPreviewAsset()));
        ClockPreviewAdapter(Activity activity, Clockface clockface) {
            super(activity, R.layout.clock_preview_card);
            addPage(new ClockfacePreviewPage(
                    clockface.getTitle(), activity , clockface.getPreviewAsset()));
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ public class GridFragment extends AppbarFragment {

        private GridPreviewPage(Activity activity, int id, Uri previewUri, String name, int rows,
                int cols) {
            super(null);
            super(null, activity);
            mPageId = id;
            mPreviewAsset = new ContentUriAsset(activity, previewUri,
                    RequestOptions.fitCenterTransform());
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public class CustomThemeNameFragment extends CustomThemeStepFragment {
    private void bindCover(CardView card) {
        Context context = getContext();
        PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(context);
        mCoverPage = new ThemeCoverPage(context, getThemeName(),
        mCoverPage = new ThemeCoverPage(getActivity(), getThemeName(),
                previewInfo.resolveAccentColor(getResources()), previewInfo.icons,
                previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
                previewInfo.shapeDrawable, previewInfo.shapeAppIcons, null,
+12 −11
Original line number Diff line number Diff line
package com.android.customization.picker.theme;

import android.content.Context;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
@@ -45,21 +45,20 @@ abstract class ThemePreviewPage extends PreviewPage {
    final int accentColor;
    protected final LayoutInflater inflater;

    public ThemePreviewPage(Context context, @StringRes int titleResId,
            @DrawableRes int iconSrc, @LayoutRes int contentLayoutRes,
            @ColorInt int accentColor) {
        super(null);
    public ThemePreviewPage(Activity activity, @StringRes int titleResId,
            @DrawableRes int iconSrc, @LayoutRes int contentLayoutRes, @ColorInt int accentColor) {
        super(null, activity);
        this.nameResId = titleResId;
        if (iconSrc != Resources.ID_NULL) {
            this.icon = context.getResources().getDrawable(iconSrc, context.getTheme());
            int size = context.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
            this.icon = activity.getResources().getDrawable(iconSrc, activity.getTheme());
            int size = activity.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
            icon.setBounds(0, 0, size, size);
        } else {
            this.icon = null;
        }
        this.contentLayoutRes = contentLayoutRes;
        this.accentColor = accentColor;
        this.inflater = LayoutInflater.from(context);
        this.inflater = LayoutInflater.from(activity);
    }

    @Override
@@ -106,15 +105,17 @@ abstract class ThemePreviewPage extends PreviewPage {
        private final int mCornerRadius;
        private final ColorStateList mTintList;

        public ThemeCoverPage(Context context, String title, int accentColor, List<Drawable> icons,
        public ThemeCoverPage(Activity activity, String title, int accentColor,
                List<Drawable> icons,
                Typeface headlineFont, int cornerRadius,
                Drawable shapeDrawable,
                List<Drawable> shapeAppIcons,
                OnClickListener editClickListener,
                int[] colorButtonIds, int[] colorTileIds, int[][] colorTileIconIds,
                int[] shapeIconIds, OnLayoutChangeListener... wallpaperListeners) {
            super(context, 0, 0, R.layout.preview_card_cover_content, accentColor);
            mRes = context.getResources();
            super(activity, 0, 0, R.layout.preview_card_cover_content,
                    accentColor);
            mRes = activity.getResources();
            mTitle = title;
            mHeadlineFont = headlineFont;
            mIcons = icons;