1 /* 2 * Copyright (C) 2022 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 static com.android.settings.accessibility.TextReadingPreferenceFragment.EXTRA_LAUNCHED_FROM; 20 21 import android.content.Context; 22 import android.os.Bundle; 23 24 import androidx.preference.Preference; 25 26 import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; 27 import com.android.settings.core.BasePreferenceController; 28 29 /** 30 * The base controller for the fragment{@link TextReadingPreferenceFragment}. 31 */ 32 public class TextReadingFragmentBaseController extends BasePreferenceController { 33 @EntryPoint 34 private int mEntryPoint; 35 TextReadingFragmentBaseController(Context context, String preferenceKey)36 private TextReadingFragmentBaseController(Context context, String preferenceKey) { 37 super(context, preferenceKey); 38 } 39 TextReadingFragmentBaseController(Context context, String preferenceKey, @EntryPoint int entryPoint)40 TextReadingFragmentBaseController(Context context, String preferenceKey, 41 @EntryPoint int entryPoint) { 42 this(context, preferenceKey); 43 mEntryPoint = entryPoint; 44 } 45 46 @Override getAvailabilityStatus()47 public int getAvailabilityStatus() { 48 return AVAILABLE; 49 } 50 51 @Override handlePreferenceTreeClick(Preference preference)52 public boolean handlePreferenceTreeClick(Preference preference) { 53 if (getPreferenceKey().equals(preference.getKey())) { 54 final Bundle extras = preference.getExtras(); 55 extras.putInt(EXTRA_LAUNCHED_FROM, mEntryPoint); 56 } 57 58 return super.handlePreferenceTreeClick(preference); 59 } 60 } 61