From f35e92c112b058c534a134b2314f6bc162d5a142 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sat, 14 Sep 2024 11:41:37 +0200 Subject: Better error message when nextcloud could not be reached (#7403) --- ui/i18n/src/main/res/values/strings.xml | 1 + .../synchronization/NextcloudAuthenticationFragment.java | 16 +++++++++++++--- .../src/main/res/layout/nextcloud_auth_dialog.xml | 8 -------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 751dad918..77214d409 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -674,6 +674,7 @@ Successful Failed Usernames may only contain letters, digits, hyphens and underscores. + Choose data folder diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java index 5df85efe2..26cc08a51 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/NextcloudAuthenticationFragment.java @@ -3,6 +3,9 @@ package de.danoeh.antennapod.ui.preferences.screen.synchronization; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.style.ForegroundColorSpan; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -55,7 +58,6 @@ public class NextcloudAuthenticationFragment extends DialogFragment } private void startLoginFlow() { - viewBinding.errorText.setVisibility(View.GONE); viewBinding.chooseHostButton.setVisibility(View.GONE); viewBinding.loginProgressContainer.setVisibility(View.VISIBLE); viewBinding.serverUrlText.setEnabled(false); @@ -106,9 +108,17 @@ public class NextcloudAuthenticationFragment extends DialogFragment @Override public void onNextcloudAuthError(String errorMessage) { viewBinding.loginProgressContainer.setVisibility(View.GONE); - viewBinding.errorText.setVisibility(View.VISIBLE); - viewBinding.errorText.setText(errorMessage); viewBinding.chooseHostButton.setVisibility(View.VISIBLE); viewBinding.serverUrlText.setEnabled(true); + + final MaterialAlertDialogBuilder errorDialog = new MaterialAlertDialogBuilder(getContext()); + errorDialog.setTitle(R.string.error_label); + String genericMessage = getString(R.string.nextcloud_login_error_generic); + SpannableString combinedMessage = new SpannableString(genericMessage + "\n\n" + errorMessage); + combinedMessage.setSpan(new ForegroundColorSpan(0x88888888), + genericMessage.length(), combinedMessage.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + errorDialog.setMessage(combinedMessage); + errorDialog.setPositiveButton(android.R.string.ok, null); + errorDialog.show(); } } diff --git a/ui/preferences/src/main/res/layout/nextcloud_auth_dialog.xml b/ui/preferences/src/main/res/layout/nextcloud_auth_dialog.xml index 0f25a271f..8a8ba6a82 100644 --- a/ui/preferences/src/main/res/layout/nextcloud_auth_dialog.xml +++ b/ui/preferences/src/main/res/layout/nextcloud_auth_dialog.xml @@ -56,14 +56,6 @@ - -