Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,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()
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -60,6 +64,7 @@ class ErrorPanelHelper(
errorActionButton.isVisible = false
errorRetryButton.isVisible = false
errorOpenInBrowserButton.isVisible = false
errorCheckForUpdatesButton.isVisible = false
}

fun showError(errorInfo: ErrorInfo) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
Expand All @@ -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;
};
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/error_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading