Merge "[hearing devices page] Add feature flag to control visibility of the hearing devices page"

This commit is contained in:
Jason Hsu
2022-12-20 10:23:58 +00:00
committed by Android (Google) Code Review
4 changed files with 183 additions and 2 deletions

View File

@@ -16,7 +16,6 @@
package com.android.settings.accessibility;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHapClient;
@@ -29,6 +28,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -129,6 +129,11 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
final CachedBluetoothDevice device = getConnectedHearingAidDevice();
if (FeatureFlagUtils.isEnabled(mContext,
FeatureFlagUtils.SETTINGS_ACCESSIBILITY_HEARING_AID_PAGE)) {
launchHearingAidPage();
return true;
}
if (device == null) {
launchHearingAidInstructionDialog();
} else {
@@ -295,7 +300,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC
.setDestination(BluetoothDeviceDetailsFragment.class.getName())
.setArguments(args)
.setTitleRes(R.string.device_details_title)
.setSourceMetricsCategory(SettingsEnums.ACCESSIBILITY)
.setSourceMetricsCategory(getMetricsCategory())
.launch();
}
@@ -304,4 +309,11 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC
HearingAidDialogFragment fragment = HearingAidDialogFragment.newInstance();
fragment.show(mFragmentManager, HearingAidDialogFragment.class.toString());
}
private void launchHearingAidPage() {
new SubSettingLauncher(mContext)
.setDestination(AccessibilityHearingAidsFragment.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
.launch();
}
}

View File

@@ -0,0 +1,68 @@
/*
* 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.accessibility;
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.settings.R;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
/** Accessibility settings for hearing aids. */
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class AccessibilityHearingAidsFragment extends RestrictedDashboardFragment {
private static final String TAG = "AccessibilityHearingAidsFragment";
public AccessibilityHearingAidsFragment() {
super(DISALLOW_CONFIG_BLUETOOTH);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO(b/237625815): Add shortcutPreference by extending
// AccessibilityShortcutPreferenceFragment
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public int getMetricsCategory() {
// TODO(b/262839191): To be updated settings_enums.proto
return 0;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.accessibility_hearing_aids;
}
@Override
protected String getLogTag() {
return TAG;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_hearing_aids);
}