Fix build

Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
Stefan Niedermann 2021-06-28 10:10:51 +02:00
parent ef993ca0d8
commit 491ccd57da
3 changed files with 12 additions and 12 deletions

View file

@ -1,15 +1,11 @@
package it.niedermann.owncloud.notes.manageaccounts; package it.niedermann.owncloud.notes.manageaccounts;
import android.graphics.Color;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.net.Uri; import android.net.Uri;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.core.util.Consumer; import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -17,17 +13,19 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import java.util.Arrays;
import java.util.stream.Stream; import java.util.stream.Stream;
import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl;
import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding;
import it.niedermann.owncloud.notes.persistence.entity.Account; 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.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static it.niedermann.owncloud.notes.branding.BrandingUtil.applyBrandToLayerDrawable; 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 { public class ManageAccountViewHolder extends RecyclerView.ViewHolder {
@ -58,7 +56,8 @@ public class ManageAccountViewHolder extends RecyclerView.ViewHolder {
binding.accountContextMenu.setOnClickListener((v) -> { binding.accountContextMenu.setOnClickListener((v) -> {
final PopupMenu popup = new PopupMenu(itemView.getContext(), v); final PopupMenu popup = new PopupMenu(itemView.getContext(), v);
popup.inflate(R.menu.menu_account); 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(); final Menu menu = popup.getMenu();
Stream.of( Stream.of(
R.id.notes_path, R.id.notes_path,

View file

@ -36,6 +36,7 @@ import retrofit2.Response;
import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1;
import static it.niedermann.owncloud.notes.shared.util.ApiVersionUtil.getPreferredApiVersion;
public class ManageAccountsActivity extends LockedActivity { public class ManageAccountsActivity extends LockedActivity {
@ -123,7 +124,7 @@ public class ManageAccountsActivity extends LockedActivity {
.setNeutralButton(android.R.string.cancel, null) .setNeutralButton(android.R.string.cancel, null)
.setPositiveButton(R.string.action_edit_save, (v, d) -> new Thread(() -> { .setPositiveButton(R.string.action_edit_save, (v, d) -> new Thread(() -> {
try { try {
final Call<NotesSettings> putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(editText.getText().toString(), null), localAccount.getPreferredApiVersion()); final Call<NotesSettings> putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(editText.getText().toString(), null), getPreferredApiVersion(localAccount.getApiVersion()));
putSettingsCall.enqueue(new Callback<NotesSettings>() { putSettingsCall.enqueue(new Callback<NotesSettings>() {
@Override @Override
public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) { public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) {
@ -146,7 +147,7 @@ public class ManageAccountsActivity extends LockedActivity {
}).start()) }).start())
.show(); .show();
try { try {
repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), localAccount.getPreferredApiVersion()) repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), getPreferredApiVersion(localAccount.getApiVersion()))
.enqueue(new Callback<NotesSettings>() { .enqueue(new Callback<NotesSettings>() {
@Override @Override
public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) { public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) {
@ -190,7 +191,7 @@ public class ManageAccountsActivity extends LockedActivity {
.setNeutralButton(android.R.string.cancel, null) .setNeutralButton(android.R.string.cancel, null)
.setPositiveButton("Save", (v, d) -> new Thread(() -> { .setPositiveButton("Save", (v, d) -> new Thread(() -> {
try { try {
final Call<NotesSettings> putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(null, spinner.getSelectedItem().toString()), localAccount.getPreferredApiVersion()); final Call<NotesSettings> putSettingsCall = repository.putServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), new NotesSettings(null, spinner.getSelectedItem().toString()), getPreferredApiVersion(localAccount.getApiVersion()));
putSettingsCall.enqueue(new Callback<NotesSettings>() { putSettingsCall.enqueue(new Callback<NotesSettings>() {
@Override @Override
public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) { public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) {
@ -213,7 +214,7 @@ public class ManageAccountsActivity extends LockedActivity {
}).start()) }).start())
.show(); .show();
try { try {
repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), localAccount.getPreferredApiVersion()) repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), getPreferredApiVersion(localAccount.getApiVersion()))
.enqueue(new Callback<NotesSettings>() { .enqueue(new Callback<NotesSettings>() {
@Override @Override
public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) { public void onResponse(@NonNull Call<NotesSettings> call, @NonNull Response<NotesSettings> response) {

View file

@ -911,11 +911,11 @@ public class NotesRepository {
} }
public Call<NotesSettings> getServerSettings(@NonNull SingleSignOnAccount ssoAccount, @Nullable ApiVersion preferredApiVersion) { public Call<NotesSettings> getServerSettings(@NonNull SingleSignOnAccount ssoAccount, @Nullable ApiVersion preferredApiVersion) {
return ApiProvider.getNotesAPI(context, ssoAccount, preferredApiVersion).getSettings(); return ApiProvider.getInstance().getNotesAPI(context, ssoAccount, preferredApiVersion).getSettings();
} }
public Call<NotesSettings> putServerSettings(@NonNull SingleSignOnAccount ssoAccount, @NonNull NotesSettings settings, @Nullable ApiVersion preferredApiVersion) { public Call<NotesSettings> 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) { public void updateDisplayName(long id, @Nullable String displayName) {