1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.wallpaper.picker; 17 18 import android.os.Bundle; 19 20 import com.android.wallpaper.R; 21 import com.android.wallpaper.model.CustomizationSectionController; 22 import com.android.wallpaper.picker.customization.ui.section.ConnectedSectionController; 23 import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController; 24 25 import java.util.List; 26 import java.util.stream.Collectors; 27 28 /** The Fragment UI for wallpaper only section. */ 29 public class WallpaperOnlyFragment extends CustomizationPickerFragment { 30 31 /** Returns a new instance of {@link WallpaperOnlyFragment}. */ newInstance(boolean isUseRevampedUi)32 public static WallpaperOnlyFragment newInstance(boolean isUseRevampedUi) { 33 final WallpaperOnlyFragment fragment = new WallpaperOnlyFragment(); 34 final Bundle args = new Bundle(); 35 args.putBoolean(KEY_IS_USE_REVAMPED_UI, isUseRevampedUi); 36 fragment.setArguments(args); 37 return fragment; 38 } 39 40 @Override getDefaultTitle()41 public CharSequence getDefaultTitle() { 42 return getString(R.string.wallpaper_app_name); 43 } 44 45 @Override filterAvailableSections( List<CustomizationSectionController<?>> controllers)46 protected List<CustomizationSectionController<?>> filterAvailableSections( 47 List<CustomizationSectionController<?>> controllers) { 48 List<CustomizationSectionController<?>> wallpaperOnlySections = controllers.stream() 49 .filter(controller -> controller instanceof ScreenPreviewSectionController 50 || controller instanceof ConnectedSectionController) 51 .collect(Collectors.toList()); 52 return super.filterAvailableSections(wallpaperOnlySections); 53 } 54 } 55