From 491ccd57dabd56c8a0b34fdc4e81a19e82d1b9a6 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Mon, 28 Jun 2021 10:10:51 +0200 Subject: [PATCH] Fix build Signed-off-by: Stefan Niedermann --- .../notes/manageaccounts/ManageAccountViewHolder.java | 11 +++++------ .../notes/manageaccounts/ManageAccountsActivity.java | 9 +++++---- .../owncloud/notes/persistence/NotesRepository.java | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) 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 1d01387a..ac56593d 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 @@ -1,15 +1,11 @@ package it.niedermann.owncloud.notes.manageaccounts; -import android.graphics.Color; import android.graphics.drawable.LayerDrawable; import android.net.Uri; -import android.view.LayoutInflater; import android.view.Menu; -import android.view.MenuInflater; import android.view.View; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.widget.PopupMenu; import androidx.core.util.Consumer; import androidx.recyclerview.widget.RecyclerView; @@ -17,17 +13,19 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import java.util.Arrays; import java.util.stream.Stream; import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; 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.model.ApiVersion; +import it.niedermann.owncloud.notes.shared.util.ApiVersionUtil; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static it.niedermann.owncloud.notes.branding.BrandingUtil.applyBrandToLayerDrawable; +import static it.niedermann.owncloud.notes.shared.util.ApiVersionUtil.getPreferredApiVersion; public class ManageAccountViewHolder extends RecyclerView.ViewHolder { @@ -58,7 +56,8 @@ public class ManageAccountViewHolder extends RecyclerView.ViewHolder { binding.accountContextMenu.setOnClickListener((v) -> { final PopupMenu popup = new PopupMenu(itemView.getContext(), v); popup.inflate(R.menu.menu_account); - if (!localAccount.getPreferredApiVersion().supportsSettings()) { + final ApiVersion preferredApiVersion = getPreferredApiVersion(localAccount.getApiVersion()); + if (preferredApiVersion != null && !preferredApiVersion.supportsSettings()) { final Menu menu = popup.getMenu(); Stream.of( R.id.notes_path, diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java index dcdd3533..fc9f18eb 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java @@ -36,6 +36,7 @@ import retrofit2.Response; import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; +import static it.niedermann.owncloud.notes.shared.util.ApiVersionUtil.getPreferredApiVersion; public class ManageAccountsActivity extends LockedActivity { @@ -123,7 +124,7 @@ public class ManageAccountsActivity extends LockedActivity { .setNeutralButton(android.R.string.cancel, null) .setPositiveButton(R.string.action_edit_save, (v, d) -> new Thread(() -> { try { - final Call putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(editText.getText().toString(), null), localAccount.getPreferredApiVersion()); + final Call putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(editText.getText().toString(), null), getPreferredApiVersion(localAccount.getApiVersion())); putSettingsCall.enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { @@ -146,7 +147,7 @@ public class ManageAccountsActivity extends LockedActivity { }).start()) .show(); try { - repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), localAccount.getPreferredApiVersion()) + repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), getPreferredApiVersion(localAccount.getApiVersion())) .enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { @@ -190,7 +191,7 @@ public class ManageAccountsActivity extends LockedActivity { .setNeutralButton(android.R.string.cancel, null) .setPositiveButton("Save", (v, d) -> new Thread(() -> { try { - final Call putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(null, spinner.getSelectedItem().toString()), localAccount.getPreferredApiVersion()); + final Call putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(null, spinner.getSelectedItem().toString()), getPreferredApiVersion(localAccount.getApiVersion())); putSettingsCall.enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { @@ -213,7 +214,7 @@ public class ManageAccountsActivity extends LockedActivity { }).start()) .show(); try { - repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), localAccount.getPreferredApiVersion()) + repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), getPreferredApiVersion(localAccount.getApiVersion())) .enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java index f36fd72a..24a28619 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java @@ -911,11 +911,11 @@ public class NotesRepository { } public Call getServerSettings(@NonNull SingleSignOnAccount ssoAccount, @Nullable ApiVersion preferredApiVersion) { - return ApiProvider.getNotesAPI(context, ssoAccount, preferredApiVersion).getSettings(); + return ApiProvider.getInstance().getNotesAPI(context, ssoAccount, preferredApiVersion).getSettings(); } public Call putServerSettings(@NonNull SingleSignOnAccount ssoAccount, @NonNull NotesSettings settings, @Nullable ApiVersion preferredApiVersion) { - return ApiProvider.getNotesAPI(context, ssoAccount, preferredApiVersion).putSettings(settings); + return ApiProvider.getInstance().getNotesAPI(context, ssoAccount, preferredApiVersion).putSettings(settings); } public void updateDisplayName(long id, @Nullable String displayName) {