Revert "Revert "Convert BT preference to use TwoTargetPreference""
This reverts commit 457c3cbec2
.
Revert with fix/test.
The fix is that we removed DevicePickerFragment#initDevicePreference(),
which incorrectly set a useless widget on preference, and removes the
gear icon from preference, preventing bind() call to go through
Change-Id: Ia70cdb51d13cca6035a4e7fe8008d195f7f00c6e
Fix: 36511169
Test: runtest --path tests/app/src/com/android/settings/bluetooth/DevicePickerActivityTest.java
This commit is contained in:
@@ -45,13 +45,14 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.LinkifyUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.location.ScanningSettings;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.widget.FooterPreference;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.SwitchBarController;
|
||||
import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
|
||||
@@ -476,24 +477,25 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
||||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener mDeviceProfilesListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// User clicked on advanced options icon for a device in the list
|
||||
if (!(v.getTag() instanceof CachedBluetoothDevice)) {
|
||||
Log.w(TAG, "onClick() called for other View: " + v);
|
||||
return;
|
||||
}
|
||||
|
||||
final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
|
||||
device.getDevice().getAddress());
|
||||
DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
|
||||
profileSettings.setArguments(args);
|
||||
profileSettings.show(getFragmentManager(),
|
||||
DeviceProfilesSettings.class.getSimpleName());
|
||||
private final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
|
||||
// User clicked on advanced options icon for a device in the list
|
||||
if (!(pref instanceof BluetoothDevicePreference)) {
|
||||
Log.w(TAG, "onClick() called for other View: " + pref);
|
||||
return;
|
||||
}
|
||||
final CachedBluetoothDevice device =
|
||||
((BluetoothDevicePreference) pref).getBluetoothDevice();
|
||||
if (device == null) {
|
||||
Log.w(TAG, "No BT device attached with this pref: " + pref);
|
||||
return;
|
||||
}
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
|
||||
device.getDevice().getAddress());
|
||||
final DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
|
||||
profileSettings.setArguments(args);
|
||||
profileSettings.show(getFragmentManager(),
|
||||
DeviceProfilesSettings.class.getSimpleName());
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -506,7 +508,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
||||
CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
|
||||
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
|
||||
// Only paired device have an associated advanced settings screen
|
||||
preference.setOnSettingsClickListener(mDeviceProfilesListener);
|
||||
preference.setOnGearClickListener(mDeviceProfilesListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user