Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2021-04-18 14:18:30 +0300
committerGitHub <noreply@github.com>2021-04-18 14:18:30 +0300
commit05486c126a0bdfeaaf1d1230596a09b649d457c6 (patch)
tree287cce950f0b8303376e7d45b6154ead9859d234 /app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java
parent33c323483c88f3c7159ef3e8e079d7d2474d9a18 (diff)
#864 Show DisplayName instead of UID attribute for LDAP users (#925)
* #864 Show DisplayName instead of UID attribute for LDAP users Signed-off-by: Stefan Niedermann <info@niedermann.it> * #864 include accounts username in liveData * #864 Show DisplayName instead of UID attribute for LDAP users Signed-off-by: Stefan Niedermann <info@niedermann.it> * #864 Show DisplayName instead of UID attribute for LDAP users Signed-off-by: Stefan Niedermann <info@niedermann.it> Co-authored-by: desperateCoder <echotodevnull@gmail.com>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java
index 49face983..c66edbc42 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java
@@ -324,7 +324,7 @@ public class DataBaseAdapter {
}
if (filter.getFilterText() != null && !filter.getFilterText().isEmpty()) {
query.append(" and (c.description like ? or c.title like ?) ");
- String filterText = "%"+filter.getFilterText()+"%";
+ String filterText = "%" + filter.getFilterText() + "%";
args.add(filterText);
args.add(filterText);
}
@@ -535,13 +535,31 @@ public class DataBaseAdapter {
db.getAccountDao().update(account);
}
+ @AnyThread
public LiveData<Account> readAccount(long id) {
- return distinctUntilChanged(db.getAccountDao().getAccountById(id));
+ return fillAccountsUserName(db.getAccountDao().getAccountById(id));
}
+ @AnyThread
public LiveData<Account> readAccount(String name) {
- return LiveDataHelper.wrapInLiveData(() -> db.getAccountDao().getAccountByNameDirectly(name));
-// return distinctUntilChanged(db.getAccountDao().getAccountByName(name));
+ return fillAccountsUserName(db.getAccountDao().getAccountByName(name));
+ }
+
+ @AnyThread
+ public LiveData<List<Account>> readAccounts() {
+ return fillAccountsListUserName(db.getAccountDao().getAllAccounts());
+ }
+
+ private LiveData<Account> fillAccountsUserName(LiveData<Account> source) {
+ return LiveDataHelper.interceptLiveData(distinctUntilChanged(source), data -> data.setUserDisplayName(db.getUserDao().getUserNameByUidDirectly(data.getId(), data.getUserName())));
+ }
+
+ private LiveData<List<Account>> fillAccountsListUserName(LiveData<List<Account>> source) {
+ return LiveDataHelper.interceptLiveData(distinctUntilChanged(source), data -> {
+ for (Account a : data) {
+ a.setUserDisplayName(db.getUserDao().getUserNameByUidDirectly(a.getId(), a.getUserName()));
+ }
+ });
}
@WorkerThread
@@ -549,9 +567,6 @@ public class DataBaseAdapter {
return db.getAccountDao().getAccountByIdDirectly(id);
}
- public LiveData<List<Account>> readAccounts() {
- return distinctUntilChanged(db.getAccountDao().getAllAccounts());
- }
public LiveData<List<Board>> getBoards(long accountId) {
return distinctUntilChanged(db.getBoardDao().getBoardsForAccount(accountId));