mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-06 08:47:56 +02:00
change Bluetooth device name to default name only if user select a different device type
This commit is contained in:
@@ -57,6 +57,8 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
|||||||
smartAssignEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_SMARTUSERASSIGN);
|
smartAssignEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_SMARTUSERASSIGN);
|
||||||
ignoreOutOfRangeEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_IGNOREOUTOFRANGE);
|
ignoreOutOfRangeEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_IGNOREOUTOFRANGE);
|
||||||
|
|
||||||
|
deviceTypes.setOnPreferenceChangeListener(new deviceTypeOnPreferenceChangeListener());
|
||||||
|
|
||||||
updateBluetoothPreferences();
|
updateBluetoothPreferences();
|
||||||
initSummary(getPreferenceScreen());
|
initSummary(getPreferenceScreen());
|
||||||
}
|
}
|
||||||
@@ -93,7 +95,6 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
|||||||
|
|
||||||
deviceTypes.setEntries(btEntries.toArray(new CharSequence[btEntries.size()]));
|
deviceTypes.setEntries(btEntries.toArray(new CharSequence[btEntries.size()]));
|
||||||
deviceTypes.setEntryValues(btEntryValues.toArray(new CharSequence[btEntryValues.size()]));
|
deviceTypes.setEntryValues(btEntryValues.toArray(new CharSequence[btEntryValues.size()]));
|
||||||
deviceTypes.setValueIndex(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,9 +153,6 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.setSummary(Html.fromHtml(summary));
|
p.setSummary(Html.fromHtml(summary));
|
||||||
|
|
||||||
deviceName.setSummary(btCom.defaultDeviceName());
|
|
||||||
deviceName.setText(btCom.defaultDeviceName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof EditTextPreference) {
|
if (p instanceof EditTextPreference) {
|
||||||
@@ -182,4 +180,19 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
|
|||||||
p.setSummary(currentEntries.toString());
|
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes"/>
|
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes" android:defaultValue="0"/>
|
||||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName"/>
|
<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_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_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"/>
|
<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"/>
|
||||||
|
Reference in New Issue
Block a user