Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Open in browser button on error panel #9180

Merged
merged 6 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.schabi.newpipe.ktx.animate
import org.schabi.newpipe.ktx.isInterruptedCaused
import org.schabi.newpipe.ktx.isNetworkRelated
import org.schabi.newpipe.util.ServiceHelper
import org.schabi.newpipe.util.external_communication.ShareUtils
import java.util.concurrent.TimeUnit

class ErrorPanelHelper(
Expand All @@ -52,6 +53,8 @@ class ErrorPanelHelper(
errorPanelRoot.findViewById(R.id.error_action_button)
private val errorRetryButton: Button =
errorPanelRoot.findViewById(R.id.error_retry_button)
private val errorOpenInBrowserButton: Button =
errorPanelRoot.findViewById(R.id.error_open_in_browser)

private var errorDisposable: Disposable? = null

Expand All @@ -69,6 +72,7 @@ class ErrorPanelHelper(
errorServiceExplanationTextView.isVisible = false
errorActionButton.isVisible = false
errorRetryButton.isVisible = false
errorOpenInBrowserButton.isVisible = false
}

fun showError(errorInfo: ErrorInfo) {
Expand Down Expand Up @@ -99,6 +103,7 @@ class ErrorPanelHelper(
}

errorRetryButton.isVisible = true
errorOpenInBrowserButton.isVisible = true
Stypox marked this conversation as resolved.
Show resolved Hide resolved
} else if (errorInfo.throwable is AccountTerminatedException) {
errorTextView.setText(R.string.account_terminated)

Expand Down Expand Up @@ -127,6 +132,10 @@ class ErrorPanelHelper(
) {
// show retry button only for content which is not unavailable or unsupported
errorRetryButton.isVisible = true
errorOpenInBrowserButton.isVisible = true
errorOpenInBrowserButton.setOnClickListener {
ShareUtils.openUrlInBrowser(context, errorInfo.request, true)
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions app/src/main/res/layout/error_panel.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_width="match_parent"
Stypox marked this conversation as resolved.
Show resolved Hide resolved
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
Expand Down Expand Up @@ -33,8 +33,8 @@
android:id="@+id/error_message_service_explanation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="@string/general_error"
android:textSize="16sp"
android:textStyle="italic"
Expand Down Expand Up @@ -72,4 +72,19 @@
android:visibility="gone"
tools:visibility="visible" />

<Button
android:id="@+id/error_open_in_browser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
Stypox marked this conversation as resolved.
Show resolved Hide resolved
android:layout_marginBottom="8dp"
android:text="@string/open_in_browser"
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" />

</LinearLayout>
10 changes: 5 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ include ':app'
// We assume, that NewPipe and NewPipe Extractor have the same parent directory.
// If this is not the case, please change the path in includeBuild().

//includeBuild('../NewPipeExtractor') {
Stypox marked this conversation as resolved.
Show resolved Hide resolved
// dependencySubstitution {
// substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
// }
//}
includeBuild('../NewPipeExtractor') {
dependencySubstitution {
substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
}
}