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 17 package com.android.settings.accessibility; 18 19 import android.content.Context; 20 import android.icu.text.MessageFormat; 21 import android.text.Html; 22 23 import androidx.preference.PreferenceScreen; 24 25 import com.android.settings.R; 26 27 /** 28 * Preference controller for accessibility button footer. 29 */ 30 public class AccessibilityButtonFooterPreferenceController extends 31 AccessibilityFooterPreferenceController { 32 AccessibilityButtonFooterPreferenceController(Context context, String key)33 public AccessibilityButtonFooterPreferenceController(Context context, String key) { 34 super(context, key); 35 } 36 37 @Override getLearnMoreText()38 protected String getLearnMoreText() { 39 return mContext.getString( 40 R.string.accessibility_button_gesture_footer_learn_more_content_description); 41 } 42 43 @Override getIntroductionTitle()44 protected String getIntroductionTitle() { 45 return mContext.getString(R.string.accessibility_button_about_title); 46 } 47 48 @Override displayPreference(PreferenceScreen screen)49 public void displayPreference(PreferenceScreen screen) { 50 // Need to update footerPreference's data before super.displayPreference(), then it will use 51 // data to update related property of footerPreference. 52 final int titleResource = AccessibilityUtil.isGestureNavigateEnabled(mContext) 53 ? R.string.accessibility_button_gesture_description 54 : R.string.accessibility_button_description; 55 final CharSequence footerText = Html.fromHtml( 56 MessageFormat.format(mContext.getString(titleResource), 1, 2, 3), 57 Html.FROM_HTML_MODE_COMPACT); 58 final AccessibilityFooterPreference footerPreference = 59 screen.findPreference(getPreferenceKey()); 60 footerPreference.setTitle(footerText); 61 super.displayPreference(screen); 62 } 63 } 64