1 /* 2 * Copyright (C) 2024 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.connecteddevice.virtual; 18 19 import android.content.Context; 20 21 import androidx.annotation.NonNull; 22 import androidx.annotation.Nullable; 23 import androidx.preference.Preference; 24 import androidx.preference.PreferenceScreen; 25 26 import com.android.settings.R; 27 import com.android.settings.core.BasePreferenceController; 28 29 /** Adds footer text on the virtual device details page. */ 30 public class VirtualDeviceDetailsFooterController extends BasePreferenceController { 31 32 private static final String KEY_VIRTUAL_DEVICE_FOOTER = "virtual_device_details_footer"; 33 34 @Nullable 35 private CharSequence mDeviceName; 36 VirtualDeviceDetailsFooterController(@onNull Context context)37 public VirtualDeviceDetailsFooterController(@NonNull Context context) { 38 super(context, KEY_VIRTUAL_DEVICE_FOOTER); 39 } 40 41 /** One-time initialization when the controller is first created. */ init(@onNull CharSequence deviceName)42 void init(@NonNull CharSequence deviceName) { 43 mDeviceName = deviceName; 44 } 45 46 @Override displayPreference(@onNull PreferenceScreen screen)47 public void displayPreference(@NonNull PreferenceScreen screen) { 48 super.displayPreference(screen); 49 Preference preference = screen.findPreference(getPreferenceKey()); 50 preference.setTitle(mContext.getString(R.string.virtual_device_details_footer_title, 51 mDeviceName)); 52 } 53 54 @Override getAvailabilityStatus()55 public int getAvailabilityStatus() { 56 return AVAILABLE; 57 } 58 } 59