Merge changes from topic "hearingAidsInT" into tm-dev

* changes:
  Add 'Live Caption' preference for hearing aids device in Device details page
  Update summary in Accessibility -> Hearing aids
  Header for hearing aids now listed in one summary
This commit is contained in:
Jason Hsu
2022-05-14 00:24:44 +00:00
committed by Android (Google) Code Review
7 changed files with 247 additions and 49 deletions

View File

@@ -75,10 +75,8 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
if (TextUtils.isEmpty(summaryText)) {
// If first summary is unavailable, not to show second summary.
mHeaderController.setSecondSummary((CharSequence)null);
} else {
// If both the hearing aids are connected, two device status should be shown.
mHeaderController.setSecondSummary(mDeviceManager.getSubDeviceSummary(mCachedDevice));
}
mHeaderController.setLabel(mCachedDevice.getName());
mHeaderController.setIcon(pair.first);
mHeaderController.setIconContentDescription(pair.second);

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.bluetooth;
import android.content.Context;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.lifecycle.Lifecycle;
/**
* This class adds related tools preference.
*/
public class BluetoothDetailsRelatedToolsController extends BluetoothDetailsController{
private static final String KEY_RELATED_TOOLS_GROUP = "bluetooth_related_tools";
private static final String KEY_LIVE_CAPTION = "live_caption";
public BluetoothDetailsRelatedToolsController(Context context,
PreferenceFragmentCompat fragment, CachedBluetoothDevice device, Lifecycle lifecycle) {
super(context, fragment, device, lifecycle);
lifecycle.addObserver(this);
}
@Override
public boolean isAvailable() {
return mCachedDevice.isHearingAidDevice();
}
@Override
protected void init(PreferenceScreen screen) {
if (!mCachedDevice.isHearingAidDevice()) {
return;
}
final PreferenceCategory preferenceCategory = screen.findPreference(getPreferenceKey());
final Preference liveCaptionPreference = screen.findPreference(KEY_LIVE_CAPTION);
if (!liveCaptionPreference.isVisible()) {
preferenceCategory.removePreference(liveCaptionPreference);
}
if (preferenceCategory.getPreferenceCount() == 0) {
screen.removePreference(preferenceCategory);
}
}
@Override
protected void refresh() {}
@Override
public String getPreferenceKey() {
return KEY_RELATED_TOOLS_GROUP;
}
}

View File

@@ -246,6 +246,8 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
mCachedDevice, lifecycle));
controllers.add(new BluetoothDetailsMacAddressController(context, this, mCachedDevice,
lifecycle));
controllers.add(new BluetoothDetailsRelatedToolsController(context, this, mCachedDevice,
lifecycle));
}
return controllers;
}