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 32687e66c10a4c4b932bca8c100b7af43beab4d8..a8dfd718a410997997d4b9524de132ccacb76350 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 c3429987b1c228e47a9c78182329420e3d73167e..e02d6a5e4ff75048602c18068af1c05fdf7a590f 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)); + } }