Better error message when nextcloud could not be reached (#7403)

This commit is contained in:
ByteHamster 2024-09-14 11:41:37 +02:00 committed by GitHub
parent b06caeadec
commit f35e92c112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 11 deletions

View File

@ -674,6 +674,7 @@
<string name="gpodnetsync_pref_report_successful">Successful</string>
<string name="gpodnetsync_pref_report_failed">Failed</string>
<string name="gpodnetsync_username_characters_error">Usernames may only contain letters, digits, hyphens and underscores.</string>
<string name="nextcloud_login_error_generic"><![CDATA[Unable to log into your Nextcloud.\n\n- Check your network connection.\n- Confirm that you are using the correct server address.\n- Make sure that the gpoddersync Nextcloud plugin is installed.]]></string>
<!-- Directory chooser -->
<string name="choose_data_directory">Choose data folder</string>

View File

@ -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();
}
}

View File

@ -56,14 +56,6 @@
</LinearLayout>
<TextView
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textColor="?attr/icon_red"
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/chooseHostButton"
android:layout_width="match_parent"