From 7b53d7cc5b359e63dd0a731189712dd31a05a0ff Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Tue, 18 Jul 2023 12:10:32 +0600 Subject: [PATCH] 1448-Hide_remove_account_option_for_murena_account issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1448 Murena account signIn & signOut is handled by accountManager app. So having remove account option for murena accounts inside Notes app is meaningless & confusing for users. --- .../notes/manageaccounts/ManageAccountViewHolder.java | 5 +++++ .../owncloud/notes/shared/util/AccountSyncUtil.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java index 32687e66c..a8dfd718a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java @@ -19,6 +19,7 @@ import com.bumptech.glide.request.RequestOptions; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; import it.niedermann.owncloud.notes.persistence.entity.Account; +import it.niedermann.owncloud.notes.shared.util.AccountSyncUtil; import it.niedermann.owncloud.notes.shared.util.DisplayUtils; public class ManageAccountViewHolder extends RecyclerView.ViewHolder { @@ -58,6 +59,10 @@ public class ManageAccountViewHolder extends RecyclerView.ViewHolder { popup.getMenu().removeItem(popup.getMenu().findItem(R.id.notes_path).getItemId()); } + if (AccountSyncUtil.isMurenaAccount(itemView.getContext(), localAccount.getAccountName())) { + popup.getMenu().removeItem(popup.getMenu().findItem(R.id.delete).getItemId()); + } + popup.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.notes_path) { callback.onChangeNotesPath(localAccount); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java index c3429987b..e02d6a5e4 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java @@ -20,6 +20,8 @@ import android.accounts.AccountManager; import android.content.ContentResolver; import android.content.Context; +import androidx.annotation.NonNull; + import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -64,4 +66,10 @@ public final class AccountSyncUtil { .filter(Objects::nonNull) .collect(Collectors.toList()); } + + public static boolean isMurenaAccount(@NonNull Context context, @NonNull String accountName) { + return getMurenaAccounts(context) + .stream() + .anyMatch(account -> accountName.equals(account.name)); + } } -- GitLab