Merge d2c15c88f8041babce88e7eeea118fd8e1135262 into 35b70c5e9e8d791ae268bac677a3b760b1b4e8bf

This commit is contained in:
Yevhen Babiichuk (DustDFG) 2026-02-20 12:48:57 +01:00 committed by GitHub
commit c89248e856
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 2 deletions

View File

@ -177,6 +177,15 @@ class NewVersionWorker(
*/
@JvmStatic
fun enqueueNewVersionCheckingWork(context: Context, isManual: Boolean) {
if (isManual) {
ContextCompat.getMainExecutor(context).execute {
Toast.makeText(
context,
R.string.checking_updates_toast,
Toast.LENGTH_SHORT
).show()
}
}
val workRequest = OneTimeWorkRequestBuilder<NewVersionWorker>()
.setInputData(workDataOf(IS_MANUAL to isManual))
.build()

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

@ -3,7 +3,6 @@ package org.schabi.newpipe.settings;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
@ -25,7 +24,6 @@ public class UpdateSettingsFragment extends BasePreferenceFragment {
};
private final Preference.OnPreferenceClickListener manualUpdateClick = preference -> {
Toast.makeText(getContext(), R.string.checking_updates_toast, Toast.LENGTH_SHORT).show();
NewVersionWorker.enqueueNewVersionCheckingWork(requireContext(), true);
return true;
};

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"