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()32 public static WallpaperOnlyFragment newInstance() { 33 final WallpaperOnlyFragment fragment = new WallpaperOnlyFragment(); 34 final Bundle args = new Bundle(); 35 fragment.setArguments(args); 36 return fragment; 37 } 38 39 @Override getDefaultTitle()40 public CharSequence getDefaultTitle() { 41 return getString(R.string.wallpaper_app_name); 42 } 43 44 @Override filterAvailableSections( List<CustomizationSectionController<?>> controllers)45 protected List<CustomizationSectionController<?>> filterAvailableSections( 46 List<CustomizationSectionController<?>> controllers) { 47 List<CustomizationSectionController<?>> wallpaperOnlySections = controllers.stream() 48 .filter(controller -> controller instanceof ScreenPreviewSectionController 49 || controller instanceof ConnectedSectionController) 50 .collect(Collectors.toList()); 51 return super.filterAvailableSections(wallpaperOnlySections); 52 } 53 } 54