Loading res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -13831,6 +13831,13 @@ <string name="tare_dialog_confirm_button_title">Confirm</string> <!-- Button to preview the selected screensaver in settings [CHAR LIMIT=40] --> <string name="dream_preview_button_title">Preview screensaver</string> <!-- The title of the category to show for the screensaver selector in settings [CHAR LIMIT=none] --> <string name="dream_picker_category">Choose an image</string> <!-- The title of the category to show for the screensaver overlay selector in settings [CHAR LIMIT=none] --> <string name="dream_complications_picker_category">Choose more options</string> <!-- The title of the category to show for the screensaver miscellaneous settings [CHAR LIMIT=none] --> <string name="dream_more_settings_category">More settings</string> <!-- Button to customize the screensaver [CHAR LIMIT=20] --> <string name="customize_button_title">Customize</string> res/xml/dream_fragment_overview.xml +27 −10 Original line number Diff line number Diff line Loading @@ -19,15 +19,32 @@ xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/screensaver_settings_title"> <PreferenceCategory android:title="@string/dream_picker_category"> <com.android.settingslib.widget.LayoutPreference android:key="dream_picker" android:selectable="false" android:layout="@layout/dream_picker_layout" settings:controller="com.android.settings.dream.DreamPickerController"/> </PreferenceCategory> <PreferenceCategory android:key="dream_complication_category" android:title="@string/dream_complications_picker_category" settings:controller="com.android.settings.dream.DreamComplicationCategoryController"> <com.android.settingslib.widget.LayoutPreference android:key="dream_complication_picker" android:selectable="false" android:layout="@layout/dream_picker_layout" settings:controller="com.android.settings.dream.DreamComplicationPickerController"/> </PreferenceCategory> <PreferenceCategory android:title="@string/dream_more_settings_category"> <Preference android:key="when_to_start" android:title="@string/screensaver_settings_when_to_dream" android:fragment="com.android.settings.dream.WhenToDreamPicker"/> </PreferenceCategory> </PreferenceScreen> src/com/android/settings/dream/DreamAdapter.java +8 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,14 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { */ public void bindView(IDreamItem item) { mTitleView.setText(item.getTitle()); mPreviewView.setImageDrawable(item.getPreviewImage()); final Drawable previewImage = item.getPreviewImage(); if (previewImage != null) { mPreviewView.setVisibility(View.VISIBLE); mPreviewView.setImageDrawable(previewImage); } else { mPreviewView.setVisibility(View.GONE); } final Drawable icon = item.getIcon(); if (icon instanceof VectorDrawable) { Loading src/com/android/settings/dream/DreamComplicationPickerController.java 0 → 100644 +116 −0 Original line number Diff line number Diff line /* * 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 Drawable mEnabledDrawable; private final Set<Integer> mSupportedComplications; private DreamAdapter mAdapter; 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 mEnabled ? mEnabledDrawable : null; } @Override public void onItemClicked() { mEnabled = !mEnabled; mBackend.setComplicationEnabled(mComplicationType, mEnabled); mAdapter.notifyDataSetChanged(); } @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(); mEnabledDrawable = context.getDrawable(R.drawable.ic_dream_check_circle); } @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); mAdapter = 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.setAdapter(mAdapter); } } } src/com/android/settings/dream/DreamPickerController.java +5 −5 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import java.util.stream.Collectors; * Controller for the dream picker where the user can select a screensaver. */ public class DreamPickerController extends BasePreferenceController { public static final String KEY = "dream_picker"; private static final String KEY = "dream_picker"; private final DreamBackend mBackend; private final MetricsFeatureProvider mMetricsFeatureProvider; Loading @@ -51,12 +51,12 @@ public class DreamPickerController extends BasePreferenceController { private DreamBackend.DreamInfo mActiveDream; private DreamAdapter mAdapter; public DreamPickerController(Context context, String preferenceKey) { this(context, preferenceKey, DreamBackend.getInstance(context)); public DreamPickerController(Context context) { this(context, DreamBackend.getInstance(context)); } public DreamPickerController(Context context, String preferenceKey, DreamBackend backend) { super(context, preferenceKey); public DreamPickerController(Context context, DreamBackend backend) { super(context, KEY); mBackend = backend; mDreamInfos = mBackend.getDreamInfos(); mActiveDrawable = context.getDrawable(R.drawable.ic_dream_check_circle); Loading Loading
res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -13831,6 +13831,13 @@ <string name="tare_dialog_confirm_button_title">Confirm</string> <!-- Button to preview the selected screensaver in settings [CHAR LIMIT=40] --> <string name="dream_preview_button_title">Preview screensaver</string> <!-- The title of the category to show for the screensaver selector in settings [CHAR LIMIT=none] --> <string name="dream_picker_category">Choose an image</string> <!-- The title of the category to show for the screensaver overlay selector in settings [CHAR LIMIT=none] --> <string name="dream_complications_picker_category">Choose more options</string> <!-- The title of the category to show for the screensaver miscellaneous settings [CHAR LIMIT=none] --> <string name="dream_more_settings_category">More settings</string> <!-- Button to customize the screensaver [CHAR LIMIT=20] --> <string name="customize_button_title">Customize</string>
res/xml/dream_fragment_overview.xml +27 −10 Original line number Diff line number Diff line Loading @@ -19,15 +19,32 @@ xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/screensaver_settings_title"> <PreferenceCategory android:title="@string/dream_picker_category"> <com.android.settingslib.widget.LayoutPreference android:key="dream_picker" android:selectable="false" android:layout="@layout/dream_picker_layout" settings:controller="com.android.settings.dream.DreamPickerController"/> </PreferenceCategory> <PreferenceCategory android:key="dream_complication_category" android:title="@string/dream_complications_picker_category" settings:controller="com.android.settings.dream.DreamComplicationCategoryController"> <com.android.settingslib.widget.LayoutPreference android:key="dream_complication_picker" android:selectable="false" android:layout="@layout/dream_picker_layout" settings:controller="com.android.settings.dream.DreamComplicationPickerController"/> </PreferenceCategory> <PreferenceCategory android:title="@string/dream_more_settings_category"> <Preference android:key="when_to_start" android:title="@string/screensaver_settings_when_to_dream" android:fragment="com.android.settings.dream.WhenToDreamPicker"/> </PreferenceCategory> </PreferenceScreen>
src/com/android/settings/dream/DreamAdapter.java +8 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,14 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { */ public void bindView(IDreamItem item) { mTitleView.setText(item.getTitle()); mPreviewView.setImageDrawable(item.getPreviewImage()); final Drawable previewImage = item.getPreviewImage(); if (previewImage != null) { mPreviewView.setVisibility(View.VISIBLE); mPreviewView.setImageDrawable(previewImage); } else { mPreviewView.setVisibility(View.GONE); } final Drawable icon = item.getIcon(); if (icon instanceof VectorDrawable) { Loading
src/com/android/settings/dream/DreamComplicationPickerController.java 0 → 100644 +116 −0 Original line number Diff line number Diff line /* * 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 Drawable mEnabledDrawable; private final Set<Integer> mSupportedComplications; private DreamAdapter mAdapter; 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 mEnabled ? mEnabledDrawable : null; } @Override public void onItemClicked() { mEnabled = !mEnabled; mBackend.setComplicationEnabled(mComplicationType, mEnabled); mAdapter.notifyDataSetChanged(); } @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(); mEnabledDrawable = context.getDrawable(R.drawable.ic_dream_check_circle); } @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); mAdapter = 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.setAdapter(mAdapter); } } }
src/com/android/settings/dream/DreamPickerController.java +5 −5 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ import java.util.stream.Collectors; * Controller for the dream picker where the user can select a screensaver. */ public class DreamPickerController extends BasePreferenceController { public static final String KEY = "dream_picker"; private static final String KEY = "dream_picker"; private final DreamBackend mBackend; private final MetricsFeatureProvider mMetricsFeatureProvider; Loading @@ -51,12 +51,12 @@ public class DreamPickerController extends BasePreferenceController { private DreamBackend.DreamInfo mActiveDream; private DreamAdapter mAdapter; public DreamPickerController(Context context, String preferenceKey) { this(context, preferenceKey, DreamBackend.getInstance(context)); public DreamPickerController(Context context) { this(context, DreamBackend.getInstance(context)); } public DreamPickerController(Context context, String preferenceKey, DreamBackend backend) { super(context, preferenceKey); public DreamPickerController(Context context, DreamBackend backend) { super(context, KEY); mBackend = backend; mDreamInfos = mBackend.getDreamInfos(); mActiveDrawable = context.getDrawable(R.drawable.ic_dream_check_circle); Loading