Fix not on the top when entering device detail page
Root Cause: Added SpacePreference in xml let the page renders order incorrectly. Solution: That SpacePreference should only be visible when the device is hearing aid. Bug: 245681095 Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDetailsPairOtherControllerTest Change-Id: Ic0be940c8466b5e1e301255868c29d06bd4428bd
This commit is contained in:
@@ -22,19 +22,25 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.SpacePreference;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.ButtonPreference;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* This class handles button preference logic to display for hearing aid device.
|
||||
*/
|
||||
public class BluetoothDetailsPairOtherController extends BluetoothDetailsController {
|
||||
private static final String KEY_PAIR_OTHER = "hearing_aid_pair_other_button";
|
||||
@VisibleForTesting
|
||||
static final String KEY_SPACE = "hearing_aid_space_layout";
|
||||
|
||||
private ButtonPreference mPreference;
|
||||
private SpacePreference mSpacePreference;
|
||||
|
||||
public BluetoothDetailsPairOtherController(Context context,
|
||||
PreferenceFragmentCompat fragment,
|
||||
@@ -57,14 +63,16 @@ public class BluetoothDetailsPairOtherController extends BluetoothDetailsControl
|
||||
@Override
|
||||
protected void init(PreferenceScreen screen) {
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
mSpacePreference = screen.findPreference(KEY_SPACE);
|
||||
updateButtonPreferenceTitle(mPreference);
|
||||
setPreferencesVisibility(getButtonPreferenceVisibility(mCachedDevice));
|
||||
mPreference.setOnClickListener(v -> launchPairingDetail());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refresh() {
|
||||
updateButtonPreferenceTitle(mPreference);
|
||||
mPreference.setVisible(getButtonPreferenceVisibility(mCachedDevice));
|
||||
setPreferencesVisibility(getButtonPreferenceVisibility(mCachedDevice));
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +85,11 @@ public class BluetoothDetailsPairOtherController extends BluetoothDetailsControl
|
||||
preference.setTitle(stringRes);
|
||||
}
|
||||
|
||||
private void setPreferencesVisibility(boolean visible) {
|
||||
mPreference.setVisible(visible);
|
||||
mSpacePreference.setVisible(visible);
|
||||
}
|
||||
|
||||
private boolean getButtonPreferenceVisibility(CachedBluetoothDevice cachedDevice) {
|
||||
return isBinauralMode(cachedDevice) && isOnlyOneSideConnected(cachedDevice);
|
||||
}
|
||||
|
Reference in New Issue
Block a user