mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 07:21:40 +02:00
Fix sync selectedUser field in driver with setSelectedScaleUser()
This commit is contained in:
@@ -110,6 +110,13 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
|||||||
MAX_STEP
|
MAX_STEP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelectedScaleUser(ScaleUser user) {
|
||||||
|
super.setSelectedScaleUser(user);
|
||||||
|
this.selectedUser = user;
|
||||||
|
LogManager.d(TAG, "setSelectedScaleUser: id=" + (user != null ? user.getId() : -1));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onNextStep(int stepNr) {
|
protected boolean onNextStep(int stepNr) {
|
||||||
|
|
||||||
@@ -746,7 +753,7 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void storeUserScaleConsentCode(int userId, int consentCode) {
|
protected synchronized void storeUserScaleConsentCode(int userId, int consentCode) {
|
||||||
prefs.edit().putInt("userConsentCode" + userId, consentCode).apply();
|
prefs.edit().putInt("userConsentCode" + userId, consentCode).commit();
|
||||||
LogManager.d(TAG, "storeUserScaleConsentCode: userId=" + userId + " now=" + getUserScaleConsent(userId));
|
LogManager.d(TAG, "storeUserScaleConsentCode: userId=" + userId + " now=" + getUserScaleConsent(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,11 +764,11 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat
|
|||||||
protected synchronized void storeUserScaleIndex(int userId, int userIndex) {
|
protected synchronized void storeUserScaleIndex(int userId, int userIndex) {
|
||||||
int currentUserIndex = getUserScaleIndex(userId);
|
int currentUserIndex = getUserScaleIndex(userId);
|
||||||
if (currentUserIndex != -1) {
|
if (currentUserIndex != -1) {
|
||||||
prefs.edit().putInt("userIdFromUserScaleIndex" + currentUserIndex, -1).apply();
|
prefs.edit().putInt("userIdFromUserScaleIndex" + currentUserIndex, -1).commit();
|
||||||
}
|
}
|
||||||
prefs.edit().putInt("userScaleIndex" + userId, userIndex).apply();
|
prefs.edit().putInt("userScaleIndex" + userId, userIndex).commit();
|
||||||
if (userIndex != -1) {
|
if (userIndex != -1) {
|
||||||
prefs.edit().putInt("userIdFromUserScaleIndex" + userIndex, userId).apply();
|
prefs.edit().putInt("userIdFromUserScaleIndex" + userIndex, userId).commit();
|
||||||
}
|
}
|
||||||
LogManager.d(TAG, "storeUserScaleIndex: userId=" + userId + " now=" + getUserScaleIndex(userId));
|
LogManager.d(TAG, "storeUserScaleIndex: userId=" + userId + " now=" + getUserScaleIndex(userId));
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,8 @@ class LegacyScaleAdapter(
|
|||||||
|
|
||||||
private suspend fun provideUserDataToLegacyDriver() {
|
private suspend fun provideUserDataToLegacyDriver() {
|
||||||
try {
|
try {
|
||||||
|
currentInternalUser?.let { bluetoothDriverInstance.setSelectedScaleUser(it) }
|
||||||
|
|
||||||
LogManager.d(TAG, "Attempting to load user data for legacy driver: ${bluetoothDriverInstance.driverName()}")
|
LogManager.d(TAG, "Attempting to load user data for legacy driver: ${bluetoothDriverInstance.driverName()}")
|
||||||
val userListFromDb = databaseRepository.getAllUsers().first()
|
val userListFromDb = databaseRepository.getAllUsers().first()
|
||||||
|
|
||||||
@@ -325,8 +327,6 @@ class LegacyScaleAdapter(
|
|||||||
|
|
||||||
provideUserDataToLegacyDriver()
|
provideUserDataToLegacyDriver()
|
||||||
|
|
||||||
currentInternalUser?.let { bluetoothDriverInstance.setSelectedScaleUser(it) }
|
|
||||||
|
|
||||||
LogManager.d(TAG, "connect: Calling connect() on Java driver instance (${bluetoothDriverInstance.driverName()}) for $address.")
|
LogManager.d(TAG, "connect: Calling connect() on Java driver instance (${bluetoothDriverInstance.driverName()}) for $address.")
|
||||||
try {
|
try {
|
||||||
bluetoothDriverInstance.connect(address)
|
bluetoothDriverInstance.connect(address)
|
||||||
|
Reference in New Issue
Block a user