Add check for update button to error screen

This commit is contained in:
Yevhen Babiichuk (DustDFG) 2026-02-09 14:30:39 +02:00
parent 9c03e4dcf5
commit d2c15c88f8
2 changed files with 27 additions and 0 deletions

View File

@ -13,8 +13,10 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.Disposable
import java.util.concurrent.TimeUnit
import org.schabi.newpipe.MainActivity
import org.schabi.newpipe.NewVersionWorker.Companion.enqueueNewVersionCheckingWork
import org.schabi.newpipe.R
import org.schabi.newpipe.ktx.animate
import org.schabi.newpipe.util.ReleaseVersionUtil
import org.schabi.newpipe.util.external_communication.ShareUtils
class ErrorPanelHelper(
@ -39,6 +41,8 @@ class ErrorPanelHelper(
errorPanelRoot.findViewById(R.id.error_retry_button)
private val errorOpenInBrowserButton: Button =
errorPanelRoot.findViewById(R.id.error_open_in_browser)
private val errorCheckForUpdatesButton: Button =
errorPanelRoot.findViewById(R.id.error_check_for_updates)
private var errorDisposable: Disposable? = null
private var retryShouldBeShown: Boolean = (onRetry != null)
@ -60,6 +64,7 @@ class ErrorPanelHelper(
errorActionButton.isVisible = false
errorRetryButton.isVisible = false
errorOpenInBrowserButton.isVisible = false
errorCheckForUpdatesButton.isVisible = false
}
fun showError(errorInfo: ErrorInfo) {
@ -78,6 +83,14 @@ class ErrorPanelHelper(
showAndSetErrorButtonAction(R.string.error_snackbar_action) {
ErrorUtil.openActivity(context, errorInfo)
}
if (ReleaseVersionUtil.isReleaseApk) {
errorCheckForUpdatesButton.isVisible = true
errorCheckForUpdatesButton.setOnClickListener {
enqueueNewVersionCheckingWork(context, true)
errorCheckForUpdatesButton.isEnabled = false
errorCheckForUpdatesButton.isVisible = false
}
}
}
if (errorInfo.isRetryable) {

View File

@ -71,6 +71,20 @@
android:visibility="gone"
tools:visibility="visible" />
<Button
android:id="@+id/error_check_for_updates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/check_for_updates"
android:textAlignment="center"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp"
android:theme="@style/ServiceColoredButton"
android:visibility="gone"
tools:visibility="visible" />
<Button
android:id="@+id/error_open_in_browser"
android:layout_width="wrap_content"