1 /* 2 * Copyright (C) 2025 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 17 package com.android.settings.notification; 18 19 import static android.service.notification.Adjustment.KEY_SUMMARIZATION; 20 21 import android.app.Activity; 22 import android.app.Application; 23 import android.app.Flags; 24 import android.app.settings.SettingsEnums; 25 import android.content.Context; 26 27 import com.android.settings.R; 28 import com.android.settings.dashboard.DashboardFragment; 29 import com.android.settings.notification.app.HeaderPreferenceController; 30 import com.android.settings.search.BaseSearchIndexProvider; 31 import com.android.settingslib.applications.ApplicationsState; 32 import com.android.settingslib.search.SearchIndexable; 33 34 /** 35 * Fragment for summarized notifications. 36 */ 37 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) 38 public class SummarizationPreferenceFragment extends DashboardFragment { 39 40 @Override getMetricsCategory()41 public int getMetricsCategory() { 42 return SettingsEnums.SUMMARIZED_NOTIFICATIONS; 43 } 44 45 @Override getPreferenceScreenResId()46 protected int getPreferenceScreenResId() { 47 return R.xml.summarization_notifications_settings; 48 } 49 @Override getLogTag()50 protected String getLogTag() { 51 return "SummarizationPreferenceFragment"; 52 } 53 54 @Override onAttach(Context context)55 public void onAttach(Context context) { 56 super.onAttach(context); 57 if (use(AdjustmentExcludedAppsPreferenceController.class) != null) { 58 final Activity activity = getActivity(); 59 Application app = null; 60 ApplicationsState appState = null; 61 if (activity != null) { 62 app = activity.getApplication(); 63 } else { 64 app = null; 65 } 66 if (app != null) { 67 appState = ApplicationsState.getInstance(app); 68 } 69 use(AdjustmentExcludedAppsPreferenceController.class).onAttach( 70 appState, this, new NotificationBackend(), KEY_SUMMARIZATION); 71 } 72 } 73 74 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 75 new BaseSearchIndexProvider(R.xml.summarization_notifications_settings) { 76 77 @Override 78 protected boolean isPageSearchEnabled(Context context) { 79 return Flags.notificationClassificationUi(); 80 } 81 }; 82 } 83