mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
Improve notification level storage
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
b998a2f6db
commit
d43c37d88b
@ -21,6 +21,7 @@
|
||||
package com.nextcloud.talk.utils.preferencestorage;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import autodagger.AutoInjector;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
@ -49,6 +50,7 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
private String conversationToken;
|
||||
private long accountIdentifier;
|
||||
|
||||
private String messageNotificationLevel;
|
||||
public DatabaseStorageModule(UserEntity conversationUser, String conversationToken) {
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
@ -68,6 +70,7 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
arbitraryStorageUtils.storeStorageSetting(accountIdentifier, key, value, conversationToken);
|
||||
} else {
|
||||
if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
||||
if (!TextUtils.isEmpty(messageNotificationLevel) && !messageNotificationLevel.equals(value)) {
|
||||
int intValue;
|
||||
switch (value) {
|
||||
case "never":
|
||||
@ -95,7 +98,7 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
|
||||
messageNotificationLevel = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +110,9 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
messageNotificationLevel = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,12 +139,16 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
|
||||
@Override
|
||||
public String getString(String key, String defaultVal) {
|
||||
if (!key.equals("message_notification_level")) {
|
||||
ArbitraryStorageEntity valueFromDb = arbitraryStorageUtils.getStorageSetting(accountIdentifier, key, conversationToken);
|
||||
if (valueFromDb == null) {
|
||||
return defaultVal;
|
||||
} else {
|
||||
return valueFromDb.getValue();
|
||||
}
|
||||
} else {
|
||||
return messageNotificationLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user