Merge "Fix popup dialog show wrong device name"
This commit is contained in:
@@ -39,10 +39,10 @@ import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||
|
||||
public class DeviceNamePreferenceController extends BasePreferenceController
|
||||
implements ValidatedEditTextPreference.Validator,
|
||||
Preference.OnPreferenceChangeListener,
|
||||
LifecycleObserver,
|
||||
OnSaveInstanceState,
|
||||
OnCreate {
|
||||
Preference.OnPreferenceChangeListener,
|
||||
LifecycleObserver,
|
||||
OnSaveInstanceState,
|
||||
OnCreate {
|
||||
private static final String PREF_KEY = "device_name";
|
||||
public static final int DEVICE_NAME_SET_WARNING_ID = 1;
|
||||
private static final String KEY_PENDING_DEVICE_NAME = "key_pending_device_name";
|
||||
@@ -116,9 +116,11 @@ public class DeviceNamePreferenceController extends BasePreferenceController
|
||||
return mWifiDeviceNameTextValidator.isTextValid(deviceName);
|
||||
}
|
||||
|
||||
public void confirmDeviceName() {
|
||||
if (mPendingDeviceName != null) {
|
||||
public void updateDeviceName(boolean update) {
|
||||
if (update && mPendingDeviceName != null) {
|
||||
setDeviceName(mPendingDeviceName);
|
||||
} else {
|
||||
mPreference.setText(getSummary().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +155,8 @@ public class DeviceNamePreferenceController extends BasePreferenceController
|
||||
* For more information, see {@link com.android.settings.bluetooth.BluetoothNameDialogFragment}.
|
||||
*/
|
||||
private static final String getFilteredBluetoothString(final String deviceName) {
|
||||
CharSequence filteredSequence = new BluetoothLengthDeviceNameFilter().filter(deviceName, 0, deviceName.length(),
|
||||
CharSequence filteredSequence = new BluetoothLengthDeviceNameFilter().filter(deviceName, 0,
|
||||
deviceName.length(),
|
||||
new SpannedString(""),
|
||||
0, 0);
|
||||
// null -> use the original
|
||||
|
@@ -66,7 +66,9 @@ public class DeviceNameWarningDialog extends InstrumentedDialogFragment
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final MyDeviceInfoFragment host = (MyDeviceInfoFragment) getTargetFragment();
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
host.onSetDeviceNameConfirm();
|
||||
host.onSetDeviceNameConfirm(true);
|
||||
} else {
|
||||
host.onSetDeviceNameConfirm(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -178,9 +178,9 @@ public class MyDeviceInfoFragment extends DashboardFragment
|
||||
DeviceNameWarningDialog.show(this);
|
||||
}
|
||||
|
||||
public void onSetDeviceNameConfirm() {
|
||||
public void onSetDeviceNameConfirm(boolean confirm) {
|
||||
final DeviceNamePreferenceController controller = use(DeviceNamePreferenceController.class);
|
||||
controller.confirmDeviceName();
|
||||
controller.updateDeviceName(confirm);
|
||||
}
|
||||
|
||||
private static class SummaryProvider implements SummaryLoader.SummaryProvider {
|
||||
|
Reference in New Issue
Block a user