mirror of
https://github.com/oliexdev/openScale.git
synced 2025-02-06 17:13:36 +01:00
change Bluetooth device name to default name only if user select a different device type
This commit is contained in:
parent
b5fef73fd7
commit
c97ae5376d
@ -57,6 +57,8 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
||||
smartAssignEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_SMARTUSERASSIGN);
|
||||
ignoreOutOfRangeEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_IGNOREOUTOFRANGE);
|
||||
|
||||
deviceTypes.setOnPreferenceChangeListener(new deviceTypeOnPreferenceChangeListener());
|
||||
|
||||
updateBluetoothPreferences();
|
||||
initSummary(getPreferenceScreen());
|
||||
}
|
||||
@ -93,7 +95,6 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
||||
|
||||
deviceTypes.setEntries(btEntries.toArray(new CharSequence[btEntries.size()]));
|
||||
deviceTypes.setEntryValues(btEntryValues.toArray(new CharSequence[btEntryValues.size()]));
|
||||
deviceTypes.setValueIndex(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,9 +153,6 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
||||
}
|
||||
|
||||
p.setSummary(Html.fromHtml(summary));
|
||||
|
||||
deviceName.setSummary(btCom.defaultDeviceName());
|
||||
deviceName.setText(btCom.defaultDeviceName());
|
||||
}
|
||||
|
||||
if (p instanceof EditTextPreference) {
|
||||
@ -182,4 +180,19 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
||||
p.setSummary(currentEntries.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private class deviceTypeOnPreferenceChangeListener implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference p, Object o) {
|
||||
int i = Integer.parseInt((String)o);
|
||||
|
||||
BluetoothCommunication btCom = BluetoothCommunication.getBtDevice(getActivity().getApplicationContext(), i);
|
||||
|
||||
deviceName.setSummary(btCom.defaultDeviceName());
|
||||
deviceName.setText(btCom.defaultDeviceName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes"/>
|
||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName"/>
|
||||
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes" android:defaultValue="0"/>
|
||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="openScale_MCU"/>
|
||||
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="btEnable" android:defaultValue="false"/>
|
||||
<CheckBoxPreference android:title="@string/label_smartUserAssign" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="smartUserAssign" android:defaultValue="false"/>
|
||||
<CheckBoxPreference android:title="@string/label_ignoreOutOfRange" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="ignoreOutOfRange" android:enabled="false" android:defaultValue="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user