Loading src/com/android/customization/picker/BasePreviewAdapter.java +10 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); Loading src/com/android/customization/picker/clock/ClockFragment.java +8 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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; } Loading @@ -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())); } } } src/com/android/customization/picker/grid/GridFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading src/com/android/customization/picker/theme/CustomThemeNameFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading src/com/android/customization/picker/theme/ThemePreviewPage.java +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; Loading Loading @@ -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 Loading Loading @@ -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; Loading Loading
src/com/android/customization/picker/BasePreviewAdapter.java +10 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); Loading
src/com/android/customization/picker/clock/ClockFragment.java +8 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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; } Loading @@ -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())); } } }
src/com/android/customization/picker/grid/GridFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading
src/com/android/customization/picker/theme/CustomThemeNameFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading
src/com/android/customization/picker/theme/ThemePreviewPage.java +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; Loading Loading @@ -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 Loading Loading @@ -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; Loading