mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-11-23 23:57:23 +00:00
Merge branch 'refactor' into History-Compose
# Conflicts: # app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java # app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java # app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java # app/src/main/res/values-ca/strings.xml # app/src/main/res/values-eu/strings.xml # app/src/main/res/values-in/strings.xml # app/src/main/res/values-lv/strings.xml
This commit is contained in:
commit
01c565e4f7
957 files changed
+24008
-7951
No files matched your search
@@ -22,7 +22,7 @@ jobs:
|
||||
github.event.comment.author_association == 'MEMBER'
|
||||
)
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Get backport metadata
|
||||
# the target branch is the first argument after `/backport`
|
||||
env:
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
mv app/build/outputs/apk/release/*.apk "app/build/outputs/apk/release/NewPipe_v$VERSION_NAME.apk"
|
||||
|
||||
- name: "Upload APK"
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: app
|
||||
path: app/build/outputs/apk/release/*.apk
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: gradle/actions/wrapper-validation@v4
|
||||
- uses: gradle/actions/wrapper-validation@v6
|
||||
|
||||
- name: create and checkout branch
|
||||
# push events already checked out the branch
|
||||
@@ -55,13 +55,13 @@ jobs:
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Build debug APK and run jvm tests
|
||||
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint
|
||||
run: ./gradlew assembleContinuous lintContinuous testDebugUnitTest --stacktrace -DskipFormatKtlint
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: app
|
||||
path: app/build/outputs/apk/debug/*.apk
|
||||
path: app/build/outputs/apk/continuous/*.apk
|
||||
|
||||
test-android:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
script: ./gradlew connectedCheck --stacktrace
|
||||
|
||||
- name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
if: failure()
|
||||
with:
|
||||
name: android-test-report-api${{ matrix.api-level }}
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
run: npm i probe-image-size@7.2.3 --ignore-scripts
|
||||
|
||||
- name: Minimize simple images
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v9
|
||||
timeout-minutes: 3
|
||||
with:
|
||||
script: |
|
||||
|
||||
+14
-1
@@ -1,7 +1,8 @@
|
||||
.gradle/
|
||||
local.properties
|
||||
.DS_Store
|
||||
build/
|
||||
**/build/
|
||||
!src/**/build/
|
||||
captures/
|
||||
.idea/
|
||||
*.iml
|
||||
@@ -21,5 +22,17 @@ bin/
|
||||
.vscode/
|
||||
*.code-workspace
|
||||
|
||||
# xcode files
|
||||
xcuserdata
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
node_modules/
|
||||
*.xcodeproj/*
|
||||
!*.xcodeproj/project.pbxproj
|
||||
!*.xcodeproj/xcshareddata/
|
||||
!*.xcodeproj/project.xcworkspace/
|
||||
!*.xcworkspace/contents.xcworkspacedata
|
||||
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||
|
||||
# logs
|
||||
*.log
|
||||
+79
-49
@@ -2,16 +2,17 @@
|
||||
* SPDX-FileCopyrightText: 2025 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import com.mikepenz.aboutlibraries.plugin.DuplicateMode
|
||||
import java.util.regex.Pattern
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
alias(libs.plugins.android.legacy.kapt)
|
||||
alias(libs.plugins.google.ksp)
|
||||
alias(libs.plugins.jetbrains.kotlin.compose)
|
||||
alias(libs.plugins.jetbrains.kotlin.kapt)
|
||||
alias(libs.plugins.jetbrains.kotlin.parcelize)
|
||||
alias(libs.plugins.jetbrains.kotlinx.serialization)
|
||||
alias(libs.plugins.google.ksp)
|
||||
alias(libs.plugins.sonarqube)
|
||||
alias(libs.plugins.hilt)
|
||||
alias(libs.plugins.about.libraries)
|
||||
@@ -21,14 +22,14 @@ plugins {
|
||||
val gitWorkingBranch = providers.exec {
|
||||
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
}.standardOutput.asText.map { it.trim() }
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
val defaultBranches = listOf("master", "dev")
|
||||
val workingBranch = gitWorkingBranch.getOrElse("")
|
||||
val normalizedWorkingBranch = workingBranch
|
||||
.replaceFirst("^[^A-Za-z]+".toRegex(), "")
|
||||
.replace("[^0-9A-Za-z]+".toRegex(), "")
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
compilerOptions {
|
||||
// TODO: Drop annotation default target when it is stable
|
||||
freeCompilerArgs.addAll(
|
||||
@@ -37,19 +38,27 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
namespace = "org.schabi.newpipe"
|
||||
configure<ApplicationExtension> {
|
||||
compileSdk {
|
||||
version = release(NEWPIPE_VERSION_SDK_COMPILE_MAJOR) {
|
||||
minorApiLevel = NEWPIPE_VERSION_SDK_COMPILE_MINOR
|
||||
}
|
||||
}
|
||||
namespace = NEWPIPE_APPLICATION_ID_OLD
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "org.schabi.newpipe"
|
||||
applicationId = NEWPIPE_APPLICATION_ID_OLD
|
||||
resValue("string", "app_name", "NewPipe")
|
||||
minSdk = 23
|
||||
targetSdk = 35
|
||||
minSdk {
|
||||
version = release(NEWPIPE_VERSION_SDK_MIN)
|
||||
}
|
||||
targetSdk {
|
||||
version = release(NEWPIPE_VERSION_SDK_TARGET)
|
||||
}
|
||||
|
||||
versionCode = System.getProperty("versionCodeOverride")?.toInt() ?: 1006
|
||||
versionCode = System.getProperty("versionCodeOverride")?.toInt() ?: NEWPIPE_VERSION_CODE
|
||||
|
||||
versionName = "0.28.1"
|
||||
versionName = NEWPIPE_VERSION_NAME
|
||||
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -60,14 +69,7 @@ android {
|
||||
isDebuggable = true
|
||||
|
||||
// suffix the app id and the app name with git branch name
|
||||
val defaultBranches = listOf("master", "dev")
|
||||
val workingBranch = gitWorkingBranch.getOrElse("")
|
||||
val normalizedWorkingBranch = workingBranch
|
||||
.replaceFirst("^[^A-Za-z]+".toRegex(), "")
|
||||
.replace("[^0-9A-Za-z]+".toRegex(), "")
|
||||
|
||||
if (normalizedWorkingBranch.isEmpty() || workingBranch in defaultBranches) {
|
||||
// default values when branch name could not be determined or is master or dev
|
||||
applicationIdSuffix = ".debug"
|
||||
resValue("string", "app_name", "NewPipe Debug")
|
||||
} else {
|
||||
@@ -82,19 +84,33 @@ android {
|
||||
resValue("string", "app_name", "NewPipe $suffix")
|
||||
}
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = false // disabled to fix F-Droid"s reproducible build
|
||||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
||||
isShrinkResources = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
|
||||
register("continuous") {
|
||||
initWith(getByName("release"))
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
isDefault = true
|
||||
|
||||
// suffix the app id and the app name with git branch name
|
||||
if (normalizedWorkingBranch.isEmpty() || workingBranch in defaultBranches) {
|
||||
applicationIdSuffix = ".continuous"
|
||||
resValue("string", "app_name", "NewPipe Continuous")
|
||||
} else {
|
||||
applicationIdSuffix = ".continuous.$normalizedWorkingBranch"
|
||||
resValue("string", "app_name", "NewPipe $workingBranch")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
checkReleaseBuilds = false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
// but continue the build even when errors are found:
|
||||
lintConfig = file("lint.xml")
|
||||
// Continue the debug build even when errors are found
|
||||
abortOnError = false
|
||||
// suppress false warning ("Resource IDs will be non-final in Android Gradle Plugin version
|
||||
// 5.0, avoid using them in switch case statements"), which affects only library projects
|
||||
disable += "NonConstantResourceId"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -105,7 +121,7 @@ android {
|
||||
|
||||
sourceSets {
|
||||
getByName("androidTest") {
|
||||
assets.srcDir("$projectDir/schemas")
|
||||
assets.directories += "$projectDir/schemas"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +133,7 @@ android {
|
||||
viewBinding = true
|
||||
compose = true
|
||||
buildConfig = true
|
||||
resValues = true
|
||||
}
|
||||
|
||||
packaging {
|
||||
@@ -140,13 +157,6 @@ ksp {
|
||||
// Custom dependency configuration for ktlint
|
||||
val ktlint by configurations.creating
|
||||
|
||||
// https://checkstyle.org/#JRE_and_JDK
|
||||
tasks.withType<Checkstyle>().configureEach {
|
||||
javaLauncher = javaToolchains.launcherFor {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
configDirectory = rootProject.file("checkstyle")
|
||||
isIgnoreFailures = false
|
||||
@@ -218,19 +228,19 @@ aboutLibraries {
|
||||
// note: offline mode prevents the plugin from fetching licenses at build time, which would be
|
||||
// harmful for reproducible builds
|
||||
offlineMode = true
|
||||
duplicationMode = DuplicateMode.MERGE
|
||||
}
|
||||
|
||||
dependencies {
|
||||
/** Desugaring **/
|
||||
// Desugaring
|
||||
coreLibraryDesugaring(libs.android.desugar)
|
||||
|
||||
/** NewPipe libraries **/
|
||||
// NewPipe libraries
|
||||
implementation(projects.shared)
|
||||
implementation(libs.newpipe.nanojson)
|
||||
implementation(libs.newpipe.extractor)
|
||||
implementation(libs.newpipe.filepicker)
|
||||
|
||||
/** Checkstyle **/
|
||||
// Checkstyle
|
||||
checkstyle(libs.puppycrawl.checkstyle)
|
||||
ktlint(libs.pinterest.ktlint)
|
||||
|
||||
@@ -269,9 +279,14 @@ dependencies {
|
||||
implementation(libs.androidx.compose.ui.text) // Needed for parsing HTML to AnnotatedString
|
||||
implementation(libs.androidx.compose.material.icons.extended)
|
||||
|
||||
// Jetpack navigatio3
|
||||
implementation(libs.androidx.navigation3.ui)
|
||||
implementation(libs.androidx.navigation3.runtime)
|
||||
implementation(libs.androidx.navigation3.viewmodel)
|
||||
|
||||
// Jetpack Compose related dependencies
|
||||
implementation(libs.androidx.paging.compose)
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
implementation(libs.androidx.hilt.navigation.compose)
|
||||
|
||||
// Coroutines interop
|
||||
implementation(libs.kotlinx.coroutines.rx3)
|
||||
@@ -289,8 +304,7 @@ dependencies {
|
||||
// Kotlinx Serialization
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
|
||||
/** Third-party libraries **/
|
||||
// Instance state boilerplate elimination
|
||||
// Third-party libraries
|
||||
implementation(libs.livefront.bridge)
|
||||
implementation(libs.evernote.statesaver.core)
|
||||
kapt(libs.evernote.statesaver.compiler)
|
||||
@@ -340,8 +354,7 @@ dependencies {
|
||||
// Date and time formatting
|
||||
implementation(libs.ocpsoft.prettytime)
|
||||
|
||||
/** Debugging **/
|
||||
// Memory leak detection
|
||||
// Debugging and memory leak detection
|
||||
debugImplementation(libs.squareup.leakcanary.watcher)
|
||||
debugImplementation(libs.squareup.leakcanary.plumber)
|
||||
debugImplementation(libs.squareup.leakcanary.core)
|
||||
@@ -364,3 +377,20 @@ dependencies {
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
}
|
||||
|
||||
aboutLibraries {
|
||||
collect {
|
||||
configPath = file("../config/aboutlibraries")
|
||||
}
|
||||
export {
|
||||
outputFile = file("../shared/src/androidMain/assets/aboutlibraries.json")
|
||||
prettyPrint = true
|
||||
excludeFields.addAll("organization", "scm", "funding")
|
||||
}
|
||||
library {
|
||||
exclusionPatterns = listOf(
|
||||
Pattern.compile("^com\\.github\\.TeamNewPipe:NewPipeExtractor$"),
|
||||
Pattern.compile("^com\\.evernote:android-state$")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
tasks.register('checkDependenciesOrder') {
|
||||
group = 'verification'
|
||||
description = 'Checks that each section in libs.versions.toml is sorted alphabetically'
|
||||
|
||||
def tomlFile = file('../gradle/libs.versions.toml')
|
||||
|
||||
doLast {
|
||||
if (!tomlFile.exists()) {
|
||||
throw new GradleException('TOML file not found')
|
||||
}
|
||||
|
||||
def lines = tomlFile.readLines()
|
||||
def nonSortedBlocks = []
|
||||
def currentBlock = []
|
||||
def prevLine = ''
|
||||
def prevIndex = 0
|
||||
|
||||
lines.eachWithIndex { line, lineIndex ->
|
||||
if (line.trim() && !line.startsWith('#')) {
|
||||
if (line.startsWith('[')) {
|
||||
prevLine = ''
|
||||
} else {
|
||||
def currIndex = lineIndex + 1
|
||||
if (prevLine > line) {
|
||||
if (currentBlock && currentBlock[-1] == "${prevIndex}: ${prevLine}") {
|
||||
currentBlock.add("${currIndex}: ${line}")
|
||||
} else {
|
||||
if (!currentBlock.isEmpty()) {
|
||||
nonSortedBlocks.add(currentBlock)
|
||||
currentBlock = []
|
||||
}
|
||||
currentBlock.add("${prevIndex}: ${prevLine}")
|
||||
currentBlock.add("${currIndex}: ${line}")
|
||||
}
|
||||
}
|
||||
prevLine = line
|
||||
prevIndex = lineIndex + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentBlock.isEmpty()) {
|
||||
nonSortedBlocks.add(currentBlock)
|
||||
throw new GradleException("The following lines were not sorted:\n" +
|
||||
nonSortedBlocks.collect { it.join("\n") }.join("\n\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
~ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
<lint>
|
||||
<issue id="MissingTranslation" severity="ignore" />
|
||||
<issue id="MissingQuantity" severity="ignore" />
|
||||
<issue id="ImpliedQuantity" severity="ignore" />
|
||||
</lint>
|
||||
Vendored
+23
-5
@@ -16,11 +16,6 @@
|
||||
-dontwarn javax.script.**
|
||||
-keep class jdk.dynalink.** { *; }
|
||||
-dontwarn jdk.dynalink.**
|
||||
# Rules for jsoup
|
||||
# Ignore intended-to-be-optional re2j classes - only needed if using re2j for jsoup regex
|
||||
# jsoup safely falls back to JDK regex if re2j not on classpath, but has concrete re2j refs
|
||||
# See https://github.com/jhy/jsoup/issues/2459 - may be resolved in future, then this may be removed
|
||||
-dontwarn com.google.re2j.**
|
||||
|
||||
## Rules for ExoPlayer
|
||||
-keep class com.google.android.exoplayer2.** { *; }
|
||||
@@ -54,3 +49,26 @@
|
||||
-keepclasseswithmembers class org.schabi.newpipe.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# Prevent R8 from stripping or renaming Protobuf internal fields
|
||||
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
|
||||
<fields>;
|
||||
}
|
||||
|
||||
## Keep Kotlinx Serialization classes
|
||||
-keepclassmembers class kotlinx.serialization.json.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class kotlinx.serialization.json.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
-keep,includedescriptorclasses class org.schabi.newpipe.**$$serializer { *; }
|
||||
-keepclassmembers class org.schabi.newpipe.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class org.schabi.newpipe.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# See https://github.com/TeamNewPipe/NewPipe/issues/13508
|
||||
-keep class org.ocpsoft.prettytime.i18n.Resources* { *; }
|
||||
@@ -9,7 +9,6 @@ import androidx.test.filters.LargeTest
|
||||
import java.io.IOException
|
||||
import java.net.SocketTimeoutException
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -25,7 +24,7 @@ import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class ErrorInfoTest {
|
||||
private val context: Context by lazy { ApplicationProvider.getApplicationContext<Context>() }
|
||||
private val context: Context by lazy { ApplicationProvider.getApplicationContext() }
|
||||
|
||||
/**
|
||||
* @param errorInfo the error info to access
|
||||
@@ -122,7 +121,7 @@ class ErrorInfoTest {
|
||||
)
|
||||
assertEquals(context.getString(R.string.recaptcha_request_toast), errorInfo.getMessage(context))
|
||||
assertEquals(url, errorInfo.recaptchaUrl)
|
||||
assertFalse(errorInfo.isReportable)
|
||||
assertTrue(errorInfo.isReportable)
|
||||
assertTrue(errorInfo.isRetryable)
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import org.junit.runner.RunWith
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.error.ErrorInfo
|
||||
import org.schabi.newpipe.error.UserAction
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
||||
import org.schabi.newpipe.extractor.exceptions.UnsupportedContentInCountryException
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@@ -71,10 +71,10 @@ class ErrorPanelTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Recaptcha Error shows solve, retry and open in browser buttons
|
||||
* Test Recaptcha Error shows all buttons: solve, retry, open in browser, report
|
||||
*/
|
||||
@Test
|
||||
fun recaptchaErrorShowsSolveAndRetryOpenInBrowserButtons() {
|
||||
fun recaptchaErrorShowsAllButtons() {
|
||||
var retryClicked = false
|
||||
val recaptchaErrorInfo = ErrorInfo(
|
||||
throwable = ReCaptchaException(
|
||||
@@ -99,7 +99,7 @@ class ErrorPanelTest {
|
||||
composeRule.onNodeWithText(text(R.string.open_in_browser), ignoreCase = true)
|
||||
.assertIsDisplayed()
|
||||
composeRule.onNodeWithText(text(R.string.error_snackbar_action), ignoreCase = true)
|
||||
.assertDoesNotExist()
|
||||
.assertIsDisplayed()
|
||||
assert(retryClicked) { "onRetry callback should have been invoked" }
|
||||
}
|
||||
|
||||
@@ -109,14 +109,14 @@ class ErrorPanelTest {
|
||||
@Test
|
||||
fun testNonRetryableErrorHidesRetryAndReportButtons() {
|
||||
val contentNotAvailable = ErrorInfo(
|
||||
throwable = ContentNotAvailableException("Video has been removed"),
|
||||
throwable = UnsupportedContentInCountryException("Not available here"),
|
||||
userAction = UserAction.REQUESTED_STREAM,
|
||||
request = "https://example.com/watch?v=qux"
|
||||
)
|
||||
|
||||
setErrorPanel(contentNotAvailable)
|
||||
|
||||
composeRule.onNodeWithText(text(R.string.content_not_available))
|
||||
composeRule.onNodeWithText(text(R.string.unsupported_content_in_country))
|
||||
.assertIsDisplayed()
|
||||
composeRule.onNodeWithText(text(R.string.retry), ignoreCase = true)
|
||||
.assertDoesNotExist()
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import leakcanary.LeakCanary;
|
||||
|
||||
/**
|
||||
* Build variant dependent (BVD) leak canary API implementation for the debug settings fragment.
|
||||
* This class is loaded via reflection by
|
||||
* {@link DebugSettingsFragment.DebugSettingsBVDLeakCanaryAPI}.
|
||||
*/
|
||||
@SuppressWarnings("unused") // Class is used but loaded via reflection
|
||||
public class DebugSettingsBVDLeakCanary
|
||||
implements DebugSettingsFragment.DebugSettingsBVDLeakCanaryAPI {
|
||||
|
||||
@Override
|
||||
public Intent getNewLeakDisplayActivityIntent() {
|
||||
return LeakCanary.INSTANCE.newLeakDisplayActivityIntent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings
|
||||
|
||||
import android.content.Intent
|
||||
import leakcanary.LeakCanary.newLeakDisplayActivityIntent
|
||||
|
||||
/**
|
||||
* Build variant dependent (BVD) leak canary API implementation for the debug settings fragment.
|
||||
* This class is loaded via reflection by
|
||||
* [DebugSettingsBVDLeakCanaryAPI].
|
||||
*/
|
||||
@Suppress("unused") // Class is used but loaded via reflection
|
||||
class DebugSettingsBVDLeakCanary :
|
||||
|
||||
DebugSettingsBVDLeakCanaryAPI {
|
||||
override fun getNewLeakDisplayActivityIntent(): Intent {
|
||||
return newLeakDisplayActivityIntent()
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,10 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".ComposeActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".player.PlayQueueActivity"
|
||||
android:exported="false"
|
||||
@@ -91,16 +95,6 @@
|
||||
android:exported="false"
|
||||
android:label="@string/settings" />
|
||||
|
||||
<activity
|
||||
android:name=".settings.SettingsV2Activity"
|
||||
android:exported="true"
|
||||
android:label="@string/settings" />
|
||||
|
||||
<activity
|
||||
android:name=".about.AboutActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_about" />
|
||||
|
||||
<service
|
||||
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
||||
android:foregroundServiceType="dataSync"
|
||||
@@ -129,10 +123,6 @@
|
||||
android:label="@string/general_error"
|
||||
android:theme="@android:style/Theme.NoDisplay" />
|
||||
|
||||
<activity
|
||||
android:name=".error.ErrorActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<!-- giga get related -->
|
||||
<activity
|
||||
android:name=".download.DownloadActivity"
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Apache License - Version 2.0, January 2004</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Apache License<br>Version 2.0, January 2004<br>
|
||||
<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a> </p>
|
||||
<p>TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION</p>
|
||||
<p><strong><a name="definitions">1. Definitions</a></strong>.</p>
|
||||
<p>"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.</p>
|
||||
<p>"Licensor" shall mean the copyright owner or entity authorized by the
|
||||
copyright owner that is granting the License.</p>
|
||||
<p>"Legal Entity" shall mean the union of the acting entity and all other
|
||||
entities that control, are controlled by, or are under common control with
|
||||
that entity. For the purposes of this definition, "control" means (i) the
|
||||
power, direct or indirect, to cause the direction or management of such
|
||||
entity, whether by contract or otherwise, or (ii) ownership of fifty
|
||||
percent (50%) or more of the outstanding shares, or (iii) beneficial
|
||||
ownership of such entity.</p>
|
||||
<p>"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.</p>
|
||||
<p>"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation source,
|
||||
and configuration files.</p>
|
||||
<p>"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled
|
||||
object code, generated documentation, and conversions to other media types.</p>
|
||||
<p>"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that
|
||||
is included in or attached to the work (an example is provided in the
|
||||
Appendix below).</p>
|
||||
<p>"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial
|
||||
revisions, annotations, elaborations, or other modifications represent, as
|
||||
a whole, an original work of authorship. For the purposes of this License,
|
||||
Derivative Works shall not include works that remain separable from, or
|
||||
merely link (or bind by name) to the interfaces of, the Work and Derivative
|
||||
Works thereof.</p>
|
||||
<p>"Contribution" shall mean any work of authorship, including the original
|
||||
version of the Work and any modifications or additions to that Work or
|
||||
Derivative Works thereof, that is intentionally submitted to Licensor for
|
||||
inclusion in the Work by the copyright owner or by an individual or Legal
|
||||
Entity authorized to submit on behalf of the copyright owner. For the
|
||||
purposes of this definition, "submitted" means any form of electronic,
|
||||
verbal, or written communication sent to the Licensor or its
|
||||
representatives, including but not limited to communication on electronic
|
||||
mailing lists, source code control systems, and issue tracking systems that
|
||||
are managed by, or on behalf of, the Licensor for the purpose of discussing
|
||||
and improving the Work, but excluding communication that is conspicuously
|
||||
marked or otherwise designated in writing by the copyright owner as "Not a
|
||||
Contribution."</p>
|
||||
<p>"Contributor" shall mean Licensor and any individual or Legal Entity on
|
||||
behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.</p>
|
||||
<p><strong><a name="copyright">2. Grant of Copyright License</a></strong>. Subject to the
|
||||
terms and conditions of this License, each Contributor hereby grants to You
|
||||
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of, publicly
|
||||
display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.</p>
|
||||
<p><strong><a name="patent">3. Grant of Patent License</a></strong>. Subject to the terms
|
||||
and conditions of this License, each Contributor hereby grants to You a
|
||||
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made, use,
|
||||
offer to sell, sell, import, and otherwise transfer the Work, where such
|
||||
license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by
|
||||
combination of their Contribution(s) with the Work to which such
|
||||
Contribution(s) was submitted. If You institute patent litigation against
|
||||
any entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that the Work or a Contribution incorporated within the Work constitutes
|
||||
direct or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate as of the
|
||||
date such litigation is filed.</p>
|
||||
<p><strong><a name="redistribution">4. Redistribution</a></strong>. You may reproduce and
|
||||
distribute copies of the Work or Derivative Works thereof in any medium,
|
||||
with or without modifications, and in Source or Object form, provided that
|
||||
You meet the following conditions:</p>
|
||||
<ol style="list-style: lower-latin;">
|
||||
<li>You must give any other recipients of the Work or Derivative Works a
|
||||
copy of this License; and</li>
|
||||
|
||||
<li>You must cause any modified files to carry prominent notices stating
|
||||
that You changed the files; and</li>
|
||||
|
||||
<li>You must retain, in the Source form of any Derivative Works that You
|
||||
distribute, all copyright, patent, trademark, and attribution notices from
|
||||
the Source form of the Work, excluding those notices that do not pertain to
|
||||
any part of the Derivative Works; and</li>
|
||||
|
||||
<li>If the Work includes a "NOTICE" text file as part of its distribution,
|
||||
then any Derivative Works that You distribute must include a readable copy
|
||||
of the attribution notices contained within such NOTICE file, excluding
|
||||
those notices that do not pertain to any part of the Derivative Works, in
|
||||
at least one of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or documentation,
|
||||
if provided along with the Derivative Works; or, within a display generated
|
||||
by the Derivative Works, if and wherever such third-party notices normally
|
||||
appear. The contents of the NOTICE file are for informational purposes only
|
||||
and do not modify the License. You may add Your own attribution notices
|
||||
within Derivative Works that You distribute, alongside or as an addendum to
|
||||
the NOTICE text from the Work, provided that such additional attribution
|
||||
notices cannot be construed as modifying the License.
|
||||
<br/>
|
||||
<br/>
|
||||
You may add Your own copyright statement to Your modifications and may
|
||||
provide additional or different license terms and conditions for use,
|
||||
reproduction, or distribution of Your modifications, or for any such
|
||||
Derivative Works as a whole, provided Your use, reproduction, and
|
||||
distribution of the Work otherwise complies with the conditions stated in
|
||||
this License.
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
|
||||
<p><strong><a name="contributions">5. Submission of Contributions</a></strong>. Unless You
|
||||
explicitly state otherwise, any Contribution intentionally submitted for
|
||||
inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the
|
||||
terms of any separate license agreement you may have executed with Licensor
|
||||
regarding such Contributions.</p>
|
||||
<p><strong><a name="trademarks">6. Trademarks</a></strong>. This License does not grant
|
||||
permission to use the trade names, trademarks, service marks, or product
|
||||
names of the Licensor, except as required for reasonable and customary use
|
||||
in describing the origin of the Work and reproducing the content of the
|
||||
NOTICE file.</p>
|
||||
<p><strong><a name="no-warranty">7. Disclaimer of Warranty</a></strong>. Unless required by
|
||||
applicable law or agreed to in writing, Licensor provides the Work (and
|
||||
each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,
|
||||
without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You
|
||||
are solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise
|
||||
of permissions under this License.</p>
|
||||
<p><strong><a name="no-liability">8. Limitation of Liability</a></strong>. In no event and
|
||||
under no legal theory, whether in tort (including negligence), contract, or
|
||||
otherwise, unless required by applicable law (such as deliberate and
|
||||
grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a result
|
||||
of this License or out of the use or inability to use the Work (including
|
||||
but not limited to damages for loss of goodwill, work stoppage, computer
|
||||
failure or malfunction, or any and all other commercial damages or losses),
|
||||
even if such Contributor has been advised of the possibility of such
|
||||
damages.</p>
|
||||
<p><strong><a name="additional">9. Accepting Warranty or Additional Liability</a></strong>.
|
||||
While redistributing the Work or Derivative Works thereof, You may choose
|
||||
to offer, and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this License.
|
||||
However, in accepting such obligations, You may act only on Your own behalf
|
||||
and on Your sole responsibility, not on behalf of any other Contributor,
|
||||
and only if You agree to indemnify, defend, and hold each Contributor
|
||||
harmless for any liability incurred by, or claims asserted against, such
|
||||
Contributor by reason of your accepting any such warranty or additional
|
||||
liability.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,245 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- saved from url=(0050)https://www.eclipse.org/org/documents/epl-v10.html -->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
|
||||
<title>Eclipse Public License - Version 1.0</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body cz-shortcut-listen="true" lang="EN-US">
|
||||
|
||||
<h2>Eclipse Public License - v 1.0</h2>
|
||||
|
||||
<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
||||
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
|
||||
DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
|
||||
AGREEMENT.</p>
|
||||
|
||||
<p><b>1. DEFINITIONS</b></p>
|
||||
|
||||
<p>"Contribution" means:</p>
|
||||
|
||||
<p class="list">a) in the case of the initial Contributor, the initial
|
||||
code and documentation distributed under this Agreement, and</p>
|
||||
<p class="list">b) in the case of each subsequent Contributor:</p>
|
||||
<p class="list">i) changes to the Program, and</p>
|
||||
<p class="list">ii) additions to the Program;</p>
|
||||
<p class="list">where such changes and/or additions to the Program
|
||||
originate from and are distributed by that particular Contributor. A
|
||||
Contribution 'originates' from a Contributor if it was added to the
|
||||
Program by such Contributor itself or anyone acting on such
|
||||
Contributor's behalf. Contributions do not include additions to the
|
||||
Program which: (i) are separate modules of software distributed in
|
||||
conjunction with the Program under their own license agreement, and (ii)
|
||||
are not derivative works of the Program.</p>
|
||||
|
||||
<p>"Contributor" means any person or entity that distributes
|
||||
the Program.</p>
|
||||
|
||||
<p>"Licensed Patents" mean patent claims licensable by a
|
||||
Contributor which are necessarily infringed by the use or sale of its
|
||||
Contribution alone or when combined with the Program.</p>
|
||||
|
||||
<p>"Program" means the Contributions distributed in accordance
|
||||
with this Agreement.</p>
|
||||
|
||||
<p>"Recipient" means anyone who receives the Program under
|
||||
this Agreement, including all Contributors.</p>
|
||||
|
||||
<p><b>2. GRANT OF RIGHTS</b></p>
|
||||
|
||||
<p class="list">a) Subject to the terms of this Agreement, each
|
||||
Contributor hereby grants Recipient a non-exclusive, worldwide,
|
||||
royalty-free copyright license to reproduce, prepare derivative works
|
||||
of, publicly display, publicly perform, distribute and sublicense the
|
||||
Contribution of such Contributor, if any, and such derivative works, in
|
||||
source code and object code form.</p>
|
||||
|
||||
<p class="list">b) Subject to the terms of this Agreement, each
|
||||
Contributor hereby grants Recipient a non-exclusive, worldwide,
|
||||
royalty-free patent license under Licensed Patents to make, use, sell,
|
||||
offer to sell, import and otherwise transfer the Contribution of such
|
||||
Contributor, if any, in source code and object code form. This patent
|
||||
license shall apply to the combination of the Contribution and the
|
||||
Program if, at the time the Contribution is added by the Contributor,
|
||||
such addition of the Contribution causes such combination to be covered
|
||||
by the Licensed Patents. The patent license shall not apply to any other
|
||||
combinations which include the Contribution. No hardware per se is
|
||||
licensed hereunder.</p>
|
||||
|
||||
<p class="list">c) Recipient understands that although each Contributor
|
||||
grants the licenses to its Contributions set forth herein, no assurances
|
||||
are provided by any Contributor that the Program does not infringe the
|
||||
patent or other intellectual property rights of any other entity. Each
|
||||
Contributor disclaims any liability to Recipient for claims brought by
|
||||
any other entity based on infringement of intellectual property rights
|
||||
or otherwise. As a condition to exercising the rights and licenses
|
||||
granted hereunder, each Recipient hereby assumes sole responsibility to
|
||||
secure any other intellectual property rights needed, if any. For
|
||||
example, if a third party patent license is required to allow Recipient
|
||||
to distribute the Program, it is Recipient's responsibility to acquire
|
||||
that license before distributing the Program.</p>
|
||||
|
||||
<p class="list">d) Each Contributor represents that to its knowledge it
|
||||
has sufficient copyright rights in its Contribution, if any, to grant
|
||||
the copyright license set forth in this Agreement.</p>
|
||||
|
||||
<p><b>3. REQUIREMENTS</b></p>
|
||||
|
||||
<p>A Contributor may choose to distribute the Program in object code
|
||||
form under its own license agreement, provided that:</p>
|
||||
|
||||
<p class="list">a) it complies with the terms and conditions of this
|
||||
Agreement; and</p>
|
||||
|
||||
<p class="list">b) its license agreement:</p>
|
||||
|
||||
<p class="list">i) effectively disclaims on behalf of all Contributors
|
||||
all warranties and conditions, express and implied, including warranties
|
||||
or conditions of title and non-infringement, and implied warranties or
|
||||
conditions of merchantability and fitness for a particular purpose;</p>
|
||||
|
||||
<p class="list">ii) effectively excludes on behalf of all Contributors
|
||||
all liability for damages, including direct, indirect, special,
|
||||
incidental and consequential damages, such as lost profits;</p>
|
||||
|
||||
<p class="list">iii) states that any provisions which differ from this
|
||||
Agreement are offered by that Contributor alone and not by any other
|
||||
party; and</p>
|
||||
|
||||
<p class="list">iv) states that source code for the Program is available
|
||||
from such Contributor, and informs licensees how to obtain it in a
|
||||
reasonable manner on or through a medium customarily used for software
|
||||
exchange.</p>
|
||||
|
||||
<p>When the Program is made available in source code form:</p>
|
||||
|
||||
<p class="list">a) it must be made available under this Agreement; and</p>
|
||||
|
||||
<p class="list">b) a copy of this Agreement must be included with each
|
||||
copy of the Program.</p>
|
||||
|
||||
<p>Contributors may not remove or alter any copyright notices contained
|
||||
within the Program.</p>
|
||||
|
||||
<p>Each Contributor must identify itself as the originator of its
|
||||
Contribution, if any, in a manner that reasonably allows subsequent
|
||||
Recipients to identify the originator of the Contribution.</p>
|
||||
|
||||
<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
|
||||
|
||||
<p>Commercial distributors of software may accept certain
|
||||
responsibilities with respect to end users, business partners and the
|
||||
like. While this license is intended to facilitate the commercial use of
|
||||
the Program, the Contributor who includes the Program in a commercial
|
||||
product offering should do so in a manner which does not create
|
||||
potential liability for other Contributors. Therefore, if a Contributor
|
||||
includes the Program in a commercial product offering, such Contributor
|
||||
("Commercial Contributor") hereby agrees to defend and
|
||||
indemnify every other Contributor ("Indemnified Contributor")
|
||||
against any losses, damages and costs (collectively "Losses")
|
||||
arising from claims, lawsuits and other legal actions brought by a third
|
||||
party against the Indemnified Contributor to the extent caused by the
|
||||
acts or omissions of such Commercial Contributor in connection with its
|
||||
distribution of the Program in a commercial product offering. The
|
||||
obligations in this section do not apply to any claims or Losses
|
||||
relating to any actual or alleged intellectual property infringement. In
|
||||
order to qualify, an Indemnified Contributor must: a) promptly notify
|
||||
the Commercial Contributor in writing of such claim, and b) allow the
|
||||
Commercial Contributor to control, and cooperate with the Commercial
|
||||
Contributor in, the defense and any related settlement negotiations. The
|
||||
Indemnified Contributor may participate in any such claim at its own
|
||||
expense.</p>
|
||||
|
||||
<p>For example, a Contributor might include the Program in a commercial
|
||||
product offering, Product X. That Contributor is then a Commercial
|
||||
Contributor. If that Commercial Contributor then makes performance
|
||||
claims, or offers warranties related to Product X, those performance
|
||||
claims and warranties are such Commercial Contributor's responsibility
|
||||
alone. Under this section, the Commercial Contributor would have to
|
||||
defend claims against the other Contributors related to those
|
||||
performance claims and warranties, and if a court requires any other
|
||||
Contributor to pay any damages as a result, the Commercial Contributor
|
||||
must pay those damages.</p>
|
||||
|
||||
<p><b>5. NO WARRANTY</b></p>
|
||||
|
||||
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
|
||||
PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
|
||||
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
|
||||
OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
|
||||
responsible for determining the appropriateness of using and
|
||||
distributing the Program and assumes all risks associated with its
|
||||
exercise of rights under this Agreement , including but not limited to
|
||||
the risks and costs of program errors, compliance with applicable laws,
|
||||
damage to or loss of data, programs or equipment, and unavailability or
|
||||
interruption of operations.</p>
|
||||
|
||||
<p><b>6. DISCLAIMER OF LIABILITY</b></p>
|
||||
|
||||
<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
|
||||
NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
|
||||
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
|
||||
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
||||
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
|
||||
|
||||
<p><b>7. GENERAL</b></p>
|
||||
|
||||
<p>If any provision of this Agreement is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this Agreement, and without further action
|
||||
by the parties hereto, such provision shall be reformed to the minimum
|
||||
extent necessary to make such provision valid and enforceable.</p>
|
||||
|
||||
<p>If Recipient institutes patent litigation against any entity
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
||||
Program itself (excluding combinations of the Program with other
|
||||
software or hardware) infringes such Recipient's patent(s), then such
|
||||
Recipient's rights granted under Section 2(b) shall terminate as of the
|
||||
date such litigation is filed.</p>
|
||||
|
||||
<p>All Recipient's rights under this Agreement shall terminate if it
|
||||
fails to comply with any of the material terms or conditions of this
|
||||
Agreement and does not cure such failure in a reasonable period of time
|
||||
after becoming aware of such noncompliance. If all Recipient's rights
|
||||
under this Agreement terminate, Recipient agrees to cease use and
|
||||
distribution of the Program as soon as reasonably practicable. However,
|
||||
Recipient's obligations under this Agreement and any licenses granted by
|
||||
Recipient relating to the Program shall continue and survive.</p>
|
||||
|
||||
<p>Everyone is permitted to copy and distribute copies of this
|
||||
Agreement, but in order to avoid inconsistency the Agreement is
|
||||
copyrighted and may only be modified in the following manner. The
|
||||
Agreement Steward reserves the right to publish new versions (including
|
||||
revisions) of this Agreement from time to time. No one other than the
|
||||
Agreement Steward has the right to modify this Agreement. The Eclipse
|
||||
Foundation is the initial Agreement Steward. The Eclipse Foundation may
|
||||
assign the responsibility to serve as the Agreement Steward to a
|
||||
suitable separate entity. Each new version of the Agreement will be
|
||||
given a distinguishing version number. The Program (including
|
||||
Contributions) may always be distributed subject to the version of the
|
||||
Agreement under which it was received. In addition, after a new version
|
||||
of the Agreement is published, Contributor may elect to distribute the
|
||||
Program (including its Contributions) under the new version. Except as
|
||||
expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
|
||||
rights or licenses to the intellectual property of any Contributor under
|
||||
this Agreement, whether expressly, by implication, estoppel or
|
||||
otherwise. All rights in the Program not expressly granted under this
|
||||
Agreement are reserved.</p>
|
||||
|
||||
<p>This Agreement is governed by the laws of the State of New York and
|
||||
the intellectual property laws of the United States of America. No party
|
||||
to this Agreement will bring a legal action under this Agreement more
|
||||
than one year after the cause of action arose. Each party waives its
|
||||
rights to a jury trial in any resulting litigation.</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,639 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF)</title>
|
||||
<link rel="alternate" type="application/rdf+xml"
|
||||
href="http://www.gnu.org/licenses/gpl-3.0.rdf" />
|
||||
</head>
|
||||
<body>
|
||||
<h3 style="text-align: center;">GNU GENERAL PUBLIC LICENSE</h3>
|
||||
<p style="text-align: center;">Version 3, 29 June 2007</p>
|
||||
|
||||
<p>Copyright © 2007 Free Software Foundation, Inc.
|
||||
<<a href="http://fsf.org/">http://fsf.org/</a>></p><p>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.</p>
|
||||
|
||||
<h3><a name="preamble"></a>Preamble</h3>
|
||||
|
||||
<p>The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.</p>
|
||||
|
||||
<p>The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.</p>
|
||||
|
||||
<p>When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.</p>
|
||||
|
||||
<p>To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.</p>
|
||||
|
||||
<p>For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.</p>
|
||||
|
||||
<p>Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.</p>
|
||||
|
||||
<p>For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.</p>
|
||||
|
||||
<p>Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.</p>
|
||||
|
||||
<p>Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.</p>
|
||||
|
||||
<p>The precise terms and conditions for copying, distribution and
|
||||
modification follow.</p>
|
||||
|
||||
<h3><a name="terms"></a>TERMS AND CONDITIONS</h3>
|
||||
|
||||
<h4><a name="section0"></a>0. Definitions.</h4>
|
||||
|
||||
<p>“This License” refers to version 3 of the GNU General Public License.</p>
|
||||
|
||||
<p>“Copyright” also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.</p>
|
||||
|
||||
<p>“The Program” refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as “you”. “Licensees” and
|
||||
“recipients” may be individuals or organizations.</p>
|
||||
|
||||
<p>To “modify” a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a “modified version” of the
|
||||
earlier work or a work “based on” the earlier work.</p>
|
||||
|
||||
<p>A “covered work” means either the unmodified Program or a work based
|
||||
on the Program.</p>
|
||||
|
||||
<p>To “propagate” a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.</p>
|
||||
|
||||
<p>To “convey” a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.</p>
|
||||
|
||||
<p>An interactive user interface displays “Appropriate Legal Notices”
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.</p>
|
||||
|
||||
<h4><a name="section1"></a>1. Source Code.</h4>
|
||||
|
||||
<p>The “source code” for a work means the preferred form of the work
|
||||
for making modifications to it. “Object code” means any non-source
|
||||
form of a work.</p>
|
||||
|
||||
<p>A “Standard Interface” means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.</p>
|
||||
|
||||
<p>The “System Libraries” of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
“Major Component”, in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.</p>
|
||||
|
||||
<p>The “Corresponding Source” for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.</p>
|
||||
|
||||
<p>The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.</p>
|
||||
|
||||
<p>The Corresponding Source for a work in source code form is that
|
||||
same work.</p>
|
||||
|
||||
<h4><a name="section2"></a>2. Basic Permissions.</h4>
|
||||
|
||||
<p>All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.</p>
|
||||
|
||||
<p>You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.</p>
|
||||
|
||||
<p>Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.</p>
|
||||
|
||||
<h4><a name="section3"></a>3. Protecting Users' Legal Rights From Anti-Circumvention Law.</h4>
|
||||
|
||||
<p>No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.</p>
|
||||
|
||||
<p>When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.</p>
|
||||
|
||||
<h4><a name="section4"></a>4. Conveying Verbatim Copies.</h4>
|
||||
|
||||
<p>You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.</p>
|
||||
|
||||
<p>You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.</p>
|
||||
|
||||
<h4><a name="section5"></a>5. Conveying Modified Source Versions.</h4>
|
||||
|
||||
<p>You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:</p>
|
||||
|
||||
<ul>
|
||||
<li>a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.</li>
|
||||
|
||||
<li>b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
“keep intact all notices”.</li>
|
||||
|
||||
<li>c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.</li>
|
||||
|
||||
<li>d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.</li>
|
||||
</ul>
|
||||
|
||||
<p>A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
“aggregate” if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.</p>
|
||||
|
||||
<h4><a name="section6"></a>6. Conveying Non-Source Forms.</h4>
|
||||
|
||||
<p>You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:</p>
|
||||
|
||||
<ul>
|
||||
<li>a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.</li>
|
||||
|
||||
<li>b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.</li>
|
||||
|
||||
<li>c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.</li>
|
||||
|
||||
<li>d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.</li>
|
||||
|
||||
<li>e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.</li>
|
||||
</ul>
|
||||
|
||||
<p>A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.</p>
|
||||
|
||||
<p>A “User Product” is either (1) a “consumer product”, which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, “normally used” refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.</p>
|
||||
|
||||
<p>“Installation Information” for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.</p>
|
||||
|
||||
<p>If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).</p>
|
||||
|
||||
<p>The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.</p>
|
||||
|
||||
<p>Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.</p>
|
||||
|
||||
<h4><a name="section7"></a>7. Additional Terms.</h4>
|
||||
|
||||
<p>“Additional permissions” are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.</p>
|
||||
|
||||
<p>When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.</p>
|
||||
|
||||
<p>Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:</p>
|
||||
|
||||
<ul>
|
||||
<li>a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or</li>
|
||||
|
||||
<li>b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or</li>
|
||||
|
||||
<li>c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or</li>
|
||||
|
||||
<li>d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or</li>
|
||||
|
||||
<li>e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or</li>
|
||||
|
||||
<li>f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.</li>
|
||||
</ul>
|
||||
|
||||
<p>All other non-permissive additional terms are considered “further
|
||||
restrictions” within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.</p>
|
||||
|
||||
<p>If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.</p>
|
||||
|
||||
<p>Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.</p>
|
||||
|
||||
<h4><a name="section8"></a>8. Termination.</h4>
|
||||
|
||||
<p>You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).</p>
|
||||
|
||||
<p>However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.</p>
|
||||
|
||||
<p>Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.</p>
|
||||
|
||||
<p>Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.</p>
|
||||
|
||||
<h4><a name="section9"></a>9. Acceptance Not Required for Having Copies.</h4>
|
||||
|
||||
<p>You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.</p>
|
||||
|
||||
<h4><a name="section10"></a>10. Automatic Licensing of Downstream Recipients.</h4>
|
||||
|
||||
<p>Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.</p>
|
||||
|
||||
<p>An “entity transaction” is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.</p>
|
||||
|
||||
<p>You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.</p>
|
||||
|
||||
<h4><a name="section11"></a>11. Patents.</h4>
|
||||
|
||||
<p>A “contributor” is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's “contributor version”.</p>
|
||||
|
||||
<p>A contributor's “essential patent claims” are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, “control” includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.</p>
|
||||
|
||||
<p>Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.</p>
|
||||
|
||||
<p>In the following three paragraphs, a “patent license” is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To “grant” such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.</p>
|
||||
|
||||
<p>If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. “Knowingly relying” means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.</p>
|
||||
|
||||
<p>If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.</p>
|
||||
|
||||
<p>A patent license is “discriminatory” if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.</p>
|
||||
|
||||
<p>Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.</p>
|
||||
|
||||
<h4><a name="section12"></a>12. No Surrender of Others' Freedom.</h4>
|
||||
|
||||
<p>If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.</p>
|
||||
|
||||
<h4><a name="section13"></a>13. Use with the GNU Affero General Public License.</h4>
|
||||
|
||||
<p>Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.</p>
|
||||
|
||||
<h4><a name="section14"></a>14. Revised Versions of this License.</h4>
|
||||
|
||||
<p>The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.</p>
|
||||
|
||||
<p>Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License “or any later version” applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.</p>
|
||||
|
||||
<p>If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.</p>
|
||||
|
||||
<p>Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.</p>
|
||||
|
||||
<h4><a name="section15"></a>15. Disclaimer of Warranty.</h4>
|
||||
|
||||
<p>THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</p>
|
||||
|
||||
<h4><a name="section16"></a>16. Limitation of Liability.</h4>
|
||||
|
||||
<p>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.</p>
|
||||
|
||||
<h4><a name="section17"></a>17. Interpretation of Sections 15 and 16.</h4>
|
||||
|
||||
<p>If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.</p>
|
||||
|
||||
</body></html>
|
||||
@@ -1,26 +0,0 @@
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<p>Copyright (c) <year> <copyright holders></p>
|
||||
|
||||
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:</p>
|
||||
|
||||
<p>
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.</p>
|
||||
<p>
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.<br />
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,261 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- saved from url=(0038)https://www.mozilla.org/en-US/MPL/2.0/ -->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Mozilla Public License, version 2.0</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="mozilla-public-license-version-2.0">Mozilla Public License<br>Version 2.0</h1>
|
||||
<h2 id="definitions">1. Definitions</h2>
|
||||
<dl>
|
||||
<dt>1.1. “Contributor”</dt>
|
||||
<dd><p>means each individual or legal entity that creates, contributes to the creation of, or
|
||||
owns Covered Software.</p>
|
||||
</dd>
|
||||
<dt>1.2. “Contributor Version”</dt>
|
||||
<dd><p>means the combination of the Contributions of others (if any) used by a Contributor and
|
||||
that particular Contributor’s Contribution.</p>
|
||||
</dd>
|
||||
<dt>1.3. “Contribution”</dt>
|
||||
<dd><p>means Covered Software of a particular Contributor.</p>
|
||||
</dd>
|
||||
<dt>1.4. “Covered Software”</dt>
|
||||
<dd><p>means Source Code Form to which the initial Contributor has attached the notice in
|
||||
Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source
|
||||
Code Form, in each case including portions thereof.</p>
|
||||
</dd>
|
||||
<dt>1.5. “Incompatible With Secondary Licenses”</dt>
|
||||
<dd><p>means</p>
|
||||
<ol type="a">
|
||||
<li><p>that the initial Contributor has attached the notice described in Exhibit B to
|
||||
the Covered Software; or</p></li>
|
||||
<li><p>that the Covered Software was made available under the terms of version 1.1 or
|
||||
earlier of the License, but not also under the terms of a Secondary License.</p>
|
||||
</li>
|
||||
</ol>
|
||||
</dd>
|
||||
<dt>1.6. “Executable Form”</dt>
|
||||
<dd><p>means any form of the work other than Source Code Form.</p>
|
||||
</dd>
|
||||
<dt>1.7. “Larger Work”</dt>
|
||||
<dd><p>means a work that combines Covered Software with other material, in a separate file or
|
||||
files, that is not Covered Software.</p>
|
||||
</dd>
|
||||
<dt>1.8. “License”</dt>
|
||||
<dd><p>means this document.</p>
|
||||
</dd>
|
||||
<dt>1.9. “Licensable”</dt>
|
||||
<dd><p>means having the right to grant, to the maximum extent possible, whether at the time of
|
||||
the initial grant or subsequently, any and all of the rights conveyed by this License.</p>
|
||||
</dd>
|
||||
<dt>1.10. “Modifications”</dt>
|
||||
<dd><p>means any of the following:</p>
|
||||
<ol type="a">
|
||||
<li><p>any file in Source Code Form that results from an addition to, deletion from, or
|
||||
modification of the contents of Covered Software; or</p></li>
|
||||
<li><p>any new file in Source Code Form that contains any Covered Software.</p></li>
|
||||
</ol>
|
||||
</dd>
|
||||
<dt>1.11. “Patent Claims” of a Contributor</dt>
|
||||
<dd><p>means any patent claim(s), including without limitation, method, process, and apparatus
|
||||
claims, in any patent Licensable by such Contributor that would be infringed, but for the
|
||||
grant of the License, by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.</p>
|
||||
</dd>
|
||||
<dt>1.12. “Secondary License”</dt>
|
||||
<dd><p>means either the GNU General Public License, Version 2.0, the GNU Lesser General Public
|
||||
License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later
|
||||
versions of those licenses.</p>
|
||||
</dd>
|
||||
<dt>1.13. “Source Code Form”</dt>
|
||||
<dd><p>means the form of the work preferred for making modifications.</p>
|
||||
</dd>
|
||||
<dt>1.14. “You” (or “Your”)</dt>
|
||||
<dd><p>means an individual or a legal entity exercising rights under this License. For legal
|
||||
entities, “You” includes any entity that controls, is controlled by, or is under common
|
||||
control with You. For purposes of this definition, “control” means (a) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or
|
||||
beneficial ownership of such entity.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 id="license-grants-and-conditions">2. License Grants and Conditions</h2>
|
||||
<h3 id="grants">2.1. Grants</h3>
|
||||
<p>Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:</p>
|
||||
<ol type="a">
|
||||
<li><p>under intellectual property rights (other than patent or trademark) Licensable by such
|
||||
Contributor to use, reproduce, make available, modify, display, perform, distribute, and
|
||||
otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and</p></li>
|
||||
<li><p>under Patent Claims of such Contributor to make, use, sell, offer for sale, have made,
|
||||
import, and otherwise transfer either its Contributions or its Contributor Version.</p></li>
|
||||
</ol>
|
||||
<h3 id="effective-date">2.2. Effective Date</h3>
|
||||
<p>The licenses granted in Section 2.1 with respect to any Contribution become effective for
|
||||
each Contribution on the date the Contributor first distributes such Contribution.</p>
|
||||
<h3 id="limitations-on-grant-scope">2.3. Limitations on Grant Scope</h3>
|
||||
<p>The licenses granted in this Section 2 are the only rights granted under this License. No
|
||||
additional rights or licenses will be implied from the distribution or licensing of Covered
|
||||
Software under this License. Notwithstanding Section 2.1(b) above, no patent license is
|
||||
granted by a Contributor:</p>
|
||||
<ol type="a">
|
||||
<li><p>for any code that a Contributor has removed from Covered Software; or</p></li>
|
||||
<li><p>for infringements caused by: (i) Your and any other third party’s modifications of
|
||||
Covered Software, or (ii) the combination of its Contributions with other software (except
|
||||
as part of its Contributor Version); or</p></li>
|
||||
<li><p>under Patent Claims infringed by Covered Software in the absence of its
|
||||
Contributions.</p></li>
|
||||
</ol>
|
||||
<p>This License does not grant any rights in the trademarks, service marks, or logos of any
|
||||
Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).</p>
|
||||
<h3 id="subsequent-licenses">2.4. Subsequent Licenses</h3>
|
||||
<p>No Contributor makes additional grants as a result of Your choice to distribute the Covered
|
||||
Software under a subsequent version of this License (see Section 10.2) or under the terms
|
||||
of a Secondary License (if permitted under the terms of Section 3.3).</p>
|
||||
<h3 id="representation">2.5. Representation</h3>
|
||||
<p>Each Contributor represents that the Contributor believes its Contributions are its original
|
||||
creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by
|
||||
this License.</p>
|
||||
<h3 id="fair-use">2.6. Fair Use</h3>
|
||||
<p>This License is not intended to limit any rights You have under applicable copyright doctrines of
|
||||
fair use, fair dealing, or other equivalents.</p>
|
||||
<h3 id="conditions">2.7. Conditions</h3>
|
||||
<p>Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.</p>
|
||||
<h2 id="responsibilities">3. Responsibilities</h2>
|
||||
<h3 id="distribution-of-source-form">3.1. Distribution of Source Form</h3>
|
||||
<p>All distribution of Covered Software in Source Code Form, including any Modifications that You
|
||||
create or to which You contribute, must be under the terms of this License. You must inform
|
||||
recipients that the Source Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not attempt to alter or
|
||||
restrict the recipients’ rights in the Source Code Form.</p>
|
||||
<h3 id="distribution-of-executable-form">3.2. Distribution of Executable Form</h3>
|
||||
<p>If You distribute Covered Software in Executable Form then:</p>
|
||||
<ol type="a">
|
||||
<li><p>such Covered Software must also be made available in Source Code Form, as described in
|
||||
Section 3.1, and You must inform recipients of the Executable Form how they can obtain
|
||||
a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and</p></li>
|
||||
<li><p>You may distribute such Executable Form under the terms of this License, or sublicense it
|
||||
under different terms, provided that the license for the Executable Form does not attempt to
|
||||
limit or alter the recipients’ rights in the Source Code Form under this License.</p></li>
|
||||
</ol>
|
||||
<h3 id="distribution-of-a-larger-work">3.3. Distribution of a Larger Work</h3>
|
||||
<p>You may create and distribute a Larger Work under terms of Your choice, provided that You also
|
||||
comply with the requirements of this License for the Covered Software. If the Larger Work is a
|
||||
combination of Covered Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this License permits You to
|
||||
additionally distribute such Covered Software under the terms of such Secondary License(s), so
|
||||
that the recipient of the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary License(s).</p>
|
||||
<h3 id="notices">3.4. Notices</h3>
|
||||
<p>You may not remove or alter the substance of any license notices (including copyright notices,
|
||||
patent notices, disclaimers of warranty, or limitations of liability) contained within the
|
||||
Source Code Form of the Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.</p>
|
||||
<h3 id="application-of-additional-terms">3.5. Application of Additional Terms</h3>
|
||||
<p>You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability
|
||||
obligations to one or more recipients of Covered Software. However, You may do so only on Your
|
||||
own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by You alone, and You
|
||||
hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a
|
||||
result of warranty, support, indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any jurisdiction.</p>
|
||||
<h2 id="inability-to-comply-due-to-statute-or-regulation">4. Inability to Comply Due to Statute or
|
||||
Regulation</h2>
|
||||
<p>If it is impossible for You to comply with any of the terms of this License with respect to some
|
||||
or all of the Covered Software due to statute, judicial order, or regulation then You must: (a)
|
||||
comply with the terms of this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a text file included
|
||||
with all distributions of the Covered Software under this License. Except to the extent
|
||||
prohibited by statute or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.</p>
|
||||
<h2 id="termination">5. Termination</h2>
|
||||
<p>5.1. The rights granted under this License will terminate automatically if You fail to comply
|
||||
with any of its terms. However, if You become compliant, then the rights granted under this
|
||||
License from a particular Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such
|
||||
Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days
|
||||
after You have come back into compliance. Moreover, Your grants from a particular Contributor
|
||||
are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by
|
||||
some reasonable means, this is the first time You have received notice of non-compliance with
|
||||
this License from such Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.</p>
|
||||
<p>5.2. If You initiate litigation against any entity by asserting a patent infringement claim
|
||||
(excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a
|
||||
Contributor Version directly or indirectly infringes any patent, then the rights granted to You
|
||||
by any and all Contributors for the Covered Software under Section 2.1 of this License
|
||||
shall terminate.</p>
|
||||
<p>5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license
|
||||
agreements (excluding distributors and resellers) which have been validly granted by You or Your
|
||||
distributors under this License prior to termination shall survive termination.</p>
|
||||
<h2 id="disclaimer-of-warranty">6. Disclaimer of Warranty</h2>
|
||||
<p><em>Covered Software is provided under this License on an “as is” basis, without warranty of any
|
||||
kind, either expressed, implied, or statutory, including, without limitation, warranties that
|
||||
the Covered Software is free of defects, merchantable, fit for a particular purpose or
|
||||
non-infringing. The entire risk as to the quality and performance of the Covered Software is
|
||||
with You. Should any Covered Software prove defective in any respect, You (not any Contributor)
|
||||
assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty
|
||||
constitutes an essential part of this License. No use of any Covered Software is authorized
|
||||
under this License except under this disclaimer.</em></p>
|
||||
<h2 id="limitation-of-liability">7. Limitation of Liability</h2>
|
||||
<p><em>Under no circumstances and under no legal theory, whether tort (including negligence),
|
||||
contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as
|
||||
permitted above, be liable to You for any direct, indirect, special, incidental, or
|
||||
consequential damages of any character including, without limitation, damages for lost profits,
|
||||
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other
|
||||
commercial damages or losses, even if such party shall have been informed of the possibility of
|
||||
such damages. This limitation of liability shall not apply to liability for death or personal
|
||||
injury resulting from such party’s negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.</em></p>
|
||||
<h2 id="litigation">8. Litigation</h2>
|
||||
<p>Any litigation relating to this License may be brought only in the courts of a jurisdiction where
|
||||
the defendant maintains its principal place of business and such litigation shall be governed by
|
||||
laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this
|
||||
Section shall prevent a party’s ability to bring cross-claims or counter-claims.</p>
|
||||
<h2 id="miscellaneous">9. Miscellaneous</h2>
|
||||
<p>This License represents the complete agreement concerning the subject matter hereof. If any
|
||||
provision of this License is held to be unenforceable, such provision shall be reformed only to
|
||||
the extent necessary to make it enforceable. Any law or regulation which provides that the
|
||||
language of a contract shall be construed against the drafter shall not be used to construe this
|
||||
License against a Contributor.</p>
|
||||
<h2 id="versions-of-the-license">10. Versions of the License</h2>
|
||||
<h3 id="new-versions">10.1. New Versions</h3>
|
||||
<p>Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other
|
||||
than the license steward has the right to modify or publish new versions of this License. Each
|
||||
version will be given a distinguishing version number.</p>
|
||||
<h3 id="effect-of-new-versions">10.2. Effect of New Versions</h3>
|
||||
<p>You may distribute the Covered Software under the terms of the version of the License under which
|
||||
You originally received the Covered Software, or under the terms of any subsequent version
|
||||
published by the license steward.</p>
|
||||
<h3 id="modified-versions">10.3. Modified Versions</h3>
|
||||
<p>If you create software not governed by this License, and you want to create a new license for
|
||||
such software, you may create and use a modified version of this License if you rename the
|
||||
license and remove any references to the name of the license steward (except to note that such
|
||||
modified license differs from this License).</p>
|
||||
<h3 id="distributing-source-code-form-that-is-incompatible-with-secondary-licenses">10.4.
|
||||
Distributing Source Code Form that is Incompatible With Secondary Licenses</h3>
|
||||
<p>If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under
|
||||
the terms of this version of the License, the notice described in Exhibit B of this License must
|
||||
be attached.</p>
|
||||
<h2 id="exhibit-a---source-code-form-license-notice">Exhibit A - Source Code Form License
|
||||
Notice</h2>
|
||||
<blockquote>
|
||||
<p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a
|
||||
copy of the MPL was not distributed with this file, You can obtain one at
|
||||
https://mozilla.org/MPL/2.0/.</p>
|
||||
</blockquote>
|
||||
<p>If it is not possible or desirable to put the notice in a particular file, then You may include
|
||||
the notice in a location (such as a LICENSE file in a relevant directory) where a recipient
|
||||
would be likely to look for such a notice.</p>
|
||||
<p>You may add additional accurate notices of copyright ownership.</p>
|
||||
<h2 id="exhibit-b---incompatible-with-secondary-licenses-notice">Exhibit B - “Incompatible With
|
||||
Secondary Licenses” Notice</h2>
|
||||
<blockquote>
|
||||
<p>This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla
|
||||
Public License, v. 2.0.</p>
|
||||
</blockquote>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.schabi.newpipe.error.ErrorInfo
|
||||
import org.schabi.newpipe.navigation.NavDisplay
|
||||
import org.schabi.newpipe.navigation.Screen
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
|
||||
/**
|
||||
* Single host activity for all Compose-based screens.
|
||||
* Other parts of the app (including legacy View-based code) launch this activity
|
||||
* via Intent with extras specifying which screen to display.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class ComposeActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge(
|
||||
navigationBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
window.isNavigationBarContrastEnforced = false
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val startDestination: NavKey = resolveStartDestination(intent)
|
||||
|
||||
setContent {
|
||||
AppTheme {
|
||||
NavDisplay(startDestination)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveStartDestination(intent: Intent): NavKey {
|
||||
return when (intent.getStringExtra(EXTRA_SCREEN)) {
|
||||
SCREEN_ABOUT -> Screen.About
|
||||
|
||||
SCREEN_ERROR -> Screen.Error
|
||||
|
||||
SCREEN_SETTINGS -> Screen.Settings.Home
|
||||
|
||||
else -> throw IllegalArgumentException(
|
||||
"Unknown screen: ${intent.getStringExtra(EXTRA_SCREEN)}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val SCREEN_ABOUT = "about"
|
||||
|
||||
const val EXTRA_SCREEN = "extra_screen"
|
||||
const val EXTRA_ERROR_INFO = "extra_error_info"
|
||||
|
||||
const val SCREEN_ERROR = "error"
|
||||
const val SCREEN_SETTINGS = "settings"
|
||||
|
||||
fun aboutIntent(context: Context): Intent {
|
||||
return Intent(context, ComposeActivity::class.java).apply {
|
||||
putExtra(EXTRA_SCREEN, SCREEN_ABOUT)
|
||||
}
|
||||
}
|
||||
|
||||
fun errorIntent(context: Context, errorInfo: ErrorInfo): Intent {
|
||||
return Intent(context, ComposeActivity::class.java).apply {
|
||||
putExtra(EXTRA_SCREEN, SCREEN_ERROR)
|
||||
putExtra(EXTRA_ERROR_INFO, errorInfo)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
}
|
||||
|
||||
fun settingsIntent(context: Context): Intent {
|
||||
return Intent(context, ComposeActivity::class.java).apply {
|
||||
putExtra(EXTRA_SCREEN, SCREEN_SETTINGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
|
||||
/*
|
||||
* Copyright (C) Hans-Christoph Steiner 2016 <hans@eds.org>
|
||||
* ExitActivity.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public class ExitActivity extends Activity {
|
||||
|
||||
public static void exitAndRemoveFromRecentApps(final Activity activity) {
|
||||
final Intent intent = new Intent(activity, ExitActivity.class);
|
||||
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
finishAndRemoveTask();
|
||||
|
||||
NavigationHelper.restartApp(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import org.schabi.newpipe.util.NavigationHelper
|
||||
|
||||
class ExitActivity : Activity() {
|
||||
@SuppressLint("NewApi")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
finishAndRemoveTask()
|
||||
NavigationHelper.restartApp(this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun exitAndRemoveFromRecentApps(activity: Activity) {
|
||||
val intent = Intent(activity, ExitActivity::class.java)
|
||||
intent.addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
or Intent.FLAG_ACTIVITY_NO_ANIMATION
|
||||
)
|
||||
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,14 @@
|
||||
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -92,6 +94,8 @@ import org.schabi.newpipe.util.ThemeHelper;
|
||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
||||
import org.schabi.newpipe.views.FocusOverlayView;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -192,6 +196,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
|
||||
}
|
||||
|
||||
// ReleaseVersionUtil.INSTANCE.isReleaseApk() will be true only for main official build
|
||||
// We want every release build (nightly, nightly-refactor) to show the popup
|
||||
if (!DEBUG) {
|
||||
showKeepAndroidDialog();
|
||||
showApi23RequirementDialog();
|
||||
}
|
||||
|
||||
MigrationManager.showUserInfoIfPresent(this);
|
||||
}
|
||||
|
||||
@@ -305,25 +316,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private boolean drawerItemSelected(final MenuItem item) {
|
||||
switch (item.getGroupId()) {
|
||||
case R.id.menu_services_group:
|
||||
changeService(item);
|
||||
break;
|
||||
case R.id.menu_tabs_group:
|
||||
tabSelected(item);
|
||||
break;
|
||||
case R.id.menu_kiosks_group:
|
||||
try {
|
||||
kioskSelected(item);
|
||||
} catch (final Exception e) {
|
||||
ErrorUtil.showUiErrorSnackbar(this, "Selecting drawer kiosk", e);
|
||||
}
|
||||
break;
|
||||
case R.id.menu_options_about_group:
|
||||
optionsAboutSelected(item);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
final int groupId = item.getGroupId();
|
||||
if (groupId == R.id.menu_services_group) {
|
||||
changeService(item);
|
||||
} else if (groupId == R.id.menu_tabs_group) {
|
||||
tabSelected(item);
|
||||
} else if (groupId == R.id.menu_kiosks_group) {
|
||||
try {
|
||||
kioskSelected(item);
|
||||
} catch (final Exception e) {
|
||||
ErrorUtil.showUiErrorSnackbar(this, "Selecting drawer kiosk", e);
|
||||
}
|
||||
} else if (groupId == R.id.menu_options_about_group) {
|
||||
optionsAboutSelected(item);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
mainBinding.getRoot().closeDrawers();
|
||||
@@ -893,4 +900,78 @@ public class MainActivity extends AppCompatActivity {
|
||||
|| sheetState == BottomSheetBehavior.STATE_COLLAPSED;
|
||||
}
|
||||
|
||||
private void showKeepAndroidDialog() {
|
||||
final var prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final var lastCheckKey = getString(R.string.kao_last_checked_key);
|
||||
final var lastCheck = Instant.ofEpochMilli(prefs.getLong(lastCheckKey, 0));
|
||||
final var now = Instant.now();
|
||||
|
||||
if (lastCheck.plus(30, ChronoUnit.DAYS).isBefore(now)) {
|
||||
final String detailsUrl = getKeepAndroidOpenDetailsUrl();
|
||||
final var solutionUrl = "https://github.com/woheller69/FreeDroidWarn#solutions";
|
||||
|
||||
final var dialog = new AlertDialog.Builder(this)
|
||||
.setTitle("Keep Android Open")
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.kao_dialog_warning)
|
||||
.setPositiveButton(android.R.string.ok, (d, w) -> prefs.edit()
|
||||
.putLong(lastCheckKey, now.toEpochMilli())
|
||||
.apply())
|
||||
.setNeutralButton(R.string.kao_solution, null)
|
||||
.setNegativeButton(R.string.kao_dialog_more_info, null)
|
||||
.show();
|
||||
|
||||
// If we use setNeutralButton/setNegativeButton, dialog will close after pressing the
|
||||
// buttons, but we want it to close only when positive button is pressed
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||
.setOnClickListener(v -> ShareUtils.openUrlInBrowser(this, detailsUrl));
|
||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
||||
.setOnClickListener(v -> ShareUtils.openUrlInBrowser(this, solutionUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static String getKeepAndroidOpenDetailsUrl() {
|
||||
final var supportedLanguages = List.of("fr", "de", "ca", "es", "id", "it", "pl",
|
||||
"pt", "cs", "sk", "fa", "ar", "tr", "el", "th", "ru", "uk", "ko", "zh", "ja");
|
||||
final String kaoBaseUrl = "https://keepandroidopen.org/";
|
||||
final var locale = Localization.getAppLocale();
|
||||
if (supportedLanguages.contains(locale.getLanguage())) {
|
||||
if ("zh".equals(locale.getLanguage())) {
|
||||
return kaoBaseUrl + ("TW".equals(locale.getCountry()) ? "zh-TW" : "zh-CN");
|
||||
} else {
|
||||
return kaoBaseUrl + locale.getLanguage();
|
||||
}
|
||||
} else {
|
||||
return kaoBaseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private void showApi23RequirementDialog() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
return; // only show dialog on the devices that will stop being supported
|
||||
}
|
||||
|
||||
final var prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final var shownKey = getString(R.string.api23_requirement_dialog_shown_key);
|
||||
if (prefs.getBoolean(shownKey, false)) {
|
||||
return; // dialog was already shown in the past, no need to show it again
|
||||
}
|
||||
|
||||
final var dialog = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.api23_requirement_dialog_title)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.api23_requirement_dialog_message)
|
||||
.setPositiveButton(android.R.string.ok, (d, w) -> prefs.edit()
|
||||
.putBoolean(shownKey, true)
|
||||
.apply())
|
||||
.setNegativeButton(R.string.api23_requirement_dialog_blogpost, null)
|
||||
.show();
|
||||
|
||||
// If we use setNegativeButton, dialog will close after pressing the button,
|
||||
// but we want it to close only when positive button is pressed
|
||||
final var blogpostUrl = "https://newpipe.net/blog/pinned/announcement/drop-android-5/";
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||
.setOnClickListener(v -> ShareUtils.openUrlInBrowser(this, blogpostUrl));
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,9 @@ class NewVersionWorker(
|
||||
)
|
||||
|
||||
val notificationManager = NotificationManagerCompat.from(applicationContext)
|
||||
notificationManager.notify(2000, notificationBuilder.build())
|
||||
if (notificationManager.areNotificationsEnabled()) {
|
||||
notificationManager.notify(2000, notificationBuilder.build())
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(IOException::class, ReCaptchaException::class)
|
||||
|
||||
@@ -41,50 +41,50 @@ public final class QueueItemMenuUtil {
|
||||
}
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_item_remove:
|
||||
final int index = playQueue.indexOf(item);
|
||||
playQueue.remove(index);
|
||||
return true;
|
||||
case R.id.menu_item_details:
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(context, item.getServiceId(),
|
||||
item.getUrl(), item.getTitle(), null,
|
||||
false);
|
||||
return true;
|
||||
case R.id.menu_item_append_playlist:
|
||||
PlaylistDialog.createCorrespondingDialog(
|
||||
context,
|
||||
List.of(new StreamEntity(item)),
|
||||
dialog -> dialog.show(
|
||||
fragmentManager,
|
||||
"QueueItemMenuUtil@append_playlist"
|
||||
)
|
||||
);
|
||||
final int itemId = menuItem.getItemId();
|
||||
if (itemId == R.id.menu_item_remove) {
|
||||
final int index = playQueue.indexOf(item);
|
||||
playQueue.remove(index);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_item_details) {
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(context, item.getServiceId(),
|
||||
item.getUrl(), item.getTitle(), null,
|
||||
false);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_item_append_playlist) {
|
||||
PlaylistDialog.createCorrespondingDialog(
|
||||
context,
|
||||
List.of(new StreamEntity(item)),
|
||||
dialog -> dialog.show(
|
||||
fragmentManager,
|
||||
"QueueItemMenuUtil@append_playlist"
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
case R.id.menu_item_channel_details:
|
||||
SparseItemUtil.fetchUploaderUrlIfSparse(context, item.getServiceId(),
|
||||
item.getUrl(), item.getUploaderUrl(),
|
||||
// An intent must be used here.
|
||||
// Opening with FragmentManager transactions is not working,
|
||||
// as PlayQueueActivity doesn't use fragments.
|
||||
uploaderUrl -> NavigationHelper.openChannelFragmentUsingIntent(
|
||||
context, item.getServiceId(), uploaderUrl, item.getUploader()
|
||||
));
|
||||
return true;
|
||||
case R.id.menu_item_share:
|
||||
shareText(context, item.getTitle(), item.getUrl(),
|
||||
item.getThumbnails());
|
||||
return true;
|
||||
case R.id.menu_item_download:
|
||||
fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), item.getUrl(),
|
||||
info -> {
|
||||
final DownloadDialog downloadDialog = new DownloadDialog(context,
|
||||
info);
|
||||
downloadDialog.show(fragmentManager, "downloadDialog");
|
||||
});
|
||||
return true;
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_item_channel_details) {
|
||||
SparseItemUtil.fetchUploaderUrlIfSparse(context, item.getServiceId(),
|
||||
item.getUrl(), item.getUploaderUrl(),
|
||||
// An intent must be used here.
|
||||
// Opening with FragmentManager transactions is not working,
|
||||
// as PlayQueueActivity doesn't use fragments.
|
||||
uploaderUrl -> NavigationHelper.openChannelFragmentUsingIntent(
|
||||
context, item.getServiceId(), uploaderUrl, item.getUploader()
|
||||
));
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_item_share) {
|
||||
shareText(context, item.getTitle(), item.getUrl(),
|
||||
item.getThumbnails());
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_item_download) {
|
||||
fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), item.getUrl(),
|
||||
info -> {
|
||||
final DownloadDialog downloadDialog = new DownloadDialog(context,
|
||||
info);
|
||||
downloadDialog.show(fragmentManager, "downloadDialog");
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -343,8 +343,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<StreamingService.ServiceInfo.MediaCapability> capabilities =
|
||||
currentService.getServiceInfo().getMediaCapabilities();
|
||||
final var capabilities = currentService.getServiceInfo().getMediaCapabilities();
|
||||
|
||||
// Check if the service supports the choice
|
||||
if ((isVideoPlayerSelected && capabilities.contains(VIDEO))
|
||||
@@ -522,8 +521,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
final List<AdapterChoiceItem> returnedItems = new ArrayList<>();
|
||||
returnedItems.add(showInfo); // Always present
|
||||
|
||||
final List<StreamingService.ServiceInfo.MediaCapability> capabilities =
|
||||
service.getServiceInfo().getMediaCapabilities();
|
||||
final var capabilities = service.getServiceInfo().getMediaCapabilities();
|
||||
|
||||
if (linkType == LinkType.STREAM || linkType == LinkType.PLAYLIST) {
|
||||
if (capabilities.contains(VIDEO)) {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.schabi.newpipe.about
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.ui.components.common.ScaffoldWithToolbar
|
||||
import org.schabi.newpipe.ui.screens.AboutScreen
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
AppTheme {
|
||||
ScaffoldWithToolbar(
|
||||
title = stringResource(R.string.title_activity_about),
|
||||
onBackClick = { onBackPressedDispatcher.onBackPressed() }
|
||||
) { padding ->
|
||||
AboutScreen(padding)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -62,11 +62,7 @@ data class PlaylistRemoteEntity(
|
||||
orderingName = playlistInfo.name,
|
||||
url = playlistInfo.url,
|
||||
thumbnailUrl = ImageStrategy.imageListToDbUrl(
|
||||
if (playlistInfo.thumbnails.isEmpty()) {
|
||||
playlistInfo.uploaderAvatars
|
||||
} else {
|
||||
playlistInfo.thumbnails
|
||||
}
|
||||
playlistInfo.thumbnails.ifEmpty { playlistInfo.uploaderAvatars }
|
||||
),
|
||||
uploader = playlistInfo.uploaderName,
|
||||
streamCount = playlistInfo.streamCount
|
||||
|
||||
@@ -85,7 +85,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
|
||||
|
||||
private fun compareAndUpdateStream(newerStream: StreamEntity) {
|
||||
val existentMinimalStream = getMinimalStreamForCompare(newerStream.serviceId, newerStream.url)
|
||||
?: throw IllegalStateException("Stream cannot be null just after insertion.")
|
||||
?: error("Stream cannot be null just after insertion.")
|
||||
newerStream.uid = existentMinimalStream.uid
|
||||
|
||||
if (!StreamTypeUtil.isLiveStream(newerStream.streamType)) {
|
||||
|
||||
@@ -100,7 +100,7 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {
|
||||
entity.uid = uidFromInsert
|
||||
} else {
|
||||
val subscriptionIdFromDb = getSubscriptionIdInternal(entity.serviceId, entity.url!!)
|
||||
?: throw IllegalStateException("Subscription cannot be null just after insertion.")
|
||||
?: error("Subscription cannot be null just after insertion.")
|
||||
entity.uid = subscriptionIdFromDb
|
||||
|
||||
update(entity)
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.os.IBinder;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
@@ -31,7 +32,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.menu.ActionMenuItemView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.collection.SparseArrayCompat;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
@@ -113,7 +113,7 @@ public class DownloadDialog extends DialogFragment
|
||||
private StoredDirectoryHelper mainStorageAudio = null;
|
||||
private StoredDirectoryHelper mainStorageVideo = null;
|
||||
private DownloadManager downloadManager = null;
|
||||
private ActionMenuItemView okButton = null;
|
||||
private MenuItem okButton = null;
|
||||
private Context context = null;
|
||||
private boolean askForSavePath;
|
||||
|
||||
@@ -344,7 +344,7 @@ public class DownloadDialog extends DialogFragment
|
||||
toolbar.setNavigationOnClickListener(v -> dismiss());
|
||||
toolbar.setNavigationContentDescription(R.string.cancel);
|
||||
|
||||
okButton = toolbar.findViewById(R.id.okay);
|
||||
okButton = toolbar.getMenu().findItem(R.id.okay);
|
||||
okButton.setEnabled(false); // disable until the download service connection is done
|
||||
|
||||
toolbar.setOnMenuItemClickListener(item -> {
|
||||
@@ -558,17 +558,13 @@ public class DownloadDialog extends DialogFragment
|
||||
}
|
||||
boolean flag = true;
|
||||
|
||||
switch (checkedId) {
|
||||
case R.id.audio_button:
|
||||
setupAudioSpinner();
|
||||
break;
|
||||
case R.id.video_button:
|
||||
setupVideoSpinner();
|
||||
break;
|
||||
case R.id.subtitle_button:
|
||||
setupSubtitleSpinner();
|
||||
flag = false;
|
||||
break;
|
||||
if (checkedId == R.id.audio_button) {
|
||||
setupAudioSpinner();
|
||||
} else if (checkedId == R.id.video_button) {
|
||||
setupVideoSpinner();
|
||||
} else if (checkedId == R.id.subtitle_button) {
|
||||
setupSubtitleSpinner();
|
||||
flag = false;
|
||||
}
|
||||
|
||||
dialogBinding.threads.setEnabled(flag);
|
||||
@@ -585,29 +581,26 @@ public class DownloadDialog extends DialogFragment
|
||||
+ "position = [" + position + "], id = [" + id + "]");
|
||||
}
|
||||
|
||||
switch (parent.getId()) {
|
||||
case R.id.quality_spinner:
|
||||
switch (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()) {
|
||||
case R.id.video_button:
|
||||
selectedVideoIndex = position;
|
||||
onVideoStreamSelected();
|
||||
break;
|
||||
case R.id.subtitle_button:
|
||||
selectedSubtitleIndex = position;
|
||||
break;
|
||||
}
|
||||
onItemSelectedSetFileName();
|
||||
break;
|
||||
case R.id.audio_track_spinner:
|
||||
final boolean trackChanged = selectedAudioTrackIndex != position;
|
||||
selectedAudioTrackIndex = position;
|
||||
if (trackChanged) {
|
||||
updateSecondaryStreams();
|
||||
fetchStreamsSize();
|
||||
}
|
||||
break;
|
||||
case R.id.audio_stream_spinner:
|
||||
selectedAudioIndex = position;
|
||||
final int parentId = parent.getId();
|
||||
if (parentId == R.id.quality_spinner) {
|
||||
final int checkedRadioButtonId = dialogBinding.videoAudioGroup
|
||||
.getCheckedRadioButtonId();
|
||||
if (checkedRadioButtonId == R.id.video_button) {
|
||||
selectedVideoIndex = position;
|
||||
onVideoStreamSelected();
|
||||
} else if (checkedRadioButtonId == R.id.subtitle_button) {
|
||||
selectedSubtitleIndex = position;
|
||||
}
|
||||
onItemSelectedSetFileName();
|
||||
} else if (parentId == R.id.audio_track_spinner) {
|
||||
final boolean trackChanged = selectedAudioTrackIndex != position;
|
||||
selectedAudioTrackIndex = position;
|
||||
if (trackChanged) {
|
||||
updateSecondaryStreams();
|
||||
fetchStreamsSize();
|
||||
}
|
||||
} else if (parentId == R.id.audio_stream_spinner) {
|
||||
selectedAudioIndex = position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,23 +615,20 @@ public class DownloadDialog extends DialogFragment
|
||||
|| prevFileName.startsWith(getString(R.string.caption_file_name, fileName, ""))) {
|
||||
// only update the file name field if it was not edited by the user
|
||||
|
||||
switch (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()) {
|
||||
case R.id.audio_button:
|
||||
case R.id.video_button:
|
||||
if (!prevFileName.equals(fileName)) {
|
||||
// since the user might have switched between audio and video, the correct
|
||||
// text might already be in place, so avoid resetting the cursor position
|
||||
dialogBinding.fileName.setText(fileName);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.subtitle_button:
|
||||
final String setSubtitleLanguageCode = subtitleStreamsAdapter
|
||||
.getItem(selectedSubtitleIndex).getLanguageTag();
|
||||
// this will reset the cursor position, which is bad UX, but it can't be avoided
|
||||
dialogBinding.fileName.setText(getString(
|
||||
R.string.caption_file_name, fileName, setSubtitleLanguageCode));
|
||||
break;
|
||||
final int radioButtonId = dialogBinding.videoAudioGroup
|
||||
.getCheckedRadioButtonId();
|
||||
if (radioButtonId == R.id.audio_button || radioButtonId == R.id.video_button) {
|
||||
if (!prevFileName.equals(fileName)) {
|
||||
// since the user might have switched between audio and video, the correct
|
||||
// text might already be in place, so avoid resetting the cursor position
|
||||
dialogBinding.fileName.setText(fileName);
|
||||
}
|
||||
} else if (radioButtonId == R.id.subtitle_button) {
|
||||
final String setSubtitleLanguageCode = subtitleStreamsAdapter
|
||||
.getItem(selectedSubtitleIndex).getLanguageTag();
|
||||
// this will reset the cursor position, which is bad UX, but it can't be avoided
|
||||
dialogBinding.fileName.setText(getString(
|
||||
R.string.caption_file_name, fileName, setSubtitleLanguageCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -770,47 +760,44 @@ public class DownloadDialog extends DialogFragment
|
||||
|
||||
filenameTmp = getNameEditText().concat(".");
|
||||
|
||||
switch (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()) {
|
||||
case R.id.audio_button:
|
||||
selectedMediaType = getString(R.string.last_download_type_audio_key);
|
||||
mainStorage = mainStorageAudio;
|
||||
format = audioStreamsAdapter.getItem(selectedAudioIndex).getFormat();
|
||||
size = getWrappedAudioStreams().getSizeInBytes(selectedAudioIndex);
|
||||
if (format == MediaFormat.WEBMA_OPUS) {
|
||||
mimeTmp = "audio/ogg";
|
||||
filenameTmp += "opus";
|
||||
} else if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
break;
|
||||
case R.id.video_button:
|
||||
selectedMediaType = getString(R.string.last_download_type_video_key);
|
||||
mainStorage = mainStorageVideo;
|
||||
format = videoStreamsAdapter.getItem(selectedVideoIndex).getFormat();
|
||||
size = wrappedVideoStreams.getSizeInBytes(selectedVideoIndex);
|
||||
if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
break;
|
||||
case R.id.subtitle_button:
|
||||
selectedMediaType = getString(R.string.last_download_type_subtitle_key);
|
||||
mainStorage = mainStorageVideo; // subtitle & video files go together
|
||||
format = subtitleStreamsAdapter.getItem(selectedSubtitleIndex).getFormat();
|
||||
size = wrappedSubtitleStreams.getSizeInBytes(selectedSubtitleIndex);
|
||||
if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
}
|
||||
final int checkedRadioButtonId = dialogBinding.videoAudioGroup.getCheckedRadioButtonId();
|
||||
if (checkedRadioButtonId == R.id.audio_button) {
|
||||
selectedMediaType = getString(R.string.last_download_type_audio_key);
|
||||
mainStorage = mainStorageAudio;
|
||||
format = audioStreamsAdapter.getItem(selectedAudioIndex).getFormat();
|
||||
size = getWrappedAudioStreams().getSizeInBytes(selectedAudioIndex);
|
||||
if (format == MediaFormat.WEBMA_OPUS) {
|
||||
mimeTmp = "audio/ogg";
|
||||
filenameTmp += "opus";
|
||||
} else if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
} else if (checkedRadioButtonId == R.id.video_button) {
|
||||
selectedMediaType = getString(R.string.last_download_type_video_key);
|
||||
mainStorage = mainStorageVideo;
|
||||
format = videoStreamsAdapter.getItem(selectedVideoIndex).getFormat();
|
||||
size = wrappedVideoStreams.getSizeInBytes(selectedVideoIndex);
|
||||
if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
} else if (checkedRadioButtonId == R.id.subtitle_button) {
|
||||
selectedMediaType = getString(R.string.last_download_type_subtitle_key);
|
||||
mainStorage = mainStorageVideo; // subtitle & video files go together
|
||||
format = subtitleStreamsAdapter.getItem(selectedSubtitleIndex).getFormat();
|
||||
size = wrappedSubtitleStreams.getSizeInBytes(selectedSubtitleIndex);
|
||||
if (format != null) {
|
||||
mimeTmp = format.mimeType;
|
||||
}
|
||||
|
||||
if (format == MediaFormat.TTML) {
|
||||
filenameTmp += MediaFormat.SRT.getSuffix();
|
||||
} else if (format != null) {
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("No stream selected");
|
||||
if (format == MediaFormat.TTML) {
|
||||
filenameTmp += MediaFormat.SRT.getSuffix();
|
||||
} else if (format != null) {
|
||||
filenameTmp += format.getSuffix();
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("No stream selected");
|
||||
}
|
||||
|
||||
if (!askForSavePath && (mainStorage == null
|
||||
@@ -1057,59 +1044,56 @@ public class DownloadDialog extends DialogFragment
|
||||
long nearLength = 0;
|
||||
|
||||
// more download logic: select muxer, subtitle converter, etc.
|
||||
switch (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()) {
|
||||
case R.id.audio_button:
|
||||
kind = 'a';
|
||||
selectedStream = audioStreamsAdapter.getItem(selectedAudioIndex);
|
||||
final int checkedRadioButtonId = dialogBinding.videoAudioGroup.getCheckedRadioButtonId();
|
||||
if (checkedRadioButtonId == R.id.audio_button) {
|
||||
kind = 'a';
|
||||
selectedStream = audioStreamsAdapter.getItem(selectedAudioIndex);
|
||||
|
||||
if (selectedStream.getFormat() == MediaFormat.M4A) {
|
||||
psName = Postprocessing.ALGORITHM_M4A_NO_DASH;
|
||||
} else if (selectedStream.getFormat() == MediaFormat.WEBMA_OPUS) {
|
||||
psName = Postprocessing.ALGORITHM_OGG_FROM_WEBM_DEMUXER;
|
||||
if (selectedStream.getFormat() == MediaFormat.M4A) {
|
||||
psName = Postprocessing.ALGORITHM_M4A_NO_DASH;
|
||||
} else if (selectedStream.getFormat() == MediaFormat.WEBMA_OPUS) {
|
||||
psName = Postprocessing.ALGORITHM_OGG_FROM_WEBM_DEMUXER;
|
||||
}
|
||||
} else if (checkedRadioButtonId == R.id.video_button) {
|
||||
kind = 'v';
|
||||
selectedStream = videoStreamsAdapter.getItem(selectedVideoIndex);
|
||||
|
||||
final SecondaryStreamHelper<AudioStream> secondary = videoStreamsAdapter
|
||||
.getAllSecondary()
|
||||
.get(wrappedVideoStreams.getStreamsList().indexOf(selectedStream));
|
||||
|
||||
if (secondary != null) {
|
||||
secondaryStream = secondary.getStream();
|
||||
|
||||
if (selectedStream.getFormat() == MediaFormat.MPEG_4) {
|
||||
psName = Postprocessing.ALGORITHM_MP4_FROM_DASH_MUXER;
|
||||
} else {
|
||||
psName = Postprocessing.ALGORITHM_WEBM_MUXER;
|
||||
}
|
||||
break;
|
||||
case R.id.video_button:
|
||||
kind = 'v';
|
||||
selectedStream = videoStreamsAdapter.getItem(selectedVideoIndex);
|
||||
|
||||
final SecondaryStreamHelper<AudioStream> secondary = videoStreamsAdapter
|
||||
.getAllSecondary()
|
||||
.get(wrappedVideoStreams.getStreamsList().indexOf(selectedStream));
|
||||
final long videoSize = wrappedVideoStreams.getSizeInBytes(
|
||||
(VideoStream) selectedStream);
|
||||
|
||||
if (secondary != null) {
|
||||
secondaryStream = secondary.getStream();
|
||||
|
||||
if (selectedStream.getFormat() == MediaFormat.MPEG_4) {
|
||||
psName = Postprocessing.ALGORITHM_MP4_FROM_DASH_MUXER;
|
||||
} else {
|
||||
psName = Postprocessing.ALGORITHM_WEBM_MUXER;
|
||||
}
|
||||
|
||||
final long videoSize = wrappedVideoStreams.getSizeInBytes(
|
||||
(VideoStream) selectedStream);
|
||||
|
||||
// set nearLength, only, if both sizes are fetched or known. This probably
|
||||
// does not work on slow networks but is later updated in the downloader
|
||||
if (secondary.getSizeInBytes() > 0 && videoSize > 0) {
|
||||
nearLength = secondary.getSizeInBytes() + videoSize;
|
||||
}
|
||||
// set nearLength, only, if both sizes are fetched or known. This probably
|
||||
// does not work on slow networks but is later updated in the downloader
|
||||
if (secondary.getSizeInBytes() > 0 && videoSize > 0) {
|
||||
nearLength = secondary.getSizeInBytes() + videoSize;
|
||||
}
|
||||
break;
|
||||
case R.id.subtitle_button:
|
||||
threads = 1; // use unique thread for subtitles due small file size
|
||||
kind = 's';
|
||||
selectedStream = subtitleStreamsAdapter.getItem(selectedSubtitleIndex);
|
||||
}
|
||||
} else if (checkedRadioButtonId == R.id.subtitle_button) {
|
||||
threads = 1; // use unique thread for subtitles due small file size
|
||||
kind = 's';
|
||||
selectedStream = subtitleStreamsAdapter.getItem(selectedSubtitleIndex);
|
||||
|
||||
if (selectedStream.getFormat() == MediaFormat.TTML) {
|
||||
psName = Postprocessing.ALGORITHM_TTML_CONVERTER;
|
||||
psArgs = new String[] {
|
||||
selectedStream.getFormat().getSuffix(),
|
||||
"false" // ignore empty frames
|
||||
};
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
if (selectedStream.getFormat() == MediaFormat.TTML) {
|
||||
psName = Postprocessing.ALGORITHM_TTML_CONVERTER;
|
||||
psArgs = new String[]{
|
||||
selectedStream.getFormat().getSuffix(),
|
||||
"false" // ignore empty frames
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (secondaryStream == null) {
|
||||
|
||||
@@ -1,323 +0,0 @@
|
||||
package org.schabi.newpipe.error;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.IntentCompat;
|
||||
|
||||
import com.grack.nanojson.JsonWriter;
|
||||
|
||||
import org.schabi.newpipe.BuildConfig;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.databinding.ActivityErrorBinding;
|
||||
import org.schabi.newpipe.util.Localization;
|
||||
import org.schabi.newpipe.util.ThemeHelper;
|
||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 24.10.15.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* ErrorActivity.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This activity is used to show error details and allow reporting them in various ways. Use {@link
|
||||
* ErrorUtil#openActivity(Context, ErrorInfo)} to correctly open this activity.
|
||||
*/
|
||||
public class ErrorActivity extends AppCompatActivity {
|
||||
// LOG TAGS
|
||||
public static final String TAG = ErrorActivity.class.toString();
|
||||
// BUNDLE TAGS
|
||||
public static final String ERROR_INFO = "error_info";
|
||||
|
||||
public static final String ERROR_EMAIL_ADDRESS = "crashreport@newpipe.schabi.org";
|
||||
public static final String ERROR_EMAIL_SUBJECT = "Exception in ";
|
||||
|
||||
public static final String ERROR_GITHUB_ISSUE_URL =
|
||||
"https://github.com/TeamNewPipe/NewPipe/issues";
|
||||
|
||||
private ErrorInfo errorInfo;
|
||||
private String currentTimeStamp;
|
||||
|
||||
private ActivityErrorBinding activityErrorBinding;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Activity lifecycle
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ThemeHelper.setDayNightMode(this);
|
||||
ThemeHelper.setTheme(this);
|
||||
|
||||
activityErrorBinding = ActivityErrorBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityErrorBinding.getRoot());
|
||||
|
||||
final Intent intent = getIntent();
|
||||
|
||||
setSupportActionBar(activityErrorBinding.toolbarLayout.toolbar);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setTitle(R.string.error_report_title);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
}
|
||||
|
||||
errorInfo = IntentCompat.getParcelableExtra(intent, ERROR_INFO, ErrorInfo.class);
|
||||
|
||||
// important add guru meditation
|
||||
addGuruMeditation();
|
||||
// print current time, as zoned ISO8601 timestamp
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
currentTimeStamp = now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
activityErrorBinding.errorReportEmailButton.setOnClickListener(v ->
|
||||
openPrivacyPolicyDialog(this, "EMAIL"));
|
||||
|
||||
activityErrorBinding.errorReportCopyButton.setOnClickListener(v ->
|
||||
ShareUtils.copyToClipboard(this, buildMarkdown()));
|
||||
|
||||
activityErrorBinding.errorReportGitHubButton.setOnClickListener(v ->
|
||||
openPrivacyPolicyDialog(this, "GITHUB"));
|
||||
|
||||
// normal bugreport
|
||||
buildInfo(errorInfo);
|
||||
activityErrorBinding.errorMessageView.setText(errorInfo.getMessage(this));
|
||||
activityErrorBinding.errorView.setText(formErrorText(errorInfo.getStackTraces()));
|
||||
|
||||
// print stack trace once again for debugging:
|
||||
for (final String e : errorInfo.getStackTraces()) {
|
||||
Log.e(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.error_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
case R.id.menu_item_share_error:
|
||||
ShareUtils.shareText(getApplicationContext(),
|
||||
getString(R.string.error_report_title), buildJson());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void openPrivacyPolicyDialog(final Context context, final String action) {
|
||||
new AlertDialog.Builder(context)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(R.string.privacy_policy_title)
|
||||
.setMessage(R.string.start_accept_privacy_policy)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.read_privacy_policy, (dialog, which) ->
|
||||
ShareUtils.openUrlInApp(context,
|
||||
context.getString(R.string.privacy_policy_url)))
|
||||
.setPositiveButton(R.string.accept, (dialog, which) -> {
|
||||
if (action.equals("EMAIL")) { // send on email
|
||||
final Intent i = new Intent(Intent.ACTION_SENDTO)
|
||||
.setData(Uri.parse("mailto:")) // only email apps should handle this
|
||||
.putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS})
|
||||
.putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT
|
||||
+ getString(R.string.app_name) + " "
|
||||
+ BuildConfig.VERSION_NAME)
|
||||
.putExtra(Intent.EXTRA_TEXT, buildJson());
|
||||
ShareUtils.openIntentInApp(context, i);
|
||||
} else if (action.equals("GITHUB")) { // open the NewPipe issue page on GitHub
|
||||
ShareUtils.openUrlInApp(this, ERROR_GITHUB_ISSUE_URL);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.decline, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private String formErrorText(final String[] el) {
|
||||
final String separator = "-------------------------------------";
|
||||
return Arrays.stream(el)
|
||||
.collect(Collectors.joining(separator + "\n", separator + "\n", separator));
|
||||
}
|
||||
|
||||
private void buildInfo(final ErrorInfo info) {
|
||||
String text = "";
|
||||
|
||||
activityErrorBinding.errorInfoLabelsView.setText(getString(R.string.info_labels)
|
||||
.replace("\\n", "\n"));
|
||||
|
||||
text += getUserActionString(info.getUserAction()) + "\n"
|
||||
+ info.getRequest() + "\n"
|
||||
+ getContentLanguageString() + "\n"
|
||||
+ getContentCountryString() + "\n"
|
||||
+ getAppLanguage() + "\n"
|
||||
+ info.getServiceName() + "\n"
|
||||
+ currentTimeStamp + "\n"
|
||||
+ getPackageName() + "\n"
|
||||
+ BuildConfig.VERSION_NAME + "\n"
|
||||
+ getOsString();
|
||||
|
||||
activityErrorBinding.errorInfosView.setText(text);
|
||||
}
|
||||
|
||||
private String buildJson() {
|
||||
try {
|
||||
return JsonWriter.string()
|
||||
.object()
|
||||
.value("user_action", getUserActionString(errorInfo.getUserAction()))
|
||||
.value("request", errorInfo.getRequest())
|
||||
.value("content_language", getContentLanguageString())
|
||||
.value("content_country", getContentCountryString())
|
||||
.value("app_language", getAppLanguage())
|
||||
.value("service", errorInfo.getServiceName())
|
||||
.value("package", getPackageName())
|
||||
.value("version", BuildConfig.VERSION_NAME)
|
||||
.value("os", getOsString())
|
||||
.value("time", currentTimeStamp)
|
||||
.array("exceptions", Arrays.asList(errorInfo.getStackTraces()))
|
||||
.value("user_comment", activityErrorBinding.errorCommentBox.getText()
|
||||
.toString())
|
||||
.end()
|
||||
.done();
|
||||
} catch (final Throwable e) {
|
||||
Log.e(TAG, "Error while erroring: Could not build json");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private String buildMarkdown() {
|
||||
try {
|
||||
final StringBuilder htmlErrorReport = new StringBuilder();
|
||||
|
||||
final String userComment = activityErrorBinding.errorCommentBox.getText().toString();
|
||||
if (!userComment.isEmpty()) {
|
||||
htmlErrorReport.append(userComment).append("\n");
|
||||
}
|
||||
|
||||
// basic error info
|
||||
htmlErrorReport
|
||||
.append("## Exception")
|
||||
.append("\n* __User Action:__ ")
|
||||
.append(getUserActionString(errorInfo.getUserAction()))
|
||||
.append("\n* __Request:__ ").append(errorInfo.getRequest())
|
||||
.append("\n* __Content Country:__ ").append(getContentCountryString())
|
||||
.append("\n* __Content Language:__ ").append(getContentLanguageString())
|
||||
.append("\n* __App Language:__ ").append(getAppLanguage())
|
||||
.append("\n* __Service:__ ").append(errorInfo.getServiceName())
|
||||
.append("\n* __Timestamp:__ ").append(currentTimeStamp)
|
||||
.append("\n* __Package:__ ").append(getPackageName())
|
||||
.append("\n* __Service:__ ").append(errorInfo.getServiceName())
|
||||
.append("\n* __Version:__ ").append(BuildConfig.VERSION_NAME)
|
||||
.append("\n* __OS:__ ").append(getOsString()).append("\n");
|
||||
|
||||
|
||||
// Collapse all logs to a single paragraph when there are more than one
|
||||
// to keep the GitHub issue clean.
|
||||
if (errorInfo.getStackTraces().length > 1) {
|
||||
htmlErrorReport
|
||||
.append("<details><summary><b>Exceptions (")
|
||||
.append(errorInfo.getStackTraces().length)
|
||||
.append(")</b></summary><p>\n");
|
||||
}
|
||||
|
||||
// add the logs
|
||||
for (int i = 0; i < errorInfo.getStackTraces().length; i++) {
|
||||
htmlErrorReport.append("<details><summary><b>Crash log ");
|
||||
if (errorInfo.getStackTraces().length > 1) {
|
||||
htmlErrorReport.append(i + 1);
|
||||
}
|
||||
htmlErrorReport.append("</b>")
|
||||
.append("</summary><p>\n")
|
||||
.append("\n```\n").append(errorInfo.getStackTraces()[i]).append("\n```\n")
|
||||
.append("</details>\n");
|
||||
}
|
||||
|
||||
// make sure to close everything
|
||||
if (errorInfo.getStackTraces().length > 1) {
|
||||
htmlErrorReport.append("</p></details>\n");
|
||||
}
|
||||
htmlErrorReport.append("<hr>\n");
|
||||
return htmlErrorReport.toString();
|
||||
} catch (final Throwable e) {
|
||||
Log.e(TAG, "Error while erroring: Could not build markdown");
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getUserActionString(final UserAction userAction) {
|
||||
if (userAction == null) {
|
||||
return "Your description is in another castle.";
|
||||
} else {
|
||||
return userAction.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private String getContentCountryString() {
|
||||
return Localization.getPreferredContentCountry(this).getCountryCode();
|
||||
}
|
||||
|
||||
private String getContentLanguageString() {
|
||||
return Localization.getPreferredLocalization(this).getLocalizationCode();
|
||||
}
|
||||
|
||||
private String getAppLanguage() {
|
||||
return Localization.getAppLocale().toString();
|
||||
}
|
||||
|
||||
private String getOsString() {
|
||||
final String osBase = Build.VERSION.BASE_OS;
|
||||
return System.getProperty("os.name")
|
||||
+ " " + (osBase.isEmpty() ? "Android" : osBase)
|
||||
+ " " + Build.VERSION.RELEASE
|
||||
+ " - " + Build.VERSION.SDK_INT;
|
||||
}
|
||||
|
||||
private void addGuruMeditation() {
|
||||
//just an easter egg
|
||||
String text = activityErrorBinding.errorSorryView.getText().toString();
|
||||
text += "\n" + getString(R.string.guru_meditation);
|
||||
activityErrorBinding.errorSorryView.setText(text);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.schabi.newpipe.error
|
||||
import android.content.Context
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.exoplayer2.ExoPlaybackException
|
||||
import com.google.android.exoplayer2.upstream.HttpDataSource
|
||||
import com.google.android.exoplayer2.upstream.Loader
|
||||
@@ -28,7 +29,7 @@ import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentExcepti
|
||||
import org.schabi.newpipe.ktx.isNetworkRelated
|
||||
import org.schabi.newpipe.player.mediasource.FailedMediaSource
|
||||
import org.schabi.newpipe.player.resolver.PlaybackResolver
|
||||
import org.schabi.newpipe.util.Localization
|
||||
import org.schabi.newpipe.util.text.getText
|
||||
|
||||
/**
|
||||
* An error has occurred in the app. This class contains plain old parcelable data that can be used
|
||||
@@ -135,8 +136,8 @@ class ErrorInfo private constructor(
|
||||
return getServiceName(serviceId)
|
||||
}
|
||||
|
||||
fun getMessage(context: Context): String {
|
||||
return message.getString(context)
|
||||
fun getMessage(context: Context): CharSequence {
|
||||
return message.getText(context)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -146,18 +147,23 @@ class ErrorInfo private constructor(
|
||||
private val stringRes: Int,
|
||||
private vararg val formatArgs: String
|
||||
) : Parcelable {
|
||||
fun getString(context: Context): String {
|
||||
// use Localization.compatGetString() just in case context is not AppCompatActivity
|
||||
fun getText(context: Context): CharSequence {
|
||||
// Ensure locale aware context via ContextCompat.getContextForLanguage() (just in case context is not AppCompatActivity)
|
||||
val ctx = ContextCompat.getContextForLanguage(context)
|
||||
return if (formatArgs.isEmpty()) {
|
||||
Localization.compatGetString(context, stringRes)
|
||||
ctx.getText(stringRes)
|
||||
} else {
|
||||
Localization.compatGetString(context, stringRes, *formatArgs)
|
||||
// ContextCompat.getString() with formatArgs does not exist, so we just
|
||||
// replicate its source code but with formatArgs
|
||||
ctx.resources.getText(stringRes, *formatArgs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const val SERVICE_NONE = "<unknown_service>"
|
||||
|
||||
const val YOUTUBE_IP_BAN_FAQ_URL = "https://newpipe.net/FAQ/#ip-banned-youtube"
|
||||
|
||||
private fun getServiceName(serviceId: Int?) = // not using getNameOfServiceById since we want to accept a nullable serviceId and we
|
||||
// want to default to SERVICE_NONE
|
||||
ServiceList.all()?.firstOrNull { it.serviceId == serviceId }?.serviceInfo?.name
|
||||
@@ -245,7 +251,11 @@ class ErrorInfo private constructor(
|
||||
ErrorMessage(R.string.youtube_music_premium_content)
|
||||
|
||||
throwable is SignInConfirmNotBotException ->
|
||||
ErrorMessage(R.string.sign_in_confirm_not_bot_error, getServiceName(serviceId))
|
||||
ErrorMessage(
|
||||
R.string.sign_in_confirm_not_bot_error,
|
||||
getServiceName(serviceId),
|
||||
YOUTUBE_IP_BAN_FAQ_URL
|
||||
)
|
||||
|
||||
throwable is ContentNotAvailableException ->
|
||||
ErrorMessage(R.string.content_not_available)
|
||||
@@ -297,13 +307,9 @@ class ErrorInfo private constructor(
|
||||
// indicates that it's important and is thus reportable
|
||||
null -> true
|
||||
|
||||
// a recaptcha was detected, and the user needs to solve it, there is no use in
|
||||
// letting users report it
|
||||
is ReCaptchaException -> false
|
||||
|
||||
// the service explicitly said that content is not available (e.g. age restrictions,
|
||||
// video deleted, etc.), there is no use in letting users report it
|
||||
is ContentNotAvailableException -> false
|
||||
// if the service explicitly said that content is not available (e.g. age
|
||||
// restrictions, video deleted, etc.), there is no use in letting users report it
|
||||
is ContentNotAvailableException -> !isContentSurelyNotAvailable(throwable)
|
||||
|
||||
// we know the content is not supported, no need to let the user report it
|
||||
is ContentNotSupportedException -> false
|
||||
@@ -320,8 +326,8 @@ class ErrorInfo private constructor(
|
||||
|
||||
fun isRetryable(throwable: Throwable?): Boolean {
|
||||
return when (throwable) {
|
||||
// we know the content is not available, retrying won't help
|
||||
is ContentNotAvailableException -> false
|
||||
// if we know the content is surely not available, retrying won't help
|
||||
is ContentNotAvailableException -> !isContentSurelyNotAvailable(throwable)
|
||||
|
||||
// we know the content is not supported, retrying won't help
|
||||
is ContentNotSupportedException -> false
|
||||
@@ -331,5 +337,28 @@ class ErrorInfo private constructor(
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unfortunately sometimes [ContentNotAvailableException] may not indicate that the content
|
||||
* is blocked/deleted/paid, but may just indicate that we could not extract it. This is an
|
||||
* inconsistency in the exceptions thrown by the extractor, but until it is fixed, this
|
||||
* function will distinguish between the two types.
|
||||
* @return `true` if the content is not available because of a limitation imposed by the
|
||||
* service or the owner, `false` if the extractor could not extract info about it
|
||||
*/
|
||||
fun isContentSurelyNotAvailable(e: ContentNotAvailableException): Boolean {
|
||||
return when (e) {
|
||||
is AccountTerminatedException,
|
||||
is AgeRestrictedContentException,
|
||||
is GeographicRestrictionException,
|
||||
is PaidContentException,
|
||||
is PrivateContentException,
|
||||
is SoundCloudGoPlusContentException,
|
||||
is UnsupportedContentInCountryException,
|
||||
is YoutubeMusicPremiumContentException -> true
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import org.schabi.newpipe.MainActivity
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.ktx.animate
|
||||
import org.schabi.newpipe.util.external_communication.ShareUtils
|
||||
import org.schabi.newpipe.util.text.setTextWithLinks
|
||||
|
||||
class ErrorPanelHelper(
|
||||
private val fragment: Fragment,
|
||||
@@ -64,7 +65,7 @@ class ErrorPanelHelper(
|
||||
|
||||
fun showError(errorInfo: ErrorInfo) {
|
||||
ensureDefaultVisibility()
|
||||
errorTextView.text = errorInfo.getMessage(context)
|
||||
errorTextView.setTextWithLinks(errorInfo.getMessage(context))
|
||||
|
||||
if (errorInfo.recaptchaUrl != null) {
|
||||
showAndSetErrorButtonAction(R.string.recaptcha_solve) {
|
||||
@@ -109,7 +110,7 @@ class ErrorPanelHelper(
|
||||
fun showTextError(errorString: String) {
|
||||
ensureDefaultVisibility()
|
||||
|
||||
errorTextView.text = errorString
|
||||
errorTextView.setTextWithLinks(errorString)
|
||||
|
||||
setRootVisible()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.error
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.core.net.toUri
|
||||
import com.grack.nanojson.JsonWriter
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import org.schabi.newpipe.BuildConfig
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.util.Localization
|
||||
import org.schabi.newpipe.util.external_communication.ShareUtils
|
||||
|
||||
/**
|
||||
* Pure utility functions for building and sending error reports.
|
||||
* No Activity dependency — only requires a [Context].
|
||||
*/
|
||||
object ErrorReportHelper {
|
||||
|
||||
private val TAG = ErrorReportHelper::class.java.simpleName
|
||||
|
||||
private const val ERROR_EMAIL_ADDRESS = "crashreport@newpipe.schabi.org"
|
||||
private const val ERROR_EMAIL_SUBJECT = "Exception in "
|
||||
const val ERROR_GITHUB_ISSUE_URL = "https://github.com/TeamNewPipe/NewPipe/issues"
|
||||
|
||||
fun buildJson(context: Context, errorInfo: ErrorInfo, comment: String): String {
|
||||
try {
|
||||
return JsonWriter.string()
|
||||
.`object`()
|
||||
.value("user_action", errorInfo.userAction.message)
|
||||
.value("request", errorInfo.request)
|
||||
.value("content_language", getContentLanguage(context))
|
||||
.value("content_country", getContentCountry(context))
|
||||
.value("app_language", getAppLanguage())
|
||||
.value("service", errorInfo.getServiceName())
|
||||
.value("package", context.packageName)
|
||||
.value("version", BuildConfig.VERSION_NAME)
|
||||
.value("os", getOsString())
|
||||
.value("time", getCurrentTimestamp())
|
||||
.array("exceptions", errorInfo.stackTraces.toList())
|
||||
.value("user_comment", comment)
|
||||
.end()
|
||||
.done()
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "Could not build json", exception)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun buildMarkdown(context: Context, errorInfo: ErrorInfo, comment: String): String {
|
||||
try {
|
||||
return buildString(1024) {
|
||||
if (comment.isNotEmpty()) {
|
||||
appendLine(comment)
|
||||
}
|
||||
|
||||
appendLine("## Exception")
|
||||
appendLine("* __User Action:__ ${errorInfo.userAction.message}")
|
||||
appendLine("* __Request:__ ${errorInfo.request}")
|
||||
appendLine("* __Content Country:__ ${getContentCountry(context)}")
|
||||
appendLine("* __Content Language:__ ${getContentLanguage(context)}")
|
||||
appendLine("* __App Language:__ ${getAppLanguage()}")
|
||||
appendLine("* __Service:__ ${errorInfo.getServiceName()}")
|
||||
appendLine("* __Timestamp:__ ${getCurrentTimestamp()}")
|
||||
appendLine("* __Package:__ ${context.packageName}")
|
||||
appendLine("* __Version:__ ${BuildConfig.VERSION_NAME}")
|
||||
appendLine("* __OS:__ ${getOsString()}")
|
||||
|
||||
if (errorInfo.stackTraces.size > 1) {
|
||||
append("<details><summary><b>Exceptions (")
|
||||
append(errorInfo.stackTraces.size)
|
||||
append(")</b></summary><p>\n")
|
||||
}
|
||||
|
||||
errorInfo.stackTraces.forEachIndexed { index, stacktrace ->
|
||||
append("<details><summary><b>Crash log ")
|
||||
if (errorInfo.stackTraces.size > 1) {
|
||||
append(index + 1)
|
||||
}
|
||||
append("</b></summary><p>\n")
|
||||
append("\n```\n$stacktrace\n```\n")
|
||||
append("</details>\n")
|
||||
}
|
||||
|
||||
if (errorInfo.stackTraces.size > 1) {
|
||||
append("</p></details>\n")
|
||||
}
|
||||
|
||||
append("<hr>\n")
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "Could not build markdown", exception)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
fun sendErrorEmail(context: Context, errorInfo: ErrorInfo, comment: String) {
|
||||
val subject = "$ERROR_EMAIL_SUBJECT${context.getString(R.string.app_name)} ${BuildConfig.VERSION_NAME}"
|
||||
val intent = Intent(Intent.ACTION_SENDTO)
|
||||
.setData("mailto:".toUri())
|
||||
.putExtra(Intent.EXTRA_EMAIL, arrayOf(ERROR_EMAIL_ADDRESS))
|
||||
.putExtra(Intent.EXTRA_SUBJECT, subject)
|
||||
.putExtra(Intent.EXTRA_TEXT, buildJson(context, errorInfo, comment))
|
||||
ShareUtils.openIntentInApp(context, intent)
|
||||
}
|
||||
|
||||
fun shareError(context: Context, errorInfo: ErrorInfo, comment: String) {
|
||||
ShareUtils.shareText(
|
||||
context,
|
||||
context.getString(R.string.error_report_title),
|
||||
buildJson(context, errorInfo, comment)
|
||||
)
|
||||
}
|
||||
|
||||
fun copyForGitHub(context: Context, errorInfo: ErrorInfo, comment: String) {
|
||||
ShareUtils.copyToClipboard(context, buildMarkdown(context, errorInfo, comment))
|
||||
}
|
||||
|
||||
fun openGitHubIssues(context: Context) {
|
||||
ShareUtils.openUrlInApp(context, ERROR_GITHUB_ISSUE_URL)
|
||||
}
|
||||
|
||||
fun openPrivacyPolicy(context: Context) {
|
||||
ShareUtils.openUrlInApp(context, context.getString(R.string.privacy_policy_url))
|
||||
}
|
||||
|
||||
private fun getContentLanguage(context: Context): String = Localization.getPreferredLocalization(context).localizationCode
|
||||
|
||||
private fun getContentCountry(context: Context): String = Localization.getPreferredContentCountry(context).countryCode
|
||||
|
||||
private fun getAppLanguage(): String = Localization.getAppLocale().toString()
|
||||
|
||||
private fun getOsString(): String {
|
||||
val name = System.getProperty("os.name")!!
|
||||
val osBase = Build.VERSION.BASE_OS.ifEmpty { "Android" }
|
||||
return "$name $osBase ${Build.VERSION.RELEASE} - ${Build.VERSION.SDK_INT}"
|
||||
}
|
||||
|
||||
private fun getCurrentTimestamp(): String = ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import org.schabi.newpipe.ComposeActivity
|
||||
import org.schabi.newpipe.MainActivity
|
||||
import org.schabi.newpipe.R
|
||||
|
||||
@@ -25,7 +26,7 @@ import org.schabi.newpipe.R
|
||||
* is available.
|
||||
* - Use a notification if the exception happens inside a background service (player, subscription
|
||||
* import, ...) or there is no activity/fragment from which to extract a root view.
|
||||
* - Finally use the error activity only as a last resort in case the exception is critical and
|
||||
* - Finally use the error screen only as a last resort in case the exception is critical and
|
||||
* happens in an open activity (since the workflow would be interrupted anyway in that case).
|
||||
*/
|
||||
class ErrorUtil {
|
||||
@@ -33,7 +34,7 @@ class ErrorUtil {
|
||||
private const val ERROR_REPORT_NOTIFICATION_ID = 5340681
|
||||
|
||||
/**
|
||||
* Starts a new error activity allowing the user to report the provided error. Only use this
|
||||
* Starts a new error screen allowing the user to report the provided error. Only use this
|
||||
* method directly as a last resort in case the exception is critical and happens in an open
|
||||
* activity (since the workflow would be interrupted anyway in that case). So never use this
|
||||
* for background services.
|
||||
@@ -50,12 +51,12 @@ class ErrorUtil {
|
||||
) {
|
||||
createNotification(context, errorInfo)
|
||||
} else {
|
||||
context.startActivity(getErrorActivityIntent(context, errorInfo))
|
||||
context.startActivity(getErrorScreenIntent(context, errorInfo))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a bottom snackbar to the user, with a report button that opens the error activity.
|
||||
* Show a bottom snackbar to the user, with a report button that opens the error screen.
|
||||
* Use this method if the exception is not critical and it happens in a place where a root
|
||||
* view is available.
|
||||
*
|
||||
@@ -70,7 +71,7 @@ class ErrorUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a bottom snackbar to the user, with a report button that opens the error activity.
|
||||
* Show a bottom snackbar to the user, with a report button that opens the error screen.
|
||||
* Use this method if the exception is not critical and it happens in a place where a root
|
||||
* view is available.
|
||||
*
|
||||
@@ -104,7 +105,7 @@ class ErrorUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an error notification. Tapping on the notification opens the error activity. Use
|
||||
* Create an error notification. Tapping on the notification opens the error screen. Use
|
||||
* this method if the exception happens inside a background service (player, subscription
|
||||
* import, ...) or there is no activity/fragment from which to extract a root view.
|
||||
*
|
||||
@@ -128,14 +129,17 @@ class ErrorUtil {
|
||||
PendingIntentCompat.getActivity(
|
||||
context,
|
||||
0,
|
||||
getErrorActivityIntent(context, errorInfo),
|
||||
getErrorScreenIntent(context, errorInfo),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
NotificationManagerCompat.from(context)
|
||||
.notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder.build())
|
||||
val notificationManager = NotificationManagerCompat.from(context)
|
||||
if (notificationManager.areNotificationsEnabled()) {
|
||||
notificationManager
|
||||
.notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder.build())
|
||||
}
|
||||
|
||||
ContextCompat.getMainExecutor(context).execute {
|
||||
// since the notification is silent, also show a toast, otherwise the user is confused
|
||||
@@ -144,11 +148,8 @@ class ErrorUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getErrorActivityIntent(context: Context, errorInfo: ErrorInfo): Intent {
|
||||
val intent = Intent(context, ErrorActivity::class.java)
|
||||
intent.putExtra(ErrorActivity.ERROR_INFO, errorInfo)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
return intent
|
||||
private fun getErrorScreenIntent(context: Context, errorInfo: ErrorInfo): Intent {
|
||||
return ComposeActivity.errorIntent(context, errorInfo)
|
||||
}
|
||||
|
||||
private fun showSnackbar(context: Context, rootView: View?, errorInfo: ErrorInfo) {
|
||||
@@ -159,7 +160,7 @@ class ErrorUtil {
|
||||
Snackbar.make(rootView, errorInfo.getMessage(context), Snackbar.LENGTH_LONG)
|
||||
.setActionTextColor(Color.YELLOW)
|
||||
.setAction(context.getString(R.string.error_snackbar_action).uppercase()) {
|
||||
context.startActivity(getErrorActivityIntent(context, errorInfo))
|
||||
context.startActivity(getErrorScreenIntent(context, errorInfo))
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint("MissingSuperCall") // saveCookiesAndFinish method handles back navigation
|
||||
public void onBackPressed() {
|
||||
saveCookiesAndFinish();
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ public abstract class BaseDescriptionFragment extends BaseFragment {
|
||||
|| image.getWidth() != Image.WIDTH_UNKNOWN
|
||||
// if even the resolution level is unknown, ?x? will be shown
|
||||
|| image.getEstimatedResolutionLevel() == Image.ResolutionLevel.UNKNOWN) {
|
||||
urls.append(imageSizeToText(image.getHeight()));
|
||||
urls.append('x');
|
||||
urls.append(imageSizeToText(image.getWidth()));
|
||||
urls.append('x');
|
||||
urls.append(imageSizeToText(image.getHeight()));
|
||||
} else {
|
||||
switch (image.getEstimatedResolutionLevel()) {
|
||||
case LOW -> urls.append(getString(R.string.image_quality_low));
|
||||
|
||||
@@ -136,7 +136,6 @@ class VideoDetailFragment :
|
||||
@State
|
||||
var title: String = ""
|
||||
|
||||
@JvmField
|
||||
@State
|
||||
var url: String? = null
|
||||
private var currentInfo: StreamInfo? = null
|
||||
@@ -148,6 +147,8 @@ class VideoDetailFragment :
|
||||
@State
|
||||
var autoPlayEnabled: Boolean = true
|
||||
|
||||
var forceFullscreen: Boolean = false
|
||||
|
||||
@JvmField
|
||||
@State
|
||||
var originalOrientation: Int = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
@@ -600,6 +601,12 @@ class VideoDetailFragment :
|
||||
override fun initListeners() {
|
||||
super.initListeners()
|
||||
|
||||
// Workaround for #5600
|
||||
// Forcefully catch click events uncaught by children because otherwise
|
||||
// they will be caught by underlying view and "click through" will happen
|
||||
binding.root.setOnClickListener { _ -> }
|
||||
binding.root.setOnLongClickListener { _ -> true }
|
||||
|
||||
setOnClickListeners()
|
||||
setOnLongClickListeners()
|
||||
|
||||
@@ -1047,7 +1054,11 @@ class VideoDetailFragment :
|
||||
* = false`, hence preventing it from going directly fullscreen.
|
||||
*/
|
||||
fun openVideoPlayerAutoFullscreen() {
|
||||
openVideoPlayer(PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext()))
|
||||
openVideoPlayer(
|
||||
forceFullscreen ||
|
||||
PlayerHelper.isStartMainPlayerFullscreenEnabled(requireContext())
|
||||
)
|
||||
forceFullscreen = false
|
||||
}
|
||||
|
||||
private fun openNormalBackgroundPlayer(append: Boolean) {
|
||||
@@ -1339,8 +1350,9 @@ class VideoDetailFragment :
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED)
|
||||
}
|
||||
// Rebound to the service if it was closed via notification or mini player
|
||||
PlayerHolder.setListener(this@VideoDetailFragment)
|
||||
PlayerHolder.tryBindIfNeeded(requireContext())
|
||||
if (!PlayerHolder.isBound) {
|
||||
PlayerHolder.startService(false, this@VideoDetailFragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1772,7 +1784,7 @@ class VideoDetailFragment :
|
||||
showSystemUi()
|
||||
}
|
||||
|
||||
binding.relatedItemsLayout?.isVisible = !fullscreen
|
||||
binding.relatedItemsLayout?.isVisible = if (showRelatedItems) !fullscreen else false
|
||||
scrollToTop()
|
||||
|
||||
tryAddVideoPlayerView()
|
||||
|
||||
@@ -161,34 +161,29 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_item_notify:
|
||||
final boolean value = !item.isChecked();
|
||||
item.setEnabled(false);
|
||||
setNotify(value);
|
||||
break;
|
||||
case R.id.action_settings:
|
||||
NavigationHelper.openSettings(requireContext());
|
||||
break;
|
||||
case R.id.menu_item_rss:
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.openUrlInApp(requireContext(), currentInfo.getFeedUrl());
|
||||
}
|
||||
break;
|
||||
case R.id.menu_item_openInBrowser:
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.openUrlInBrowser(requireContext(),
|
||||
currentInfo.getOriginalUrl());
|
||||
}
|
||||
break;
|
||||
case R.id.menu_item_share:
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.shareText(requireContext(), name,
|
||||
currentInfo.getOriginalUrl(), currentInfo.getAvatars());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.menu_item_notify) {
|
||||
final boolean value = !item.isChecked();
|
||||
item.setEnabled(false);
|
||||
setNotify(value);
|
||||
} else if (itemId == R.id.action_settings) {
|
||||
NavigationHelper.openSettings(requireContext());
|
||||
} else if (itemId == R.id.menu_item_rss) {
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.openUrlInApp(requireContext(), currentInfo.getFeedUrl());
|
||||
}
|
||||
} else if (itemId == R.id.menu_item_openInBrowser) {
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.openUrlInBrowser(requireContext(),
|
||||
currentInfo.getOriginalUrl());
|
||||
}
|
||||
} else if (itemId == R.id.menu_item_share) {
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.shareText(requireContext(), name,
|
||||
currentInfo.getOriginalUrl(), currentInfo.getAvatars());
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.fragments.list.kiosk;
|
||||
|
||||
import android.os.Bundle;
|
||||
@@ -33,30 +38,6 @@ import org.schabi.newpipe.util.Localization;
|
||||
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 23.09.17.
|
||||
* <p>
|
||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||
* KioskFragment.java is part of NewPipe.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class KioskFragment extends BaseListInfoFragment<StreamInfoItem, KioskInfo> {
|
||||
@State
|
||||
String kioskId = "";
|
||||
|
||||
+24
-29
@@ -231,35 +231,30 @@ public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, Playl
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_settings:
|
||||
NavigationHelper.openSettings(requireContext());
|
||||
break;
|
||||
case R.id.menu_item_openInBrowser:
|
||||
ShareUtils.openUrlInBrowser(requireContext(), url);
|
||||
break;
|
||||
case R.id.menu_item_share:
|
||||
ShareUtils.shareText(requireContext(), name, url,
|
||||
currentInfo == null ? List.of() : currentInfo.getThumbnails());
|
||||
break;
|
||||
case R.id.menu_item_bookmark:
|
||||
onBookmarkClicked();
|
||||
break;
|
||||
case R.id.menu_item_append_playlist:
|
||||
if (currentInfo != null) {
|
||||
disposables.add(PlaylistDialog.createCorrespondingDialog(
|
||||
getContext(),
|
||||
getPlayQueue()
|
||||
.getStreams()
|
||||
.stream()
|
||||
.map(StreamEntity::new)
|
||||
.collect(Collectors.toList()),
|
||||
dialog -> dialog.show(getFM(), TAG)
|
||||
));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_settings) {
|
||||
NavigationHelper.openSettings(requireContext());
|
||||
} else if (itemId == R.id.menu_item_openInBrowser) {
|
||||
ShareUtils.openUrlInBrowser(requireContext(), url);
|
||||
} else if (itemId == R.id.menu_item_share) {
|
||||
ShareUtils.shareText(requireContext(), name, url,
|
||||
currentInfo == null ? List.of() : currentInfo.getThumbnails());
|
||||
} else if (itemId == R.id.menu_item_bookmark) {
|
||||
onBookmarkClicked();
|
||||
} else if (itemId == R.id.menu_item_append_playlist) {
|
||||
if (currentInfo != null) {
|
||||
disposables.add(PlaylistDialog.createCorrespondingDialog(
|
||||
getContext(),
|
||||
getPlayQueue()
|
||||
.getStreams()
|
||||
.stream()
|
||||
.map(StreamEntity::new)
|
||||
.collect(Collectors.toList()),
|
||||
dialog -> dialog.show(getFM(), TAG)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1013,7 +1013,11 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||
Log.d(TAG, "handleSuggestions() called with: suggestions = [" + suggestions + "]");
|
||||
}
|
||||
suggestionListAdapter.submitList(suggestions,
|
||||
() -> searchBinding.suggestionsList.scrollToPosition(0));
|
||||
() -> {
|
||||
if (searchBinding != null) {
|
||||
searchBinding.suggestionsList.scrollToPosition(0);
|
||||
}
|
||||
});
|
||||
|
||||
if (suggestionsPanelVisible && isErrorPanelVisible()) {
|
||||
hideLoading();
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
package org.schabi.newpipe.info_list;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.info_list.holder.ChannelInfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.InfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.PlaylistInfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.PlaylistMiniInfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.StreamInfoItemHolder;
|
||||
import org.schabi.newpipe.info_list.holder.StreamMiniInfoItemHolder;
|
||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||
import org.schabi.newpipe.util.OnClickGesture;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 26.09.16.
|
||||
* <p>
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* InfoItemBuilder.java is part of NewPipe.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class InfoItemBuilder {
|
||||
private final Context context;
|
||||
|
||||
private OnClickGesture<StreamInfoItem> onStreamSelectedListener;
|
||||
private OnClickGesture<ChannelInfoItem> onChannelSelectedListener;
|
||||
private OnClickGesture<PlaylistInfoItem> onPlaylistSelectedListener;
|
||||
private OnClickGesture<CommentsInfoItem> onCommentsSelectedListener;
|
||||
|
||||
public InfoItemBuilder(final Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem,
|
||||
final HistoryRecordManager historyRecordManager) {
|
||||
return buildView(parent, infoItem, historyRecordManager, false);
|
||||
}
|
||||
|
||||
public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem,
|
||||
final HistoryRecordManager historyRecordManager,
|
||||
final boolean useMiniVariant) {
|
||||
final InfoItemHolder holder =
|
||||
holderFromInfoType(parent, infoItem.getInfoType(), useMiniVariant);
|
||||
holder.updateFromItem(infoItem, historyRecordManager);
|
||||
return holder.itemView;
|
||||
}
|
||||
|
||||
private InfoItemHolder holderFromInfoType(@NonNull final ViewGroup parent,
|
||||
@NonNull final InfoItem.InfoType infoType,
|
||||
final boolean useMiniVariant) {
|
||||
return switch (infoType) {
|
||||
case STREAM -> useMiniVariant ? new StreamMiniInfoItemHolder(this, parent)
|
||||
: new StreamInfoItemHolder(this, parent);
|
||||
case CHANNEL -> useMiniVariant ? new ChannelMiniInfoItemHolder(this, parent)
|
||||
: new ChannelInfoItemHolder(this, parent);
|
||||
case PLAYLIST -> useMiniVariant ? new PlaylistMiniInfoItemHolder(this, parent)
|
||||
: new PlaylistInfoItemHolder(this, parent);
|
||||
case COMMENT ->
|
||||
throw new IllegalArgumentException("Comments should be rendered using Compose");
|
||||
};
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public OnClickGesture<StreamInfoItem> getOnStreamSelectedListener() {
|
||||
return onStreamSelectedListener;
|
||||
}
|
||||
|
||||
public void setOnStreamSelectedListener(final OnClickGesture<StreamInfoItem> listener) {
|
||||
this.onStreamSelectedListener = listener;
|
||||
}
|
||||
|
||||
public OnClickGesture<ChannelInfoItem> getOnChannelSelectedListener() {
|
||||
return onChannelSelectedListener;
|
||||
}
|
||||
|
||||
public void setOnChannelSelectedListener(final OnClickGesture<ChannelInfoItem> listener) {
|
||||
this.onChannelSelectedListener = listener;
|
||||
}
|
||||
|
||||
public OnClickGesture<PlaylistInfoItem> getOnPlaylistSelectedListener() {
|
||||
return onPlaylistSelectedListener;
|
||||
}
|
||||
|
||||
public void setOnPlaylistSelectedListener(final OnClickGesture<PlaylistInfoItem> listener) {
|
||||
this.onPlaylistSelectedListener = listener;
|
||||
}
|
||||
|
||||
public OnClickGesture<CommentsInfoItem> getOnCommentsSelectedListener() {
|
||||
return onCommentsSelectedListener;
|
||||
}
|
||||
|
||||
public void setOnCommentsSelectedListener(
|
||||
final OnClickGesture<CommentsInfoItem> onCommentsSelectedListener) {
|
||||
this.onCommentsSelectedListener = onCommentsSelectedListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.info_list
|
||||
|
||||
import android.content.Context
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||
import org.schabi.newpipe.util.OnClickGesture
|
||||
|
||||
class InfoItemBuilder(val context: Context) {
|
||||
var onStreamSelectedListener: OnClickGesture<StreamInfoItem>? = null
|
||||
var onChannelSelectedListener: OnClickGesture<ChannelInfoItem>? = null
|
||||
var onPlaylistSelectedListener: OnClickGesture<PlaylistInfoItem>? = null
|
||||
var onCommentsSelectedListener: OnClickGesture<CommentsInfoItem>? = null
|
||||
}
|
||||
+21
-15
@@ -5,6 +5,7 @@ import static org.schabi.newpipe.util.SparseItemUtil.fetchItemInfoIfSparse;
|
||||
import static org.schabi.newpipe.util.SparseItemUtil.fetchStreamInfoAndSaveToDatabase;
|
||||
import static org.schabi.newpipe.util.SparseItemUtil.fetchUploaderUrlIfSparse;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -53,28 +54,33 @@ public enum StreamDialogDefaultEntry {
|
||||
/**
|
||||
* Enqueues the stream automatically to the current PlayerType.
|
||||
*/
|
||||
ENQUEUE(R.string.enqueue_stream, (fragment, item) ->
|
||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
||||
NavigationHelper.enqueueOnPlayer(fragment.getContext(), singlePlayQueue))
|
||||
),
|
||||
ENQUEUE(R.string.enqueue_stream, (fragment, item) -> {
|
||||
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||
NavigationHelper.enqueueOnPlayer(ctx, singlePlayQueue));
|
||||
}),
|
||||
|
||||
/**
|
||||
* Enqueues the stream automatically to the current PlayerType
|
||||
* after the currently playing stream.
|
||||
*/
|
||||
ENQUEUE_NEXT(R.string.enqueue_next_stream, (fragment, item) ->
|
||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
||||
NavigationHelper.enqueueNextOnPlayer(fragment.getContext(), singlePlayQueue))
|
||||
),
|
||||
ENQUEUE_NEXT(R.string.enqueue_next_stream, (fragment, item) -> {
|
||||
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||
NavigationHelper.enqueueNextOnPlayer(ctx, singlePlayQueue));
|
||||
}),
|
||||
|
||||
START_HERE_ON_BACKGROUND(R.string.start_here_on_background, (fragment, item) ->
|
||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
||||
NavigationHelper.playOnBackgroundPlayer(
|
||||
fragment.getContext(), singlePlayQueue, true))),
|
||||
START_HERE_ON_BACKGROUND(R.string.start_here_on_background, (fragment, item) -> {
|
||||
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||
NavigationHelper.playOnBackgroundPlayer(ctx, singlePlayQueue, true));
|
||||
}),
|
||||
|
||||
START_HERE_ON_POPUP(R.string.start_here_on_popup, (fragment, item) ->
|
||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
||||
NavigationHelper.playOnPopupPlayer(fragment.getContext(), singlePlayQueue, true))),
|
||||
START_HERE_ON_POPUP(R.string.start_here_on_popup, (fragment, item) -> {
|
||||
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||
NavigationHelper.playOnPopupPlayer(ctx, singlePlayQueue, true));
|
||||
}),
|
||||
|
||||
SET_AS_PLAYLIST_THUMBNAIL(R.string.set_as_playlist_thumbnail, (fragment, item) -> {
|
||||
throw new UnsupportedOperationException("This needs to be implemented manually "
|
||||
|
||||
@@ -2,7 +2,12 @@ package org.schabi.newpipe.ktx
|
||||
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.newpipe.Constants
|
||||
import net.newpipe.app.ComposeActivity
|
||||
import net.newpipe.app.navigation.Destination
|
||||
|
||||
tailrec fun Context.findFragmentActivity(): FragmentActivity {
|
||||
return when (this) {
|
||||
@@ -11,3 +16,12 @@ tailrec fun Context.findFragmentActivity(): FragmentActivity {
|
||||
else -> throw IllegalStateException("Unable to find FragmentActivity")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigates to a given compose destination
|
||||
*/
|
||||
fun Context.navigateTo(destination: Destination) {
|
||||
val intent = Intent(this, ComposeActivity::class.java)
|
||||
.putExtra(Constants.INTENT_SCREEN_KEY, Json.encodeToString(destination))
|
||||
startActivity(intent)
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import static org.schabi.newpipe.ktx.ViewUtils.animate;
|
||||
import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling;
|
||||
import static org.schabi.newpipe.util.ThemeHelper.getItemViewMode;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* This fragment is design to be used with persistent data such as
|
||||
* {@link org.schabi.newpipe.database.LocalItem}, and does not cache the data contained
|
||||
@@ -100,7 +102,7 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Nullable
|
||||
protected ViewBinding getListHeader() {
|
||||
protected Supplier<View> getListHeaderSupplier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -131,9 +133,9 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
|
||||
itemsList = rootView.findViewById(R.id.items_list);
|
||||
refreshItemViewMode();
|
||||
|
||||
headerRootBinding = getListHeader();
|
||||
if (headerRootBinding != null) {
|
||||
itemListAdapter.setHeader(headerRootBinding.getRoot());
|
||||
final Supplier<View> listHeaderSupplier = getListHeaderSupplier();
|
||||
if (listHeaderSupplier != null) {
|
||||
itemListAdapter.setHeaderSupplier(listHeaderSupplier);
|
||||
}
|
||||
footerRootBinding = getListFooter();
|
||||
itemListAdapter.setFooter(footerRootBinding.getRoot());
|
||||
@@ -210,6 +212,8 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
|
||||
showListFooter(false);
|
||||
}
|
||||
|
||||
@Deprecated(since = "Calling this method with `true` may cause crashes, see "
|
||||
+ "https://github.com/TeamNewPipe/NewPipe/pull/12996#pullrequestreview-3713317115")
|
||||
@Override
|
||||
public void showListFooter(final boolean show) {
|
||||
if (itemsList == null) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 01.08.16.
|
||||
@@ -82,7 +83,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private final DateTimeFormatter dateTimeFormatter;
|
||||
|
||||
private boolean showFooter = false;
|
||||
private View header = null;
|
||||
private Supplier<View> headerSupplier = null;
|
||||
private View footer = null;
|
||||
private ItemViewMode itemViewMode = ItemViewMode.LIST;
|
||||
private boolean useItemHandle = false;
|
||||
@@ -91,6 +92,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
recordManager = new HistoryRecordManager(context);
|
||||
localItemBuilder = new LocalItemBuilder(context);
|
||||
localItems = new ArrayList<>();
|
||||
|
||||
dateTimeFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
|
||||
.withLocale(Localization.getPreferredLocale(context));
|
||||
}
|
||||
@@ -118,7 +120,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "addItems() after > offsetStart = " + offsetStart + ", "
|
||||
+ "localItems.size() = " + localItems.size() + ", "
|
||||
+ "header = " + header + ", footer = " + footer + ", "
|
||||
+ "header = " + hasHeader() + ", footer = " + footer + ", "
|
||||
+ "showFooter = " + showFooter);
|
||||
}
|
||||
notifyItemRangeInserted(offsetStart, data.size());
|
||||
@@ -138,7 +140,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
final int index = localItems.indexOf(data);
|
||||
if (index != -1) {
|
||||
localItems.remove(index);
|
||||
notifyItemRemoved(index + (header != null ? 1 : 0));
|
||||
notifyItemRemoved(index + (hasHeader() ? 1 : 0));
|
||||
} else {
|
||||
// this happens when
|
||||
// 1) removeItem is called on infoItemDuplicate as in showStreamItemDialog of
|
||||
@@ -183,9 +185,9 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.useItemHandle = useItemHandle;
|
||||
}
|
||||
|
||||
public void setHeader(final View header) {
|
||||
final boolean changed = header != this.header;
|
||||
this.header = header;
|
||||
public void setHeaderSupplier(@Nullable final Supplier<View> headerSupplier) {
|
||||
final boolean changed = headerSupplier != this.headerSupplier;
|
||||
this.headerSupplier = headerSupplier;
|
||||
if (changed) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@@ -195,6 +197,12 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.footer = view;
|
||||
}
|
||||
|
||||
protected boolean hasHeader() {
|
||||
return this.headerSupplier != null;
|
||||
}
|
||||
|
||||
@Deprecated(since = "Calling this method with `true` may cause crashes, see "
|
||||
+ "https://github.com/TeamNewPipe/NewPipe/pull/12996#pullrequestreview-3713317115")
|
||||
public void showFooter(final boolean show) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "showFooter() called with: show = [" + show + "]");
|
||||
@@ -205,6 +213,8 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
showFooter = show;
|
||||
if (show) {
|
||||
Log.w(TAG, "Calling LocalItemListAdapter.showFooter(true) may cause crashes, see https"
|
||||
+ "://github.com/TeamNewPipe/NewPipe/pull/12996#pullrequestreview-3713317115");
|
||||
notifyItemInserted(sizeConsideringHeader());
|
||||
} else {
|
||||
notifyItemRemoved(sizeConsideringHeader());
|
||||
@@ -212,11 +222,11 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
private int adapterOffsetWithoutHeader(final int offset) {
|
||||
return offset - (header != null ? 1 : 0);
|
||||
return offset - (hasHeader() ? 1 : 0);
|
||||
}
|
||||
|
||||
private int sizeConsideringHeader() {
|
||||
return localItems.size() + (header != null ? 1 : 0);
|
||||
return localItems.size() + (hasHeader() ? 1 : 0);
|
||||
}
|
||||
|
||||
public ArrayList<LocalItem> getItemsList() {
|
||||
@@ -226,7 +236,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int count = localItems.size();
|
||||
if (header != null) {
|
||||
if (hasHeader()) {
|
||||
count++;
|
||||
}
|
||||
if (footer != null && showFooter) {
|
||||
@@ -236,7 +246,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "getItemCount() called, count = " + count + ", "
|
||||
+ "localItems.size() = " + localItems.size() + ", "
|
||||
+ "header = " + header + ", footer = " + footer + ", "
|
||||
+ "header = " + hasHeader() + ", footer = " + footer + ", "
|
||||
+ "showFooter = " + showFooter);
|
||||
}
|
||||
return count;
|
||||
@@ -249,9 +259,9 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
Log.d(TAG, "getItemViewType() called with: position = [" + position + "]");
|
||||
}
|
||||
|
||||
if (header != null && position == 0) {
|
||||
if (hasHeader() && position == 0) {
|
||||
return HEADER_TYPE;
|
||||
} else if (header != null) {
|
||||
} else if (hasHeader()) {
|
||||
position--;
|
||||
}
|
||||
if (footer != null && position == localItems.size() && showFooter) {
|
||||
@@ -303,7 +313,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
+ "parent = [" + parent + "], type = [" + type + "]");
|
||||
}
|
||||
return switch (type) {
|
||||
case HEADER_TYPE -> new HeaderFooterHolder(header);
|
||||
case HEADER_TYPE -> new HeaderFooterHolder(headerSupplier.get());
|
||||
case FOOTER_TYPE -> new HeaderFooterHolder(footer);
|
||||
case LOCAL_PLAYLIST_HOLDER_TYPE ->
|
||||
new LocalPlaylistItemHolder(localItemBuilder, parent);
|
||||
@@ -345,14 +355,14 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
if (holder instanceof LocalItemHolder) {
|
||||
// If header isn't null, offset the items by -1
|
||||
if (header != null) {
|
||||
if (hasHeader()) {
|
||||
position--;
|
||||
}
|
||||
|
||||
((LocalItemHolder) holder)
|
||||
.updateFromItem(localItems.get(position), recordManager, dateTimeFormatter);
|
||||
} else if (holder instanceof HeaderFooterHolder && position == 0 && header != null) {
|
||||
((HeaderFooterHolder) holder).view = header;
|
||||
} else if (holder instanceof HeaderFooterHolder && position == 0 && hasHeader()) {
|
||||
((HeaderFooterHolder) holder).view = headerSupplier.get();
|
||||
} else if (holder instanceof HeaderFooterHolder && position == sizeConsideringHeader()
|
||||
&& footer != null && showFooter) {
|
||||
((HeaderFooterHolder) holder).view = footer;
|
||||
@@ -366,10 +376,10 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
for (final Object payload : payloads) {
|
||||
if (payload instanceof StreamStateEntity) {
|
||||
((LocalItemHolder) holder).updateState(localItems
|
||||
.get(header == null ? position : position - 1), recordManager);
|
||||
.get(hasHeader() ? position - 1 : position), recordManager);
|
||||
} else if (payload instanceof Boolean) {
|
||||
((LocalItemHolder) holder).updateState(localItems
|
||||
.get(header == null ? position : position - 1), recordManager);
|
||||
.get(hasHeader() ? position - 1 : position), recordManager);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -129,8 +129,7 @@ class FeedViewModel(
|
||||
fun setSaveShowPlayedItems(showPlayedItems: Boolean) {
|
||||
this.showPlayedItems.onNext(showPlayedItems)
|
||||
PreferenceManager.getDefaultSharedPreferences(application).edit {
|
||||
this.putBoolean(application.getString(R.string.feed_show_watched_items_key), showPlayedItems)
|
||||
this.apply()
|
||||
putBoolean(application.getString(R.string.feed_show_watched_items_key), showPlayedItems)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +138,7 @@ class FeedViewModel(
|
||||
fun setSaveShowPartiallyPlayedItems(showPartiallyPlayedItems: Boolean) {
|
||||
this.showPartiallyPlayedItems.onNext(showPartiallyPlayedItems)
|
||||
PreferenceManager.getDefaultSharedPreferences(application).edit {
|
||||
this.putBoolean(application.getString(R.string.feed_show_partially_watched_items_key), showPartiallyPlayedItems)
|
||||
this.apply()
|
||||
putBoolean(application.getString(R.string.feed_show_partially_watched_items_key), showPartiallyPlayedItems)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +147,7 @@ class FeedViewModel(
|
||||
fun setSaveShowFutureItems(showFutureItems: Boolean) {
|
||||
this.showFutureItems.onNext(showFutureItems)
|
||||
PreferenceManager.getDefaultSharedPreferences(application).edit {
|
||||
this.putBoolean(application.getString(R.string.feed_show_future_items_key), showFutureItems)
|
||||
this.apply()
|
||||
putBoolean(application.getString(R.string.feed_show_future_items_key), showFutureItems)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,9 @@ class NotificationHelper(val context: Context) {
|
||||
// Show individual stream notifications, set channel icon only if there is actually one
|
||||
showStreamNotifications(newStreams, data.serviceId, avatarIcon)
|
||||
// Show summary notification
|
||||
manager.notify(data.pseudoId, summaryBuilder.build())
|
||||
if (manager.areNotificationsEnabled()) {
|
||||
manager.notify(data.pseudoId, summaryBuilder.build())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showStreamNotifications(
|
||||
@@ -90,9 +92,12 @@ class NotificationHelper(val context: Context) {
|
||||
serviceId: Int,
|
||||
channelIcon: Bitmap?
|
||||
) {
|
||||
for (stream in newStreams) {
|
||||
val notification = createStreamNotification(stream, serviceId, channelIcon)
|
||||
manager.notify(stream.url.hashCode(), notification)
|
||||
if (manager.areNotificationsEnabled()) {
|
||||
newStreams.forEach { stream ->
|
||||
val notification =
|
||||
createStreamNotification(stream, serviceId, channelIcon)
|
||||
manager.notify(stream.url.hashCode(), notification)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,8 @@ class FeedLoadManager(private val context: Context) {
|
||||
broadcastProgress()
|
||||
}
|
||||
.observeOn(Schedulers.io())
|
||||
.flatMap { Flowable.fromIterable(it) }
|
||||
// Randomize user subscription ordering to attempt to resist fingerprinting
|
||||
.flatMap { Flowable.fromIterable(it.shuffled()) }
|
||||
.takeWhile { !cancelSignal.get() }
|
||||
.doOnNext { subscriptionEntity ->
|
||||
// throttle YouTube extractions once every BATCH_SIZE to avoid being rate limited
|
||||
|
||||
@@ -185,7 +185,9 @@ class FeedLoadService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build())
|
||||
if (notificationManager.areNotificationsEnabled()) {
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build())
|
||||
}
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.schabi.newpipe.local.playlist;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static org.schabi.newpipe.error.ErrorUtil.showUiErrorSnackbar;
|
||||
import static org.schabi.newpipe.ktx.ViewUtils.animate;
|
||||
import static org.schabi.newpipe.local.playlist.ExportPlaylistKt.export;
|
||||
@@ -22,6 +24,8 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -29,7 +33,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewbinding.ViewBinding;
|
||||
|
||||
import com.evernote.android.state.State;
|
||||
import org.reactivestreams.Subscriber;
|
||||
@@ -55,6 +58,7 @@ import org.schabi.newpipe.local.BaseLocalListFragment;
|
||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||
import org.schabi.newpipe.util.DeviceUtils;
|
||||
import org.schabi.newpipe.util.Localization;
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
import org.schabi.newpipe.util.OnClickGesture;
|
||||
@@ -67,6 +71,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
@@ -158,14 +163,14 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewBinding getListHeader() {
|
||||
protected Supplier<View> getListHeaderSupplier() {
|
||||
headerBinding = LocalPlaylistHeaderBinding.inflate(activity.getLayoutInflater(), itemsList,
|
||||
false);
|
||||
false);
|
||||
playlistControlBinding = headerBinding.playlistControl;
|
||||
|
||||
headerBinding.playlistTitleView.setSelected(true);
|
||||
|
||||
return headerBinding;
|
||||
return headerBinding::getRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -365,17 +370,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
createRenameDialog();
|
||||
} else if (item.getItemId() == R.id.menu_item_remove_watched) {
|
||||
if (!isRewritingPlaylist) {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setMessage(R.string.remove_watched_popup_warning)
|
||||
.setTitle(R.string.remove_watched_popup_title)
|
||||
.setPositiveButton(R.string.ok, (d, id) ->
|
||||
removeWatchedStreams(false))
|
||||
.setNeutralButton(
|
||||
R.string.remove_watched_popup_yes_and_partially_watched_videos,
|
||||
(d, id) -> removeWatchedStreams(true))
|
||||
.setNegativeButton(R.string.cancel,
|
||||
(d, id) -> d.cancel())
|
||||
.show();
|
||||
openRemoveWatchedConfirmationDialog();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {
|
||||
if (!isRewritingPlaylist) {
|
||||
@@ -447,39 +442,28 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
.getIsPlaylistThumbnailPermanent(playlistId);
|
||||
boolean thumbnailVideoRemoved = false;
|
||||
|
||||
if (removePartiallyWatched) {
|
||||
for (final var playlistItem : playlist) {
|
||||
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
||||
playlistItem.getStreamId());
|
||||
final var streamStates = recordManager
|
||||
.loadLocalStreamStateBatch(playlist).blockingGet();
|
||||
|
||||
if (indexInHistory < 0) {
|
||||
itemsToKeep.add(playlistItem);
|
||||
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
||||
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
||||
== playlistItem.getStreamEntity().getUid()) {
|
||||
thumbnailVideoRemoved = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final var streamStates = recordManager
|
||||
.loadLocalStreamStateBatch(playlist).blockingGet();
|
||||
for (int i = 0; i < playlist.size(); i++) {
|
||||
final var playlistItem = playlist.get(i);
|
||||
final var streamStateEntity = streamStates.get(i);
|
||||
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
||||
playlistItem.getStreamId());
|
||||
final long duration = playlistItem.toStreamInfoItem().getDuration();
|
||||
|
||||
for (int i = 0; i < playlist.size(); i++) {
|
||||
final var playlistItem = playlist.get(i);
|
||||
final var streamStateEntity = streamStates.get(i);
|
||||
|
||||
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
||||
playlistItem.getStreamId());
|
||||
final long duration = playlistItem.toStreamInfoItem().getDuration();
|
||||
|
||||
if (indexInHistory < 0 || (streamStateEntity != null
|
||||
&& !streamStateEntity.isFinished(duration))) {
|
||||
itemsToKeep.add(playlistItem);
|
||||
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
||||
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
||||
== playlistItem.getStreamEntity().getUid()) {
|
||||
thumbnailVideoRemoved = true;
|
||||
}
|
||||
if (indexInHistory < 0 // stream is not in history
|
||||
// stream is in history but the streamStateEntity is null
|
||||
// if the stream was played for less than 5 seconds, see
|
||||
// StreamStateEntity#PLAYBACK_SAVE_THRESHOLD_START_MILLISECONDS
|
||||
|| streamStateEntity == null
|
||||
|| (!removePartiallyWatched
|
||||
&& !streamStateEntity.isFinished(duration))) {
|
||||
itemsToKeep.add(playlistItem);
|
||||
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
||||
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
||||
== playlistItem.getStreamEntity().getUid()) {
|
||||
thumbnailVideoRemoved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,6 +888,35 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a confirmation dialog to remove watched streams from the playlist.
|
||||
* The user can also choose to remove partially watched streams.
|
||||
*/
|
||||
private void openRemoveWatchedConfirmationDialog() {
|
||||
final android.widget.CheckBox removePartiallyWatchedCheckbox =
|
||||
new android.widget.CheckBox(requireContext());
|
||||
removePartiallyWatchedCheckbox.setText(
|
||||
R.string.remove_watched_popup_partially_watched_streams);
|
||||
|
||||
// Wrap the checkbox in a container with dialog-like horizontal padding
|
||||
// so it aligns with the dialog title and message on the start side.
|
||||
final LinearLayout checkboxContainer = new LinearLayout(requireContext());
|
||||
checkboxContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
final int padding = DeviceUtils.dpToPx(20, requireContext());
|
||||
checkboxContainer.setPadding(padding, padding, padding, 0);
|
||||
checkboxContainer.addView(removePartiallyWatchedCheckbox,
|
||||
new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
|
||||
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setMessage(R.string.remove_watched_popup_warning)
|
||||
.setTitle(R.string.remove_watched_popup_title)
|
||||
.setView(checkboxContainer)
|
||||
.setPositiveButton(R.string.yes, (d, id) ->
|
||||
removeWatchedStreams(removePartiallyWatchedCheckbox.isChecked()))
|
||||
.setNegativeButton(R.string.cancel, (d, id) -> d.cancel())
|
||||
.show();
|
||||
}
|
||||
|
||||
public void setTabsPagerAdapter(
|
||||
@Nullable final MainFragment.SelectedTabsPagerAdapter tabsPagerAdapter) {
|
||||
this.tabsPagerAdapter = tabsPagerAdapter;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.schabi.newpipe.local.subscription
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
@@ -14,8 +13,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.MimeTypeMap
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
@@ -26,9 +23,6 @@ import com.xwray.groupie.GroupAdapter
|
||||
import com.xwray.groupie.Section
|
||||
import com.xwray.groupie.viewbinding.GroupieViewHolder
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.database.feed.model.FeedGroupEntity.Companion.GROUP_ALL_ID
|
||||
import org.schabi.newpipe.databinding.DialogTitleBinding
|
||||
@@ -52,10 +46,6 @@ import org.schabi.newpipe.local.subscription.item.FeedGroupCarouselItem
|
||||
import org.schabi.newpipe.local.subscription.item.GroupsHeader
|
||||
import org.schabi.newpipe.local.subscription.item.Header
|
||||
import org.schabi.newpipe.local.subscription.item.ImportSubscriptionsHintPlaceholderItem
|
||||
import org.schabi.newpipe.local.subscription.workers.SubscriptionExportWorker
|
||||
import org.schabi.newpipe.local.subscription.workers.SubscriptionImportInput
|
||||
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard
|
||||
import org.schabi.newpipe.streams.io.StoredFileHelper
|
||||
import org.schabi.newpipe.ui.emptystate.setEmptyStateComposable
|
||||
import org.schabi.newpipe.util.NavigationHelper
|
||||
import org.schabi.newpipe.util.OnClickGesture
|
||||
@@ -69,6 +59,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
|
||||
private lateinit var viewModel: SubscriptionViewModel
|
||||
private lateinit var subscriptionManager: SubscriptionManager
|
||||
private lateinit var importExportHelper: SubscriptionsImportExportHelper
|
||||
private val disposables: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||
@@ -77,11 +68,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
private lateinit var feedGroupsSortMenuItem: GroupsHeader
|
||||
private val subscriptionsSection = Section()
|
||||
|
||||
private val requestExportLauncher =
|
||||
registerForActivityResult(StartActivityForResult(), this::requestExportResult)
|
||||
private val requestImportLauncher =
|
||||
registerForActivityResult(StartActivityForResult(), this::requestImportResult)
|
||||
|
||||
@State
|
||||
@JvmField
|
||||
var itemsListState: Parcelable? = null
|
||||
@@ -101,6 +87,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
subscriptionManager = SubscriptionManager(requireContext())
|
||||
importExportHelper = SubscriptionsImportExportHelper(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
@@ -141,7 +128,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
// -- Import --
|
||||
val importSubMenu = menu.addSubMenu(R.string.import_from)
|
||||
|
||||
addMenuItemToSubmenu(importSubMenu, R.string.previous_export) { onImportPreviousSelected() }
|
||||
addMenuItemToSubmenu(importSubMenu, R.string.previous_export) { importExportHelper.onImportPreviousSelected() }
|
||||
.setIcon(R.drawable.ic_backup)
|
||||
|
||||
for (service in ServiceList.all()) {
|
||||
@@ -159,7 +146,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
// -- Export --
|
||||
val exportSubMenu = menu.addSubMenu(R.string.export_to)
|
||||
|
||||
addMenuItemToSubmenu(exportSubMenu, R.string.file) { onExportSelected() }
|
||||
addMenuItemToSubmenu(exportSubMenu, R.string.file) { importExportHelper.onExportSelected() }
|
||||
.setIcon(R.drawable.ic_save)
|
||||
}
|
||||
|
||||
@@ -195,48 +182,10 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||
NavigationHelper.openSubscriptionsImportFragment(fragmentManager, serviceId)
|
||||
}
|
||||
|
||||
private fun onImportPreviousSelected() {
|
||||
NoFileManagerSafeGuard.launchSafe(
|
||||
requestImportLauncher,
|
||||
StoredFileHelper.getPicker(activity, JSON_MIME_TYPE),
|
||||
TAG,
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
|
||||
private fun onExportSelected() {
|
||||
val date = SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH).format(Date())
|
||||
val exportName = "newpipe_subscriptions_$date.json"
|
||||
|
||||
NoFileManagerSafeGuard.launchSafe(
|
||||
requestExportLauncher,
|
||||
StoredFileHelper.getNewPicker(activity, exportName, JSON_MIME_TYPE, null),
|
||||
TAG,
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
|
||||
private fun openReorderDialog() {
|
||||
FeedGroupReorderDialog().show(parentFragmentManager, null)
|
||||
}
|
||||
|
||||
private fun requestExportResult(result: ActivityResult) {
|
||||
val data = result.data?.data
|
||||
if (data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
SubscriptionExportWorker.schedule(activity, data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestImportResult(result: ActivityResult) {
|
||||
val data = result.data?.dataString
|
||||
if (data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
ImportConfirmationDialog.show(
|
||||
this,
|
||||
SubscriptionImportInput.PreviousExportMode(data)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// Fragment Views
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package org.schabi.newpipe.local.subscription
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
|
||||
import androidx.fragment.app.Fragment
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import org.schabi.newpipe.local.subscription.SubscriptionFragment.Companion.JSON_MIME_TYPE
|
||||
import org.schabi.newpipe.local.subscription.workers.SubscriptionExportWorker
|
||||
import org.schabi.newpipe.local.subscription.workers.SubscriptionImportInput
|
||||
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard
|
||||
import org.schabi.newpipe.streams.io.StoredFileHelper
|
||||
|
||||
/**
|
||||
* This class has to be created in onAttach() or onCreate().
|
||||
*
|
||||
* It contains registerForActivityResult calls and those
|
||||
* calls are only allowed before a fragment/activity is created.
|
||||
*/
|
||||
class SubscriptionsImportExportHelper(
|
||||
val fragment: Fragment
|
||||
) {
|
||||
val context: Context = fragment.requireContext()
|
||||
|
||||
companion object {
|
||||
val TAG: String =
|
||||
SubscriptionsImportExportHelper::class.java.simpleName + "@" + Integer.toHexString(
|
||||
hashCode()
|
||||
)
|
||||
}
|
||||
|
||||
private val requestExportLauncher =
|
||||
fragment.registerForActivityResult(StartActivityForResult(), this::requestExportResult)
|
||||
private val requestImportLauncher =
|
||||
fragment.registerForActivityResult(StartActivityForResult(), this::requestImportResult)
|
||||
|
||||
private fun requestExportResult(result: ActivityResult) {
|
||||
val data = result.data?.data
|
||||
if (data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
SubscriptionExportWorker.schedule(context, data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestImportResult(result: ActivityResult) {
|
||||
val data = result.data?.dataString
|
||||
if (data != null && result.resultCode == Activity.RESULT_OK) {
|
||||
ImportConfirmationDialog.show(
|
||||
fragment,
|
||||
SubscriptionImportInput.PreviousExportMode(data)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onExportSelected() {
|
||||
val date = SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH).format(Date())
|
||||
val exportName = "newpipe_subscriptions_$date.json"
|
||||
|
||||
NoFileManagerSafeGuard.launchSafe(
|
||||
requestExportLauncher,
|
||||
StoredFileHelper.getNewPicker(
|
||||
context,
|
||||
exportName,
|
||||
JSON_MIME_TYPE,
|
||||
null
|
||||
),
|
||||
TAG,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
fun onImportPreviousSelected() {
|
||||
NoFileManagerSafeGuard.launchSafe(
|
||||
requestImportLauncher,
|
||||
StoredFileHelper.getPicker(context, JSON_MIME_TYPE),
|
||||
TAG,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||
groupIcon = feedGroupEntity?.icon
|
||||
groupSortOrder = feedGroupEntity?.sortOrder ?: -1
|
||||
|
||||
val feedGroupIcon = if (selectedIcon == null) icon else selectedIcon!!
|
||||
val feedGroupIcon = selectedIcon ?: icon
|
||||
feedGroupCreateBinding.iconPreview.setImageResource(feedGroupIcon.getDrawableRes())
|
||||
|
||||
if (feedGroupCreateBinding.groupNameInput.text.isNullOrBlank()) {
|
||||
@@ -507,7 +507,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||
private fun hideKeyboardSearch() {
|
||||
inputMethodManager.hideSoftInputFromWindow(
|
||||
searchLayoutBinding.toolbarSearchEditText.windowToken,
|
||||
InputMethodManager.RESULT_UNCHANGED_SHOWN
|
||||
InputMethodManager.HIDE_NOT_ALWAYS
|
||||
)
|
||||
searchLayoutBinding.toolbarSearchEditText.clearFocus()
|
||||
}
|
||||
@@ -524,7 +524,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||
private fun hideKeyboard() {
|
||||
inputMethodManager.hideSoftInputFromWindow(
|
||||
feedGroupCreateBinding.groupNameInput.windowToken,
|
||||
InputMethodManager.RESULT_UNCHANGED_SHOWN
|
||||
InputMethodManager.HIDE_NOT_ALWAYS
|
||||
)
|
||||
feedGroupCreateBinding.groupNameInput.clearFocus()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.navigation
|
||||
|
||||
import androidx.activity.compose.LocalActivity
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.core.content.IntentCompat
|
||||
import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDecorator
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import androidx.navigation3.runtime.entryProvider
|
||||
import androidx.navigation3.runtime.rememberNavBackStack
|
||||
import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator
|
||||
import androidx.navigation3.ui.NavDisplay
|
||||
import org.schabi.newpipe.ComposeActivity
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.error.ErrorInfo
|
||||
import org.schabi.newpipe.error.ErrorReportHelper
|
||||
import org.schabi.newpipe.ui.components.common.ScaffoldWithToolbar
|
||||
import org.schabi.newpipe.ui.screens.AboutScreen
|
||||
import org.schabi.newpipe.ui.screens.ErrorReportEvent
|
||||
import org.schabi.newpipe.ui.screens.ErrorReportScreen
|
||||
import org.schabi.newpipe.ui.screens.settings.debug.DebugScreen
|
||||
import org.schabi.newpipe.ui.screens.settings.home.SettingsHomeScreen
|
||||
|
||||
/**
|
||||
* Top-level navigation display for all Compose screens in the app.
|
||||
* @param startDestination the initial screen to display, resolved from the launching Intent.
|
||||
*/
|
||||
@Composable
|
||||
fun NavDisplay(startDestination: NavKey) {
|
||||
val backstack = rememberNavBackStack(startDestination)
|
||||
val context = LocalContext.current
|
||||
|
||||
// TODO: Drop this logic once everything is in Compose
|
||||
val activity = LocalActivity.current
|
||||
|
||||
fun onNavigateUp() {
|
||||
if (backstack.size > 1) {
|
||||
backstack.removeLastOrNull()
|
||||
} else {
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
NavDisplay(
|
||||
backStack = backstack,
|
||||
onBack = ::onNavigateUp,
|
||||
entryDecorators = listOf(
|
||||
rememberSaveableStateHolderNavEntryDecorator(),
|
||||
rememberViewModelStoreNavEntryDecorator()
|
||||
),
|
||||
entryProvider = entryProvider {
|
||||
// About
|
||||
entry<Screen.About> {
|
||||
ScaffoldWithToolbar(
|
||||
title = stringResource(R.string.title_activity_about),
|
||||
onBackClick = ::onNavigateUp
|
||||
) { padding ->
|
||||
AboutScreen(padding)
|
||||
}
|
||||
}
|
||||
|
||||
// Error Report
|
||||
entry<Screen.Error> {
|
||||
val errorInfo = remember {
|
||||
IntentCompat.getParcelableExtra(
|
||||
activity!!.intent,
|
||||
ComposeActivity.EXTRA_ERROR_INFO,
|
||||
ErrorInfo::class.java
|
||||
)!!
|
||||
}
|
||||
|
||||
ErrorReportScreen(
|
||||
errorInfo = errorInfo,
|
||||
onEvent = { event ->
|
||||
when (event) {
|
||||
is ErrorReportEvent.ReportViaEmail ->
|
||||
ErrorReportHelper.sendErrorEmail(context, errorInfo, event.comment)
|
||||
|
||||
is ErrorReportEvent.CopyForGitHub ->
|
||||
ErrorReportHelper.copyForGitHub(context, errorInfo, event.comment)
|
||||
|
||||
is ErrorReportEvent.ReportOnGitHub ->
|
||||
ErrorReportHelper.openGitHubIssues(context)
|
||||
|
||||
is ErrorReportEvent.ReadPrivacyPolicy ->
|
||||
ErrorReportHelper.openPrivacyPolicy(context)
|
||||
|
||||
is ErrorReportEvent.ShareError ->
|
||||
ErrorReportHelper.shareError(context, errorInfo, event.comment)
|
||||
|
||||
is ErrorReportEvent.NavigateUp ->
|
||||
onNavigateUp()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Settings
|
||||
entry<Screen.Settings.Home> {
|
||||
SettingsHomeScreen(
|
||||
onNavigate = { screen -> backstack.add(screen) },
|
||||
onBackClick = ::onNavigateUp
|
||||
)
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Player> {
|
||||
Text(stringResource(id = R.string.settings_category_player_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Behaviour> {
|
||||
Text(stringResource(id = R.string.settings_category_player_behavior_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Download> {
|
||||
Text(stringResource(id = R.string.settings_category_downloads_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.LookFeel> {
|
||||
Text(stringResource(id = R.string.settings_category_look_and_feel_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.HistoryCache> {
|
||||
Text(stringResource(id = R.string.settings_category_history_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Content> {
|
||||
Text(stringResource(id = R.string.settings_category_content_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Feed> {
|
||||
Text(stringResource(id = R.string.settings_category_feed_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Services> {
|
||||
Text(stringResource(id = R.string.settings_category_services_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Language> {
|
||||
Text(stringResource(id = R.string.settings_category_language_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.BackupRestore> {
|
||||
Text(stringResource(id = R.string.settings_category_backup_restore_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Updates> {
|
||||
Text(stringResource(id = R.string.settings_category_updates_title))
|
||||
}
|
||||
|
||||
entry<Screen.Settings.Debug> {
|
||||
DebugScreen(onBackClick = { backstack.removeLastOrNull() })
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.navigation
|
||||
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface Screen : NavKey {
|
||||
|
||||
@Serializable
|
||||
data object About : Screen
|
||||
|
||||
@Serializable
|
||||
data object Error : Screen
|
||||
|
||||
sealed interface Settings : Screen {
|
||||
@Serializable
|
||||
data object Home : Settings
|
||||
|
||||
@Serializable
|
||||
data object Player : Settings
|
||||
|
||||
@Serializable
|
||||
data object Behaviour : Settings
|
||||
|
||||
@Serializable
|
||||
data object Download : Settings
|
||||
|
||||
@Serializable
|
||||
data object LookFeel : Settings
|
||||
|
||||
@Serializable
|
||||
data object HistoryCache : Settings
|
||||
|
||||
@Serializable
|
||||
data object Content : Settings
|
||||
|
||||
@Serializable
|
||||
data object Feed : Settings
|
||||
|
||||
@Serializable
|
||||
data object Services : Settings
|
||||
|
||||
@Serializable
|
||||
data object Language : Settings
|
||||
|
||||
@Serializable
|
||||
data object BackupRestore : Settings
|
||||
|
||||
@Serializable
|
||||
data object Updates : Settings
|
||||
|
||||
@Serializable
|
||||
data object Debug : Settings
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,20 @@ class CommentRepliesSource(
|
||||
private val service = NewPipe.getService(commentInfo.serviceId)
|
||||
|
||||
override suspend fun load(params: LoadParams<Page>): LoadResult<Page, CommentsInfoItem> {
|
||||
// params.key is null the first time load() is called, and we need to return the first page
|
||||
val repliesPage = params.key ?: commentInfo.replies
|
||||
val info = withContext(Dispatchers.IO) {
|
||||
CommentsInfo.getMoreItems(service, commentInfo.url, repliesPage)
|
||||
return try {
|
||||
// params.key is null the first time load() is called, and we need to return the first page
|
||||
val repliesPage = params.key ?: commentInfo.replies
|
||||
|
||||
val info = withContext(Dispatchers.IO) {
|
||||
CommentsInfo.getMoreItems(service, commentInfo.url, repliesPage)
|
||||
}
|
||||
|
||||
LoadResult.Page(info.items, null, info.nextPage)
|
||||
} catch (e: Exception) {
|
||||
// Catches UnknownHostException (offline) or any extraction errors
|
||||
// and tells Paging3 to show the error state in the UI.
|
||||
LoadResult.Error(e)
|
||||
}
|
||||
return LoadResult.Page(info.items, null, info.nextPage)
|
||||
}
|
||||
|
||||
override fun getRefreshKey(state: PagingState<Page, CommentsInfoItem>) = null
|
||||
|
||||
@@ -20,11 +20,14 @@ class CommentsSource(private val commentInfo: CommentInfo) : PagingSource<Page,
|
||||
if (params.key == null) {
|
||||
return LoadResult.Page(commentInfo.comments, null, commentInfo.nextPage)
|
||||
} else {
|
||||
val info = withContext(Dispatchers.IO) {
|
||||
CommentsInfo.getMoreItems(service, commentInfo.url, params.key)
|
||||
return try {
|
||||
val info = withContext(Dispatchers.IO) {
|
||||
CommentsInfo.getMoreItems(service, commentInfo.url, params.key)
|
||||
}
|
||||
LoadResult.Page(info.items, null, info.nextPage)
|
||||
} catch (exception: Exception) {
|
||||
LoadResult.Error(exception)
|
||||
}
|
||||
|
||||
return LoadResult.Page(info.items, null, info.nextPage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,39 +167,39 @@ public final class PlayQueueActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
NavigationHelper.openSettings(this);
|
||||
return true;
|
||||
case R.id.action_append_playlist:
|
||||
PlaylistDialog.showForPlayQueue(player, getSupportFragmentManager());
|
||||
return true;
|
||||
case R.id.action_playback_speed:
|
||||
openPlaybackParameterDialog();
|
||||
return true;
|
||||
case R.id.action_mute:
|
||||
player.toggleMute();
|
||||
return true;
|
||||
case R.id.action_system_audio:
|
||||
startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS));
|
||||
return true;
|
||||
case R.id.action_switch_main:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_settings) {
|
||||
NavigationHelper.openSettings(this);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_append_playlist) {
|
||||
PlaylistDialog.showForPlayQueue(player, getSupportFragmentManager());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_playback_speed) {
|
||||
openPlaybackParameterDialog();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_mute) {
|
||||
player.toggleMute();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_system_audio) {
|
||||
startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS));
|
||||
return true;
|
||||
} else if (itemId == R.id.action_switch_main) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnMainPlayer(this, player.getPlayQueue(), true);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_switch_popup) {
|
||||
if (PermissionHelper.isPopupEnabledElseAsk(this)) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnMainPlayer(this, player.getPlayQueue(), true);
|
||||
return true;
|
||||
case R.id.action_switch_popup:
|
||||
if (PermissionHelper.isPopupEnabledElseAsk(this)) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnPopupPlayer(this, player.getPlayQueue(), true);
|
||||
}
|
||||
return true;
|
||||
case R.id.action_switch_background:
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnBackgroundPlayer(this, player.getPlayQueue(), true);
|
||||
return true;
|
||||
NavigationHelper.playOnPopupPlayer(this, player.getPlayQueue(), true);
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.action_switch_background) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnBackgroundPlayer(this, player.getPlayQueue(), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getGroupId() == MENU_ID_AUDIO_TRACK) {
|
||||
|
||||
@@ -112,6 +112,7 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||
import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver.SourceType;
|
||||
import org.schabi.newpipe.player.ui.BackgroundPlayerUi;
|
||||
import org.schabi.newpipe.player.ui.MainPlayerUi;
|
||||
import org.schabi.newpipe.player.ui.PlayerUi;
|
||||
import org.schabi.newpipe.player.ui.PlayerUiList;
|
||||
@@ -269,6 +270,7 @@ public final class Player implements PlaybackListener, Listener {
|
||||
@NonNull
|
||||
private final HistoryRecordManager recordManager;
|
||||
|
||||
private boolean screenOn = true;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@@ -478,7 +480,7 @@ public final class Player implements PlaybackListener, Listener {
|
||||
&& newQueue.size() == 1 && newQueue.getItem() != null
|
||||
&& playQueue != null && playQueue.size() == 1 && playQueue.getItem() != null
|
||||
&& newQueue.getItem().equals(playQueue.getItem())
|
||||
&& newQueue.getItem().getRecoveryPosition() != Long.MIN_VALUE) {
|
||||
&& newQueue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
|
||||
// Player can have state = IDLE when playback is stopped or failed
|
||||
// and we should retry in this case
|
||||
if (simpleExoPlayer.getPlaybackState()
|
||||
@@ -507,7 +509,7 @@ public final class Player implements PlaybackListener, Listener {
|
||||
&& (playQueue == null || !playQueue.equalStreamsAndIndex(newQueue))
|
||||
&& !newQueue.isEmpty()
|
||||
&& newQueue.getItem() != null
|
||||
&& newQueue.getItem().getRecoveryPosition() == Long.MIN_VALUE) {
|
||||
&& newQueue.getItem().getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
||||
databaseUpdateDisposable.add(recordManager.loadStreamState(newQueue.getItem())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
// Do not place initPlayback() in doFinally() because
|
||||
@@ -560,17 +562,13 @@ public final class Player implements PlaybackListener, Listener {
|
||||
if (queueCache == null) {
|
||||
return null;
|
||||
}
|
||||
final PlayQueue newQueue = SerializedCache.getInstance().take(queueCache, PlayQueue.class);
|
||||
if (newQueue == null) {
|
||||
return null;
|
||||
}
|
||||
return newQueue;
|
||||
return SerializedCache.getInstance().take(queueCache, PlayQueue.class);
|
||||
}
|
||||
|
||||
private void initUIsForCurrentPlayerType() {
|
||||
if ((UIs.get(MainPlayerUi.class) != null && playerType == PlayerType.MAIN)
|
||||
|| (UIs.get(PopupPlayerUi.class) != null
|
||||
&& playerType == PlayerType.POPUP)) {
|
||||
|| (UIs.get(BackgroundPlayerUi.class) != null && playerType == PlayerType.AUDIO)
|
||||
|| (UIs.get(PopupPlayerUi.class) != null && playerType == PlayerType.POPUP)) {
|
||||
// correct UI already in place
|
||||
return;
|
||||
}
|
||||
@@ -589,14 +587,18 @@ public final class Player implements PlaybackListener, Listener {
|
||||
switch (playerType) {
|
||||
case MAIN:
|
||||
UIs.destroyAllOfType(PopupPlayerUi.class);
|
||||
UIs.destroyAllOfType(BackgroundPlayerUi.class);
|
||||
UIs.addAndPrepare(new MainPlayerUi(this, binding));
|
||||
break;
|
||||
case POPUP:
|
||||
UIs.destroyAllOfType(MainPlayerUi.class);
|
||||
UIs.destroyAllOfType(BackgroundPlayerUi.class);
|
||||
UIs.addAndPrepare(new PopupPlayerUi(this, binding));
|
||||
break;
|
||||
case AUDIO:
|
||||
// destroys both MainPlayerUi and PopupPlayerUi
|
||||
UIs.destroyAllOfType(VideoPlayerUi.class);
|
||||
UIs.addAndPrepare(new BackgroundPlayerUi(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -844,6 +846,12 @@ public final class Player implements PlaybackListener, Listener {
|
||||
case ACTION_SHUFFLE:
|
||||
toggleShuffleModeEnabled();
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_OFF:
|
||||
screenOn = false;
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_ON:
|
||||
screenOn = true;
|
||||
break;
|
||||
case Intent.ACTION_CONFIGURATION_CHANGED:
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "ACTION_CONFIGURATION_CHANGED received");
|
||||
@@ -1692,7 +1700,7 @@ public final class Player implements PlaybackListener, Listener {
|
||||
}
|
||||
|
||||
// sync the player index with the queue index, and seek to the correct position
|
||||
if (item.getRecoveryPosition() != Long.MIN_VALUE) {
|
||||
if (item.getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
|
||||
simpleExoPlayer.seekTo(playQueueIndex, item.getRecoveryPosition());
|
||||
playQueue.unsetRecovery(playQueueIndex);
|
||||
} else {
|
||||
@@ -1753,6 +1761,13 @@ public final class Player implements PlaybackListener, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (isStopped()) {
|
||||
// Some phones suspend a paused player after 10 minutes. This causes the player to
|
||||
// enter STATE_IDLE, causing playback to fail. So we try to recover from that here.
|
||||
setRecovery();
|
||||
reloadPlayQueueManager();
|
||||
}
|
||||
|
||||
simpleExoPlayer.play();
|
||||
saveStreamProgressState();
|
||||
}
|
||||
@@ -2021,7 +2036,7 @@ public final class Player implements PlaybackListener, Listener {
|
||||
// resolver was called when the app was in background, the app will only stream audio when
|
||||
// the user come back to the app and will never fetch the video stream.
|
||||
// Note that the video is not fetched when the app is in background because the video
|
||||
// renderer is fully disabled (see useVideoSource method), except for HLS streams
|
||||
// renderer is fully disabled (see useVideoAndSubtitles method), except for HLS streams
|
||||
// (see https://github.com/google/ExoPlayer/issues/9282).
|
||||
return videoResolver.resolve(info);
|
||||
}
|
||||
@@ -2195,12 +2210,19 @@ public final class Player implements PlaybackListener, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void useVideoSource(final boolean videoEnabled) {
|
||||
if (playQueue == null || audioPlayerSelected()) {
|
||||
public void useVideoAndSubtitles(final boolean videoAndSubtitlesEnabled) {
|
||||
if (playQueue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
isAudioOnly = !videoEnabled;
|
||||
isAudioOnly = !videoAndSubtitlesEnabled;
|
||||
|
||||
final var item = playQueue.getItem();
|
||||
final boolean hasPendingRecovery =
|
||||
item != null && item.getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET;
|
||||
final boolean hasTimeline =
|
||||
!exoPlayerIsNull() && !simpleExoPlayer.getCurrentTimeline().isEmpty();
|
||||
|
||||
|
||||
getCurrentStreamInfo().ifPresentOrElse(info -> {
|
||||
// In case we don't know the source type, fall back to either video-with-audio, or
|
||||
@@ -2208,27 +2230,34 @@ public final class Player implements PlaybackListener, Listener {
|
||||
final SourceType sourceType = videoResolver.getStreamSourceType()
|
||||
.orElse(SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY);
|
||||
|
||||
if (hasTimeline || !hasPendingRecovery) {
|
||||
// making sure to save playback position before reloadPlayQueueManager()
|
||||
setRecovery();
|
||||
}
|
||||
|
||||
if (playQueueManagerReloadingNeeded(sourceType, info, getVideoRendererIndex())) {
|
||||
reloadPlayQueueManager();
|
||||
}
|
||||
|
||||
setRecovery();
|
||||
|
||||
// Disable or enable video and subtitles renderers depending of the videoEnabled value
|
||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoEnabled)
|
||||
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoEnabled));
|
||||
}, () -> {
|
||||
/*
|
||||
The current metadata may be null sometimes (for e.g. when using an unstable connection
|
||||
in livestreams) so we will be not able to execute the block below
|
||||
in livestreams) so we will be not able to execute the block above
|
||||
|
||||
Reload the play queue manager in this case, which is the behavior when we don't know the
|
||||
index of the video renderer or playQueueManagerReloadingNeeded returns true
|
||||
*/
|
||||
if (hasTimeline || !hasPendingRecovery) {
|
||||
// making sure to save playback position before reloadPlayQueueManager()
|
||||
setRecovery();
|
||||
}
|
||||
reloadPlayQueueManager();
|
||||
setRecovery();
|
||||
});
|
||||
|
||||
// Disable or enable video and subtitles renderers depending of the
|
||||
// videoAndSubtitlesEnabled value
|
||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
||||
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoAndSubtitlesEnabled)
|
||||
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoAndSubtitlesEnabled));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2461,4 +2490,11 @@ public final class Player implements PlaybackListener, Listener {
|
||||
.orElse(RENDERER_UNAVAILABLE);
|
||||
}
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* @return whether the device screen is turned on.
|
||||
*/
|
||||
public boolean isScreenOn() {
|
||||
return screenOn;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getAndroidUserAgent;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getIosUserAgent;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTvHtml5UserAgent;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getVisionOsUserAgent;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isAndroidStreamingUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isIosStreamingUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isTvHtml5StreamingUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isVisionOsStreamingUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebStreamingUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isWebEmbeddedPlayerStreamingUrl;
|
||||
import static java.lang.Math.min;
|
||||
@@ -661,10 +661,7 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isTvHtml5StreamingUrl = isTvHtml5StreamingUrl(requestUrl);
|
||||
|
||||
if (isWebStreamingUrl(requestUrl)
|
||||
|| isTvHtml5StreamingUrl
|
||||
|| isWebEmbeddedPlayerStreamingUrl(requestUrl)) {
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.ORIGIN, YOUTUBE_BASE_URL);
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.REFERER, YOUTUBE_BASE_URL);
|
||||
@@ -675,19 +672,17 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
|
||||
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.TE, "trailers");
|
||||
|
||||
final boolean isAndroidStreamingUrl = isAndroidStreamingUrl(requestUrl);
|
||||
final boolean isIosStreamingUrl = isIosStreamingUrl(requestUrl);
|
||||
if (isAndroidStreamingUrl) {
|
||||
if (isAndroidStreamingUrl(requestUrl)) {
|
||||
// Improvement which may be done: find the content country used to request YouTube
|
||||
// contents to add it in the user agent instead of using the default
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
|
||||
getAndroidUserAgent(null));
|
||||
} else if (isIosStreamingUrl) {
|
||||
} else if (isIosStreamingUrl(requestUrl)) {
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
|
||||
getIosUserAgent(null));
|
||||
} else if (isTvHtml5StreamingUrl) {
|
||||
} else if (isVisionOsStreamingUrl(requestUrl)) {
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT,
|
||||
getTvHtml5UserAgent());
|
||||
getVisionOsUserAgent(null));
|
||||
} else {
|
||||
// non-mobile user agent
|
||||
httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT, DownloaderImpl.USER_AGENT);
|
||||
|
||||
@@ -47,6 +47,9 @@ abstract class BasePlayerGestureListener(
|
||||
startMultiDoubleTap(event)
|
||||
} else if (portion === DisplayPortion.MIDDLE) {
|
||||
player.playPause()
|
||||
if (player.isPlaying) {
|
||||
playerUi.hideControls(0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,13 @@ public class PlayerDataSource {
|
||||
getDefaultDashChunkSourceFactory(cachelessDataSourceFactory),
|
||||
cachelessDataSourceFactory);
|
||||
}
|
||||
|
||||
public DashMediaSource.Factory getLiveYoutubeDashMediaSourceFactory() {
|
||||
return new DashMediaSource.Factory(
|
||||
getDefaultDashChunkSourceFactory(cachelessDataSourceFactory),
|
||||
cachelessDataSourceFactory)
|
||||
.setManifestParser(new YoutubeDashLiveManifestParser());
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@ import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PlayerHelper {
|
||||
private static final FormattersProvider FORMATTERS_PROVIDER = new FormattersProvider();
|
||||
@@ -87,11 +87,11 @@ public final class PlayerHelper {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getTimeString(final int milliSeconds) {
|
||||
final int seconds = (milliSeconds % 60000) / 1000;
|
||||
final int minutes = (milliSeconds % 3600000) / 60000;
|
||||
final int hours = (milliSeconds % 86400000) / 3600000;
|
||||
final int days = (milliSeconds % (86400000 * 7)) / 86400000;
|
||||
public static String getTimeString(final long milliSeconds) {
|
||||
final long seconds = (milliSeconds % 60000) / 1000;
|
||||
final long minutes = (milliSeconds % 3600000) / 60000;
|
||||
final long hours = (milliSeconds % 86400000) / 3600000;
|
||||
final long days = (milliSeconds % (86400000 * 7)) / 86400000;
|
||||
|
||||
final Formatters formatters = FORMATTERS_PROVIDER.formatters();
|
||||
if (days > 0) {
|
||||
@@ -174,10 +174,9 @@ public final class PlayerHelper {
|
||||
@Nullable
|
||||
public static PlayQueue autoQueueOf(@NonNull final StreamInfo info,
|
||||
@NonNull final List<PlayQueueItem> existingItems) {
|
||||
final Set<String> urls = new HashSet<>(existingItems.size());
|
||||
for (final PlayQueueItem item : existingItems) {
|
||||
urls.add(item.getUrl());
|
||||
}
|
||||
final Set<String> urls = existingItems.stream()
|
||||
.map(PlayQueueItem::getUrl)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
final List<InfoItem> relatedItems = info.getRelatedItems();
|
||||
if (Utils.isNullOrEmpty(relatedItems)) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.schabi.newpipe.player.helper;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.Period;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.ProgramInformation;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.ServiceDescriptionElement;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.UtcTimingElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link DashManifestParser} fixing YouTube DASH manifests to allow starting playback from the
|
||||
* newest period available instead of the earliest one in some cases.
|
||||
*
|
||||
* <p>
|
||||
* It changes the {@code availabilityStartTime} passed to a custom value doing the workaround.
|
||||
* A better approach to fix the issue should be investigated and used in the future.
|
||||
* </p>
|
||||
*/
|
||||
public class YoutubeDashLiveManifestParser extends DashManifestParser {
|
||||
|
||||
// Result of Util.parseXsDateTime("1970-01-01T00:00:00Z")
|
||||
private static final long AVAILABILITY_START_TIME_TO_USE = 0;
|
||||
|
||||
// There is no computation made with the availabilityStartTime value in the
|
||||
// parseMediaPresentationDescription method itself, so we can just override methods called in
|
||||
// this method using the workaround value
|
||||
// Overriding parsePeriod does not seem to be needed
|
||||
|
||||
@SuppressWarnings("checkstyle:ParameterNumber")
|
||||
@NonNull
|
||||
@Override
|
||||
protected DashManifest buildMediaPresentationDescription(
|
||||
final long availabilityStartTime,
|
||||
final long durationMs,
|
||||
final long minBufferTimeMs,
|
||||
final boolean dynamic,
|
||||
final long minUpdateTimeMs,
|
||||
final long timeShiftBufferDepthMs,
|
||||
final long suggestedPresentationDelayMs,
|
||||
final long publishTimeMs,
|
||||
@Nullable final ProgramInformation programInformation,
|
||||
@Nullable final UtcTimingElement utcTiming,
|
||||
@Nullable final ServiceDescriptionElement serviceDescription,
|
||||
@Nullable final Uri location,
|
||||
@NonNull final List<Period> periods) {
|
||||
return super.buildMediaPresentationDescription(
|
||||
AVAILABILITY_START_TIME_TO_USE,
|
||||
durationMs,
|
||||
minBufferTimeMs,
|
||||
dynamic,
|
||||
minUpdateTimeMs,
|
||||
timeShiftBufferDepthMs,
|
||||
suggestedPresentationDelayMs,
|
||||
publishTimeMs,
|
||||
programInformation,
|
||||
utcTiming,
|
||||
serviceDescription,
|
||||
location,
|
||||
periods);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ internal fun infoItemTypeToString(type: InfoType): String {
|
||||
InfoType.STREAM -> ID_STREAM
|
||||
InfoType.PLAYLIST -> ID_PLAYLIST
|
||||
InfoType.CHANNEL -> ID_CHANNEL
|
||||
else -> throw IllegalStateException("Unexpected value: $type")
|
||||
else -> error("Unexpected value: $type")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ internal fun infoItemTypeFromString(type: String): InfoType {
|
||||
ID_STREAM -> InfoType.STREAM
|
||||
ID_PLAYLIST -> InfoType.PLAYLIST
|
||||
ID_CHANNEL -> InfoType.CHANNEL
|
||||
else -> throw IllegalStateException("Unexpected value: $type")
|
||||
else -> error("Unexpected value: $type")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ import org.schabi.newpipe.util.NavigationHelper
|
||||
*/
|
||||
class MediaBrowserPlaybackPreparer(
|
||||
private val context: Context,
|
||||
private val setMediaSessionError: BiConsumer<String, Int>, // error string, error code
|
||||
private val setMediaSessionError: BiConsumer<CharSequence, Int>, // error string, error code
|
||||
private val clearMediaSessionError: Runnable,
|
||||
private val onPrepare: Consumer<Boolean>
|
||||
) : PlaybackPreparer {
|
||||
@@ -118,7 +118,7 @@ class MediaBrowserPlaybackPreparer(
|
||||
|
||||
private fun onPrepareError(throwable: Throwable) {
|
||||
setMediaSessionError.accept(
|
||||
ErrorInfo.getMessage(throwable, null, null).getString(context),
|
||||
ErrorInfo.getMessage(throwable, null, null).getText(context),
|
||||
PlaybackStateCompat.ERROR_CODE_APP_ERROR
|
||||
)
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ internal class PackageValidator(context: Context) {
|
||||
|
||||
// Build the caller info for the rest of the checks here.
|
||||
val callerPackageInfo = buildCallerInfo(callingPackage)
|
||||
?: throw IllegalStateException("Caller wasn't found in the system?")
|
||||
?: error("Caller wasn't found in the system?")
|
||||
|
||||
// Verify that things aren't ... broken. (This test should always pass.)
|
||||
if (callerPackageInfo.uid != callingUid) {
|
||||
throw IllegalStateException("Caller's package UID doesn't match caller's actual UID?")
|
||||
check(callerPackageInfo.uid == callingUid) {
|
||||
"Caller's package UID doesn't match caller's actual UID?"
|
||||
}
|
||||
|
||||
val callerSignature = callerPackageInfo.signature
|
||||
@@ -202,7 +202,7 @@ internal class PackageValidator(context: Context) {
|
||||
*/
|
||||
private fun getSystemSignature(): String = getPackageInfo(ANDROID_PLATFORM)?.let { platformInfo ->
|
||||
getSignature(platformInfo)
|
||||
} ?: throw IllegalStateException("Platform signature not found")
|
||||
} ?: error("Platform signature not found")
|
||||
|
||||
/**
|
||||
* Creates a SHA-256 signature given a certificate byte array.
|
||||
|
||||
@@ -72,7 +72,9 @@ public final class NotificationUtil {
|
||||
notificationBuilder = createNotification();
|
||||
}
|
||||
updateNotification();
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
||||
if (notificationManager.areNotificationsEnabled()) {
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateThumbnail() {
|
||||
@@ -84,7 +86,9 @@ public final class NotificationUtil {
|
||||
}
|
||||
|
||||
setLargeIcon(notificationBuilder);
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
||||
if (notificationManager.areNotificationsEnabled()) {
|
||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RecoveryEvent
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ReorderEvent
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.SelectEvent
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueItem
|
||||
|
||||
/**
|
||||
* PlayQueue is responsible for keeping track of a list of streams and the index of
|
||||
@@ -390,7 +391,7 @@ abstract class PlayQueue internal constructor(
|
||||
*/
|
||||
@Synchronized
|
||||
fun unsetRecovery(index: Int) {
|
||||
setRecovery(index, Long.Companion.MIN_VALUE)
|
||||
setRecovery(index, PlayQueueItem.RECOVERY_UNSET)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.player.playqueue;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -22,30 +27,6 @@ import java.util.List;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 01.08.16.
|
||||
* <p>
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* InfoListAdapter.java is part of NewPipe.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class PlayQueueAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private static final String TAG = PlayQueueAdapter.class.toString();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class PlayQueueItem private constructor(
|
||||
var isAutoQueued: Boolean = false
|
||||
|
||||
// package-private
|
||||
var recoveryPosition = Long.Companion.MIN_VALUE
|
||||
var recoveryPosition = RECOVERY_UNSET
|
||||
var error: Throwable? = null
|
||||
private set
|
||||
|
||||
@@ -68,4 +68,8 @@ class PlayQueueItem private constructor(
|
||||
override fun equals(o: Any?) = o is PlayQueueItem && serviceId == o.serviceId && url == o.url
|
||||
|
||||
override fun hashCode() = Objects.hash(url, serviceId)
|
||||
|
||||
companion object {
|
||||
const val RECOVERY_UNSET = Long.MIN_VALUE
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2021 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.player.playqueue;
|
||||
|
||||
import android.view.View;
|
||||
@@ -8,30 +13,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 01.08.16.
|
||||
* <p>
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* StreamInfoItemHolder.java is part of NewPipe.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class PlayQueueItemHolder extends RecyclerView.ViewHolder {
|
||||
public final TextView itemVideoTitleView;
|
||||
public final TextView itemDurationView;
|
||||
|
||||
@@ -5,8 +5,8 @@ import androidx.annotation.NonNull;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class SinglePlayQueue extends PlayQueue {
|
||||
public SinglePlayQueue(final StreamInfoItem item) {
|
||||
@@ -29,11 +29,7 @@ public final class SinglePlayQueue extends PlayQueue {
|
||||
}
|
||||
|
||||
private static List<PlayQueueItem> playQueueItemsOf(@NonNull final List<StreamInfoItem> items) {
|
||||
final List<PlayQueueItem> playQueueItems = new ArrayList<>(items.size());
|
||||
for (final StreamInfoItem item : items) {
|
||||
playQueueItems.add(new PlayQueueItem(item));
|
||||
}
|
||||
return playQueueItems;
|
||||
return items.stream().map(PlayQueueItem::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -201,12 +201,15 @@ public interface PlaybackResolver extends Resolver<StreamInfo, MediaSource> {
|
||||
|
||||
try {
|
||||
final StreamInfoTag tag = StreamInfoTag.of(info);
|
||||
if (!info.getHlsUrl().isEmpty()) {
|
||||
return buildLiveMediaSource(dataSource, info.getHlsUrl(), C.CONTENT_TYPE_HLS, tag);
|
||||
} else if (!info.getDashMpdUrl().isEmpty()) {
|
||||
// Prefer DASH over HLS because of an exoPlayer bug that causes the background player to
|
||||
// also fetch the video stream even if it is supposed to just fetch the audio stream.
|
||||
if (!info.getDashMpdUrl().isEmpty()) {
|
||||
return buildLiveMediaSource(
|
||||
dataSource, info.getDashMpdUrl(), C.CONTENT_TYPE_DASH, tag);
|
||||
}
|
||||
if (!info.getHlsUrl().isEmpty()) {
|
||||
return buildLiveMediaSource(dataSource, info.getHlsUrl(), C.CONTENT_TYPE_HLS, tag);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Log.w(TAG, "Error when generating live media source, falling back to standard sources",
|
||||
e);
|
||||
@@ -225,7 +228,11 @@ public interface PlaybackResolver extends Resolver<StreamInfo, MediaSource> {
|
||||
factory = dataSource.getLiveSsMediaSourceFactory();
|
||||
break;
|
||||
case C.CONTENT_TYPE_DASH:
|
||||
factory = dataSource.getLiveDashMediaSourceFactory();
|
||||
if (metadata.getServiceId() == ServiceList.YouTube.getServiceId()) {
|
||||
factory = dataSource.getLiveYoutubeDashMediaSourceFactory();
|
||||
} else {
|
||||
factory = dataSource.getLiveDashMediaSourceFactory();
|
||||
}
|
||||
break;
|
||||
case C.CONTENT_TYPE_HLS:
|
||||
factory = dataSource.getLiveHlsMediaSourceFactory();
|
||||
|
||||
+2
-2
@@ -134,7 +134,7 @@ public class SeekbarPreviewThumbnailHolder {
|
||||
// Get the bounds where the frame is found
|
||||
final int[] bounds = frameset.getFrameBoundsAt(currentPosMs);
|
||||
generatedDataForUrl.put(currentPosMs,
|
||||
createBitmapSupplier(srcBitMap, bounds, frameset));
|
||||
createBitmapSupplier(srcBitMap, bounds, frameset));
|
||||
|
||||
currentPosMs += frameset.getDurationPerFrame();
|
||||
pos++;
|
||||
@@ -192,7 +192,7 @@ public class SeekbarPreviewThumbnailHolder {
|
||||
// Reference: https://stackoverflow.com/a/23683075 + first comment
|
||||
// Fixes: https://github.com/TeamNewPipe/NewPipe/issues/11461
|
||||
return cutOutBitmap == srcBitMap
|
||||
? cutOutBitmap.copy(cutOutBitmap.getConfig(), true) : cutOutBitmap;
|
||||
? cutOutBitmap.copy(Bitmap.Config.ARGB_8888, true) : cutOutBitmap;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.schabi.newpipe.player.ui;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.schabi.newpipe.player.Player;
|
||||
|
||||
/**
|
||||
* This is not a "graphical" UI for the background player, but it is used to disable fetching video
|
||||
* and text tracks with it.
|
||||
*
|
||||
* <p>
|
||||
* This allows reducing data usage for manifest sources with demuxed audio and video,
|
||||
* such as livestreams.
|
||||
* </p>
|
||||
*/
|
||||
public class BackgroundPlayerUi extends PlayerUi {
|
||||
|
||||
public BackgroundPlayerUi(@NonNull final Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPlayback() {
|
||||
super.initPlayback();
|
||||
|
||||
// Make sure to disable video and subtitles track types
|
||||
player.useVideoAndSubtitles(false);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutChangeListener {
|
||||
private static final String TAG = MainPlayerUi.class.getSimpleName();
|
||||
@@ -216,6 +217,10 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
|
||||
playQueueAdapter = new PlayQueueAdapter(context,
|
||||
Objects.requireNonNull(player.getPlayQueue()));
|
||||
segmentAdapter = new StreamSegmentAdapter(getStreamSegmentListener());
|
||||
|
||||
// Make sure video and text tracks are enabled if the user is in the app, in the case user
|
||||
// switched from background player to main player
|
||||
player.useVideoAndSubtitles(fragmentIsVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,7 +336,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
|
||||
} else if (VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED.equals(intent.getAction())) {
|
||||
// Restore video source when user returns to the fragment
|
||||
fragmentIsVisible = true;
|
||||
player.useVideoSource(true);
|
||||
player.useVideoAndSubtitles(true);
|
||||
|
||||
// When a user returns from background, the system UI will always be shown even if
|
||||
// controls are invisible: hide it in that case
|
||||
@@ -370,7 +375,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
|
||||
if (player.isPlaying() || player.isLoading()) {
|
||||
switch (getMinimizeOnExitAction(context)) {
|
||||
case MINIMIZE_ON_EXIT_MODE_BACKGROUND:
|
||||
player.useVideoSource(false);
|
||||
player.useVideoAndSubtitles(false);
|
||||
break;
|
||||
case MINIMIZE_ON_EXIT_MODE_POPUP:
|
||||
getParentActivity().ifPresent(activity -> {
|
||||
@@ -745,13 +750,13 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
|
||||
}
|
||||
|
||||
private int getNearestStreamSegmentPosition(final long playbackPosition) {
|
||||
int nearestPosition = 0;
|
||||
final List<StreamSegment> segments = player.getCurrentStreamInfo()
|
||||
.map(StreamInfo::getStreamSegments)
|
||||
.orElse(Collections.emptyList());
|
||||
|
||||
for (int i = 0; i < segments.size(); i++) {
|
||||
if (segments.get(i).getStartTimeSeconds() * 1000L > playbackPosition) {
|
||||
int nearestPosition = 0;
|
||||
for (final var segment : segments) {
|
||||
if (segment.getStartTimeSeconds() * 1000L > playbackPosition) {
|
||||
break;
|
||||
}
|
||||
nearestPosition++;
|
||||
@@ -812,22 +817,13 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
|
||||
}
|
||||
|
||||
final int currentStream = playQueue.getIndex();
|
||||
int before = 0;
|
||||
int after = 0;
|
||||
|
||||
final List<PlayQueueItem> streams = playQueue.getStreams();
|
||||
final int nStreams = streams.size();
|
||||
|
||||
for (int i = 0; i < nStreams; i++) {
|
||||
if (i < currentStream) {
|
||||
before += streams.get(i).getDuration();
|
||||
} else {
|
||||
after += streams.get(i).getDuration();
|
||||
}
|
||||
}
|
||||
final long before = streams.subList(0, currentStream).stream()
|
||||
.collect(Collectors.summingLong(PlayQueueItem::getDuration)) * 1000;
|
||||
|
||||
before *= 1000;
|
||||
after *= 1000;
|
||||
final long after = streams.subList(currentStream, streams.size()).stream()
|
||||
.collect(Collectors.summingLong(PlayQueueItem::getDuration)) * 1000;
|
||||
|
||||
binding.itemsListHeaderDuration.setText(
|
||||
String.format("%s/%s",
|
||||
|
||||
@@ -152,6 +152,14 @@ public final class PopupPlayerUi extends VideoPlayerUi {
|
||||
windowManager.addView(closeOverlayBinding.getRoot(), closeOverlayLayoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPlayback() {
|
||||
super.initPlayback();
|
||||
// Make sure video and text tracks are enabled if the screen is turned on (which should
|
||||
// always be the case), in the case user switched from background player to popup player
|
||||
player.useVideoAndSubtitles(player.isScreenOn());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupElementsVisibility() {
|
||||
binding.fullscreenToggleButtonSecondaryMenu.setVisibility(View.VISIBLE);
|
||||
@@ -219,10 +227,10 @@ public final class PopupPlayerUi extends VideoPlayerUi {
|
||||
} else if (player.isPlaying() || player.isLoading()) {
|
||||
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
|
||||
// Use only audio source when screen turns off while popup player is playing
|
||||
player.useVideoSource(false);
|
||||
player.useVideoAndSubtitles(false);
|
||||
} else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
|
||||
// Restore video source when screen turns on and user was watching video in popup
|
||||
player.useVideoSource(true);
|
||||
player.useVideoAndSubtitles(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +400,10 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
|
||||
|
||||
// #6825 - Ensure that the shuffle-button is in the correct state on the UI
|
||||
setShuffleButton(player.getExoPlayer().getShuffleModeEnabled());
|
||||
|
||||
// Set repeat button to the correct UI state
|
||||
setRepeatButton(player.getExoPlayer().getRepeatMode());
|
||||
|
||||
}
|
||||
|
||||
public abstract void removeViewFromParent();
|
||||
@@ -985,6 +989,18 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
|
||||
private void setShuffleButton(final boolean shuffled) {
|
||||
binding.shuffleButton.setImageAlpha(shuffled ? 255 : 77);
|
||||
}
|
||||
|
||||
private void setRepeatButton(final int repeatMode) {
|
||||
final int resId = switch (repeatMode) {
|
||||
case REPEAT_MODE_ALL
|
||||
-> com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_all;
|
||||
case REPEAT_MODE_ONE
|
||||
-> com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_one;
|
||||
default -> com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_off;
|
||||
};
|
||||
binding.repeatButton.setImageResource(resId);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.schabi.newpipe.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.settings.viewmodel.SettingsViewModel
|
||||
import org.schabi.newpipe.ui.SwitchPreference
|
||||
import org.schabi.newpipe.ui.theme.SizeTokens
|
||||
|
||||
@Composable
|
||||
fun DebugScreen(viewModel: SettingsViewModel, modifier: Modifier = Modifier) {
|
||||
val settingsLayoutRedesign by viewModel.settingsLayoutRedesign.collectAsState()
|
||||
|
||||
Column(modifier = modifier) {
|
||||
SwitchPreference(
|
||||
modifier = Modifier.padding(SizeTokens.SpacingExtraSmall),
|
||||
R.string.settings_layout_redesign,
|
||||
settingsLayoutRedesign,
|
||||
viewModel::toggleSettingsLayoutRedesign
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings
|
||||
|
||||
import android.content.Intent
|
||||
|
||||
/**
|
||||
* Build variant dependent (BVD) leak canary API.
|
||||
* Why is LeakCanary not used directly? Because it can't be assured to be available.
|
||||
*/
|
||||
interface DebugSettingsBVDLeakCanaryAPI {
|
||||
fun getNewLeakDisplayActivityIntent(): Intent
|
||||
|
||||
companion object {
|
||||
const val IMPL_CLASS = "org.schabi.newpipe.settings.DebugSettingsBVDLeakCanary"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -88,15 +93,4 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build variant dependent (BVD) leak canary API for this fragment.
|
||||
* Why is LeakCanary not used directly? Because it can't be assured
|
||||
*/
|
||||
public interface DebugSettingsBVDLeakCanaryAPI {
|
||||
String IMPL_CLASS =
|
||||
"org.schabi.newpipe.settings.DebugSettingsBVDLeakCanary";
|
||||
|
||||
Intent getNewLeakDisplayActivityIntent();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
@@ -33,27 +38,6 @@ import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 26.09.17.
|
||||
* SelectChannelFragment.java is part of NewPipe.
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class SelectChannelFragment extends DialogFragment {
|
||||
|
||||
private OnSelectedListener onSelectedListener = null;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
@@ -30,27 +35,6 @@ import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 26.09.17.
|
||||
* SelectChannelFragment.java is part of NewPipe.
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class SelectFeedGroupFragment extends DialogFragment {
|
||||
|
||||
private OnSelectedListener onSelectedListener = null;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2022 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
@@ -25,27 +30,6 @@ import org.schabi.newpipe.util.ThemeHelper;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 09.10.17.
|
||||
* SelectKioskFragment.java is part of NewPipe.
|
||||
* <p>
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* </p>
|
||||
* <p>
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* </p>
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class SelectKioskFragment extends DialogFragment {
|
||||
private SelectKioskAdapter selectKioskAdapter = null;
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.schabi.newpipe.settings
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.ui.TextPreference
|
||||
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
onSelectSettingOption: (SettingsScreenKey) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
TextPreference(
|
||||
title = R.string.settings_category_debug_title,
|
||||
onClick = { onSelectSettingOption(SettingsScreenKey.DEBUG) }
|
||||
)
|
||||
HorizontalDivider(color = Color.Black)
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package org.schabi.newpipe.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.settings.viewmodel.SettingsViewModel
|
||||
import org.schabi.newpipe.ui.Toolbar
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
|
||||
const val SCREEN_TITLE_KEY = "SCREEN_TITLE_KEY"
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SettingsV2Activity : ComponentActivity() {
|
||||
|
||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
val navController = rememberNavController()
|
||||
var screenTitle by remember { mutableIntStateOf(SettingsScreenKey.ROOT.screenTitle) }
|
||||
navController.addOnDestinationChangedListener { _, _, arguments ->
|
||||
screenTitle =
|
||||
arguments?.getInt(SCREEN_TITLE_KEY) ?: SettingsScreenKey.ROOT.screenTitle
|
||||
}
|
||||
|
||||
AppTheme {
|
||||
Scaffold(topBar = {
|
||||
Toolbar(
|
||||
title = stringResource(id = screenTitle),
|
||||
hasSearch = true,
|
||||
onSearchQueryChange = null // TODO: Add suggestions logic
|
||||
)
|
||||
}) { padding ->
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = SettingsScreenKey.ROOT.name,
|
||||
modifier = Modifier.padding(padding)
|
||||
) {
|
||||
composable(
|
||||
SettingsScreenKey.ROOT.name,
|
||||
listOf(createScreenTitleArg(SettingsScreenKey.ROOT.screenTitle))
|
||||
) {
|
||||
SettingsScreen(onSelectSettingOption = { screen ->
|
||||
navController.navigate(screen.name)
|
||||
})
|
||||
}
|
||||
composable(
|
||||
SettingsScreenKey.DEBUG.name,
|
||||
listOf(createScreenTitleArg(SettingsScreenKey.DEBUG.screenTitle))
|
||||
) {
|
||||
DebugScreen(settingsViewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun createScreenTitleArg(@StringRes screenTitle: Int) = navArgument(SCREEN_TITLE_KEY) {
|
||||
defaultValue = screenTitle
|
||||
}
|
||||
|
||||
enum class SettingsScreenKey(@StringRes val screenTitle: Int) {
|
||||
ROOT(R.string.settings),
|
||||
DEBUG(R.string.settings_category_debug_title)
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package org.schabi.newpipe.settings.export;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An {@link ObjectInputStream} that only allows preferences-related types to be deserialized, to
|
||||
* prevent injections. The only allowed types are: all primitive types, all boxed primitive types,
|
||||
* null, strings. HashMap, HashSet and arrays of previously defined types are also allowed. Sources:
|
||||
* <a href="https://wiki.sei.cmu.edu/confluence/display/java/SER00-J.+Enable+serialization+compatibility+during+class+evolution">
|
||||
* cmu.edu
|
||||
* </a>,
|
||||
* <a href="https://cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html#harden-your-own-javaioobjectinputstream">
|
||||
* OWASP cheatsheet
|
||||
* </a>,
|
||||
* <a href="https://commons.apache.org/proper/commons-io/apidocs/src-html/org/apache/commons/io/serialization/ValidatingObjectInputStream.html#line-118">
|
||||
* Apache's {@code ValidatingObjectInputStream}
|
||||
* </a>
|
||||
*/
|
||||
public class PreferencesObjectInputStream extends ObjectInputStream {
|
||||
|
||||
/**
|
||||
* Primitive types, strings and other built-in types do not pass through resolveClass() but
|
||||
* instead have a custom encoding; see
|
||||
* <a href="https://docs.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html#10152">
|
||||
* official docs</a>.
|
||||
*/
|
||||
private static final Set<String> CLASS_WHITELIST = Set.of(
|
||||
"java.lang.Boolean",
|
||||
"java.lang.Byte",
|
||||
"java.lang.Character",
|
||||
"java.lang.Short",
|
||||
"java.lang.Integer",
|
||||
"java.lang.Long",
|
||||
"java.lang.Float",
|
||||
"java.lang.Double",
|
||||
"java.lang.Void",
|
||||
"java.util.HashMap",
|
||||
"java.util.HashSet"
|
||||
);
|
||||
|
||||
public PreferencesObjectInputStream(final InputStream in) throws IOException {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> resolveClass(final ObjectStreamClass desc)
|
||||
throws ClassNotFoundException, IOException {
|
||||
if (CLASS_WHITELIST.contains(desc.getName())) {
|
||||
return super.resolveClass(desc);
|
||||
} else {
|
||||
throw new ClassNotFoundException("Class not allowed: " + desc.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.settings.export
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.ObjectInputStream
|
||||
import java.io.ObjectStreamClass
|
||||
|
||||
/**
|
||||
* An [ObjectInputStream] that only allows preferences-related types to be deserialized, to
|
||||
* prevent injections. The only allowed types are: all primitive types, all boxed primitive types,
|
||||
* null, strings. HashMap, HashSet and arrays of previously defined types are also allowed. Sources:
|
||||
* [cmu.edu](https://wiki.sei.cmu.edu/confluence/display/java/SER00-J.+Enable+serialization+compatibility+during+class+evolution) * ,
|
||||
* [OWASP cheatsheet](https://cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html#harden-your-own-javaioobjectinputstream) * ,
|
||||
* [Apache's `ValidatingObjectInputStream`](https://commons.apache.org/proper/commons-io/apidocs/src-html/org/apache/commons/io/serialization/ValidatingObjectInputStream.html#line-118) *
|
||||
*/
|
||||
class PreferencesObjectInputStream(stream: InputStream) : ObjectInputStream(stream) {
|
||||
@Throws(ClassNotFoundException::class, IOException::class)
|
||||
override fun resolveClass(desc: ObjectStreamClass): Class<*> {
|
||||
if (desc.name in CLASS_WHITELIST) {
|
||||
return super.resolveClass(desc)
|
||||
} else {
|
||||
throw ClassNotFoundException("Class not allowed: $desc.name")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Primitive types, strings and other built-in types do not pass through resolveClass() but
|
||||
* instead have a custom encoding; see
|
||||
* [
|
||||
* official docs](https://docs.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html#10152).
|
||||
*/
|
||||
private val CLASS_WHITELIST = setOf<String>(
|
||||
"java.lang.Boolean",
|
||||
"java.lang.Byte",
|
||||
"java.lang.Character",
|
||||
"java.lang.Short",
|
||||
"java.lang.Integer",
|
||||
"java.lang.Long",
|
||||
"java.lang.Float",
|
||||
"java.lang.Double",
|
||||
"java.lang.Void",
|
||||
"java.util.HashMap",
|
||||
"java.util.HashSet"
|
||||
)
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -12,7 +12,7 @@ import androidx.annotation.XmlRes
|
||||
*
|
||||
* @param key Key of the setting/preference. E.g. used inside [android.content.SharedPreferences].
|
||||
* @param title Title of the setting, e.g. 'Default resolution' or 'Show higher resolutions'.
|
||||
* @param summary Summary of the setting, e.g. '480p' or 'Only some devices can play 2k/4k'.
|
||||
* @param summary Summary of the setting, e.g. '480p' or 'Only some devices can play 1440p/4k'.
|
||||
* @param entries Possible entries of the setting, e.g. 480p,720p,...
|
||||
* @param breadcrumbs Breadcrumbs - a hint where the setting is located e.g. 'Video and Audio > Player'
|
||||
* @param searchIndexItemResId The xml-resource where this item was found/built from.
|
||||
@@ -26,14 +26,13 @@ data class PreferenceSearchItem(
|
||||
val breadcrumbs: String,
|
||||
@XmlRes val searchIndexItemResId: Int
|
||||
) {
|
||||
val allRelevantSearchFields: List<String>
|
||||
get() = listOf(title, summary, entries, breadcrumbs)
|
||||
|
||||
fun hasData(): Boolean {
|
||||
return !key.isEmpty() && !title.isEmpty()
|
||||
}
|
||||
|
||||
fun getAllRelevantSearchFields(): MutableList<String?> {
|
||||
return mutableListOf(title, summary, entries, breadcrumbs)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "PreferenceItem: $title $summary $key"
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ import com.grack.nanojson.JsonParserException;
|
||||
import com.grack.nanojson.JsonStringWriter;
|
||||
import com.grack.nanojson.JsonWriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Class to get a JSON representation of a list of tabs, and the other way around.
|
||||
@@ -44,39 +45,25 @@ public final class TabsJsonHelper {
|
||||
return getDefaultTabs();
|
||||
}
|
||||
|
||||
final List<Tab> returnTabs = new ArrayList<>();
|
||||
|
||||
final JsonObject outerJsonObject;
|
||||
try {
|
||||
outerJsonObject = JsonParser.object().from(tabsJson);
|
||||
final JsonObject outerJsonObject = JsonParser.object().from(tabsJson);
|
||||
|
||||
if (!outerJsonObject.has(JSON_TABS_ARRAY_KEY)) {
|
||||
throw new InvalidJsonException("JSON doesn't contain \"" + JSON_TABS_ARRAY_KEY
|
||||
+ "\" array");
|
||||
}
|
||||
|
||||
final JsonArray tabsArray = outerJsonObject.getArray(JSON_TABS_ARRAY_KEY);
|
||||
final JsonArray tabsArray = outerJsonObject.getArray(JSON_TABS_ARRAY_KEY, null);
|
||||
|
||||
for (final Object o : tabsArray) {
|
||||
if (!(o instanceof JsonObject)) {
|
||||
continue;
|
||||
}
|
||||
final var returnTabs = tabsArray.streamAsJsonObjects()
|
||||
.map(Tab::from)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
|
||||
final Tab tab = Tab.from((JsonObject) o);
|
||||
|
||||
if (tab != null) {
|
||||
returnTabs.add(tab);
|
||||
}
|
||||
}
|
||||
return returnTabs.isEmpty() ? getDefaultTabs() : returnTabs;
|
||||
} catch (final JsonParserException e) {
|
||||
throw new InvalidJsonException(e);
|
||||
}
|
||||
|
||||
if (returnTabs.isEmpty()) {
|
||||
return getDefaultTabs();
|
||||
}
|
||||
|
||||
return returnTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.schabi.newpipe.settings.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.util.Localization
|
||||
|
||||
@HiltViewModel
|
||||
class SettingsViewModel @Inject constructor(
|
||||
@ApplicationContext context: Context,
|
||||
private val preferenceManager: SharedPreferences
|
||||
) : AndroidViewModel(context.applicationContext as Application) {
|
||||
|
||||
private var settingsLayoutRedesignPref: Boolean
|
||||
get() = preferenceManager.getBoolean(
|
||||
Localization.compatGetString(getApplication(), R.string.settings_layout_redesign_key),
|
||||
false
|
||||
)
|
||||
set(value) {
|
||||
preferenceManager.edit().putBoolean(
|
||||
Localization.compatGetString(getApplication(), R.string.settings_layout_redesign_key),
|
||||
value
|
||||
).apply()
|
||||
}
|
||||
private val _settingsLayoutRedesign: MutableStateFlow<Boolean> =
|
||||
MutableStateFlow(settingsLayoutRedesignPref)
|
||||
val settingsLayoutRedesign = _settingsLayoutRedesign.asStateFlow()
|
||||
|
||||
fun toggleSettingsLayoutRedesign(newState: Boolean) {
|
||||
_settingsLayoutRedesign.value = newState
|
||||
settingsLayoutRedesignPref = newState
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,48 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.ui
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import org.schabi.newpipe.ui.theme.SizeTokens
|
||||
|
||||
@Composable
|
||||
fun SwitchPreference(
|
||||
modifier: Modifier = Modifier,
|
||||
@StringRes title: Int,
|
||||
title: String,
|
||||
isChecked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
@StringRes summary: Int? = null
|
||||
summary: String? = null,
|
||||
enabled: Boolean = true
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = modifier.fillMaxWidth()
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(SizeTokens.SpacingSmall)
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(id = title),
|
||||
modifier = Modifier.padding(SizeTokens.SpacingExtraSmall),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
summary?.let {
|
||||
Text(
|
||||
text = stringResource(id = summary),
|
||||
modifier = Modifier.padding(SizeTokens.SpacingExtraSmall),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
TextBase(title = title, summary = summary, enabled = enabled)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(SizeTokens.SpacingSmall))
|
||||
Switch(checked = isChecked, onCheckedChange = onCheckedChange)
|
||||
Spacer(modifier = Modifier.width(SizeTokens.SpacingExtraSmall))
|
||||
Switch(
|
||||
checked = isChecked,
|
||||
onCheckedChange = onCheckedChange,
|
||||
enabled = enabled
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
/**
|
||||
* A base composable that displays a title and an optional summary text. Used in settings preference
|
||||
* items such as TextPreference and SwitchPreference.
|
||||
*
|
||||
* @param title the title text to display
|
||||
* @param summary the optional summary text to display below the title
|
||||
* @param enabled whether the text should be displayed in an enabled or disabled state
|
||||
*/
|
||||
@Composable
|
||||
internal fun TextBase(
|
||||
title: String,
|
||||
summary: String?,
|
||||
enabled: Boolean = true
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
textAlign = TextAlign.Start,
|
||||
color = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
)
|
||||
summary?.let {
|
||||
Text(
|
||||
text = it,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Start,
|
||||
color = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.38f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, backgroundColor = 0xFFFFFFFF)
|
||||
@Composable
|
||||
private fun TextBasePreview() {
|
||||
TextBase("Debug", "Debug settings summary")
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.ui
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -13,54 +18,41 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import org.schabi.newpipe.ui.theme.SizeTokens
|
||||
|
||||
@Composable
|
||||
fun TextPreference(
|
||||
modifier: Modifier = Modifier,
|
||||
@StringRes title: Int,
|
||||
title: String,
|
||||
@DrawableRes icon: Int? = null,
|
||||
@StringRes summary: Int? = null,
|
||||
onClick: () -> Unit
|
||||
summary: String? = null,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean = true
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(SizeTokens.SpacingSmall)
|
||||
.defaultMinSize(minHeight = SizeTokens.SpaceMinSize)
|
||||
.clickable { onClick() }
|
||||
.clickable(enabled = enabled) { onClick() }
|
||||
) {
|
||||
icon?.let {
|
||||
Icon(
|
||||
painter = painterResource(id = icon),
|
||||
contentDescription = "icon for $title preference"
|
||||
contentDescription = null,
|
||||
tint = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(SizeTokens.SpacingSmall))
|
||||
}
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(id = title),
|
||||
modifier = Modifier.padding(SizeTokens.SpacingExtraSmall),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
summary?.let {
|
||||
Text(
|
||||
text = stringResource(id = summary),
|
||||
modifier = Modifier.padding(SizeTokens.SpacingExtraSmall),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.Start
|
||||
)
|
||||
}
|
||||
TextBase(title = title, summary = summary, enabled = enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,7 @@ import com.mikepenz.aboutlibraries.entity.Library
|
||||
import com.mikepenz.aboutlibraries.entity.License
|
||||
import com.mikepenz.aboutlibraries.entity.Organization
|
||||
import com.mikepenz.aboutlibraries.entity.Scm
|
||||
import com.mikepenz.aboutlibraries.ui.compose.m3.util.author
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import com.mikepenz.aboutlibraries.ui.compose.util.author
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
import org.schabi.newpipe.util.external_communication.ShareUtils
|
||||
|
||||
@@ -140,7 +138,7 @@ private class LibraryProvider : CollectionPreviewParameterProvider<Library>(
|
||||
name = "NewPipeExtractor",
|
||||
description = "NewPipe Extractor is a library for extracting things from streaming sites. It is a core component of NewPipe, but could be used independently.",
|
||||
website = "https://newpipe.net",
|
||||
developers = listOf(Developer("TeamNewPipe", "https://newpipe.net")).toImmutableList(),
|
||||
developers = listOf(Developer("TeamNewPipe", "https://newpipe.net")),
|
||||
organization = Organization("TeamNewPipe", "https://newpipe.net"),
|
||||
scm = Scm(null, null, "https://github.com/TeamNewPipe/NewPipeExtractor"),
|
||||
licenses = setOf(
|
||||
@@ -160,7 +158,7 @@ private class LibraryProvider : CollectionPreviewParameterProvider<Library>(
|
||||
licenseContent = LoremIpsum().values.first(),
|
||||
hash = "4321"
|
||||
)
|
||||
).toImmutableSet()
|
||||
)
|
||||
),
|
||||
Library(
|
||||
uniqueId = "org.schabi.newpipe.extractor",
|
||||
@@ -168,7 +166,7 @@ private class LibraryProvider : CollectionPreviewParameterProvider<Library>(
|
||||
name = "NewPipeExtractor",
|
||||
description = "NewPipe Extractor is a library for extracting things from streaming sites. It is a core component of NewPipe, but could be used independently.",
|
||||
website = null,
|
||||
developers = listOf<Developer>().toImmutableList(),
|
||||
developers = listOf<Developer>(),
|
||||
organization = null,
|
||||
scm = null,
|
||||
licenses = setOf(
|
||||
@@ -180,7 +178,7 @@ private class LibraryProvider : CollectionPreviewParameterProvider<Library>(
|
||||
licenseContent = LoremIpsum().values.first(),
|
||||
hash = "1234"
|
||||
)
|
||||
).toImmutableSet()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
Loaded 100 of 957 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user