Cleanup for theme picker
- Remove the ThemePreviewPage and related layout/dimens.
- Remove the v2 suffix, they are the v1 now.
Test: Build and run successfully
Bug: 151285476
Change-Id: Ie79b8676c3f28cbec77c04db65c16445276a3345
diff --git a/res/layout-land/fragment_custom_theme_name.xml b/res/layout-land/fragment_custom_theme_name.xml
index bc55bb6..53cf513 100644
--- a/res/layout-land/fragment_custom_theme_name.xml
+++ b/res/layout-land/fragment_custom_theme_name.xml
@@ -35,7 +35,7 @@
android:paddingBottom="@dimen/preview_content_padding_bottom"
android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<LinearLayout
android:id="@+id/options_section"
diff --git a/res/layout-land/fragment_theme_picker.xml b/res/layout-land/fragment_theme_picker.xml
index 915fb47..fe660cf 100644
--- a/res/layout-land/fragment_theme_picker.xml
+++ b/res/layout-land/fragment_theme_picker.xml
@@ -38,12 +38,12 @@
<FrameLayout
android:id="@+id/preview_card_container"
android:layout_width="match_parent"
- android:layout_height="@dimen/preview_content_height"
+ android:layout_height="wrap_content"
android:paddingTop="@dimen/preview_content_padding_top"
android:paddingBottom="@dimen/preview_content_padding_bottom"
android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
</FrameLayout>
diff --git a/res/layout/fragment_custom_theme_name.xml b/res/layout/fragment_custom_theme_name.xml
index f5dfd42..27a8f19 100644
--- a/res/layout/fragment_custom_theme_name.xml
+++ b/res/layout/fragment_custom_theme_name.xml
@@ -43,7 +43,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<androidx.constraintlayout.widget.Guideline
diff --git a/res/layout/fragment_theme_full_preview.xml b/res/layout/fragment_theme_full_preview.xml
index 7573c5b..008a795 100644
--- a/res/layout/fragment_theme_full_preview.xml
+++ b/res/layout/fragment_theme_full_preview.xml
@@ -31,6 +31,6 @@
android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index c61c389..a773207 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -46,7 +46,7 @@
app:layout_constraintHeight_max="@dimen/preview_pager_max_height"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHeight_percent="@dimen/preview_pager_maximum_height_ratio">
- <include layout="@layout/theme_preview_card_v2"/>
+ <include layout="@layout/theme_preview_card"/>
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
diff --git a/res/layout/preview_card_cover_content.xml b/res/layout/preview_card_cover_content.xml
deleted file mode 100644
index 3ab13a4..0000000
--- a/res/layout/preview_card_cover_content.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2019 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.
--->
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_marginHorizontal="@dimen/preview_theme_cover_content_extra_margin"
- android:gravity="center_horizontal"
- android:clipChildren="false"
- tools:showIn="@layout/theme_preview_card">
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_marginLeft="6dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:id="@+id/preview_color_qs_0_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_0_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_gravity="center_horizontal">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_gravity="center"
- android:id="@+id/preview_color_qs_1_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_1_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
- <FrameLayout
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:layout_marginRight="6dp"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true">
- <ImageView
- android:layout_width="@dimen/preview_theme_icon_size"
- android:layout_height="@dimen/preview_theme_icon_size"
- android:id="@+id/preview_color_qs_2_bg"/>
- <ImageView
- android:layout_width="@dimen/preview_theme_tile_size"
- android:layout_height="@dimen/preview_theme_tile_size"
- android:id="@+id/preview_color_qs_2_icon"
- android:tint="@color/tile_enabled_icon_color"
- android:layout_gravity="center"/>
- </FrameLayout>
-
- <ImageView
- android:id="@+id/shape_preview_icon_0"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_marginVertical="4dp"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:elevation="4dp"/>
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_centerHorizontal="true">
- <ImageView
- android:id="@+id/shape_preview_icon_1"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_gravity="center_horizontal"
- android:layout_marginVertical="4dp"
- android:elevation="4dp"/>
- </FrameLayout>
- <ImageView
- android:id="@+id/shape_preview_icon_2"
- android:layout_width="@dimen/preview_theme_shape_size"
- android:layout_height="@dimen/preview_theme_shape_size"
- android:layout_marginVertical="4dp"
- android:layout_marginRight="2dp"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:elevation="4dp"/>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true">
- <include layout="@layout/theme_cover_qsb"/>
- </FrameLayout>
-</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/theme_preview_card.xml b/res/layout/theme_preview_card.xml
index f80e846..74d1e68 100644
--- a/res/layout/theme_preview_card.xml
+++ b/res/layout/theme_preview_card.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2019 The Android Open Source Project
+ 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.
@@ -16,12 +16,24 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- style="@style/PreviewCard"
+ style="@style/FullContentPreviewCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:contentPadding="0dp">
+ android:layout_gravity="center">
- <include layout="@layout/theme_component_preview"/>
+ <ImageView
+ android:id="@+id/wallpaper_preview_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/primary_color" />
+
+ <SurfaceView
+ android:id="@+id/wallpaper_preview_surface"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <FrameLayout
+ android:id="@+id/theme_preview_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
</androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/theme_preview_card_v2.xml b/res/layout/theme_preview_card_v2.xml
deleted file mode 100644
index 74d1e68..0000000
--- a/res/layout/theme_preview_card_v2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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.
--->
-<androidx.cardview.widget.CardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/FullContentPreviewCard"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center">
-
- <ImageView
- android:id="@+id/wallpaper_preview_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/primary_color" />
-
- <SurfaceView
- android:id="@+id/wallpaper_preview_surface"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <FrameLayout
- android:id="@+id/theme_preview_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-</androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/theme_preview_content_v2.xml b/res/layout/theme_preview_content.xml
similarity index 100%
rename from res/layout/theme_preview_content_v2.xml
rename to res/layout/theme_preview_content.xml
diff --git a/res/values-h740dp/dimens.xml b/res/values-h740dp/dimens.xml
index a752b6b..250262f 100644
--- a/res/values-h740dp/dimens.xml
+++ b/res/values-h740dp/dimens.xml
@@ -21,7 +21,6 @@
<dimen name="preview_theme_icon_size">40dp</dimen>
<dimen name="preview_theme_tile_size">20dp</dimen>
<dimen name="preview_theme_shape_size">52dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">8dp</dimen>
<dimen name="preview_theme_content_min_height">152dp</dimen>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index bd37bae..134bfa7 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -29,9 +29,7 @@
<dimen name="preview_theme_icon_size">26dp</dimen>
<dimen name="preview_theme_tile_size">14dp</dimen>
<dimen name="preview_theme_shape_size">30dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">0dp</dimen>
<dimen name="preview_theme_content_bottom">8dp</dimen>
- <dimen name="preview_theme_cover_content_bottom">36dp</dimen>
<dimen name="font_preview_divider_gap">12dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ec21329..44b9f30 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -68,9 +68,7 @@
<dimen name="preview_theme_shape_size">36dp</dimen>
<dimen name="preview_theme_cover_topbar_clock_size">12sp</dimen>
<dimen name="preview_theme_cover_topbar_icon_size">16dp</dimen>
- <dimen name="preview_theme_cover_content_extra_margin">16dp</dimen>
<dimen name="preview_theme_content_bottom">@dimen/min_taptarget_height</dimen>
- <dimen name="preview_theme_cover_content_bottom">@dimen/preview_theme_content_bottom</dimen>
<!-- For the new preview of theme picker. -->
<dimen name="preview_theme_content_padding_top">12dp</dimen>
@@ -92,7 +90,6 @@
<dimen name="preview_theme_color_icons_buttons_margin_bottom">28dp</dimen>
<!-- For the customization previews on the picker. -->
- <dimen name="preview_content_height">@dimen/preview_pager_height</dimen>
<dimen name="preview_content_padding_top">@dimen/preview_page_top_margin</dimen>
<dimen name="preview_content_padding_bottom">@dimen/indicator_container_height</dimen>
diff --git a/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java b/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
index a5ebbc2..684ac51 100644
--- a/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
+++ b/src/com/android/customization/picker/theme/ThemeOptionPreviewer.java
@@ -107,7 +107,7 @@
mContext = context;
mContentView = LayoutInflater.from(context).inflate(
- R.layout.theme_preview_content_v2, /* root= */ null);
+ R.layout.theme_preview_content, /* root= */ null);
mStatusBarClock = mContentView.findViewById(R.id.theme_preview_clock);
mSmartSpaceDate = mContentView.findViewById(R.id.smart_space_date);
updateTime();
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
deleted file mode 100644
index b8152d9..0000000
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ /dev/null
@@ -1,276 +0,0 @@
-package com.android.customization.picker.theme;
-
-import android.app.Activity;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.icu.text.DateFormat;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLayoutChangeListener;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.LayoutRes;
-import androidx.annotation.StringRes;
-import androidx.constraintlayout.widget.Guideline;
-
-import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
-import com.android.wallpaper.R;
-
-import java.text.FieldPosition;
-import java.util.Calendar;
-import java.util.List;
-import java.util.TimeZone;
-
-abstract class ThemePreviewPage extends PreviewPage {
-
- public interface TimeContainer {
- void updateTime();
- }
-
- @StringRes
- final int nameResId;
- final Drawable icon;
- @LayoutRes
- final int contentLayoutRes;
- @ColorInt
- final int accentColor;
- protected final LayoutInflater inflater;
-
- 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 = 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(activity);
- }
-
- @Override
- public void bindPreviewContent() {
- TextView header = card.findViewById(R.id.theme_preview_card_header);
- header.setText(nameResId);
- header.setCompoundDrawables(null, icon, null, null);
- header.setCompoundDrawableTintList(ColorStateList.valueOf(accentColor));
- card.findViewById(R.id.theme_preview_top_bar).setVisibility(View.GONE);
- card.findViewById(R.id.edit_label).setVisibility(View.GONE);
-
- ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
- inflater.inflate(contentLayoutRes, body, true);
- bindBody(false);
- }
-
- protected boolean containsWallpaper() {
- return false;
- }
-
- protected abstract void bindBody(boolean forceRebind);
-
- static class ThemeCoverPage extends ThemePreviewPage implements TimeContainer {
-
- public static final int COVER_PAGE_WALLPAPER_ALPHA = 0x66;
- /**
- * Maps which icon from ResourceConstants#ICONS_FOR_PREVIEW to use for each icon in the
- * top bar (fake "status bar") of the cover page.
- */
- private static final int [] sTopBarIconToPreviewIcon = new int [] { 0, 6, 7 };
-
- private final Typeface mHeadlineFont;
- private final List<Drawable> mIcons;
- private final List<Drawable> mShapeAppIcons;
- private Drawable mShapeDrawable;
- private final int[] mColorButtonIds;
- private final int[] mColorTileIds;
- private final int[][] mColorTileIconIds;
- private final int[] mShapeIconIds;
- private final Resources mRes;
- private String mTitle;
- private OnClickListener mEditClickListener;
- private final OnLayoutChangeListener[] mListeners;
- private final int mCornerRadius;
- private final ColorStateList mTintList;
-
- 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(activity, 0, 0, R.layout.preview_card_cover_content,
- accentColor);
- mRes = activity.getResources();
- mTitle = title;
- mHeadlineFont = headlineFont;
- mIcons = icons;
- mCornerRadius = cornerRadius;
- mShapeDrawable = shapeDrawable;
- mShapeAppIcons = shapeAppIcons;
- mEditClickListener = editClickListener;
- mColorButtonIds = colorButtonIds;
- mColorTileIds = colorTileIds;
- mColorTileIconIds = colorTileIconIds;
- mShapeIconIds = shapeIconIds;
- mListeners = wallpaperListeners;
- // Color QS icons:
- int controlGreyColor = mRes.getColor(R.color.control_grey, null);
- mTintList = new ColorStateList(
- new int[][]{
- new int[]{android.R.attr.state_selected},
- new int[]{android.R.attr.state_checked},
- new int[]{-android.R.attr.state_enabled},
- },
- new int[] {
- accentColor,
- accentColor,
- controlGreyColor
- }
- );
- }
-
- @Override
- protected void bindBody(boolean forceRebind) {
- if (card == null) {
- return;
- }
- if (mListeners != null) {
- for (OnLayoutChangeListener listener : mListeners) {
- if (listener != null) {
- card.addOnLayoutChangeListener(listener);
- }
- }
- }
-
- if (forceRebind) {
- card.requestLayout();
- }
-
- for (int i = 0; i < mColorButtonIds.length; i++) {
- CompoundButton button = card.findViewById(mColorButtonIds[i]);
- if (button != null) {
- button.setButtonTintList(mTintList);
- }
- }
- for (int i = 0; i < 3 && i < mIcons.size(); i++) {
- Drawable icon = mIcons.get(mColorTileIconIds[i][1]).getConstantState()
- .newDrawable().mutate();
- Drawable bgShape = mShapeDrawable.getConstantState().newDrawable();
- bgShape.setTint(accentColor);
-
- ImageView bg = card.findViewById(mColorTileIds[i]);
- bg.setImageDrawable(bgShape);
- ImageView fg = card.findViewById(mColorTileIconIds[i][0]);
- fg.setImageDrawable(icon);
- }
-
- // Shape preview icons:
- for (int i = 0; i < 3 && i < mShapeAppIcons.size(); i++) {
- ImageView iconView = card.findViewById(mShapeIconIds[i]);
- iconView.setBackground(mShapeAppIcons.get(i));
- }
- }
-
- @Override
- public void bindPreviewContent() {
- TextView header = card.findViewById(R.id.theme_preview_card_header);
- header.setText(mTitle);
- header.setTextAppearance(R.style.CoverTitleTextAppearance);
- header.setTypeface(mHeadlineFont);
-
- card.findViewById(R.id.theme_preview_top_bar).setVisibility(View.VISIBLE);
- TextView clock = card.findViewById(R.id.theme_preview_clock);
- clock.setText(getFormattedTime());
- clock.setTypeface(mHeadlineFont);
-
- ViewGroup iconsContainer = card.findViewById(R.id.theme_preview_top_bar_icons);
-
- for (int i = 0; i < iconsContainer.getChildCount(); i++) {
- int iconIndex = sTopBarIconToPreviewIcon[i];
- if (iconIndex < mIcons.size()) {
- ((ImageView) iconsContainer.getChildAt(i))
- .setImageDrawable(mIcons.get(iconIndex).getConstantState()
- .newDrawable().mutate());
- } else {
- iconsContainer.getChildAt(i).setVisibility(View.GONE);
- }
- }
-
- ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
-
- inflater.inflate(contentLayoutRes, body, true);
-
- bindBody(false);
-
- TextView editLabel = card.findViewById(R.id.edit_label);
- editLabel.setOnClickListener(mEditClickListener);
- card.setOnClickListener(mEditClickListener);
- card.setClickable(mEditClickListener != null);
-
- editLabel.setVisibility(mEditClickListener != null
- ? View.VISIBLE : View.INVISIBLE);
-
- View qsb = card.findViewById(R.id.theme_qsb);
- if (qsb != null && qsb.getVisibility() == View.VISIBLE) {
- if (qsb.getBackground() instanceof GradientDrawable) {
- GradientDrawable bg = (GradientDrawable) qsb.getBackground();
- float cornerRadius = useRoundedQSB(mCornerRadius)
- ? (float)qsb.getLayoutParams().height / 2 : mCornerRadius;
- bg.setCornerRadii(new float[]{
- cornerRadius, cornerRadius, cornerRadius, cornerRadius,
- cornerRadius, cornerRadius, cornerRadius, cornerRadius});
- }
- }
-
- Guideline guideline = card.findViewById(R.id.guideline);
- if (guideline != null) {
- guideline.setGuidelineEnd(card.getResources().getDimensionPixelOffset(
- R.dimen.preview_theme_cover_content_bottom));
- }
- }
-
- @Override
- public void updateTime() {
- if (card != null) {
- ((TextView) card.findViewById(R.id.theme_preview_clock)).setText(
- getFormattedTime());
- }
- }
-
- private boolean useRoundedQSB(int cornerRadius) {
- return cornerRadius >=
- card.getResources().getDimensionPixelSize(R.dimen.roundCornerThreshold);
- }
-
- private String getFormattedTime() {
- DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
- StringBuffer time = new StringBuffer();
- FieldPosition amPmPosition = new FieldPosition(DateFormat.Field.AM_PM);
- df.format(Calendar.getInstance(TimeZone.getDefault()).getTime(), time, amPmPosition);
- if (amPmPosition.getBeginIndex() > 0) {
- time.delete(amPmPosition.getBeginIndex(), amPmPosition.getEndIndex());
- }
- return time.toString();
- }
-
- @Override
- protected boolean containsWallpaper() {
- return true;
- }
- }
-}