1 /* 2 * Copyright (C) 2019 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.accessibility; 18 19 import android.app.Dialog; 20 import android.app.settings.SettingsEnums; 21 import android.content.Context; 22 23 import com.android.settings.DialogCreatable; 24 import com.android.settings.R; 25 import com.android.settings.dashboard.DashboardFragment; 26 import com.android.settings.search.BaseSearchIndexProvider; 27 import com.android.settingslib.search.SearchIndexable; 28 29 /** Settings page for magnification. */ 30 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) 31 public class MagnificationSettingsFragment extends DashboardFragment implements 32 MagnificationModePreferenceController.DialogHelper { 33 34 private static final String TAG = "MagnificationSettingsFragment"; 35 36 private DialogCreatable mDialogDelegate; 37 38 39 @Override getMetricsCategory()40 public int getMetricsCategory() { 41 return SettingsEnums.ACCESSIBILITY_MAGNIFICATION_SETTINGS; 42 } 43 44 @Override onAttach(Context context)45 public void onAttach(Context context) { 46 super.onAttach(context); 47 use(MagnificationModePreferenceController.class).setDialogHelper(this); 48 } 49 50 @Override showDialog(int dialogId)51 public void showDialog(int dialogId) { 52 super.showDialog(dialogId); 53 } 54 55 @Override setDialogDelegate(DialogCreatable delegate)56 public void setDialogDelegate(DialogCreatable delegate) { 57 mDialogDelegate = delegate; 58 } 59 60 @Override getDialogMetricsCategory(int dialogId)61 public int getDialogMetricsCategory(int dialogId) { 62 if (mDialogDelegate != null) { 63 return mDialogDelegate.getDialogMetricsCategory(dialogId); 64 } 65 return 0; 66 } 67 68 @Override getLogTag()69 protected String getLogTag() { 70 return TAG; 71 } 72 73 @Override getPreferenceScreenResId()74 protected int getPreferenceScreenResId() { 75 return R.xml.accessibility_magnification_service_settings; 76 } 77 78 @Override onCreateDialog(int dialogId)79 public Dialog onCreateDialog(int dialogId) { 80 if (mDialogDelegate != null) { 81 final Dialog dialog = mDialogDelegate.onCreateDialog(dialogId); 82 if (dialog != null) { 83 return dialog; 84 } 85 } 86 throw new IllegalArgumentException("Unsupported dialogId " + dialogId); 87 } 88 89 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 90 new BaseSearchIndexProvider(R.xml.accessibility_magnification_service_settings); 91 } 92