Show detailed error message when an account has been terminated by the service
This commit is contained in:
parent
6ad4b425e4
commit
ccc46971b4
4 changed files with 60 additions and 1 deletions
|
@ -6,6 +6,7 @@ import kotlinx.android.parcel.Parcelize
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.extractor.Info
|
import org.schabi.newpipe.extractor.Info
|
||||||
import org.schabi.newpipe.extractor.NewPipe
|
import org.schabi.newpipe.extractor.NewPipe
|
||||||
|
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.exceptions.ContentNotSupportedException
|
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException
|
||||||
|
@ -95,6 +96,7 @@ class ErrorInfo(
|
||||||
action: UserAction
|
action: UserAction
|
||||||
): Int {
|
): Int {
|
||||||
return when {
|
return when {
|
||||||
|
throwable is AccountTerminatedException -> R.string.account_terminated
|
||||||
throwable is ContentNotAvailableException -> R.string.content_not_available
|
throwable is ContentNotAvailableException -> R.string.content_not_available
|
||||||
throwable != null && throwable.isNetworkRelated -> R.string.network_error
|
throwable != null && throwable.isNetworkRelated -> R.string.network_error
|
||||||
throwable is ContentNotSupportedException -> R.string.content_not_supported
|
throwable is ContentNotSupportedException -> R.string.content_not_supported
|
||||||
|
|
|
@ -13,6 +13,8 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.rxjava3.disposables.Disposable
|
import io.reactivex.rxjava3.disposables.Disposable
|
||||||
import org.schabi.newpipe.MainActivity
|
import org.schabi.newpipe.MainActivity
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException
|
||||||
import org.schabi.newpipe.extractor.exceptions.AgeRestrictedContentException
|
import org.schabi.newpipe.extractor.exceptions.AgeRestrictedContentException
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException
|
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException
|
||||||
|
@ -22,9 +24,11 @@ import org.schabi.newpipe.extractor.exceptions.PrivateContentException
|
||||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
||||||
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException
|
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException
|
||||||
import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException
|
import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException
|
||||||
|
import org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty
|
||||||
import org.schabi.newpipe.ktx.animate
|
import org.schabi.newpipe.ktx.animate
|
||||||
import org.schabi.newpipe.ktx.isInterruptedCaused
|
import org.schabi.newpipe.ktx.isInterruptedCaused
|
||||||
import org.schabi.newpipe.ktx.isNetworkRelated
|
import org.schabi.newpipe.ktx.isNetworkRelated
|
||||||
|
import org.schabi.newpipe.util.ServiceHelper
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ErrorPanelHelper(
|
class ErrorPanelHelper(
|
||||||
|
@ -35,6 +39,8 @@ class ErrorPanelHelper(
|
||||||
private val context: Context = rootView.context!!
|
private val context: Context = rootView.context!!
|
||||||
private val errorPanelRoot: View = rootView.findViewById(R.id.error_panel)
|
private val errorPanelRoot: View = rootView.findViewById(R.id.error_panel)
|
||||||
private val errorTextView: TextView = errorPanelRoot.findViewById(R.id.error_message_view)
|
private val errorTextView: TextView = errorPanelRoot.findViewById(R.id.error_message_view)
|
||||||
|
private val errorServiceInfoTextView: TextView = errorPanelRoot.findViewById(R.id.error_message_service_info_view)
|
||||||
|
private val errorServiceExplenationTextView: TextView = errorPanelRoot.findViewById(R.id.error_message_service_explenation_view)
|
||||||
private val errorButtonAction: Button = errorPanelRoot.findViewById(R.id.error_button_action)
|
private val errorButtonAction: Button = errorPanelRoot.findViewById(R.id.error_button_action)
|
||||||
private val errorButtonRetry: Button = errorPanelRoot.findViewById(R.id.error_button_retry)
|
private val errorButtonRetry: Button = errorPanelRoot.findViewById(R.id.error_button_retry)
|
||||||
|
|
||||||
|
@ -70,13 +76,40 @@ class ErrorPanelHelper(
|
||||||
errorButtonAction.setOnClickListener(null)
|
errorButtonAction.setOnClickListener(null)
|
||||||
}
|
}
|
||||||
errorTextView.setText(R.string.recaptcha_request_toast)
|
errorTextView.setText(R.string.recaptcha_request_toast)
|
||||||
|
// additional info is only provided by AccountTerminatedException
|
||||||
|
errorServiceInfoTextView.isVisible = false
|
||||||
|
errorServiceExplenationTextView.isVisible = false
|
||||||
errorButtonRetry.isVisible = true
|
errorButtonRetry.isVisible = true
|
||||||
|
} else if (errorInfo.throwable is AccountTerminatedException) {
|
||||||
|
errorButtonRetry.isVisible = false
|
||||||
|
errorButtonAction.isVisible = false
|
||||||
|
errorTextView.setText(R.string.account_terminated)
|
||||||
|
if (!isNullOrEmpty((errorInfo.throwable as AccountTerminatedException).message)) {
|
||||||
|
errorServiceInfoTextView.setText(
|
||||||
|
context.resources.getString(
|
||||||
|
R.string.service_provides_reason,
|
||||||
|
NewPipe.getNameOfService(ServiceHelper.getSelectedServiceId(context))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
errorServiceExplenationTextView.setText(
|
||||||
|
(errorInfo.throwable as AccountTerminatedException).message
|
||||||
|
)
|
||||||
|
errorServiceInfoTextView.isVisible = true
|
||||||
|
errorServiceExplenationTextView.isVisible = true
|
||||||
|
} else {
|
||||||
|
errorServiceInfoTextView.isVisible = false
|
||||||
|
errorServiceExplenationTextView.isVisible = false
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errorButtonAction.setText(R.string.error_snackbar_action)
|
errorButtonAction.setText(R.string.error_snackbar_action)
|
||||||
errorButtonAction.setOnClickListener {
|
errorButtonAction.setOnClickListener {
|
||||||
ErrorActivity.reportError(context, errorInfo)
|
ErrorActivity.reportError(context, errorInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// additional info is only provided by AccountTerminatedException
|
||||||
|
errorServiceInfoTextView.isVisible = false
|
||||||
|
errorServiceExplenationTextView.isVisible = false
|
||||||
|
|
||||||
// hide retry button by default, then show only if not unavailable/unsupported content
|
// hide retry button by default, then show only if not unavailable/unsupported content
|
||||||
errorButtonRetry.isVisible = false
|
errorButtonRetry.isVisible = false
|
||||||
errorTextView.setText(
|
errorTextView.setText(
|
||||||
|
|
|
@ -15,7 +15,29 @@
|
||||||
android:text="@string/general_error"
|
android:text="@string/general_error"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="Network error" />
|
tools:text="Account terminated" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error_message_service_info_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:text="@string/general_error"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="YouTube provides this reason:" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error_message_service_explenation_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="@string/general_error"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="italic"
|
||||||
|
tools:text="This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted." />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/error_button_action"
|
android:id="@+id/error_button_action"
|
||||||
|
|
|
@ -714,6 +714,8 @@
|
||||||
<string name="soundcloud_go_plus_content">This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe.</string>
|
<string name="soundcloud_go_plus_content">This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed or downloaded by NewPipe.</string>
|
||||||
<string name="private_content">This content is private, so it cannot be streamed or downloaded by NewPipe.</string>
|
<string name="private_content">This content is private, so it cannot be streamed or downloaded by NewPipe.</string>
|
||||||
<string name="youtube_music_premium_content">This video is available only to YouTube Music Premium members, so it cannot be streamed or downloaded by NewPipe.</string>
|
<string name="youtube_music_premium_content">This video is available only to YouTube Music Premium members, so it cannot be streamed or downloaded by NewPipe.</string>
|
||||||
|
<string name="account_terminated">Account terminated</string>
|
||||||
|
<string name="service_provides_reason">%s provides this reason:</string>
|
||||||
<string name="paid_content">This content is only available to users who have paid, so it cannot be streamed or downloaded by NewPipe.</string>
|
<string name="paid_content">This content is only available to users who have paid, so it cannot be streamed or downloaded by NewPipe.</string>
|
||||||
<string name="featured">Featured</string>
|
<string name="featured">Featured</string>
|
||||||
<string name="radio">Radio</string>
|
<string name="radio">Radio</string>
|
||||||
|
|
Loading…
Reference in a new issue