diff --git a/res/color/dream_card_color_state_list.xml b/res/color/dream_card_color_state_list.xml
index b5de7b4c377..b0c86bba121 100644
--- a/res/color/dream_card_color_state_list.xml
+++ b/res/color/dream_card_color_state_list.xml
@@ -17,6 +17,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/res/color/dream_card_text_color_state_list.xml b/res/color/dream_card_text_color_state_list.xml
new file mode 100644
index 00000000000..438855fd233
--- /dev/null
+++ b/res/color/dream_card_text_color_state_list.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/dream_preview_rounded_bg.xml b/res/drawable/dream_preview_rounded_bg.xml
new file mode 100644
index 00000000000..be83be560c0
--- /dev/null
+++ b/res/drawable/dream_preview_rounded_bg.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/dream_picker_layout.xml b/res/layout/dream_picker_layout.xml
index 6de7ff6fec9..68e2051c067 100644
--- a/res/layout/dream_picker_layout.xml
+++ b/res/layout/dream_picker_layout.xml
@@ -15,32 +15,25 @@
limitations under the License.
-->
-
-
+ android:clipToPadding="true"
+ android:nestedScrollingEnabled="false"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingBottom="@dimen/dream_preference_card_padding"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"/>
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/res/layout/dream_preference_layout.xml b/res/layout/dream_preference_layout.xml
index 2bc67ba3f01..b1aed735c38 100644
--- a/res/layout/dream_preference_layout.xml
+++ b/res/layout/dream_preference_layout.xml
@@ -17,7 +17,6 @@
-
-
-
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+ app:layout_constraintTop_toTopOf="@+id/preview"
+ app:layout_constraintBottom_toBottomOf="@+id/preview"
+ app:layout_constraintStart_toStartOf="@+id/preview"
+ app:layout_constraintEnd_toEndOf="@+id/preview"/>
@@ -82,8 +75,9 @@
android:gravity="center_vertical"
android:maxLines="1"
android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceListItemSmall"
- app:layout_constraintTop_toBottomOf="@+id/preview_container"
+ android:textSize="16sp"
+ android:textColor="@color/dream_card_text_color_state_list"
+ app:layout_constraintTop_toBottomOf="@+id/preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/icon"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index be1ba5b48c6..7ddfaa60ffc 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -449,7 +449,7 @@
8dp
18dp
10dp
- 10dp
+ 20dp
20dp
48dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5472a9d7b45..40e0008804e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -13905,11 +13905,13 @@
Confirm
- Preview screensaver
+ Preview screen saver
- Choose an image
-
- Choose more options
+ Choose a background
+
+ Show additional information
+
+ Display data time, date and weather on the screen saver
More settings
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a64eb1f5b3b..ebaea6b18aa 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -944,23 +944,10 @@
-
-
diff --git a/res/xml/dream_fragment_overview.xml b/res/xml/dream_fragment_overview.xml
index 9dfa105afcd..105cec47cc7 100644
--- a/res/xml/dream_fragment_overview.xml
+++ b/res/xml/dream_fragment_overview.xml
@@ -28,19 +28,13 @@
settings:controller="com.android.settings.dream.DreamPickerController"/>
-
-
-
-
+
if (previewImage != null) {
mPreviewView.setVisibility(View.VISIBLE);
mPreviewView.setImageDrawable(previewImage);
+ mPreviewView.setClipToOutline(true);
} else {
mPreviewView.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/dream/DreamComplicationPickerController.java b/src/com/android/settings/dream/DreamComplicationPickerController.java
deleted file mode 100644
index 09ed8da40d4..00000000000
--- a/src/com/android/settings/dream/DreamComplicationPickerController.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2022 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.settings.dream;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-
-import androidx.preference.PreferenceScreen;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.dream.DreamBackend;
-import com.android.settingslib.widget.LayoutPreference;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Controller for the component allowing a user to select overlays to show on top of dreams.
- */
-public class DreamComplicationPickerController extends BasePreferenceController {
- private static final String KEY = "dream_complication_picker";
-
- private final DreamBackend mBackend;
- private final Set mSupportedComplications;
-
- private class ComplicationItem implements IDreamItem {
- private final int mComplicationType;
- private boolean mEnabled;
-
- ComplicationItem(@DreamBackend.ComplicationType int complicationType) {
- mComplicationType = complicationType;
- mEnabled = mBackend.isComplicationEnabled(mComplicationType);
- }
-
- @Override
- public CharSequence getTitle() {
- return mBackend.getComplicationTitle(mComplicationType);
- }
-
- @Override
- public Drawable getIcon() {
- // TODO(b/215703483): add icon for each complication
- return null;
- }
-
- @Override
- public void onItemClicked() {
- mEnabled = !mEnabled;
- mBackend.setComplicationEnabled(mComplicationType, mEnabled);
- }
-
- @Override
- public Drawable getPreviewImage() {
- // TODO(b/215703483): add preview image for each complication
- return null;
- }
-
- @Override
- public boolean isActive() {
- return mEnabled;
- }
- }
-
- public DreamComplicationPickerController(Context context) {
- super(context, KEY);
- mBackend = DreamBackend.getInstance(context);
- mSupportedComplications = mBackend.getSupportedComplications();
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- @Override
- public int getAvailabilityStatus() {
- return mSupportedComplications.size() > 0 ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
-
- DreamAdapter adapter = new DreamAdapter(mSupportedComplications.stream()
- .map(ComplicationItem::new)
- .collect(Collectors.toList()));
-
- LayoutPreference pref = screen.findPreference(getPreferenceKey());
- if (pref != null) {
- final RecyclerView recyclerView = pref.findViewById(R.id.dream_list);
- recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
- recyclerView.setHasFixedSize(true);
- recyclerView.setAdapter(adapter);
- }
- }
-}
diff --git a/src/com/android/settings/dream/DreamComplicationPreferenceController.java b/src/com/android/settings/dream/DreamComplicationPreferenceController.java
new file mode 100644
index 00000000000..d9c4fb3512a
--- /dev/null
+++ b/src/com/android/settings/dream/DreamComplicationPreferenceController.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022 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.settings.dream;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.dream.DreamBackend;
+
+/**
+ * Controller for the {@link androidx.preference.SwitchPreference} which controls if dream
+ * overlays should be enabled.
+ */
+public class DreamComplicationPreferenceController extends TogglePreferenceController {
+ private final DreamBackend mBackend;
+
+ public DreamComplicationPreferenceController(Context context, String key) {
+ super(context, key);
+ mBackend = DreamBackend.getInstance(context);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mBackend.getSupportedComplications().isEmpty() ? CONDITIONALLY_UNAVAILABLE
+ : AVAILABLE;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mBackend.getEnabledComplications().containsAll(mBackend.getSupportedComplications());
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ for (int complication : mBackend.getSupportedComplications()) {
+ mBackend.setComplicationEnabled(complication, isChecked);
+ }
+ return true;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_display;
+ }
+}
diff --git a/src/com/android/settings/dream/DreamPickerController.java b/src/com/android/settings/dream/DreamPickerController.java
index 6d5463c1d6c..b7ba6142413 100644
--- a/src/com/android/settings/dream/DreamPickerController.java
+++ b/src/com/android/settings/dream/DreamPickerController.java
@@ -21,7 +21,7 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
-import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
@@ -71,16 +71,21 @@ public class DreamPickerController extends BasePreferenceController {
}
@Override
- public void updateState(Preference preference) {
- super.updateState(preference);
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
mAdapter = new DreamAdapter(mDreamInfos.stream()
.map(DreamItem::new)
.collect(Collectors.toList()));
- final RecyclerView recyclerView =
- ((LayoutPreference) preference).findViewById(R.id.dream_list);
+ final LayoutPreference pref = screen.findPreference(getPreferenceKey());
+ if (pref == null) {
+ return;
+ }
+ final RecyclerView recyclerView = pref.findViewById(R.id.dream_list);
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
+ recyclerView.addItemDecoration(
+ new GridSpacingItemDecoration(mContext, R.dimen.dream_preference_card_padding));
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(mAdapter);
}
diff --git a/src/com/android/settings/dream/DreamSettings.java b/src/com/android/settings/dream/DreamSettings.java
index 2acce07828e..bfa19a9e91f 100644
--- a/src/com/android/settings/dream/DreamSettings.java
+++ b/src/com/android/settings/dream/DreamSettings.java
@@ -34,14 +34,12 @@ import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.dream.DreamBackend;
import com.android.settingslib.dream.DreamBackend.WhenToDream;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
@SearchIndexable
@@ -52,7 +50,6 @@ public class DreamSettings extends DashboardFragment {
static final String WHILE_DOCKED_ONLY = "while_docked_only";
static final String EITHER_CHARGING_OR_DOCKED = "either_charging_or_docked";
static final String NEVER_DREAM = "never";
- private static final String COMPLICATIONS_CATEGORY_KEY = "dream_complication_category";
@WhenToDream
static int getSettingFromPrefKey(String key) {
@@ -138,14 +135,8 @@ public class DreamSettings extends DashboardFragment {
private static List buildPreferenceControllers(Context context) {
final List controllers = new ArrayList<>();
- final DreamComplicationPickerController complicationPickerController =
- new DreamComplicationPickerController(context);
-
- controllers.add(complicationPickerController);
- controllers.add(new WhenToDreamPreferenceController(context));
controllers.add(new DreamPickerController(context));
- controllers.add(new PreferenceCategoryController(context, COMPLICATIONS_CATEGORY_KEY)
- .setChildren(Collections.singletonList(complicationPickerController)));
+ controllers.add(new WhenToDreamPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/dream/GridSpacingItemDecoration.java b/src/com/android/settings/dream/GridSpacingItemDecoration.java
new file mode 100644
index 00000000000..6e6a5518e5e
--- /dev/null
+++ b/src/com/android/settings/dream/GridSpacingItemDecoration.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2022 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.settings.dream;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.view.View;
+
+import androidx.annotation.DimenRes;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+/**
+ * RecyclerView item decorator to be used with {@link GridLayoutManager} for applying padding to
+ * only the inner elements of the grid.
+ */
+public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
+ private final int mSpacing;
+ private final boolean mRtl;
+
+ public GridSpacingItemDecoration(Context context, @DimenRes int spacingId) {
+ mSpacing = context.getResources().getDimensionPixelSize(spacingId);
+ mRtl = context.getResources().getConfiguration().getLayoutDirection()
+ == View.LAYOUT_DIRECTION_RTL;
+ }
+
+ @Override
+ public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
+ RecyclerView.State state) {
+ final RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
+
+ if (!(layoutManager instanceof GridLayoutManager)) {
+ return;
+ }
+
+ final int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
+ final int position = parent.getChildAdapterPosition(view);
+ final int column = position % spanCount;
+
+ final int startPadding = column * mSpacing / spanCount;
+ final int endPadding = mSpacing - (column + 1) * mSpacing / spanCount;
+
+ outRect.left = mRtl ? endPadding : startPadding;
+ outRect.right = mRtl ? startPadding : endPadding;
+ if (position >= spanCount) {
+ outRect.top = mSpacing;
+ }
+ }
+}