Skip to content

Commit d2c15c8

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Add check for update button to error screen
1 parent 9c03e4d commit d2c15c8

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
1313
import io.reactivex.rxjava3.disposables.Disposable
1414
import java.util.concurrent.TimeUnit
1515
import org.schabi.newpipe.MainActivity
16+
import org.schabi.newpipe.NewVersionWorker.Companion.enqueueNewVersionCheckingWork
1617
import org.schabi.newpipe.R
1718
import org.schabi.newpipe.ktx.animate
19+
import org.schabi.newpipe.util.ReleaseVersionUtil
1820
import org.schabi.newpipe.util.external_communication.ShareUtils
1921

2022
class ErrorPanelHelper(
@@ -39,6 +41,8 @@ class ErrorPanelHelper(
3941
errorPanelRoot.findViewById(R.id.error_retry_button)
4042
private val errorOpenInBrowserButton: Button =
4143
errorPanelRoot.findViewById(R.id.error_open_in_browser)
44+
private val errorCheckForUpdatesButton: Button =
45+
errorPanelRoot.findViewById(R.id.error_check_for_updates)
4246

4347
private var errorDisposable: Disposable? = null
4448
private var retryShouldBeShown: Boolean = (onRetry != null)
@@ -60,6 +64,7 @@ class ErrorPanelHelper(
6064
errorActionButton.isVisible = false
6165
errorRetryButton.isVisible = false
6266
errorOpenInBrowserButton.isVisible = false
67+
errorCheckForUpdatesButton.isVisible = false
6368
}
6469

6570
fun showError(errorInfo: ErrorInfo) {
@@ -78,6 +83,14 @@ class ErrorPanelHelper(
7883
showAndSetErrorButtonAction(R.string.error_snackbar_action) {
7984
ErrorUtil.openActivity(context, errorInfo)
8085
}
86+
if (ReleaseVersionUtil.isReleaseApk) {
87+
errorCheckForUpdatesButton.isVisible = true
88+
errorCheckForUpdatesButton.setOnClickListener {
89+
enqueueNewVersionCheckingWork(context, true)
90+
errorCheckForUpdatesButton.isEnabled = false
91+
errorCheckForUpdatesButton.isVisible = false
92+
}
93+
}
8194
}
8295

8396
if (errorInfo.isRetryable) {

app/src/main/res/layout/error_panel.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@
7171
android:visibility="gone"
7272
tools:visibility="visible" />
7373

74+
<Button
75+
android:id="@+id/error_check_for_updates"
76+
android:layout_width="wrap_content"
77+
android:layout_height="wrap_content"
78+
android:layout_marginTop="4dp"
79+
android:text="@string/check_for_updates"
80+
android:textAlignment="center"
81+
android:textAllCaps="true"
82+
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
83+
android:textSize="16sp"
84+
android:theme="@style/ServiceColoredButton"
85+
android:visibility="gone"
86+
tools:visibility="visible" />
87+
7488
<Button
7589
android:id="@+id/error_open_in_browser"
7690
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)