Improve error message when loading feed

Add name of unavailable channel
This commit is contained in:
TobiGr 2021-03-31 23:32:53 +02:00
parent ccc46971b4
commit c5dd3dc7a9
2 changed files with 12 additions and 6 deletions

View file

@ -50,6 +50,7 @@ import org.schabi.newpipe.error.ErrorInfo
import org.schabi.newpipe.error.UserAction import org.schabi.newpipe.error.UserAction
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException
import org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty
import org.schabi.newpipe.fragments.list.BaseListFragment import org.schabi.newpipe.fragments.list.BaseListFragment
import org.schabi.newpipe.ktx.animate import org.schabi.newpipe.ktx.animate
import org.schabi.newpipe.ktx.animateHideRecyclerViewAllowingScrolling import org.schabi.newpipe.ktx.animateHideRecyclerViewAllowingScrolling
@ -323,17 +324,22 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
} }
) )
.setNegativeButton(R.string.cancel, DialogInterface.OnClickListener { _, _ -> }) .setNegativeButton(R.string.cancel, DialogInterface.OnClickListener { _, _ -> })
var message = getString(R.string.feed_load_error_account_info, subscriptionEntity.name)
if (cause is AccountTerminatedException) { if (cause is AccountTerminatedException) {
builder.setMessage(R.string.feed_load_error_terminated) message += "\n" + getString(R.string.feed_load_error_terminated)
} else if (cause is ContentNotAvailableException && isFastFeedModeEnabled) { } else if (cause is ContentNotAvailableException) {
builder.setMessage(R.string.feed_load_error_fast_unknown) if (isFastFeedModeEnabled) {
.setNeutralButton(R.string.feed_use_dedicated_fetch_method_disable_button) { _, _ -> message += "\n" + getString(R.string.feed_load_error_fast_unknown)
builder.setNeutralButton(R.string.feed_use_dedicated_fetch_method_disable_button) { _, _ ->
sharedPreferences.edit { sharedPreferences.edit {
putBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), false) putBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), false)
} }
} }
} else if (!isNullOrEmpty(cause.message)) {
message += "\n" + cause.message
}
} }
builder.create().show() builder.setMessage(message).create().show()
} }
private fun updateRelativeTimeViews() { private fun updateRelativeTimeViews() {

View file

@ -692,7 +692,7 @@
<string name="feed_update_threshold_option_always_update">Always update</string> <string name="feed_update_threshold_option_always_update">Always update</string>
<string name="feed_load_error">Error loading feed</string> <string name="feed_load_error">Error loading feed</string>
<string name="feed_load_error_account_info">Could not load feed for \'%s\'.</string> <string name="feed_load_error_account_info">Could not load feed for \'%s\'.</string>
<string name="feed_load_error_terminated">The author\'s account has been terminated.\nNewPipe will not be able to load this feed in the future.\Do you want to unsubscribe from this channel?</string> <string name="feed_load_error_terminated">The author\'s account has been terminated.\nNewPipe will not be able to load this feed in the future.\nDo you want to unsubscribe from this channel?</string>
<string name="feed_load_error_fast_unknown">The fast feed mode does not provide more info on this.</string> <string name="feed_load_error_fast_unknown">The fast feed mode does not provide more info on this.</string>
<string name="feed_use_dedicated_fetch_method_title">Fetch from dedicated feed when available</string> <string name="feed_use_dedicated_fetch_method_title">Fetch from dedicated feed when available</string>
<string name="feed_use_dedicated_fetch_method_summary">Available in some services, it is usually much faster but may return a limited amount of items and often incomplete information (e.g. no duration, item type, no live status).</string> <string name="feed_use_dedicated_fetch_method_summary">Available in some services, it is usually much faster but may return a limited amount of items and often incomplete information (e.g. no duration, item type, no live status).</string>