Make errors on 'add feed' page more pretty
This commit is contained in:
parent
6020f481c5
commit
2e750effa1
|
@ -8,7 +8,10 @@ import android.content.SharedPreferences;
|
|||
import android.graphics.LightingColorFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -288,11 +291,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
dialog.show();
|
||||
}
|
||||
} else {
|
||||
String errorMsg = status.getReason().getErrorString(OnlineFeedViewActivity.this);
|
||||
if (status.getReasonDetailed() != null) {
|
||||
errorMsg += " (" + status.getReasonDetailed() + ")";
|
||||
}
|
||||
showErrorDialog(errorMsg);
|
||||
showErrorDialog(status.getReason().getErrorString(OnlineFeedViewActivity.this), status.getReasonDetailed());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,18 +323,17 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
parser = Observable.fromCallable(this::doParseFeed)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(optionalResult -> {
|
||||
if(optionalResult.isPresent()) {
|
||||
FeedHandlerResult result = optionalResult.get();
|
||||
beforeShowFeedInformation(result.feed);
|
||||
showFeedInformation(result.feed, result.alternateFeedUrls);
|
||||
}
|
||||
}, error -> {
|
||||
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
|
||||
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
|
||||
showErrorDialog(errorMsg);
|
||||
Log.d(TAG, "Feed parser exception: " + Log.getStackTraceString(error));
|
||||
});
|
||||
.subscribe(
|
||||
optionalResult -> {
|
||||
if (optionalResult.isPresent()) {
|
||||
FeedHandlerResult result = optionalResult.get();
|
||||
beforeShowFeedInformation(result.feed);
|
||||
showFeedInformation(result.feed, result.alternateFeedUrls);
|
||||
}
|
||||
}, error -> {
|
||||
showErrorDialog(error.getMessage(), "");
|
||||
Log.d(TAG, "Feed parser exception: " + Log.getStackTraceString(error));
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -350,8 +348,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
if (dialogShown) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
Log.d(TAG, "Supplied feed is an HTML web page that has no references to any feed");
|
||||
throw e;
|
||||
throw new UnsupportedFeedtypeException(getString(R.string.download_error_unsupported_type_html));
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
|
@ -570,12 +567,16 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
@UiThread
|
||||
private void showErrorDialog(String errorMsg) {
|
||||
private void showErrorDialog(String errorMsg, String details) {
|
||||
if (!isFinishing() && !isPaused) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.error_label);
|
||||
if (errorMsg != null) {
|
||||
builder.setMessage(errorMsg);
|
||||
String total = errorMsg + "\n\n" + details;
|
||||
SpannableString errorMessage = new SpannableString(total);
|
||||
errorMessage.setSpan(new ForegroundColorSpan(0x88888888),
|
||||
errorMsg.length(), total.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.setMessage(errorMessage);
|
||||
} else {
|
||||
builder.setMessage(R.string.download_error_error_unknown);
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@
|
|||
<string name="download_error_unsupported_type_html">The podcast host\'s server sent a website, not a podcast.</string>
|
||||
<string name="download_error_not_found">The podcast host\'s server does not know where to find the file. It may have been deleted.</string>
|
||||
<string name="download_error_connection_error">Connection Error</string>
|
||||
<string name="download_error_unknown_host">Unknown Host</string>
|
||||
<string name="download_error_unknown_host">Cannot find the server. Check if the address is typed correctly and if you have a working network connection.</string>
|
||||
<string name="download_error_unauthorized">Authentication Error</string>
|
||||
<string name="download_error_file_type_type">File Type Error</string>
|
||||
<string name="download_error_forbidden">The podcast host\'s server refuses to respond.</string>
|
||||
|
|
Loading…
Reference in New Issue