Remove extra space around profiles and audio category
BUG: 376021212 Test: local test Flag: com.android.settings.flags.enable_bluetooth_device_details_polish Change-Id: If3e18ce26c688087158542e28e4981cf821fa2b8
This commit is contained in:
26
res/layout/preference_category_bluetooth_no_padding.xml
Normal file
26
res/layout/preference_category_bluetooth_no_padding.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingTop="0dp"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
</LinearLayout>
|
||||||
@@ -38,6 +38,7 @@ import androidx.preference.PreferenceFragmentCompat;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.flags.Flags;
|
||||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LeAudioProfile;
|
import com.android.settingslib.bluetooth.LeAudioProfile;
|
||||||
@@ -134,6 +135,9 @@ public class BluetoothDetailsAudioDeviceTypeController extends BluetoothDetailsC
|
|||||||
@Override
|
@Override
|
||||||
protected void init(PreferenceScreen screen) {
|
protected void init(PreferenceScreen screen) {
|
||||||
mProfilesContainer = screen.findPreference(getPreferenceKey());
|
mProfilesContainer = screen.findPreference(getPreferenceKey());
|
||||||
|
if (Flags.enableBluetoothDeviceDetailsPolish()) {
|
||||||
|
mProfilesContainer.setLayoutResource(R.layout.preference_category_bluetooth_no_padding);
|
||||||
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
new HashMap<String, List<CachedBluetoothDevice>>();
|
new HashMap<String, List<CachedBluetoothDevice>>();
|
||||||
private boolean mIsLeAudioToggleEnabled = false;
|
private boolean mIsLeAudioToggleEnabled = false;
|
||||||
private boolean mIsLeAudioOnlyDevice = false;
|
private boolean mIsLeAudioOnlyDevice = false;
|
||||||
|
private boolean mHasExtraSpace;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PreferenceCategory mProfilesContainer;
|
PreferenceCategory mProfilesContainer;
|
||||||
@@ -106,7 +107,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
LocalBluetoothManager manager,
|
LocalBluetoothManager manager,
|
||||||
CachedBluetoothDevice device,
|
CachedBluetoothDevice device,
|
||||||
Lifecycle lifecycle,
|
Lifecycle lifecycle,
|
||||||
@Nullable List<String> invisibleProfiles) {
|
@Nullable List<String> invisibleProfiles,
|
||||||
|
boolean hasExtraSpace) {
|
||||||
super(context, fragment, device, lifecycle);
|
super(context, fragment, device, lifecycle);
|
||||||
mManager = manager;
|
mManager = manager;
|
||||||
mProfileManager = mManager.getProfileManager();
|
mProfileManager = mManager.getProfileManager();
|
||||||
@@ -115,12 +117,17 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
if (invisibleProfiles != null) {
|
if (invisibleProfiles != null) {
|
||||||
mInvisibleProfiles = Set.copyOf(invisibleProfiles);
|
mInvisibleProfiles = Set.copyOf(invisibleProfiles);
|
||||||
}
|
}
|
||||||
|
mHasExtraSpace = hasExtraSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init(PreferenceScreen screen) {
|
protected void init(PreferenceScreen screen) {
|
||||||
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
|
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
|
||||||
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
if (mHasExtraSpace) {
|
||||||
|
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
||||||
|
} else {
|
||||||
|
mProfilesContainer.setLayoutResource(R.layout.preference_category_bluetooth_no_padding);
|
||||||
|
}
|
||||||
// Call refresh here even though it will get called later in onResume, to avoid the
|
// Call refresh here even though it will get called later in onResume, to avoid the
|
||||||
// list of switches appearing to "pop" into the page.
|
// list of switches appearing to "pop" into the page.
|
||||||
refresh();
|
refresh();
|
||||||
@@ -609,7 +616,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
Preference preference = mProfilesContainer.findPreference(KEY_BOTTOM_PREFERENCE);
|
Preference preference = mProfilesContainer.findPreference(KEY_BOTTOM_PREFERENCE);
|
||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
preference = new Preference(mContext);
|
preference = new Preference(mContext);
|
||||||
preference.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
if (mHasExtraSpace) {
|
||||||
|
preference.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
||||||
|
} else {
|
||||||
|
preference.setLayoutResource(R.layout.preference_category_bluetooth_no_padding);
|
||||||
|
}
|
||||||
preference.setEnabled(false);
|
preference.setEnabled(false);
|
||||||
preference.setKey(KEY_BOTTOM_PREFERENCE);
|
preference.setKey(KEY_BOTTOM_PREFERENCE);
|
||||||
preference.setOrder(ORDINAL);
|
preference.setOrder(ORDINAL);
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
|||||||
controllers.add(new BluetoothDetailsSpatialAudioController(context, this, mCachedDevice,
|
controllers.add(new BluetoothDetailsSpatialAudioController(context, this, mCachedDevice,
|
||||||
lifecycle));
|
lifecycle));
|
||||||
controllers.add(new BluetoothDetailsProfilesController(context, this, mManager,
|
controllers.add(new BluetoothDetailsProfilesController(context, this, mManager,
|
||||||
mCachedDevice, lifecycle, invisibleProfiles));
|
mCachedDevice, lifecycle, invisibleProfiles, invisibleProfiles == null));
|
||||||
controllers.add(new BluetoothDetailsMacAddressController(context, this, mCachedDevice,
|
controllers.add(new BluetoothDetailsMacAddressController(context, this, mCachedDevice,
|
||||||
lifecycle));
|
lifecycle));
|
||||||
controllers.add(new StylusDevicesController(context, mInputDevice, mCachedDevice,
|
controllers.add(new StylusDevicesController(context, mInputDevice, mCachedDevice,
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ class DeviceDetailsMoreSettingsFragment : DashboardFragment() {
|
|||||||
formatter.getInvisibleBluetoothProfiles(
|
formatter.getInvisibleBluetoothProfiles(
|
||||||
FragmentTypeModel.DeviceDetailsMoreSettingsFragment
|
FragmentTypeModel.DeviceDetailsMoreSettingsFragment
|
||||||
),
|
),
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
BluetoothDetailsAudioDeviceTypeController(
|
BluetoothDetailsAudioDeviceTypeController(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -656,7 +656,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
|
|||||||
|
|
||||||
private void initController(List<String> invisibleProfiles) {
|
private void initController(List<String> invisibleProfiles) {
|
||||||
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
|
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
|
||||||
mCachedDevice, mLifecycle, invisibleProfiles);
|
mCachedDevice, mLifecycle, invisibleProfiles, true);
|
||||||
mProfiles.setKey(mController.getPreferenceKey());
|
mProfiles.setKey(mController.getPreferenceKey());
|
||||||
mController.mProfilesContainer = mProfiles;
|
mController.mProfilesContainer = mProfiles;
|
||||||
mScreen.removeAll();
|
mScreen.removeAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user