1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Merge pull request #10283 from TeamNewPipe/release/0.25.2

Release v0.25.2 (994)
This commit is contained in:
Stypox 2023-08-02 20:14:14 +02:00 committed by GitHub
commit 1e8efa7165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
346 changed files with 8236 additions and 2251 deletions

View File

@ -1,3 +1,5 @@
### Please do **not** open pull requests for *new features* now, as we are planning to rewrite large chunks of the code. Only bugfix PRs will be accepted. More details will be announced soon!
NewPipe contribution guidelines
===============================

View File

@ -1,11 +1,11 @@
name: Question
description: Ask about anything NewPipe-related
labels: [question, needs triage]
labels: [question]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this issue! :hugs:
Thanks for taking the time to fill out this form! :hugs:
Note that you can also ask questions on our [IRC channel](https://web.libera.chat/#newpipe).
@ -14,7 +14,7 @@ body:
attributes:
label: "Checklist"
options:
- label: "I made sure that there are *no existing issues* - [open](https://github.com/TeamNewPipe/NewPipe/issues) or [closed](https://github.com/TeamNewPipe/NewPipe/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
- label: "I made sure that there are *no existing issues or discussions* - [open](https://github.com/TeamNewPipe/NewPipe/issues) or [closed](https://github.com/TeamNewPipe/NewPipe/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have read the [FAQ](https://newpipe.net/FAQ/) and my question isn't listed."
required: true

View File

@ -1,5 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: ❓ Question
url: https://github.com/TeamNewPipe/NewPipe/discussions/new?category=questions
about: Ask about anything NewPipe-related
- name: 💬 IRC
url: https://web.libera.chat/#newpipe
about: Chat with us via IRC for quick Q/A

View File

@ -28,7 +28,7 @@
#### APK testing
<!-- Use a new, meaningfully named branch. The name is used as a suffix for the app ID to allow installing and testing multiple versions of NewPipe, e.g. "commentfix", if your PR implements a bugfix for comments. (No names like "patch-0" and "feature-1".) -->
<!-- Remove the following line if you directly link the APK created by the CI pipeline. Directly linking is preferred if you need to let users test.-->
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration [on this wiki page](https://github.com/TeamNewPipe/NewPipe/wiki/Download-APK-for-PR).
#### Due diligence
- [ ] I read the [contribution guidelines](https://github.com/TeamNewPipe/NewPipe/blob/HEAD/.github/CONTRIBUTING.md).

View File

@ -42,12 +42,14 @@ jobs:
- name: create and checkout branch
# push events already checked out the branch
if: github.event_name == 'pull_request'
run: git checkout -B ${{ github.head_ref }}
env:
BRANCH: ${{ github.head_ref }}
run: git checkout -B "$BRANCH"
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: "temurin"
cache: 'gradle'
@ -66,8 +68,13 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
# api-level 19 is min sdk, but throws errors related to desugaring
api-level: [ 21, 29 ]
include:
- api-level: 21
target: default
arch: x86
- api-level: 33
target: google_apis # emulator API 33 only exists with Google APIs
arch: x86_64
permissions:
contents: read
@ -75,10 +82,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: "temurin"
cache: 'gradle'
@ -86,8 +93,8 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
emulator-build: 7425822
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
script: ./gradlew connectedCheck --stacktrace
- name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
@ -108,10 +115,10 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11 # Sonar requires JDK 11
java-version: 17
distribution: "temurin"
cache: 'gradle'

View File

@ -17,6 +17,8 @@ module.exports = async ({github, context}) => {
initialBody = context.payload.comment.body;
} else if (context.eventName == 'issues') {
initialBody = context.payload.issue.body;
} else if (context.eventName == 'pull_request') {
initialBody = context.payload.pull_request.body;
} else {
console.log('Aborting: No body found');
return;
@ -30,10 +32,12 @@ module.exports = async ({github, context}) => {
}
// Regex for finding images (simple variant) ![ALT_TEXT](https://*.githubusercontent.com/<number>/<variousHexStringsAnd->.<fileExtension>)
const REGEX_IMAGE_LOOKUP = /\!\[(.*)\]\((https:\/\/[-a-z0-9]+\.githubusercontent\.com\/\d+\/[-0-9a-f]{32,512}\.(jpg|gif|png))\)/gm;
const REGEX_USER_CONTENT_IMAGE_LOOKUP = /\!\[(.*)\]\((https:\/\/[-a-z0-9]+\.githubusercontent\.com\/\d+\/[-0-9a-f]{32,512}\.(jpg|gif|png))\)/gm;
const REGEX_ASSETS_IMAGE_LOCKUP = /\!\[(.*)\]\((https:\/\/github\.com\/[-\w\d]+\/[-\w\d]+\/assets\/\d+\/[\-0-9a-f]{32,512})\)/gm;
// Check if we found something
let foundSimpleImages = REGEX_IMAGE_LOOKUP.test(initialBody);
let foundSimpleImages = REGEX_USER_CONTENT_IMAGE_LOOKUP.test(initialBody)
|| REGEX_ASSETS_IMAGE_LOCKUP.test(initialBody);
if (!foundSimpleImages) {
console.log('Found no simple images to process');
return;
@ -47,7 +51,53 @@ module.exports = async ({github, context}) => {
var wasMatchModified = false;
// Try to find and replace the images with minimized ones
let newBody = await replaceAsync(initialBody, REGEX_IMAGE_LOOKUP, async (match, g1, g2) => {
let newBody = await replaceAsync(initialBody, REGEX_USER_CONTENT_IMAGE_LOOKUP, minimizeAsync);
newBody = await replaceAsync(newBody, REGEX_ASSETS_IMAGE_LOCKUP, minimizeAsync);
if (!wasMatchModified) {
console.log('Nothing was modified. Skipping update');
return;
}
// Update the corresponding element
if (context.eventName == 'issue_comment') {
console.log('Updating comment with id', context.payload.comment.id);
await github.rest.issues.updateComment({
comment_id: context.payload.comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: newBody
})
} else if (context.eventName == 'issues') {
console.log('Updating issue', context.payload.issue.number);
await github.rest.issues.update({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: newBody
});
} else if (context.eventName == 'pull_request') {
console.log('Updating pull request', context.payload.pull_request.number);
await github.rest.pulls.update({
pull_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: newBody
});
}
// Asnyc replace function from https://stackoverflow.com/a/48032528
async function replaceAsync(str, regex, asyncFn) {
const promises = [];
str.replace(regex, (match, ...args) => {
const promise = asyncFn(match, ...args);
promises.push(promise);
});
const data = await Promise.all(promises);
return str.replace(regex, () => data.shift());
}
async function minimizeAsync(match, g1, g2) {
console.log(`Found match '${match}'`);
if (g1.endsWith(IGNORE_ALT_NAME_END)) {
@ -93,40 +143,5 @@ module.exports = async ({github, context}) => {
console.log(`Match '${match}' is ok/will not be modified`);
return match;
});
if (!wasMatchModified) {
console.log('Nothing was modified. Skipping update');
return;
}
// Update the corresponding element
if (context.eventName == 'issue_comment') {
console.log('Updating comment with id', context.payload.comment.id);
await github.rest.issues.updateComment({
comment_id: context.payload.comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: newBody
})
} else if (context.eventName == 'issues') {
console.log('Updating issue', context.payload.issue.number);
await github.rest.issues.update({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: newBody
});
}
// Asnyc replace function from https://stackoverflow.com/a/48032528
async function replaceAsync(str, regex, asyncFn) {
const promises = [];
str.replace(regex, (match, ...args) => {
const promise = asyncFn(match, ...args);
promises.push(promise);
});
const data = await Promise.all(promises);
return str.replace(regex, () => data.shift());
}
}

View File

@ -5,6 +5,8 @@ on:
types: [created, edited]
issues:
types: [opened, edited]
pull_request:
types: [opened, edited]
permissions:
issues: write

View File

@ -1,3 +1,6 @@
<h3 align="center">We are planning to <i>rewrite</i> large chunks of the codebase, to bring about <a href="https://github.com/TeamNewPipe/NewPipe/discussions/10118">a new, modern and stable NewPipe</a>!</h3>
<h4 align="center">Please do <b>not</b> open pull requests for <i>new features</i> now, only bugfix PRs will be accepted.</h4>
<p align="center"><a href="https://newpipe.net"><img src="assets/new_pipe_icon_5.png" width="150"></a></p>
<h2 align="center"><b>NewPipe</b></h2>
<h4 align="center">A libre lightweight streaming front-end for Android.</h4>
@ -17,7 +20,7 @@
<p align="center"><a href="https://newpipe.net">Website</a> &bull; <a href="https://newpipe.net/blog/">Blog</a> &bull; <a href="https://newpipe.net/FAQ/">FAQ</a> &bull; <a href="https://newpipe.net/press/">Press</a></p>
<hr>
*Read this in other languages: [English](README.md), [Español](doc/README.es.md), [हिन्दी](doc/README.hi.md), [한국어](doc/README.ko.md), [Soomaali](doc/README.so.md), [Português Brasil](doc/README.pt_BR.md), [Polski](doc/README.pl.md), [日本語](doc/README.ja.md), [Română](doc/README.ro.md), [Türkçe](doc/README.tr.md), [正體中文](doc/README.zh_TW.md).*
*Read this document in other languages: [Deutsch](doc/README.de.md), [English](README.md), [Español](doc/README.es.md), [Français](doc/README.fr.md), [हिन्दी](doc/README.hi.md), [Italiano](doc/README.it.md), [한국어](doc/README.ko.md), [Português Brasil](doc/README.pt_BR.md), [Polski](doc/README.pl.md), [ਪੰਜਾਬੀ ](doc/README.pa.md), [日本語](doc/README.ja.md), [Română](doc/README.ro.md), [Soomaali](doc/README.so.md), [Türkçe](doc/README.tr.md), [正體中文](doc/README.zh_TW.md), [অসমীয়া](doc/README.asm.md)*
<b>WARNING: THIS APP IS IN BETA, SO YOU MAY ENCOUNTER BUGS. IF YOU DO, OPEN AN ISSUE IN OUR GITHUB REPOSITORY BY FILLING OUT THE ISSUE TEMPLATE.</b>
@ -25,18 +28,18 @@
## Screenshots
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_01.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_01.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_02.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_02.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_03.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_03.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_04.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_04.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_05.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_05.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_06.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_06.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_07.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_07.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_08.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_08.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_09.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_09.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_10.png)
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_11.png)
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/shot_12.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/00.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/00.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/01.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/01.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/02.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/02.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/03.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/03.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/04.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/04.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/05.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/05.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/06.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/06.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/07.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/07.png)
[<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/08.png" width=160>](fastlane/metadata/android/en-US/images/phoneScreenshots/08.png)
<br/><br/>
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/09.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/09.png)
[<img src="fastlane/metadata/android/en-US/images/tenInchScreenshots/10.png" width=405>](fastlane/metadata/android/en-US/images/tenInchScreenshots/10.png)
### Supported Services

View File

@ -8,7 +8,7 @@ plugins {
id "kotlin-kapt"
id "kotlin-parcelize"
id "checkstyle"
id "org.sonarqube" version "3.5.0.2730"
id "org.sonarqube" version "4.0.0.2929"
}
android {
@ -20,8 +20,8 @@ android {
resValue "string", "app_name", "NewPipe"
minSdk 21
targetSdk 33
versionCode 993
versionName "0.25.1"
versionCode 994
versionName "0.25.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -80,13 +80,13 @@ android {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
encoding 'utf-8'
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
jvmTarget = JavaVersion.VERSION_17
}
sourceSets {
@ -96,25 +96,32 @@ android {
buildFeatures {
viewBinding true
}
packagingOptions {
resources {
// remove two files which belong to jsoup
// no idea how they ended up in the META-INF dir...
excludes += ['META-INF/README.md', 'META-INF/CHANGES']
}
}
}
ext {
checkstyleVersion = '10.3.1'
checkstyleVersion = '10.12.1'
androidxLifecycleVersion = '2.5.1'
androidxRoomVersion = '2.4.3'
androidxRoomVersion = '2.5.2'
androidxWorkVersion = '2.7.1'
icepickVersion = '3.2.0'
exoPlayerVersion = '2.18.5'
exoPlayerVersion = '2.18.7'
googleAutoServiceVersion = '1.0.1'
groupieVersion = '2.10.1'
markwonVersion = '4.6.2'
leakCanaryVersion = '2.9.1'
leakCanaryVersion = '2.12'
stethoVersion = '1.6.0'
mockitoVersion = '4.0.0'
assertJVersion = '3.23.1'
}
configurations {
@ -156,6 +163,7 @@ task runKtlint(type: JavaExec) {
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "src/**/*.kt"
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
task formatKtlint(type: JavaExec) {
@ -164,6 +172,7 @@ task formatKtlint(type: JavaExec) {
getMainClass().set("com.pinterest.ktlint.Main")
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
afterEvaluate {
@ -183,7 +192,7 @@ sonar {
dependencies {
/** Desugaring **/
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
/** NewPipe libraries **/
// You can use a local version by uncommenting a few lines in settings.gradle
@ -191,7 +200,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.22.6'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.22.7'
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
/** Checkstyle **/
@ -205,7 +214,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}"
@ -231,10 +240,13 @@ dependencies {
kapt "frankiesardo:icepick-processor:${icepickVersion}"
// HTML parser
implementation "org.jsoup:jsoup:1.15.3"
implementation "org.jsoup:jsoup:1.16.1"
// HTTP client
implementation "com.squareup.okhttp3:okhttp:4.10.0"
implementation "com.squareup.okhttp3:okhttp:4.11.0"
// okhttp3:4.11.0 introduces a vulnerability from com.squareup.okio:okio@3.3.0,
// remove com.squareup.okio:okio when updating okhttp
implementation "com.squareup.okio:okio:3.4.0"
// Media player
implementation "com.google.android.exoplayer:exoplayer-core:${exoPlayerVersion}"
@ -263,13 +275,13 @@ dependencies {
implementation "io.noties.markwon:linkify:${markwonVersion}"
// Crash reporting
implementation "ch.acra:acra-core:5.9.7"
implementation "ch.acra:acra-core:5.10.1"
// Properly restarting
implementation 'com.jakewharton:process-phoenix:2.1.2'
// Reactive extensions for Java VM
implementation "io.reactivex.rxjava3:rxjava:3.1.5"
implementation "io.reactivex.rxjava3:rxjava:3.1.6"
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
// RxJava binding APIs for Android UI widgets
implementation "com.jakewharton.rxbinding4:rxbinding:4.0.0"
@ -279,9 +291,9 @@ dependencies {
/** Debugging **/
// Memory leak detection
implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
implementation "com.squareup.leakcanary:plumber-android:${leakCanaryVersion}"
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
debugImplementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
debugImplementation "com.squareup.leakcanary:plumber-android:${leakCanaryVersion}"
debugImplementation "com.squareup.leakcanary:leakcanary-android-core:${leakCanaryVersion}"
// Debug bridge for Android
debugImplementation "com.facebook.stetho:stetho:${stethoVersion}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"
@ -291,10 +303,10 @@ dependencies {
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test:runner:1.4.0"
androidTestImplementation "androidx.test.ext:junit:1.1.5"
androidTestImplementation "androidx.test:runner:1.5.2"
androidTestImplementation "androidx.room:room-testing:${androidxRoomVersion}"
androidTestImplementation "org.assertj:assertj-core:${assertJVersion}"
androidTestImplementation "org.assertj:assertj-core:3.23.1"
}
static String getGitWorkingBranch() {
@ -313,6 +325,7 @@ static String getGitWorkingBranch() {
}
}
// fix reproducible builds
project.afterEvaluate {
tasks.compileReleaseArtProfile.doLast {
outputs.files.each { file ->

View File

@ -1,32 +1,18 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/the-scrabi/bin/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# https://developer.android.com/build/shrink-code
## Helps debug release versions
-dontobfuscate
## Rules for NewPipeExtractor
-keep class org.schabi.newpipe.extractor.timeago.patterns.** { *; }
-keep class org.mozilla.javascript.** { *; }
-keep class org.mozilla.classfile.ClassFileWriter
-keep class com.google.android.exoplayer2.** { *; }
-dontwarn org.mozilla.javascript.tools.**
# Rules for icepick. Copy paste from https://github.com/frankiesardo/icepick
## Rules for ExoPlayer
-keep class com.google.android.exoplayer2.** { *; }
## Rules for Icepick. Copy pasted from https://github.com/frankiesardo/icepick
-dontwarn icepick.**
-keep class icepick.** { *; }
-keep class **$$Icepick { *; }
@ -35,11 +21,11 @@
}
-keepnames class * { @icepick.State *;}
## Rules for OkHttp. Copy paste from https://github.com/square/okhttp
## Rules for OkHttp. Copy pasted from https://github.com/square/okhttp
-dontwarn okhttp3.**
-dontwarn okio.**
##
## See https://github.com/TeamNewPipe/NewPipe/pull/1441
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
!static !transient <fields>;
@ -47,5 +33,5 @@
private void readObject(java.io.ObjectInputStream);
}
# for some reason NotificationModeConfigFragment wasn't kept (only referenced in a preference xml)
## For some reason NotificationModeConfigFragment wasn't kept (only referenced in a preference xml)
-keep class org.schabi.newpipe.settings.notifications.** { *; }

View File

@ -4,7 +4,6 @@ import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import androidx.room.Room
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
@ -33,8 +32,7 @@ class DatabaseMigrationTest {
@get:Rule
val testHelper = MigrationTestHelper(
InstrumentationRegistry.getInstrumentation(),
AppDatabase::class.java.canonicalName,
FrameworkSQLiteOpenHelperFactory()
AppDatabase::class.java
)
@Test

View File

@ -0,0 +1,119 @@
package org.schabi.newpipe.local.subscription;
import static org.junit.Assert.assertEquals;
import androidx.test.core.app.ApplicationProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.schabi.newpipe.database.AppDatabase;
import org.schabi.newpipe.database.feed.model.FeedGroupEntity;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.database.subscription.SubscriptionEntity;
import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.testUtil.TestDatabase;
import org.schabi.newpipe.testUtil.TrampolineSchedulerRule;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Comparator;
import java.util.List;
public class SubscriptionManagerTest {
private AppDatabase database;
private SubscriptionManager manager;
@Rule
public TrampolineSchedulerRule trampolineScheduler = new TrampolineSchedulerRule();
private SubscriptionEntity getAssertOneSubscriptionEntity() {
final List<SubscriptionEntity> entities = manager
.getSubscriptions(FeedGroupEntity.GROUP_ALL_ID, "", false)
.blockingFirst();
assertEquals(1, entities.size());
return entities.get(0);
}
@Before
public void setup() {
database = TestDatabase.Companion.createReplacingNewPipeDatabase();
manager = new SubscriptionManager(ApplicationProvider.getApplicationContext());
}
@After
public void cleanUp() {
database.close();
}
@Test
public void testInsert() throws ExtractionException, IOException {
final ChannelInfo info = ChannelInfo.getInfo("https://www.youtube.com/c/3blue1brown");
final SubscriptionEntity subscription = SubscriptionEntity.from(info);
manager.insertSubscription(subscription, info);
final SubscriptionEntity readSubscription = getAssertOneSubscriptionEntity();
// the uid has changed, since the uid is chosen upon inserting, but the rest should match
assertEquals(subscription.getServiceId(), readSubscription.getServiceId());
assertEquals(subscription.getUrl(), readSubscription.getUrl());
assertEquals(subscription.getName(), readSubscription.getName());
assertEquals(subscription.getAvatarUrl(), readSubscription.getAvatarUrl());
assertEquals(subscription.getSubscriberCount(), readSubscription.getSubscriberCount());
assertEquals(subscription.getDescription(), readSubscription.getDescription());
}
@Test
public void testUpdateNotificationMode() throws ExtractionException, IOException {
final ChannelInfo info = ChannelInfo.getInfo("https://www.youtube.com/c/veritasium");
final SubscriptionEntity subscription = SubscriptionEntity.from(info);
subscription.setNotificationMode(0);
manager.insertSubscription(subscription, info);
manager.updateNotificationMode(subscription.getServiceId(), subscription.getUrl(), 1)
.blockingAwait();
final SubscriptionEntity anotherSubscription = getAssertOneSubscriptionEntity();
assertEquals(0, subscription.getNotificationMode());
assertEquals(subscription.getUrl(), anotherSubscription.getUrl());
assertEquals(1, anotherSubscription.getNotificationMode());
}
@Test
public void testRememberRecentStreams() throws ExtractionException, IOException {
final ChannelInfo info = ChannelInfo.getInfo("https://www.youtube.com/c/Polyphia");
final List<StreamInfoItem> relatedItems = List.of(
new StreamInfoItem(0, "a", "b", StreamType.VIDEO_STREAM),
new StreamInfoItem(1, "c", "d", StreamType.AUDIO_STREAM),
new StreamInfoItem(2, "e", "f", StreamType.AUDIO_LIVE_STREAM),
new StreamInfoItem(3, "g", "h", StreamType.LIVE_STREAM));
relatedItems.forEach(item -> {
// these two fields must be non-null for the insert to succeed
item.setUploaderUrl(info.getUrl());
item.setUploaderName(info.getName());
// the upload date must not be too much in the past for the item to actually be inserted
item.setUploadDate(new DateWrapper(OffsetDateTime.now()));
});
info.setRelatedItems(relatedItems);
final SubscriptionEntity subscription = SubscriptionEntity.from(info);
manager.insertSubscription(subscription, info);
final List<StreamEntity> streams = database.streamDAO().getAll().blockingFirst();
assertEquals(4, streams.size());
streams.sort(Comparator.comparing(StreamEntity::getServiceId));
for (int i = 0; i < 4; i++) {
assertEquals(relatedItems.get(0).getServiceId(), streams.get(0).getServiceId());
assertEquals(relatedItems.get(0).getUrl(), streams.get(0).getUrl());
assertEquals(relatedItems.get(0).getName(), streams.get(0).getTitle());
assertEquals(relatedItems.get(0).getStreamType(), streams.get(0).getStreamType());
}
}
}

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe
import androidx.preference.PreferenceManager
import com.facebook.stetho.Stetho
import com.facebook.stetho.okhttp3.StethoInterceptor
import leakcanary.AppWatcher
import leakcanary.LeakCanary
import okhttp3.OkHttpClient
import org.schabi.newpipe.extractor.downloader.Downloader
@ -13,8 +12,6 @@ class DebugApp : App() {
super.onCreate()
initStetho()
// Give each object 10 seconds to be GC'ed, before LeakCanary gets nosy on it
AppWatcher.config = AppWatcher.config.copy(watchDurationMillis = 10000)
LeakCanary.config = LeakCanary.config.copy(
dumpHeap = PreferenceManager
.getDefaultSharedPreferences(this).getBoolean(

View File

@ -357,15 +357,16 @@
<data android:host="eduvid.org" />
<data android:host="framatube.org" />
<data android:host="media.assassinate-you.net" />
<data android:host="media.fsfe.org" />
<data android:host="peertube.co.uk" />
<data android:host="peertube.cpy.re" />
<data android:host="peertube.mastodon.host" />
<data android:host="peertube.fr" />
<data android:host="tilvids.com" />
<data android:host="video.ploud.fr" />
<data android:host="video.lqdn.fr" />
<data android:host="peertube.mastodon.host" />
<data android:host="peertube.stream" />
<data android:host="skeptikon.fr" />
<data android:host="media.fsfe.org" />
<data android:host="tilvids.com" />
<data android:host="video.lqdn.fr" />
<data android:host="video.ploud.fr" />
<data android:pathPrefix="/videos/" /> <!-- it contains playlists -->
<data android:pathPrefix="/w/" /> <!-- short video URLs -->

View File

@ -12,7 +12,6 @@ import androidx.fragment.app.FragmentManager;
import icepick.Icepick;
import icepick.State;
import leakcanary.AppWatcher;
public abstract class BaseFragment extends Fragment {
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
@ -77,13 +76,6 @@ public abstract class BaseFragment extends Fragment {
protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
}
@Override
public void onDestroy() {
super.onDestroy();
AppWatcher.INSTANCE.getObjectWatcher().watch(this);
}
/*//////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////*/

View File

@ -6,6 +6,7 @@ import android.util.Log
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.net.toUri
@ -19,7 +20,6 @@ import com.grack.nanojson.JsonParser
import com.grack.nanojson.JsonParserException
import org.schabi.newpipe.extractor.downloader.Response
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
import org.schabi.newpipe.util.PendingIntentCompat
import org.schabi.newpipe.util.ReleaseVersionUtil.coerceUpdateCheckExpiry
import org.schabi.newpipe.util.ReleaseVersionUtil.isLastUpdateCheckExpired
import org.schabi.newpipe.util.ReleaseVersionUtil.isReleaseApk
@ -60,7 +60,7 @@ class NewVersionWorker(
val intent = Intent(Intent.ACTION_VIEW, apkLocationUrl?.toUri())
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val pendingIntent = PendingIntentCompat.getActivity(
applicationContext, 0, intent, 0
applicationContext, 0, intent, 0, false
)
val channelId = applicationContext.getString(R.string.app_update_notification_channel_id)
val notificationBuilder = NotificationCompat.Builder(applicationContext, channelId)

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.database.feed.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.ForeignKey.CASCADE
import androidx.room.Index
import org.schabi.newpipe.database.feed.model.FeedGroupSubscriptionEntity.Companion.FEED_GROUP_SUBSCRIPTION_TABLE
import org.schabi.newpipe.database.feed.model.FeedGroupSubscriptionEntity.Companion.GROUP_ID
@ -19,14 +18,14 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity
entity = FeedGroupEntity::class,
parentColumns = [FeedGroupEntity.ID],
childColumns = [GROUP_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
),
ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
)
]
)

View File

@ -68,6 +68,8 @@ import org.schabi.newpipe.util.SecondaryStreamHelper;
import org.schabi.newpipe.util.SimpleOnSeekBarChangeListener;
import org.schabi.newpipe.util.StreamItemAdapter;
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
import org.schabi.newpipe.util.AudioTrackAdapter;
import org.schabi.newpipe.util.AudioTrackAdapter.AudioTracksWrapper;
import org.schabi.newpipe.util.ThemeHelper;
import java.io.File;
@ -95,12 +97,14 @@ public class DownloadDialog extends DialogFragment
@State
StreamInfo currentInfo;
@State
StreamSizeWrapper<AudioStream> wrappedAudioStreams;
@State
StreamSizeWrapper<VideoStream> wrappedVideoStreams;
@State
StreamSizeWrapper<SubtitlesStream> wrappedSubtitleStreams;
@State
AudioTracksWrapper wrappedAudioTracks;
@State
int selectedAudioTrackIndex;
@State
int selectedVideoIndex; // set in the constructor
@State
int selectedAudioIndex = 0; // default to the first item
@ -117,6 +121,7 @@ public class DownloadDialog extends DialogFragment
private Context context;
private boolean askForSavePath;
private AudioTrackAdapter audioTrackAdapter;
private StreamItemAdapter<AudioStream, Stream> audioStreamsAdapter;
private StreamItemAdapter<VideoStream, AudioStream> videoStreamsAdapter;
private StreamItemAdapter<SubtitlesStream, Stream> subtitleStreamsAdapter;
@ -163,18 +168,26 @@ public class DownloadDialog extends DialogFragment
public DownloadDialog(@NonNull final Context context, @NonNull final StreamInfo info) {
this.currentInfo = info;
final List<AudioStream> audioStreams =
getStreamsOfSpecifiedDelivery(info.getAudioStreams(), PROGRESSIVE_HTTP);
final List<List<AudioStream>> groupedAudioStreams =
ListHelper.getGroupedAudioStreams(context, audioStreams);
this.wrappedAudioTracks = new AudioTracksWrapper(groupedAudioStreams, context);
this.selectedAudioTrackIndex =
ListHelper.getDefaultAudioTrackGroup(context, groupedAudioStreams);
// TODO: Adapt this code when the downloader support other types of stream deliveries
final List<VideoStream> videoStreams = ListHelper.getSortedStreamVideosList(
context,
getStreamsOfSpecifiedDelivery(info.getVideoStreams(), PROGRESSIVE_HTTP),
getStreamsOfSpecifiedDelivery(info.getVideoOnlyStreams(), PROGRESSIVE_HTTP),
false,
false
// If there are multiple languages available, prefer streams without audio
// to allow language selection
wrappedAudioTracks.size() > 1
);
this.wrappedVideoStreams = new StreamSizeWrapper<>(videoStreams, context);
this.wrappedAudioStreams = new StreamSizeWrapper<>(
getStreamsOfSpecifiedDelivery(info.getAudioStreams(), PROGRESSIVE_HTTP), context);
this.wrappedSubtitleStreams = new StreamSizeWrapper<>(
getStreamsOfSpecifiedDelivery(info.getSubtitles(), PROGRESSIVE_HTTP), context);
@ -212,33 +225,9 @@ public class DownloadDialog extends DialogFragment
setStyle(STYLE_NO_TITLE, ThemeHelper.getDialogTheme(context));
Icepick.restoreInstanceState(this, savedInstanceState);
final var secondaryStreams = new SparseArrayCompat<SecondaryStreamHelper<AudioStream>>(4);
final List<VideoStream> videoStreams = wrappedVideoStreams.getStreamsList();
for (int i = 0; i < videoStreams.size(); i++) {
if (!videoStreams.get(i).isVideoOnly()) {
continue;
}
final AudioStream audioStream = SecondaryStreamHelper
.getAudioStreamFor(wrappedAudioStreams.getStreamsList(), videoStreams.get(i));
if (audioStream != null) {
secondaryStreams.append(i, new SecondaryStreamHelper<>(wrappedAudioStreams,
audioStream));
} else if (DEBUG) {
final MediaFormat mediaFormat = videoStreams.get(i).getFormat();
if (mediaFormat != null) {
Log.w(TAG, "No audio stream candidates for video format "
+ mediaFormat.name());
} else {
Log.w(TAG, "No audio stream candidates for unknown video format");
}
}
}
this.videoStreamsAdapter = new StreamItemAdapter<>(wrappedVideoStreams, secondaryStreams);
this.audioStreamsAdapter = new StreamItemAdapter<>(wrappedAudioStreams);
this.audioTrackAdapter = new AudioTrackAdapter(wrappedAudioTracks);
this.subtitleStreamsAdapter = new StreamItemAdapter<>(wrappedSubtitleStreams);
updateSecondaryStreams();
final Intent intent = new Intent(context, DownloadManagerService.class);
context.startService(intent);
@ -265,6 +254,39 @@ public class DownloadDialog extends DialogFragment
}, Context.BIND_AUTO_CREATE);
}
/**
* Update the displayed video streams based on the selected audio track.
*/
private void updateSecondaryStreams() {
final StreamSizeWrapper<AudioStream> audioStreams = getWrappedAudioStreams();
final var secondaryStreams = new SparseArrayCompat<SecondaryStreamHelper<AudioStream>>(4);
final List<VideoStream> videoStreams = wrappedVideoStreams.getStreamsList();
wrappedVideoStreams.resetSizes();
for (int i = 0; i < videoStreams.size(); i++) {
if (!videoStreams.get(i).isVideoOnly()) {
continue;
}
final AudioStream audioStream = SecondaryStreamHelper
.getAudioStreamFor(audioStreams.getStreamsList(), videoStreams.get(i));
if (audioStream != null) {
secondaryStreams.append(i, new SecondaryStreamHelper<>(audioStreams, audioStream));
} else if (DEBUG) {
final MediaFormat mediaFormat = videoStreams.get(i).getFormat();
if (mediaFormat != null) {
Log.w(TAG, "No audio stream candidates for video format "
+ mediaFormat.name());
} else {
Log.w(TAG, "No audio stream candidates for unknown video format");
}
}
}
this.videoStreamsAdapter = new StreamItemAdapter<>(wrappedVideoStreams, secondaryStreams);
this.audioStreamsAdapter = new StreamItemAdapter<>(audioStreams);
}
@Override
public View onCreateView(@NonNull final LayoutInflater inflater,
final ViewGroup container,
@ -285,13 +307,14 @@ public class DownloadDialog extends DialogFragment
dialogBinding.fileName.setText(FilenameUtils.createFilename(getContext(),
currentInfo.getName()));
selectedAudioIndex = ListHelper
.getDefaultAudioFormat(getContext(), wrappedAudioStreams.getStreamsList());
selectedAudioIndex = ListHelper.getDefaultAudioFormat(getContext(),
getWrappedAudioStreams().getStreamsList());
selectedSubtitleIndex = getSubtitleIndexBy(subtitleStreamsAdapter.getAll());
dialogBinding.qualitySpinner.setOnItemSelectedListener(this);
dialogBinding.audioStreamSpinner.setOnItemSelectedListener(this);
dialogBinding.audioTrackSpinner.setOnItemSelectedListener(this);
dialogBinding.videoAudioGroup.setOnCheckedChangeListener(this);
initToolbar(dialogBinding.toolbarLayout.toolbar);
@ -383,7 +406,7 @@ public class DownloadDialog extends DialogFragment
new ErrorInfo(throwable, UserAction.DOWNLOAD_OPEN_DIALOG,
"Downloading video stream size",
currentInfo.getServiceId()))));
disposables.add(StreamSizeWrapper.fetchSizeForWrapper(wrappedAudioStreams)
disposables.add(StreamSizeWrapper.fetchSizeForWrapper(getWrappedAudioStreams())
.subscribe(result -> {
if (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()
== R.id.audio_button) {
@ -405,14 +428,28 @@ public class DownloadDialog extends DialogFragment
currentInfo.getServiceId()))));
}
private void setupAudioTrackSpinner() {
if (getContext() == null) {
return;
}
dialogBinding.audioTrackSpinner.setAdapter(audioTrackAdapter);
dialogBinding.audioTrackSpinner.setSelection(selectedAudioTrackIndex);
}
private void setupAudioSpinner() {
if (getContext() == null) {
return;
}
dialogBinding.qualitySpinner.setAdapter(audioStreamsAdapter);
dialogBinding.qualitySpinner.setSelection(selectedAudioIndex);
dialogBinding.qualitySpinner.setVisibility(View.GONE);
setRadioButtonsState(true);
dialogBinding.audioStreamSpinner.setAdapter(audioStreamsAdapter);
dialogBinding.audioStreamSpinner.setSelection(selectedAudioIndex);
dialogBinding.audioStreamSpinner.setVisibility(View.VISIBLE);
dialogBinding.audioTrackSpinner.setVisibility(
wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE);
dialogBinding.audioTrackPresentInVideoText.setVisibility(View.GONE);
}
private void setupVideoSpinner() {
@ -422,7 +459,19 @@ public class DownloadDialog extends DialogFragment
dialogBinding.qualitySpinner.setAdapter(videoStreamsAdapter);
dialogBinding.qualitySpinner.setSelection(selectedVideoIndex);
dialogBinding.qualitySpinner.setVisibility(View.VISIBLE);
setRadioButtonsState(true);
dialogBinding.audioStreamSpinner.setVisibility(View.GONE);
onVideoStreamSelected();
}
private void onVideoStreamSelected() {
final boolean isVideoOnly = videoStreamsAdapter.getItem(selectedVideoIndex).isVideoOnly();
dialogBinding.audioTrackSpinner.setVisibility(
isVideoOnly && wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE);
dialogBinding.audioTrackPresentInVideoText.setVisibility(
!isVideoOnly && wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE);
}
private void setupSubtitleSpinner() {
@ -432,7 +481,11 @@ public class DownloadDialog extends DialogFragment
dialogBinding.qualitySpinner.setAdapter(subtitleStreamsAdapter);
dialogBinding.qualitySpinner.setSelection(selectedSubtitleIndex);
dialogBinding.qualitySpinner.setVisibility(View.VISIBLE);
setRadioButtonsState(true);
dialogBinding.audioStreamSpinner.setVisibility(View.GONE);
dialogBinding.audioTrackSpinner.setVisibility(View.GONE);
dialogBinding.audioTrackPresentInVideoText.setVisibility(View.GONE);
}
@ -550,18 +603,31 @@ public class DownloadDialog extends DialogFragment
+ "parent = [" + parent + "], view = [" + view + "], "
+ "position = [" + position + "], id = [" + id + "]");
}
switch (parent.getId()) {
case R.id.quality_spinner:
switch (dialogBinding.videoAudioGroup.getCheckedRadioButtonId()) {
case R.id.audio_button:
selectedAudioIndex = position;
break;
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;
}
}
private void onItemSelectedSetFileName() {
@ -607,6 +673,7 @@ public class DownloadDialog extends DialogFragment
protected void setupDownloadOptions() {
setRadioButtonsState(false);
setupAudioTrackSpinner();
final boolean isVideoStreamsAvailable = videoStreamsAdapter.getCount() > 0;
final boolean isAudioStreamsAvailable = audioStreamsAdapter.getCount() > 0;
@ -657,6 +724,13 @@ public class DownloadDialog extends DialogFragment
dialogBinding.subtitleButton.setEnabled(enabled);
}
private StreamSizeWrapper<AudioStream> getWrappedAudioStreams() {
if (selectedAudioTrackIndex < 0 || selectedAudioTrackIndex > wrappedAudioTracks.size()) {
return StreamSizeWrapper.empty();
}
return wrappedAudioTracks.getTracksList().get(selectedAudioTrackIndex);
}
private int getSubtitleIndexBy(@NonNull final List<SubtitlesStream> streams) {
final Localization preferredLocalization = NewPipe.getPreferredLocalization();
@ -697,7 +771,6 @@ public class DownloadDialog extends DialogFragment
.setTitle(R.string.general_error)
.setMessage(msg)
.setNegativeButton(getString(R.string.ok), null)
.create()
.show();
}
@ -910,7 +983,7 @@ public class DownloadDialog extends DialogFragment
break;
}
askDialog.create().show();
askDialog.show();
return;
}
@ -954,7 +1027,7 @@ public class DownloadDialog extends DialogFragment
}
});
askDialog.create().show();
askDialog.show();
}
private void continueSelectedDownload(@NonNull final StoredFileHelper storage) {
@ -1013,7 +1086,6 @@ public class DownloadDialog extends DialogFragment
psName = Postprocessing.ALGORITHM_WEBM_MUXER;
}
psArgs = null;
final long videoSize = wrappedVideoStreams.getSizeInBytes(
(VideoStream) selectedStream);

View File

@ -176,9 +176,7 @@ public class ErrorActivity extends AppCompatActivity {
ShareUtils.openUrlInApp(this, ERROR_GITHUB_ISSUE_URL);
}
})
.setNegativeButton(R.string.decline, (dialog, which) -> {
// do nothing
})
.setNegativeButton(R.string.decline, null)
.show();
}

View File

@ -9,10 +9,10 @@ import android.view.View
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.fragment.app.Fragment
import com.google.android.material.snackbar.Snackbar
import org.schabi.newpipe.R
import org.schabi.newpipe.util.PendingIntentCompat
/**
* This class contains all of the methods that should be used to let the user know that an error has
@ -118,7 +118,8 @@ class ErrorUtil {
context,
0,
getErrorActivityIntent(context, errorInfo),
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT,
false
)
)

View File

@ -1,6 +1,16 @@
package org.schabi.newpipe.fragments;
import static android.widget.RelativeLayout.ABOVE;
import static android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM;
import static android.widget.RelativeLayout.ALIGN_PARENT_TOP;
import static android.widget.RelativeLayout.BELOW;
import static com.google.android.material.tabs.TabLayout.INDICATOR_GRAVITY_BOTTOM;
import static com.google.android.material.tabs.TabLayout.INDICATOR_GRAVITY_TOP;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@ -9,7 +19,9 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
@ -17,6 +29,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround;
import androidx.preference.PreferenceManager;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
@ -29,6 +42,8 @@ import org.schabi.newpipe.settings.tabs.Tab;
import org.schabi.newpipe.settings.tabs.TabsManager;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.ScrollableTabLayout;
import java.util.ArrayList;
import java.util.List;
@ -42,8 +57,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
private boolean hasTabsChanged = false;
private boolean previousYoutubeRestrictedModeEnabled;
private SharedPreferences prefs;
private boolean youtubeRestrictedModeEnabled;
private String youtubeRestrictedModeEnabledKey;
private boolean mainTabsPositionBottom;
private String mainTabsPositionKey;
/*//////////////////////////////////////////////////////////////////////////
// Fragment's LifeCycle
@ -66,10 +84,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
}
});
prefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled);
previousYoutubeRestrictedModeEnabled =
PreferenceManager.getDefaultSharedPreferences(requireContext())
.getBoolean(youtubeRestrictedModeEnabledKey, false);
youtubeRestrictedModeEnabled = prefs.getBoolean(youtubeRestrictedModeEnabledKey, false);
mainTabsPositionKey = getString(R.string.main_tabs_position_key);
mainTabsPositionBottom = prefs.getBoolean(mainTabsPositionKey, false);
}
@Override
@ -87,25 +106,27 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
binding.mainTabLayout.setupWithViewPager(binding.pager);
binding.mainTabLayout.addOnTabSelectedListener(this);
binding.mainTabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor()
.withAlpha(32));
setupTabs();
updateTabLayoutPosition();
}
@Override
public void onResume() {
super.onResume();
final boolean youtubeRestrictedModeEnabled =
PreferenceManager.getDefaultSharedPreferences(requireContext())
.getBoolean(youtubeRestrictedModeEnabledKey, false);
if (previousYoutubeRestrictedModeEnabled != youtubeRestrictedModeEnabled) {
previousYoutubeRestrictedModeEnabled = youtubeRestrictedModeEnabled;
setupTabs();
} else if (hasTabsChanged) {
final boolean newYoutubeRestrictedModeEnabled =
prefs.getBoolean(youtubeRestrictedModeEnabledKey, false);
if (youtubeRestrictedModeEnabled != newYoutubeRestrictedModeEnabled || hasTabsChanged) {
youtubeRestrictedModeEnabled = newYoutubeRestrictedModeEnabled;
setupTabs();
}
final boolean newMainTabsPosition = prefs.getBoolean(mainTabsPositionKey, false);
if (mainTabsPositionBottom != newMainTabsPosition) {
mainTabsPositionBottom = newMainTabsPosition;
updateTabLayoutPosition();
}
}
@Override
@ -190,6 +211,38 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
setTitle(tabsList.get(tabPosition).getTabName(requireContext()));
}
private void updateTabLayoutPosition() {
final ScrollableTabLayout tabLayout = binding.mainTabLayout;
final ViewPager viewPager = binding.pager;
final boolean bottom = mainTabsPositionBottom;
// change layout params to make the tab layout appear either at the top or at the bottom
final var tabParams = (RelativeLayout.LayoutParams) tabLayout.getLayoutParams();
final var pagerParams = (RelativeLayout.LayoutParams) viewPager.getLayoutParams();
tabParams.removeRule(bottom ? ALIGN_PARENT_TOP : ALIGN_PARENT_BOTTOM);
tabParams.addRule(bottom ? ALIGN_PARENT_BOTTOM : ALIGN_PARENT_TOP);
pagerParams.removeRule(bottom ? BELOW : ABOVE);
pagerParams.addRule(bottom ? ABOVE : BELOW, R.id.main_tab_layout);
tabLayout.setSelectedTabIndicatorGravity(
bottom ? INDICATOR_GRAVITY_TOP : INDICATOR_GRAVITY_BOTTOM);
tabLayout.setLayoutParams(tabParams);
viewPager.setLayoutParams(pagerParams);
// change the background and icon color of the tab layout:
// service-colored at the top, app-background-colored at the bottom
tabLayout.setBackgroundColor(ThemeHelper.resolveColorFromAttr(requireContext(),
bottom ? R.attr.colorSecondary : R.attr.colorPrimary));
@ColorInt final int iconColor = bottom
? ThemeHelper.resolveColorFromAttr(requireContext(), R.attr.colorAccent)
: Color.WHITE;
tabLayout.setTabRippleColor(ColorStateList.valueOf(iconColor).withAlpha(32));
tabLayout.setTabIconTint(ColorStateList.valueOf(iconColor));
tabLayout.setSelectedTabIndicatorColor(iconColor);
}
@Override
public void onTabSelected(final TabLayout.Tab selectedTab) {
if (DEBUG) {

View File

@ -61,7 +61,6 @@ import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.tabs.TabLayout;
import com.squareup.picasso.Callback;
import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
@ -162,8 +161,12 @@ public final class VideoDetailFragment
private boolean showRelatedItems;
private boolean showDescription;
private String selectedTabTag;
@AttrRes @NonNull final List<Integer> tabIcons = new ArrayList<>();
@StringRes @NonNull final List<Integer> tabContentDescriptions = new ArrayList<>();
@AttrRes
@NonNull
final List<Integer> tabIcons = new ArrayList<>();
@StringRes
@NonNull
final List<Integer> tabContentDescriptions = new ArrayList<>();
private boolean tabSettingsChanged = false;
private int lastAppBarVerticalOffset = Integer.MAX_VALUE; // prevents useless updates
@ -645,27 +648,6 @@ public final class VideoDetailFragment
}
}
private void initThumbnailViews(@NonNull final StreamInfo info) {
PicassoHelper.loadDetailsThumbnail(info.getThumbnailUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailThumbnailImageView, new Callback() {
@Override
public void onSuccess() {
// nothing to do, the image was loaded correctly into the thumbnail
}
@Override
public void onError(final Exception e) {
showSnackBarError(new ErrorInfo(e, UserAction.LOAD_IMAGE,
info.getThumbnailUrl(), info));
}
});
PicassoHelper.loadAvatar(info.getSubChannelAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailSubChannelThumbnailView);
PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailUploaderThumbnailView);
}
/*//////////////////////////////////////////////////////////////////////////
// OwnStack
//////////////////////////////////////////////////////////////////////////*/
@ -1040,20 +1022,10 @@ public final class VideoDetailFragment
player.setRecovery();
}
if (!useExternalAudioPlayer) {
openNormalBackgroundPlayer(append);
if (useExternalAudioPlayer) {
showExternalAudioPlaybackDialog();
} else {
final List<AudioStream> audioStreams = getUrlAndNonTorrentStreams(
currentInfo.getAudioStreams());
final int index = ListHelper.getDefaultAudioFormat(activity, audioStreams);
if (index == -1) {
Toast.makeText(activity, R.string.no_audio_streams_available_for_external_players,
Toast.LENGTH_SHORT).show();
return;
}
startOnExternalPlayer(activity, currentInfo, audioStreams.get(index));
openNormalBackgroundPlayer(append);
}
}
@ -1106,7 +1078,7 @@ public final class VideoDetailFragment
if (PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
showExternalPlaybackDialog();
showExternalVideoPlaybackDialog();
} else {
replaceQueueIfUserConfirms(this::openMainPlayer);
}
@ -1486,12 +1458,9 @@ public final class VideoDetailFragment
binding.detailSubChannelThumbnailView.setVisibility(View.GONE);
if (!isEmpty(info.getSubChannelName())) {
displayBothUploaderAndSubChannel(info, activity);
} else if (!isEmpty(info.getUploaderName())) {
displayUploaderAsSubChannel(info, activity);
displayBothUploaderAndSubChannel(info);
} else {
binding.detailUploaderTextView.setVisibility(View.GONE);
binding.detailUploaderThumbnailView.setVisibility(View.GONE);
displayUploaderAsSubChannel(info);
}
final Drawable buddyDrawable =
@ -1565,7 +1534,8 @@ public final class VideoDetailFragment
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
checkUpdateProgressInfo(info);
initThumbnailViews(info);
PicassoHelper.loadDetailsThumbnail(info.getThumbnailUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailThumbnailImageView);
showMetaInfoInTextView(info.getMetaInfo(), binding.detailMetaInfoTextView,
binding.detailMetaInfoSeparator, disposables);
@ -1602,27 +1572,30 @@ public final class VideoDetailFragment
noVideoStreams ? R.drawable.ic_headset_shadow : R.drawable.ic_play_arrow_shadow);
}
private void displayUploaderAsSubChannel(final StreamInfo info, final Context context) {
private void displayUploaderAsSubChannel(final StreamInfo info) {
binding.detailSubChannelTextView.setText(info.getUploaderName());
binding.detailSubChannelTextView.setVisibility(View.VISIBLE);
binding.detailSubChannelTextView.setSelected(true);
if (info.getUploaderSubscriberCount() > -1) {
binding.detailUploaderTextView.setText(
Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount()));
Localization.shortSubscriberCount(activity, info.getUploaderSubscriberCount()));
binding.detailUploaderTextView.setVisibility(View.VISIBLE);
} else {
binding.detailUploaderTextView.setVisibility(View.GONE);
}
PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailSubChannelThumbnailView);
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
binding.detailUploaderThumbnailView.setVisibility(View.GONE);
}
private void displayBothUploaderAndSubChannel(final StreamInfo info, final Context context) {
private void displayBothUploaderAndSubChannel(final StreamInfo info) {
binding.detailSubChannelTextView.setText(info.getSubChannelName());
binding.detailSubChannelTextView.setVisibility(View.VISIBLE);
binding.detailSubChannelTextView.setSelected(true);
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
final StringBuilder subText = new StringBuilder();
if (!isEmpty(info.getUploaderName())) {
subText.append(
@ -1633,7 +1606,7 @@ public final class VideoDetailFragment
subText.append(Localization.DOT_SEPARATOR);
}
subText.append(
Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount()));
Localization.shortSubscriberCount(activity, info.getUploaderSubscriberCount()));
}
if (subText.length() > 0) {
@ -1643,6 +1616,13 @@ public final class VideoDetailFragment
} else {
binding.detailUploaderTextView.setVisibility(View.GONE);
}
PicassoHelper.loadAvatar(info.getSubChannelAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailSubChannelThumbnailView);
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
PicassoHelper.loadAvatar(info.getUploaderAvatarUrl()).tag(PICASSO_VIDEO_DETAILS_TAG)
.into(binding.detailUploaderThumbnailView);
binding.detailUploaderThumbnailView.setVisibility(View.VISIBLE);
}
public void openDownloadDialog() {
@ -2013,7 +1993,10 @@ public final class VideoDetailFragment
restoreDefaultBrightness();
} else {
// Do not restore if user has disabled brightness gesture
if (!PlayerHelper.isBrightnessGestureEnabled(activity)) {
if (!PlayerHelper.getActionForRightGestureSide(activity)
.equals(getString(R.string.brightness_control_key))
&& !PlayerHelper.getActionForLeftGestureSide(activity)
.equals(getString(R.string.brightness_control_key))) {
return;
}
// Restore already saved brightness level
@ -2106,10 +2089,11 @@ public final class VideoDetailFragment
.setPositiveButton(R.string.ok, (dialog, which) -> {
onAllow.run();
dialog.dismiss();
}).show();
})
.show();
}
private void showExternalPlaybackDialog() {
private void showExternalVideoPlaybackDialog() {
if (currentInfo == null) {
return;
}
@ -2156,6 +2140,43 @@ public final class VideoDetailFragment
builder.show();
}
private void showExternalAudioPlaybackDialog() {
if (currentInfo == null) {
return;
}
final List<AudioStream> audioStreams = getUrlAndNonTorrentStreams(
currentInfo.getAudioStreams());
final List<AudioStream> audioTracks =
ListHelper.getFilteredAudioStreams(activity, audioStreams);
if (audioTracks.isEmpty()) {
Toast.makeText(activity, R.string.no_audio_streams_available_for_external_players,
Toast.LENGTH_SHORT).show();
} else if (audioTracks.size() == 1) {
startOnExternalPlayer(activity, currentInfo, audioTracks.get(0));
} else {
final int selectedAudioStream =
ListHelper.getDefaultAudioFormat(activity, audioTracks);
final CharSequence[] trackNames = audioTracks.stream()
.map(audioStream -> Localization.audioTrackName(activity, audioStream))
.toArray(CharSequence[]::new);
new AlertDialog.Builder(activity)
.setTitle(R.string.select_audio_track_external_players)
.setNeutralButton(R.string.open_in_browser, (dialog, i) ->
ShareUtils.openUrlInBrowser(requireActivity(), url))
.setSingleChoiceItems(trackNames, selectedAudioStream, null)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok, (dialog, i) -> {
final int index = ((AlertDialog) dialog).getListView()
.getCheckedItemPosition();
startOnExternalPlayer(activity, currentInfo, audioTracks.get(index));
})
.show();
}
}
/*
* Remove unneeded information while waiting for a next task
* */

View File

@ -264,8 +264,6 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
final boolean isThumbnailPermanent = localPlaylistManager
.getIsPlaylistThumbnailPermanent(selectedItem.uid);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final ArrayList<String> items = new ArrayList<>();
items.add(rename);
items.add(delete);
@ -289,7 +287,9 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
}
};
builder.setItems(items.toArray(new String[0]), action).create().show();
new AlertDialog.Builder(activity)
.setItems(items.toArray(new String[0]), action)
.show();
}
private void showRenameDialog(final PlaylistMetadataEntry selectedItem) {
@ -299,14 +299,13 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
dialogBinding.dialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
dialogBinding.dialogEditText.setText(selectedItem.name);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(dialogBinding.getRoot())
new AlertDialog.Builder(activity)
.setView(dialogBinding.getRoot())
.setPositiveButton(R.string.rename_playlist, (dialog, which) ->
changeLocalPlaylistName(
selectedItem.uid,
dialogBinding.dialogEditText.getText().toString()))
.setNegativeButton(R.string.cancel, null)
.create()
.show();
}

View File

@ -231,7 +231,6 @@ class FeedFragment : BaseStateFragment<FeedState>() {
}
}
.setPositiveButton(resources.getString(R.string.ok), null)
.create()
.show()
return true
} else if (item.itemId == R.id.menu_item_feed_toggle_played_items) {
@ -254,22 +253,18 @@ class FeedFragment : BaseStateFragment<FeedState>() {
viewModel.getShowFutureItemsFromPreferences()
)
val builder = AlertDialog.Builder(context!!)
builder.setTitle(R.string.feed_hide_streams_title)
builder.setMultiChoiceItems(dialogItems, checkedDialogItems) { _, which, isChecked ->
AlertDialog.Builder(context!!)
.setTitle(R.string.feed_hide_streams_title)
.setMultiChoiceItems(dialogItems, checkedDialogItems) { _, which, isChecked ->
checkedDialogItems[which] = isChecked
}
builder.setPositiveButton(R.string.ok) { _, _ ->
.setPositiveButton(R.string.ok) { _, _ ->
viewModel.setSaveShowPlayedItems(checkedDialogItems[0])
viewModel.setSaveShowPartiallyPlayedItems(checkedDialogItems[1])
viewModel.setSaveShowFutureItems(checkedDialogItems[2])
}
builder.setNegativeButton(R.string.cancel, null)
builder.create().show()
.setNegativeButton(R.string.cancel, null)
.show()
}
override fun onDestroyOptionsMenu() {
@ -490,15 +485,13 @@ class FeedFragment : BaseStateFragment<FeedState>() {
val builder = AlertDialog.Builder(requireContext())
.setTitle(R.string.feed_load_error)
.setPositiveButton(
R.string.unsubscribe
) { _, _ ->
SubscriptionManager(requireContext()).deleteSubscription(
subscriptionEntity.serviceId, subscriptionEntity.url
).subscribe()
.setPositiveButton(R.string.unsubscribe) { _, _ ->
SubscriptionManager(requireContext())
.deleteSubscription(subscriptionEntity.serviceId, subscriptionEntity.url)
.subscribe()
handleItemsErrors(nextItemsErrors)
}
.setNegativeButton(R.string.cancel) { _, _ -> }
.setNegativeButton(R.string.cancel, null)
var message = getString(R.string.feed_load_error_account_info, subscriptionEntity.name)
if (cause is AccountTerminatedException) {
@ -515,7 +508,8 @@ class FeedFragment : BaseStateFragment<FeedState>() {
message += "\n" + cause.message
}
}
builder.setMessage(message).create().show()
builder.setMessage(message)
.show()
}
private fun updateRelativeTimeViews() {

View File

@ -1,6 +1,8 @@
package org.schabi.newpipe.local.feed.notifications
import android.app.Notification
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
@ -10,48 +12,43 @@ import android.os.Build
import android.provider.Settings
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import androidx.preference.PreferenceManager
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import org.schabi.newpipe.R
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipe.local.feed.service.FeedUpdateInfo
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.PendingIntentCompat
import org.schabi.newpipe.util.PicassoHelper
/**
* Helper for everything related to show notifications about new streams to the user.
*/
class NotificationHelper(val context: Context) {
private val manager = context.getSystemService(
Context.NOTIFICATION_SERVICE
) as NotificationManager
private val manager = NotificationManagerCompat.from(context)
private val iconLoadingTargets = ArrayList<Target>()
/**
* Show a notification about new streams from a single channel.
* Opening the notification will open the corresponding channel page.
* Show notifications for new streams from a single channel. The individual notifications are
* expandable on Android 7.0 and later.
*
* Opening the summary notification will open the corresponding channel page. Opening the
* individual notifications will open the corresponding video.
*/
fun displayNewStreamsNotification(data: FeedUpdateInfo) {
val newStreams: List<StreamInfoItem> = data.newStreams
fun displayNewStreamsNotifications(data: FeedUpdateInfo) {
val newStreams = data.newStreams
val summary = context.resources.getQuantityString(
R.plurals.new_streams, newStreams.size, newStreams.size
)
val builder = NotificationCompat.Builder(
val summaryBuilder = NotificationCompat.Builder(
context,
context.getString(R.string.streams_notification_channel_id)
)
.setContentTitle(Localization.concatenateStrings(data.name, summary))
.setContentText(
data.listInfo.relatedItems.joinToString(
context.getString(R.string.enumeration_comma)
) { x -> x.name }
)
.setContentTitle(data.name)
.setContentText(summary)
.setNumber(newStreams.size)
.setBadgeIconType(NotificationCompat.BADGE_ICON_LARGE)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
@ -60,36 +57,49 @@ class NotificationHelper(val context: Context) {
.setColorized(true)
.setAutoCancel(true)
.setCategory(NotificationCompat.CATEGORY_SOCIAL)
.setGroupSummary(true)
.setGroup(data.listInfo.url)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
// Build style
// Build a summary notification for Android versions < 7.0
val style = NotificationCompat.InboxStyle()
.setBigContentTitle(data.name)
newStreams.forEach { style.addLine(it.name) }
style.setSummaryText(summary)
style.setBigContentTitle(data.name)
builder.setStyle(style)
summaryBuilder.setStyle(style)
// open the channel page when clicking on the notification
builder.setContentIntent(
// open the channel page when clicking on the summary notification
summaryBuilder.setContentIntent(
PendingIntentCompat.getActivity(
context,
data.pseudoId,
NavigationHelper
.getChannelIntent(context, data.listInfo.serviceId, data.listInfo.url)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
0
0,
false
)
)
// a Target is like a listener for image loading events
val target = object : Target {
override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) {
builder.setLargeIcon(bitmap) // set only if there is actually one
manager.notify(data.pseudoId, builder.build())
// set channel icon only if there is actually one (for Android versions < 7.0)
summaryBuilder.setLargeIcon(bitmap)
// Show individual stream notifications, set channel icon only if there is actually
// one
showStreamNotifications(newStreams, data.listInfo.serviceId, bitmap)
// Show summary notification
manager.notify(data.pseudoId, summaryBuilder.build())
iconLoadingTargets.remove(this) // allow it to be garbage-collected
}
override fun onBitmapFailed(e: Exception, errorDrawable: Drawable) {
manager.notify(data.pseudoId, builder.build())
// Show individual stream notifications
showStreamNotifications(newStreams, data.listInfo.serviceId, null)
// Show summary notification
manager.notify(data.pseudoId, summaryBuilder.build())
iconLoadingTargets.remove(this) // allow it to be garbage-collected
}
@ -105,6 +115,49 @@ class NotificationHelper(val context: Context) {
PicassoHelper.loadNotificationIcon(data.avatarUrl).into(target)
}
private fun showStreamNotifications(
newStreams: List<StreamInfoItem>,
serviceId: Int,
channelIcon: Bitmap?
) {
for (stream in newStreams) {
val notification = createStreamNotification(stream, serviceId, channelIcon)
manager.notify(stream.url.hashCode(), notification)
}
}
private fun createStreamNotification(
item: StreamInfoItem,
serviceId: Int,
channelIcon: Bitmap?
): Notification {
return NotificationCompat.Builder(
context,
context.getString(R.string.streams_notification_channel_id)
)
.setSmallIcon(R.drawable.ic_newpipe_triangle_white)
.setLargeIcon(channelIcon)
.setContentTitle(item.name)
.setContentText(item.uploaderName)
.setGroup(item.uploaderUrl)
.setColor(ContextCompat.getColor(context, R.color.ic_launcher_background))
.setColorized(true)
.setAutoCancel(true)
.setCategory(NotificationCompat.CATEGORY_SOCIAL)
.setContentIntent(
// Open the stream link in the player when clicking on the notification.
PendingIntentCompat.getActivity(
context,
item.url.hashCode(),
NavigationHelper.getStreamIntent(context, serviceId, item.url, item.name),
PendingIntent.FLAG_UPDATE_CURRENT,
false
)
)
.setSilent(true) // Avoid creating noise for individual stream notifications.
.build()
}
companion object {
/**
* Check whether notifications are enabled on the device.
@ -123,9 +176,7 @@ class NotificationHelper(val context: Context) {
fun areNotificationsEnabledOnDevice(context: Context): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channelId = context.getString(R.string.streams_notification_channel_id)
val manager = context.getSystemService(
Context.NOTIFICATION_SERVICE
) as NotificationManager
val manager = context.getSystemService<NotificationManager>()!!
val enabled = manager.areNotificationsEnabled()
val channel = manager.getNotificationChannel(channelId)
val importance = channel?.importance

View File

@ -55,7 +55,7 @@ class NotificationWorker(
.map { feedUpdateInfoList ->
// display notifications for each feedUpdateInfo (i.e. channel)
feedUpdateInfoList.forEach { feedUpdateInfo ->
notificationHelper.displayNewStreamsNotification(feedUpdateInfo)
notificationHelper.displayNewStreamsNotifications(feedUpdateInfo)
}
return@map Result.success()
}

View File

@ -29,6 +29,7 @@ import android.os.IBinder
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.app.ServiceCompat
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
@ -42,7 +43,6 @@ import org.schabi.newpipe.extractor.ListInfo
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ErrorResultEvent
import org.schabi.newpipe.local.feed.service.FeedEventManager.postEvent
import org.schabi.newpipe.util.PendingIntentCompat
import java.util.concurrent.TimeUnit
class FeedLoadService : Service() {
@ -95,13 +95,7 @@ class FeedLoadService : Service() {
.doOnSubscribe {
startForeground(NOTIFICATION_ID, notificationBuilder.build())
}
.subscribe { _, error ->
// There seems to be a bug in the kotlin plugin as it tells you when
// building that this can't be null:
// "Condition 'error != null' is always 'true'"
// However it can indeed be null
// The suppression may be removed in further versions
@Suppress("SENSELESS_COMPARISON")
.subscribe { _, error: Throwable? -> // explicitly mark error as nullable
if (error != null) {
Log.e(TAG, "Error while storing result", error)
handleError(error)
@ -152,8 +146,8 @@ class FeedLoadService : Service() {
private lateinit var notificationBuilder: NotificationCompat.Builder
private fun createNotification(): NotificationCompat.Builder {
val cancelActionIntent =
PendingIntentCompat.getBroadcast(this, NOTIFICATION_ID, Intent(ACTION_CANCEL), 0)
val cancelActionIntent = PendingIntentCompat
.getBroadcast(this, NOTIFICATION_ID, Intent(ACTION_CANCEL), 0, false)
return NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setOngoing(true)

View File

@ -5,7 +5,6 @@ import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.InputType;
@ -358,14 +357,13 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
new AlertDialog.Builder(requireContext())
.setMessage(R.string.remove_watched_popup_warning)
.setTitle(R.string.remove_watched_popup_title)
.setPositiveButton(R.string.ok,
(DialogInterface d, int id) -> removeWatchedStreams(false))
.setPositiveButton(R.string.ok, (d, id) ->
removeWatchedStreams(false))
.setNeutralButton(
R.string.remove_watched_popup_yes_and_partially_watched_videos,
(DialogInterface d, int id) -> removeWatchedStreams(true))
(d, id) -> removeWatchedStreams(true))
.setNegativeButton(R.string.cancel,
(DialogInterface d, int id) -> d.cancel())
.create()
(d, id) -> d.cancel())
.show();
}
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {
@ -560,15 +558,14 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
dialogBinding.dialogEditText.setSelection(dialogBinding.dialogEditText.getText().length());
dialogBinding.dialogEditText.setText(name);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext())
new AlertDialog.Builder(getContext())
.setTitle(R.string.rename_playlist)
.setView(dialogBinding.getRoot())
.setCancelable(true)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.rename, (dialogInterface, i) ->
changePlaylistName(dialogBinding.dialogEditText.getText().toString()));
dialogBuilder.show();
changePlaylistName(dialogBinding.dialogEditText.getText().toString()))
.show();
}
private void changePlaylistName(final String title) {
@ -634,15 +631,13 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
}
private void openRemoveDuplicatesDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
builder.setTitle(R.string.remove_duplicates_title)
new AlertDialog.Builder(this.getActivity())
.setTitle(R.string.remove_duplicates_title)
.setMessage(R.string.remove_duplicates_message)
.setPositiveButton(R.string.ok,
(dialog, i) -> removeDuplicatesInPlaylist())
.setNeutralButton(R.string.cancel, null);
builder.create().show();
.setPositiveButton(R.string.ok, (dialog, i) ->
removeDuplicatesInPlaylist())
.setNeutralButton(R.string.cancel, null)
.show();
}
private void removeDuplicatesInPlaylist() {

View File

@ -352,7 +352,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
AlertDialog.Builder(requireContext())
.setCustomTitle(dialogTitleBinding.root)
.setItems(commands, actions)
.create()
.show()
}

View File

@ -13,6 +13,7 @@ import android.provider.Settings;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
@ -27,11 +28,13 @@ import com.google.android.exoplayer2.PlaybackParameters;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ActivityPlayerQueueControlBinding;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
import org.schabi.newpipe.local.dialog.PlaylistDialog;
import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.helper.PlaybackParameterDialog;
import org.schabi.newpipe.player.mediaitem.MediaItemTag;
import org.schabi.newpipe.player.playqueue.PlayQueue;
import org.schabi.newpipe.player.playqueue.PlayQueueAdapter;
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
@ -44,6 +47,9 @@ import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import java.util.List;
import java.util.Optional;
public final class PlayQueueActivity extends AppCompatActivity
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
View.OnClickListener, PlaybackParameterDialog.Callback {
@ -52,6 +58,8 @@ public final class PlayQueueActivity extends AppCompatActivity
private static final int SMOOTH_SCROLL_MAXIMUM_DISTANCE = 80;
private static final int MENU_ID_AUDIO_TRACK = 71;
private Player player;
private boolean serviceBound;
@ -97,6 +105,7 @@ public final class PlayQueueActivity extends AppCompatActivity
this.menu = m;
getMenuInflater().inflate(R.menu.menu_play_queue, m);
getMenuInflater().inflate(R.menu.menu_play_queue_bg, m);
buildAudioTrackMenu();
onMaybeMuteChanged();
// to avoid null reference
if (player != null) {
@ -153,6 +162,12 @@ public final class PlayQueueActivity extends AppCompatActivity
NavigationHelper.playOnBackgroundPlayer(this, player.getPlayQueue(), true);
return true;
}
if (item.getGroupId() == MENU_ID_AUDIO_TRACK) {
onAudioTrackClick(item.getItemId());
return true;
}
return super.onOptionsItemSelected(item);
}
@ -591,4 +606,69 @@ public final class PlayQueueActivity extends AppCompatActivity
item.setIcon(player.isMuted() ? R.drawable.ic_volume_off : R.drawable.ic_volume_up);
}
}
@Override
public void onAudioTrackUpdate() {
buildAudioTrackMenu();
}
private void buildAudioTrackMenu() {
if (menu == null) {
return;
}
final MenuItem audioTrackSelector = menu.findItem(R.id.action_audio_track);
final List<AudioStream> availableStreams =
Optional.ofNullable(player.getCurrentMetadata())
.flatMap(MediaItemTag::getMaybeAudioTrack)
.map(MediaItemTag.AudioTrack::getAudioStreams)
.orElse(null);
final Optional<AudioStream> selectedAudioStream = player.getSelectedAudioStream();
if (availableStreams == null || availableStreams.size() < 2
|| selectedAudioStream.isEmpty()) {
audioTrackSelector.setVisible(false);
} else {
final SubMenu audioTrackMenu = audioTrackSelector.getSubMenu();
audioTrackMenu.clear();
for (int i = 0; i < availableStreams.size(); i++) {
final AudioStream audioStream = availableStreams.get(i);
audioTrackMenu.add(MENU_ID_AUDIO_TRACK, i, Menu.NONE,
Localization.audioTrackName(this, audioStream));
}
final AudioStream s = selectedAudioStream.get();
final String trackName = Localization.audioTrackName(this, s);
audioTrackSelector.setTitle(
getString(R.string.play_queue_audio_track, trackName));
final String shortName = s.getAudioLocale() != null
? s.getAudioLocale().getLanguage() : trackName;
audioTrackSelector.setTitleCondensed(
shortName.substring(0, Math.min(shortName.length(), 2)));
audioTrackSelector.setVisible(true);
}
}
/**
* Called when an item from the audio track selector is selected.
*
* @param itemId index of the selected item
*/
private void onAudioTrackClick(final int itemId) {
if (player.getCurrentMetadata() == null) {
return;
}
player.getCurrentMetadata().getMaybeAudioTrack().ifPresent(audioTrack -> {
final List<AudioStream> availableStreams = audioTrack.getAudioStreams();
final int selectedStreamIndex = audioTrack.getSelectedAudioStreamIndex();
if (selectedStreamIndex == itemId || availableStreams.size() <= itemId) {
return;
}
final String newAudioTrack = availableStreams.get(itemId).getAudioTrackId();
player.setAudioTrack(newAudioTrack);
});
}
}

View File

@ -69,7 +69,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player.PositionInfo;
import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Tracks;
import com.google.android.exoplayer2.source.MediaSource;
@ -77,7 +76,6 @@ import com.google.android.exoplayer2.text.CueGroup;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
@ -88,6 +86,7 @@ import org.schabi.newpipe.databinding.PlayerBinding;
import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.ErrorUtil;
import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -96,6 +95,7 @@ import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.event.PlayerServiceEventListener;
import org.schabi.newpipe.player.helper.AudioReactor;
import org.schabi.newpipe.player.helper.CustomRenderersFactory;
import org.schabi.newpipe.player.helper.LoadController;
import org.schabi.newpipe.player.helper.PlayerDataSource;
import org.schabi.newpipe.player.helper.PlayerHelper;
@ -115,7 +115,6 @@ import org.schabi.newpipe.player.ui.PlayerUiList;
import org.schabi.newpipe.player.ui.PopupPlayerUi;
import org.schabi.newpipe.player.ui.VideoPlayerUi;
import org.schabi.newpipe.util.DependentPreferenceHelper;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PicassoHelper;
@ -181,13 +180,18 @@ public final class Player implements PlaybackListener, Listener {
//////////////////////////////////////////////////////////////////////////*/
// play queue might be null e.g. while player is starting
@Nullable private PlayQueue playQueue;
@Nullable
private PlayQueue playQueue;
@Nullable private MediaSourceManager playQueueManager;
@Nullable
private MediaSourceManager playQueueManager;
@Nullable private PlayQueueItem currentItem;
@Nullable private MediaItemTag currentMetadata;
@Nullable private Bitmap currentThumbnail;
@Nullable
private PlayQueueItem currentItem;
@Nullable
private MediaItemTag currentMetadata;
@Nullable
private Bitmap currentThumbnail;
/*//////////////////////////////////////////////////////////////////////////
// Player
@ -196,12 +200,17 @@ public final class Player implements PlaybackListener, Listener {
private ExoPlayer simpleExoPlayer;
private AudioReactor audioReactor;
@NonNull private final DefaultTrackSelector trackSelector;
@NonNull private final LoadController loadController;
@NonNull private final RenderersFactory renderFactory;
@NonNull
private final DefaultTrackSelector trackSelector;
@NonNull
private final LoadController loadController;
@NonNull
private final DefaultRenderersFactory renderFactory;
@NonNull private final VideoPlaybackResolver videoResolver;
@NonNull private final AudioPlaybackResolver audioResolver;
@NonNull
private final VideoPlaybackResolver videoResolver;
@NonNull
private final AudioPlaybackResolver audioResolver;
private final PlayerService service; //TODO try to remove and replace everything with context
@ -226,24 +235,32 @@ public final class Player implements PlaybackListener, Listener {
private BroadcastReceiver broadcastReceiver;
private IntentFilter intentFilter;
@Nullable private PlayerServiceEventListener fragmentListener = null;
@Nullable private PlayerEventListener activityListener = null;
@Nullable
private PlayerServiceEventListener fragmentListener = null;
@Nullable
private PlayerEventListener activityListener = null;
@NonNull private final SerialDisposable progressUpdateDisposable = new SerialDisposable();
@NonNull private final CompositeDisposable databaseUpdateDisposable = new CompositeDisposable();
@NonNull
private final SerialDisposable progressUpdateDisposable = new SerialDisposable();
@NonNull
private final CompositeDisposable databaseUpdateDisposable = new CompositeDisposable();
// This is the only listener we need for thumbnail loading, since there is always at most only
// one thumbnail being loaded at a time. This field is also here to maintain a strong reference,
// which would otherwise be garbage collected since Picasso holds weak references to targets.
@NonNull private final Target currentThumbnailTarget;
@NonNull
private final Target currentThumbnailTarget;
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
@NonNull private final Context context;
@NonNull private final SharedPreferences prefs;
@NonNull private final HistoryRecordManager recordManager;
@NonNull
private final Context context;
@NonNull
private final SharedPreferences prefs;
@NonNull
private final HistoryRecordManager recordManager;
/*//////////////////////////////////////////////////////////////////////////
@ -263,7 +280,16 @@ public final class Player implements PlaybackListener, Listener {
final PlayerDataSource dataSource = new PlayerDataSource(context,
new DefaultBandwidthMeter.Builder(context).build());
loadController = new LoadController();
renderFactory = new DefaultRenderersFactory(context);
renderFactory = prefs.getBoolean(
context.getString(
R.string.always_use_exoplayer_set_output_surface_workaround_key), false)
? new CustomRenderersFactory(context) : new DefaultRenderersFactory(context);
renderFactory.setEnableDecoderFallback(
prefs.getBoolean(
context.getString(
R.string.use_exoplayer_decoder_fallback_key), false));
videoResolver = new VideoPlaybackResolver(context, dataSource, getQualityResolver());
audioResolver = new AudioPlaybackResolver(context, dataSource);
@ -326,7 +352,7 @@ public final class Player implements PlaybackListener, Listener {
isAudioOnly = audioPlayerSelected();
if (intent.hasExtra(PLAYBACK_QUALITY)) {
setPlaybackQuality(intent.getStringExtra(PLAYBACK_QUALITY));
videoResolver.setPlaybackQuality(intent.getStringExtra(PLAYBACK_QUALITY));
}
// Resolve enqueue intents
@ -520,16 +546,11 @@ public final class Player implements PlaybackListener, Listener {
// Setup UIs
UIs.call(PlayerUi::initPlayer);
// enable media tunneling
if (DEBUG && PreferenceManager.getDefaultSharedPreferences(context)
// Disable media tunneling if requested by the user from ExoPlayer settings
if (!PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.disable_media_tunneling_key), false)) {
Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] "
+ "media tunneling disabled in debug preferences");
} else if (DeviceUtils.shouldSupportMediaTunneling()) {
trackSelector.setParameters(trackSelector.buildUponParameters()
.setTunnelingEnabled(true));
} else if (DEBUG) {
Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] does not support media tunneling");
}
}
//endregion
@ -920,7 +941,6 @@ public final class Player implements PlaybackListener, Listener {
//endregion
/*//////////////////////////////////////////////////////////////////////////
// Playback states
//////////////////////////////////////////////////////////////////////////*/
@ -1242,6 +1262,9 @@ public final class Player implements PlaybackListener, Listener {
}
final StreamInfo previousInfo = Optional.ofNullable(currentMetadata)
.flatMap(MediaItemTag::getMaybeStreamInfo).orElse(null);
final MediaItemTag.AudioTrack previousAudioTrack =
Optional.ofNullable(currentMetadata)
.flatMap(MediaItemTag::getMaybeAudioTrack).orElse(null);
currentMetadata = tag;
if (!currentMetadata.getErrors().isEmpty()) {
@ -1262,6 +1285,12 @@ public final class Player implements PlaybackListener, Listener {
if (previousInfo == null || !previousInfo.getUrl().equals(info.getUrl())) {
// only update with the new stream info if it has actually changed
updateMetadataWith(info);
} else if (previousAudioTrack == null
|| tag.getMaybeAudioTrack()
.map(t -> t.getSelectedAudioStreamIndex()
!= previousAudioTrack.getSelectedAudioStreamIndex())
.orElse(false)) {
notifyAudioTrackUpdateToListeners();
}
});
});
@ -1349,6 +1378,7 @@ public final class Player implements PlaybackListener, Listener {
// Errors
//////////////////////////////////////////////////////////////////////////*/
//region Errors
/**
* Process exceptions produced by {@link com.google.android.exoplayer2.ExoPlayer ExoPlayer}.
* <p>There are multiple types of errors:</p>
@ -1375,8 +1405,9 @@ public final class Player implements PlaybackListener, Listener {
* For any error above that is <b>not</b> explicitly <b>catchable</b>, the player will
* create a notification so users are aware.
* </ul>
*
* @see com.google.android.exoplayer2.Player.Listener#onPlayerError(PlaybackException)
* */
*/
// Any error code not explicitly covered here are either unrelated to NewPipe use case
// (e.g. DRM) or not recoverable (e.g. Decoder error). In both cases, the player should
// shutdown.
@ -1758,6 +1789,7 @@ public final class Player implements PlaybackListener, Listener {
registerStreamViewed();
notifyMetadataUpdateToListeners();
notifyAudioTrackUpdateToListeners();
UIs.call(playerUi -> playerUi.onMetadataChanged(info));
}
@ -1886,6 +1918,12 @@ public final class Player implements PlaybackListener, Listener {
.map(quality -> quality.getSortedVideoStreams()
.get(quality.getSelectedVideoStreamIndex()));
}
public Optional<AudioStream> getSelectedAudioStream() {
return Optional.ofNullable(currentMetadata)
.flatMap(MediaItemTag::getMaybeAudioTrack)
.map(MediaItemTag.AudioTrack::getSelectedAudioStream);
}
//endregion
@ -2017,44 +2055,46 @@ public final class Player implements PlaybackListener, Listener {
}
}
private void notifyAudioTrackUpdateToListeners() {
if (fragmentListener != null) {
fragmentListener.onAudioTrackUpdate();
}
if (activityListener != null) {
activityListener.onAudioTrackUpdate();
}
}
public void useVideoSource(final boolean videoEnabled) {
if (playQueue == null || isAudioOnly == !videoEnabled || audioPlayerSelected()) {
if (playQueue == null || audioPlayerSelected()) {
return;
}
isAudioOnly = !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.
// 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.
getCurrentStreamInfo().ifPresentOrElse(info -> {
// In the case we don't know the source type, fallback to the one with video with audio
// or audio-only source.
// In case we don't know the source type, fall back to either video-with-audio, or
// audio-only source type
final SourceType sourceType = videoResolver.getStreamSourceType()
.orElse(SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY);
if (playQueueManagerReloadingNeeded(sourceType, info, getVideoRendererIndex())) {
reloadPlayQueueManager();
} else {
if (StreamTypeUtil.isAudio(info.getStreamType())) {
// Nothing to do more than setting the recovery position
setRecovery();
return;
}
final var parametersBuilder = trackSelector.buildUponParameters();
// Enable/disable the video track and the ability to select subtitles
parametersBuilder.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, !videoEnabled);
parametersBuilder.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, !videoEnabled);
trackSelector.setParameters(parametersBuilder);
}
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));
}, () -> {
// This is executed when the current stream info is not available.
/*
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
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
*/
reloadPlayQueueManager();
setRecovery();
});
@ -2175,7 +2215,18 @@ public final class Player implements PlaybackListener, Listener {
}
public void setPlaybackQuality(@Nullable final String quality) {
saveStreamProgressState();
setRecovery();
videoResolver.setPlaybackQuality(quality);
reloadPlayQueueManager();
}
public void setAudioTrack(@Nullable final String audioTrackId) {
saveStreamProgressState();
setRecovery();
videoResolver.setAudioTrack(audioTrackId);
audioResolver.setAudioTrack(audioTrackId);
reloadPlayQueueManager();
}
@ -2253,7 +2304,7 @@ public final class Player implements PlaybackListener, Listener {
/**
* Get the video renderer index of the current playing stream.
*
* <p>
* This method returns the video renderer index of the current
* {@link MappingTrackSelector.MappedTrackInfo} or {@link #RENDERER_UNAVAILABLE} if the current
* {@link MappingTrackSelector.MappedTrackInfo} is null or if there is no video renderer index.

View File

@ -31,6 +31,8 @@ import android.util.Log;
import org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi;
import org.schabi.newpipe.util.ThemeHelper;
import java.lang.ref.WeakReference;
/**
* One service for all players.
@ -41,7 +43,7 @@ public final class PlayerService extends Service {
private Player player;
private final IBinder mBinder = new PlayerService.LocalBinder();
private final IBinder mBinder = new PlayerService.LocalBinder(this);
/*//////////////////////////////////////////////////////////////////////////
@ -134,14 +136,19 @@ public final class PlayerService extends Service {
return mBinder;
}
public class LocalBinder extends Binder {
public static class LocalBinder extends Binder {
private final WeakReference<PlayerService> playerService;
LocalBinder(final PlayerService playerService) {
this.playerService = new WeakReference<>(playerService);
}
public PlayerService getService() {
return PlayerService.this;
return playerService.get();
}
public Player getPlayer() {
return PlayerService.this.player;
return playerService.get().player;
}
}
}

View File

@ -11,5 +11,6 @@ public interface PlayerEventListener {
PlaybackParameters parameters);
void onProgressUpdate(int currentProgress, int duration, int bufferPercent);
void onMetadataUpdate(StreamInfo info, PlayQueue queue);
default void onAudioTrackUpdate() { }
void onServiceStopped();
}

View File

@ -193,18 +193,20 @@ class MainPlayerGestureListener(
isMoving = true
// -- Brightness and Volume control --
val isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(player.context)
val isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(player.context)
if (isBrightnessGestureEnabled && isVolumeGestureEnabled) {
if (getDisplayHalfPortion(initialEvent) === DisplayPortion.LEFT_HALF) {
onScrollBrightness(distanceY)
} else /* DisplayPortion.RIGHT_HALF */ {
if (getDisplayHalfPortion(initialEvent) == DisplayPortion.RIGHT_HALF) {
when (PlayerHelper.getActionForRightGestureSide(player.context)) {
player.context.getString(R.string.volume_control_key) ->
onScrollVolume(distanceY)
player.context.getString(R.string.brightness_control_key) ->
onScrollBrightness(distanceY)
}
} else if (isBrightnessGestureEnabled) {
onScrollBrightness(distanceY)
} else if (isVolumeGestureEnabled) {
} else {
when (PlayerHelper.getActionForLeftGestureSide(player.context)) {
player.context.getString(R.string.volume_control_key) ->
onScrollVolume(distanceY)
player.context.getString(R.string.brightness_control_key) ->
onScrollBrightness(distanceY)
}
}
return true

View File

@ -0,0 +1,54 @@
package org.schabi.newpipe.player.helper;
import android.content.Context;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.mediacodec.MediaCodecAdapter;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
/**
* A {@link MediaCodecVideoRenderer} which always enable the output surface workaround that
* ExoPlayer enables on several devices which are known to implement
* {@link android.media.MediaCodec#setOutputSurface(android.view.Surface)
* MediaCodec.setOutputSurface(Surface)} incorrectly.
*
* <p>
* See {@link MediaCodecVideoRenderer#codecNeedsSetOutputSurfaceWorkaround(String)} for more
* details.
* </p>
*
* <p>
* This custom {@link MediaCodecVideoRenderer} may be useful in the case a device is affected by
* this issue but is not present in ExoPlayer's list.
* </p>
*
* <p>
* This class has only effect on devices with Android 6 and higher, as the {@code setOutputSurface}
* method is only implemented in these Android versions and the method used as a workaround is
* always applied on older Android versions (releasing and re-instantiating video codec instances).
* </p>
*/
public final class CustomMediaCodecVideoRenderer extends MediaCodecVideoRenderer {
@SuppressWarnings({"checkstyle:ParameterNumber", "squid:S107"})
public CustomMediaCodecVideoRenderer(final Context context,
final MediaCodecAdapter.Factory codecAdapterFactory,
final MediaCodecSelector mediaCodecSelector,
final long allowedJoiningTimeMs,
final boolean enableDecoderFallback,
@Nullable final Handler eventHandler,
@Nullable final VideoRendererEventListener eventListener,
final int maxDroppedFramesToNotify) {
super(context, codecAdapterFactory, mediaCodecSelector, allowedJoiningTimeMs,
enableDecoderFallback, eventHandler, eventListener, maxDroppedFramesToNotify);
}
@Override
protected boolean codecNeedsSetOutputSurfaceWorkaround(final String name) {
return true;
}
}

View File

@ -0,0 +1,43 @@
package org.schabi.newpipe.player.helper;
import android.content.Context;
import android.os.Handler;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import java.util.ArrayList;
/**
* A {@link DefaultRenderersFactory} which only uses {@link CustomMediaCodecVideoRenderer} as an
* implementation of video codec renders.
*
* <p>
* As no ExoPlayer extension is currently used, the reflection code used by ExoPlayer to try to
* load video extension libraries is not needed in our case and has been removed. This should be
* changed in the case an extension is shipped with the app, such as the AV1 one.
* </p>
*/
public final class CustomRenderersFactory extends DefaultRenderersFactory {
public CustomRenderersFactory(final Context context) {
super(context);
}
@SuppressWarnings("checkstyle:ParameterNumber")
@Override
protected void buildVideoRenderers(final Context context,
@ExtensionRendererMode final int extensionRendererMode,
final MediaCodecSelector mediaCodecSelector,
final boolean enableDecoderFallback,
final Handler eventHandler,
final VideoRendererEventListener eventListener,
final long allowedVideoJoiningTimeMs,
final ArrayList<Renderer> out) {
out.add(new CustomMediaCodecVideoRenderer(context, getCodecAdapterFactory(),
mediaCodecSelector, allowedVideoJoiningTimeMs, enableDecoderFallback, eventHandler,
eventListener, MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY));
}
}

View File

@ -228,14 +228,16 @@ public final class PlayerHelper {
.getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), false);
}
public static boolean isVolumeGestureEnabled(@NonNull final Context context) {
public static String getActionForRightGestureSide(@NonNull final Context context) {
return getPreferences(context)
.getBoolean(context.getString(R.string.volume_gesture_control_key), true);
.getString(context.getString(R.string.right_gesture_control_key),
context.getString(R.string.default_right_gesture_control_value));
}
public static boolean isBrightnessGestureEnabled(@NonNull final Context context) {
public static String getActionForLeftGestureSide(@NonNull final Context context) {
return getPreferences(context)
.getBoolean(context.getString(R.string.brightness_gesture_control_key), true);
.getString(context.getString(R.string.left_gesture_control_key),
context.getString(R.string.default_left_gesture_control_value));
}
public static boolean isStartMainPlayerFullscreenEnabled(@NonNull final Context context) {

View File

@ -7,6 +7,7 @@ import com.google.android.exoplayer2.MediaItem.RequestMetadata;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.Player;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -55,6 +56,11 @@ public interface MediaItemTag {
return Optional.empty();
}
@NonNull
default Optional<AudioTrack> getMaybeAudioTrack() {
return Optional.empty();
}
<T> Optional<T> getMaybeExtras(@NonNull Class<T> type);
<T> MediaItemTag withExtras(@NonNull T extra);
@ -128,4 +134,37 @@ public interface MediaItemTag {
? null : sortedVideoStreams.get(selectedVideoStreamIndex);
}
}
final class AudioTrack {
@NonNull
private final List<AudioStream> audioStreams;
private final int selectedAudioStreamIndex;
private AudioTrack(@NonNull final List<AudioStream> audioStreams,
final int selectedAudioStreamIndex) {
this.audioStreams = audioStreams;
this.selectedAudioStreamIndex = selectedAudioStreamIndex;
}
static AudioTrack of(@NonNull final List<AudioStream> audioStreams,
final int selectedAudioStreamIndex) {
return new AudioTrack(audioStreams, selectedAudioStreamIndex);
}
@NonNull
public List<AudioStream> getAudioStreams() {
return audioStreams;
}
public int getSelectedAudioStreamIndex() {
return selectedAudioStreamIndex;
}
@Nullable
public AudioStream getSelectedAudioStream() {
return selectedAudioStreamIndex < 0
|| selectedAudioStreamIndex >= audioStreams.size()
? null : audioStreams.get(selectedAudioStreamIndex);
}
}
}

View File

@ -2,6 +2,7 @@ package org.schabi.newpipe.player.mediaitem;
import com.google.android.exoplayer2.MediaItem;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -25,25 +26,41 @@ public final class StreamInfoTag implements MediaItemTag {
@Nullable
private final MediaItemTag.Quality quality;
@Nullable
private final MediaItemTag.AudioTrack audioTrack;
@Nullable
private final Object extras;
private StreamInfoTag(@NonNull final StreamInfo streamInfo,
@Nullable final MediaItemTag.Quality quality,
@Nullable final MediaItemTag.AudioTrack audioTrack,
@Nullable final Object extras) {
this.streamInfo = streamInfo;
this.quality = quality;
this.audioTrack = audioTrack;
this.extras = extras;
}
public static StreamInfoTag of(@NonNull final StreamInfo streamInfo,
@NonNull final List<VideoStream> sortedVideoStreams,
final int selectedVideoStreamIndex) {
final int selectedVideoStreamIndex,
@NonNull final List<AudioStream> audioStreams,
final int selectedAudioStreamIndex) {
final Quality quality = Quality.of(sortedVideoStreams, selectedVideoStreamIndex);
return new StreamInfoTag(streamInfo, quality, null);
final AudioTrack audioTrack =
AudioTrack.of(audioStreams, selectedAudioStreamIndex);
return new StreamInfoTag(streamInfo, quality, audioTrack, null);
}
public static StreamInfoTag of(@NonNull final StreamInfo streamInfo,
@NonNull final List<AudioStream> audioStreams,
final int selectedAudioStreamIndex) {
final AudioTrack audioTrack =
AudioTrack.of(audioStreams, selectedAudioStreamIndex);
return new StreamInfoTag(streamInfo, null, audioTrack, null);
}
public static StreamInfoTag of(@NonNull final StreamInfo streamInfo) {
return new StreamInfoTag(streamInfo, null, null);
return new StreamInfoTag(streamInfo, null, null, null);
}
@Override
@ -103,6 +120,12 @@ public final class StreamInfoTag implements MediaItemTag {
return Optional.ofNullable(quality);
}
@NonNull
@Override
public Optional<AudioTrack> getMaybeAudioTrack() {
return Optional.ofNullable(audioTrack);
}
@Override
public <T> Optional<T> getMaybeExtras(@NonNull final Class<T> type) {
return Optional.ofNullable(extras).map(type::cast);
@ -110,6 +133,6 @@ public final class StreamInfoTag implements MediaItemTag {
@Override
public StreamInfoTag withExtras(@NonNull final Object extra) {
return new StreamInfoTag(streamInfo, quality, extra);
return new StreamInfoTag(streamInfo, quality, audioTrack, extra);
}
}

View File

@ -13,6 +13,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.PendingIntentCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;
@ -21,7 +22,6 @@ import org.schabi.newpipe.R;
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PendingIntentCompat;
import java.util.List;
import java.util.Objects;
@ -134,7 +134,7 @@ public final class NotificationUtil {
.setColorized(player.getPrefs().getBoolean(
player.getContext().getString(R.string.notification_colorize_key), true))
.setDeleteIntent(PendingIntentCompat.getBroadcast(player.getContext(),
NOTIFICATION_ID, new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT));
NOTIFICATION_ID, new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT, false));
// set the initial value for the video thumbnail, updatable with updateNotificationThumbnail
setLargeIcon(builder);
@ -152,7 +152,7 @@ public final class NotificationUtil {
// also update content intent, in case the user switched players
notificationBuilder.setContentIntent(PendingIntentCompat.getActivity(player.getContext(),
NOTIFICATION_ID, getIntentForNotification(), FLAG_UPDATE_CURRENT));
NOTIFICATION_ID, getIntentForNotification(), FLAG_UPDATE_CURRENT, false));
notificationBuilder.setContentTitle(player.getVideoTitle());
notificationBuilder.setContentText(player.getUploaderName());
notificationBuilder.setTicker(player.getVideoTitle());
@ -335,7 +335,7 @@ public final class NotificationUtil {
final String intentAction) {
return new NotificationCompat.Action(drawable, player.getContext().getString(title),
PendingIntentCompat.getBroadcast(player.getContext(), NOTIFICATION_ID,
new Intent(intentAction), FLAG_UPDATE_CURRENT));
new Intent(intentAction), FLAG_UPDATE_CURRENT, false));
}
private Intent getIntentForNotification() {

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.player.resolver;
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
import android.content.Context;
import android.util.Log;
@ -28,6 +29,8 @@ public class AudioPlaybackResolver implements PlaybackResolver {
private final Context context;
@NonNull
private final PlayerDataSource dataSource;
@Nullable
private String audioTrack;
public AudioPlaybackResolver(@NonNull final Context context,
@NonNull final PlayerDataSource dataSource) {
@ -35,6 +38,13 @@ public class AudioPlaybackResolver implements PlaybackResolver {
this.dataSource = dataSource;
}
/**
* Get a media source providing audio. If a service has no separate {@link AudioStream}s we
* use a video stream as audio source to support audio background playback.
*
* @param info of the stream
* @return the audio source to use or null if none could be found
*/
@Override
@Nullable
public MediaSource resolve(@NonNull final StreamInfo info) {
@ -43,12 +53,27 @@ public class AudioPlaybackResolver implements PlaybackResolver {
return liveSource;
}
final Stream stream = getAudioSource(info);
if (stream == null) {
final List<AudioStream> audioStreams =
getFilteredAudioStreams(context, info.getAudioStreams());
final Stream stream;
final MediaItemTag tag;
if (!audioStreams.isEmpty()) {
final int audioIndex =
ListHelper.getAudioFormatIndex(context, audioStreams, audioTrack);
stream = getStreamForIndex(audioIndex, audioStreams);
tag = StreamInfoTag.of(info, audioStreams, audioIndex);
} else {
final List<VideoStream> videoStreams =
getPlayableStreams(info.getVideoStreams(), info.getServiceId());
if (!videoStreams.isEmpty()) {
final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams);
stream = getStreamForIndex(index, videoStreams);
tag = StreamInfoTag.of(info);
} else {
return null;
}
final MediaItemTag tag = StreamInfoTag.of(info);
}
try {
return PlaybackResolver.buildMediaSource(
@ -59,29 +84,6 @@ public class AudioPlaybackResolver implements PlaybackResolver {
}
}
/**
* Get a stream to be played as audio. If a service has no separate {@link AudioStream}s we
* use a video stream as audio source to support audio background playback.
*
* @param info of the stream
* @return the audio source to use or null if none could be found
*/
@Nullable
private Stream getAudioSource(@NonNull final StreamInfo info) {
final List<AudioStream> audioStreams = getNonTorrentStreams(info.getAudioStreams());
if (!audioStreams.isEmpty()) {
final int index = ListHelper.getDefaultAudioFormat(context, audioStreams);
return getStreamForIndex(index, audioStreams);
} else {
final List<VideoStream> videoStreams = getNonTorrentStreams(info.getVideoStreams());
if (!videoStreams.isEmpty()) {
final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams);
return getStreamForIndex(index, videoStreams);
}
}
return null;
}
@Nullable
Stream getStreamForIndex(final int index, @NonNull final List<? extends Stream> streams) {
if (index >= 0 && index < streams.size()) {
@ -89,4 +91,13 @@ public class AudioPlaybackResolver implements PlaybackResolver {
}
return null;
}
@Nullable
public String getAudioTrack() {
return audioTrack;
}
public void setAudioTrack(@Nullable final String audioLanguage) {
this.audioTrack = audioLanguage;
}
}

View File

@ -156,6 +156,16 @@ public interface PlaybackResolver extends Resolver<StreamInfo, MediaSource> {
cacheKey.append(audioStream.getAverageBitrate());
}
if (audioStream.getAudioTrackId() != null) {
cacheKey.append(" ");
cacheKey.append(audioStream.getAudioTrackId());
}
if (audioStream.getAudioLocale() != null) {
cacheKey.append(" ");
cacheKey.append(audioStream.getAudioLocale().getISO3Language());
}
return cacheKey.toString();
}

View File

@ -28,8 +28,9 @@ import java.util.List;
import java.util.Optional;
import static com.google.android.exoplayer2.C.TIME_UNSET;
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
public class VideoPlaybackResolver implements PlaybackResolver {
private static final String TAG = VideoPlaybackResolver.class.getSimpleName();
@ -44,6 +45,8 @@ public class VideoPlaybackResolver implements PlaybackResolver {
@Nullable
private String playbackQuality;
@Nullable
private String audioTrack;
public enum SourceType {
LIVE_STREAM,
@ -72,21 +75,31 @@ public class VideoPlaybackResolver implements PlaybackResolver {
// Create video stream source
final List<VideoStream> videoStreamsList = ListHelper.getSortedStreamVideosList(context,
getNonTorrentStreams(info.getVideoStreams()),
getNonTorrentStreams(info.getVideoOnlyStreams()), false, true);
final int index;
getPlayableStreams(info.getVideoStreams(), info.getServiceId()),
getPlayableStreams(info.getVideoOnlyStreams(), info.getServiceId()), false, true);
final List<AudioStream> audioStreamsList =
getFilteredAudioStreams(context, info.getAudioStreams());
final int videoIndex;
if (videoStreamsList.isEmpty()) {
index = -1;
videoIndex = -1;
} else if (playbackQuality == null) {
index = qualityResolver.getDefaultResolutionIndex(videoStreamsList);
videoIndex = qualityResolver.getDefaultResolutionIndex(videoStreamsList);
} else {
index = qualityResolver.getOverrideResolutionIndex(videoStreamsList,
videoIndex = qualityResolver.getOverrideResolutionIndex(videoStreamsList,
getPlaybackQuality());
}
final MediaItemTag tag = StreamInfoTag.of(info, videoStreamsList, index);
final int audioIndex =
ListHelper.getAudioFormatIndex(context, audioStreamsList, audioTrack);
final MediaItemTag tag =
StreamInfoTag.of(info, videoStreamsList, videoIndex, audioStreamsList, audioIndex);
@Nullable final VideoStream video = tag.getMaybeQuality()
.map(MediaItemTag.Quality::getSelectedVideoStream)
.orElse(null);
@Nullable final AudioStream audio = tag.getMaybeAudioTrack()
.map(MediaItemTag.AudioTrack::getSelectedAudioStream)
.orElse(null);
if (video != null) {
try {
@ -99,14 +112,9 @@ public class VideoPlaybackResolver implements PlaybackResolver {
}
}
// Create optional audio stream source
final List<AudioStream> audioStreams = getNonTorrentStreams(info.getAudioStreams());
final AudioStream audio = audioStreams.isEmpty() ? null : audioStreams.get(
ListHelper.getDefaultAudioFormat(context, audioStreams));
// Use the audio stream if there is no video stream, or
// merge with audio stream in case if video does not contain audio
if (audio != null && (video == null || video.isVideoOnly())) {
if (audio != null && (video == null || video.isVideoOnly() || audioTrack != null)) {
try {
final MediaSource audioSource = PlaybackResolver.buildMediaSource(
dataSource, audio, info, PlaybackResolver.cacheKeyOf(info, audio), tag);
@ -179,6 +187,15 @@ public class VideoPlaybackResolver implements PlaybackResolver {
this.playbackQuality = playbackQuality;
}
@Nullable
public String getAudioTrack() {
return audioTrack;
}
public void setAudioTrack(@Nullable final String audioLanguage) {
this.audioTrack = audioLanguage;
}
public interface QualityResolver {
int getDefaultResolutionIndex(List<VideoStream> sortedVideos);

View File

@ -63,6 +63,7 @@ import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.PlayerBinding;
import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
@ -78,6 +79,7 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper;
import org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHolder;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.external_communication.KoreUtils;
import org.schabi.newpipe.util.external_communication.ShareUtils;
@ -108,7 +110,8 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
protected PlayerBinding binding;
private final Handler controlsVisibilityHandler = new Handler(Looper.getMainLooper());
@Nullable private SurfaceHolderCallback surfaceHolderCallback;
@Nullable
private SurfaceHolderCallback surfaceHolderCallback;
boolean surfaceIsSetup = false;
@ -117,11 +120,13 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
//////////////////////////////////////////////////////////////////////////*/
private static final int POPUP_MENU_ID_QUALITY = 69;
private static final int POPUP_MENU_ID_AUDIO_TRACK = 70;
private static final int POPUP_MENU_ID_PLAYBACK_SPEED = 79;
private static final int POPUP_MENU_ID_CAPTION = 89;
protected boolean isSomePopupMenuVisible = false;
private PopupMenu qualityPopupMenu;
private PopupMenu audioTrackPopupMenu;
protected PopupMenu playbackSpeedPopupMenu;
private PopupMenu captionPopupMenu;
@ -173,6 +178,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
R.style.DarkPopupMenu);
qualityPopupMenu = new PopupMenu(themeWrapper, binding.qualityTextView);
audioTrackPopupMenu = new PopupMenu(themeWrapper, binding.audioTrackTextView);
playbackSpeedPopupMenu = new PopupMenu(context, binding.playbackSpeed);
captionPopupMenu = new PopupMenu(themeWrapper, binding.captionTextView);
@ -190,6 +196,8 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
protected void initListeners() {
binding.qualityTextView.setOnClickListener(makeOnClickListener(this::onQualityClicked));
binding.audioTrackTextView.setOnClickListener(
makeOnClickListener(this::onAudioTracksClicked));
binding.playbackSpeed.setOnClickListener(makeOnClickListener(this::onPlaybackSpeedClicked));
binding.playbackSeekBar.setOnSeekBarChangeListener(this);
@ -266,6 +274,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
protected void deinitListeners() {
binding.qualityTextView.setOnClickListener(null);
binding.audioTrackTextView.setOnClickListener(null);
binding.playbackSpeed.setOnClickListener(null);
binding.playbackSeekBar.setOnSeekBarChangeListener(null);
binding.captionTextView.setOnClickListener(null);
@ -419,6 +428,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
binding.topControls.setPaddingRelative(controlsPad, playerTopPad, controlsPad, 0);
binding.bottomControls.setPaddingRelative(controlsPad, 0, controlsPad, 0);
binding.qualityTextView.setPadding(buttonsPad, buttonsPad, buttonsPad, buttonsPad);
binding.audioTrackTextView.setPadding(buttonsPad, buttonsPad, buttonsPad, buttonsPad);
binding.playbackSpeed.setPadding(buttonsPad, buttonsPad, buttonsPad, buttonsPad);
binding.playbackSpeed.setMinimumWidth(buttonsMinWidth);
binding.captionTextView.setPadding(buttonsPad, buttonsPad, buttonsPad, buttonsPad);
@ -524,6 +534,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
/**
* Sets the current duration into the corresponding elements.
*
* @param currentProgress the current progress, in milliseconds
*/
private void updatePlayBackElementsCurrentDuration(final int currentProgress) {
@ -536,6 +547,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
/**
* Sets the video duration time into all control components (e.g. seekbar).
*
* @param duration the video duration, in milliseconds
*/
private void setVideoDurationToControls(final int duration) {
@ -984,6 +996,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
private void updateStreamRelatedViews() {
player.getCurrentStreamInfo().ifPresent(info -> {
binding.qualityTextView.setVisibility(View.GONE);
binding.audioTrackTextView.setVisibility(View.GONE);
binding.playbackSpeed.setVisibility(View.GONE);
binding.playbackEndTime.setVisibility(View.GONE);
@ -1019,6 +1032,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
}
buildQualityMenu();
buildAudioTrackMenu();
binding.qualityTextView.setVisibility(View.VISIBLE);
binding.surfaceView.setVisibility(View.VISIBLE);
@ -1067,6 +1081,34 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
.ifPresent(s -> binding.qualityTextView.setText(s.getResolution()));
}
private void buildAudioTrackMenu() {
if (audioTrackPopupMenu == null) {
return;
}
audioTrackPopupMenu.getMenu().removeGroup(POPUP_MENU_ID_AUDIO_TRACK);
final List<AudioStream> availableStreams = Optional.ofNullable(player.getCurrentMetadata())
.flatMap(MediaItemTag::getMaybeAudioTrack)
.map(MediaItemTag.AudioTrack::getAudioStreams)
.orElse(null);
if (availableStreams == null || availableStreams.size() < 2) {
return;
}
for (int i = 0; i < availableStreams.size(); i++) {
final AudioStream audioStream = availableStreams.get(i);
audioTrackPopupMenu.getMenu().add(POPUP_MENU_ID_AUDIO_TRACK, i, Menu.NONE,
Localization.audioTrackName(context, audioStream));
}
player.getSelectedAudioStream()
.ifPresent(s -> binding.audioTrackTextView.setText(
Localization.audioTrackName(context, s)));
binding.audioTrackTextView.setVisibility(View.VISIBLE);
audioTrackPopupMenu.setOnMenuItemClickListener(this);
audioTrackPopupMenu.setOnDismissListener(this);
}
private void buildPlaybackSpeedMenu() {
if (playbackSpeedPopupMenu == null) {
return;
@ -1175,6 +1217,11 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
.ifPresent(binding.qualityTextView::setText);
}
private void onAudioTracksClicked() {
audioTrackPopupMenu.show();
isSomePopupMenuVisible = true;
}
/**
* Called when an item of the quality selector or the playback speed selector is selected.
*/
@ -1187,26 +1234,10 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
}
if (menuItem.getGroupId() == POPUP_MENU_ID_QUALITY) {
final int menuItemIndex = menuItem.getItemId();
@Nullable final MediaItemTag currentMetadata = player.getCurrentMetadata();
if (currentMetadata == null || currentMetadata.getMaybeQuality().isEmpty()) {
onQualityItemClick(menuItem);
return true;
}
final MediaItemTag.Quality quality = currentMetadata.getMaybeQuality().get();
final List<VideoStream> availableStreams = quality.getSortedVideoStreams();
final int selectedStreamIndex = quality.getSelectedVideoStreamIndex();
if (selectedStreamIndex == menuItemIndex || availableStreams.size() <= menuItemIndex) {
return true;
}
player.saveStreamProgressState(); //TODO added, check if good
final String newResolution = availableStreams.get(menuItemIndex).getResolution();
player.setRecovery();
player.setPlaybackQuality(newResolution);
player.reloadPlayQueueManager();
binding.qualityTextView.setText(menuItem.getTitle());
} else if (menuItem.getGroupId() == POPUP_MENU_ID_AUDIO_TRACK) {
onAudioTrackItemClick(menuItem);
return true;
} else if (menuItem.getGroupId() == POPUP_MENU_ID_PLAYBACK_SPEED) {
final int speedIndex = menuItem.getItemId();
@ -1219,6 +1250,47 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
return false;
}
private void onQualityItemClick(@NonNull final MenuItem menuItem) {
final int menuItemIndex = menuItem.getItemId();
@Nullable final MediaItemTag currentMetadata = player.getCurrentMetadata();
if (currentMetadata == null || currentMetadata.getMaybeQuality().isEmpty()) {
return;
}
final MediaItemTag.Quality quality = currentMetadata.getMaybeQuality().get();
final List<VideoStream> availableStreams = quality.getSortedVideoStreams();
final int selectedStreamIndex = quality.getSelectedVideoStreamIndex();
if (selectedStreamIndex == menuItemIndex || availableStreams.size() <= menuItemIndex) {
return;
}
final String newResolution = availableStreams.get(menuItemIndex).getResolution();
player.setPlaybackQuality(newResolution);
binding.qualityTextView.setText(menuItem.getTitle());
}
private void onAudioTrackItemClick(@NonNull final MenuItem menuItem) {
final int menuItemIndex = menuItem.getItemId();
@Nullable final MediaItemTag currentMetadata = player.getCurrentMetadata();
if (currentMetadata == null || currentMetadata.getMaybeAudioTrack().isEmpty()) {
return;
}
final MediaItemTag.AudioTrack audioTrack =
currentMetadata.getMaybeAudioTrack().get();
final List<AudioStream> availableStreams = audioTrack.getAudioStreams();
final int selectedStreamIndex = audioTrack.getSelectedAudioStreamIndex();
if (selectedStreamIndex == menuItemIndex || availableStreams.size() <= menuItemIndex) {
return;
}
final String newAudioTrack = availableStreams.get(menuItemIndex).getAudioTrackId();
player.setAudioTrack(newAudioTrack);
binding.audioTrackTextView.setText(menuItem.getTitle());
}
/**
* Called when some popup menu is dismissed.
*/

View File

@ -15,6 +15,7 @@ import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.preference.Preference;
@ -182,7 +183,6 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
importDatabase(file, lastImportDataUri))
.setNegativeButton(R.string.cancel, (d, id) ->
d.cancel())
.create()
.show();
}
}
@ -223,20 +223,22 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
// if settings file exist, ask if it should be imported.
if (manager.extractSettings(file)) {
final AlertDialog.Builder alert = new AlertDialog.Builder(requireContext());
alert.setTitle(R.string.import_settings);
alert.setNegativeButton(R.string.cancel, (dialog, which) -> {
new AlertDialog.Builder(requireContext())
.setTitle(R.string.import_settings)
.setNegativeButton(R.string.cancel, (dialog, which) -> {
dialog.dismiss();
finishImport(importDataUri);
});
alert.setPositiveButton(R.string.ok, (dialog, which) -> {
})
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
manager.loadSharedPreferences(PreferenceManager
.getDefaultSharedPreferences(requireContext()));
final Context context = requireContext();
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(context);
manager.loadSharedPreferences(prefs);
cleanImport(context, prefs);
finishImport(importDataUri);
});
alert.show();
})
.show();
} else {
finishImport(importDataUri);
}
@ -245,6 +247,38 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
}
}
/**
* Remove settings that are not supposed to be imported on different devices
* and reset them to default values.
* @param context the context used for the import
* @param prefs the preferences used while running the import
*/
private void cleanImport(@NonNull final Context context,
@NonNull final SharedPreferences prefs) {
// Check if media tunnelling needs to be disabled automatically,
// if it was disabled automatically in the imported preferences.
final String tunnelingKey = context.getString(R.string.disable_media_tunneling_key);
final String automaticTunnelingKey =
context.getString(R.string.disabled_media_tunneling_automatically_key);
// R.string.disable_media_tunneling_key should always be true
// if R.string.disabled_media_tunneling_automatically_key equals 1,
// but we double check here just to be sure and to avoid regressions
// caused by possible later modification of the media tunneling functionality.
// R.string.disabled_media_tunneling_automatically_key == 0:
// automatic value overridden by user in settings
// R.string.disabled_media_tunneling_automatically_key == -1: not set
final boolean wasMediaTunnelingDisabledAutomatically =
prefs.getInt(automaticTunnelingKey, -1) == 1
&& prefs.getBoolean(tunnelingKey, false);
if (wasMediaTunnelingDisabledAutomatically) {
prefs.edit()
.putInt(automaticTunnelingKey, -1)
.putBoolean(tunnelingKey, false)
.apply();
NewPipeSettings.setMediaTunneling(context);
}
}
/**
* Save import path and restart system.
*

View File

@ -67,6 +67,9 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
return ZipHelper.extractFileFromZip(file, fileLocator.settings.path, "newpipe.settings")
}
/**
* Remove all shared preferences from the app and load the preferences supplied to the manager.
*/
fun loadSharedPreferences(preferences: SharedPreferences) {
try {
val preferenceEditor = preferences.edit()

View File

@ -170,11 +170,11 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
}
private void showMessageDialog(@StringRes final int title, @StringRes final int message) {
final AlertDialog.Builder msg = new AlertDialog.Builder(ctx);
msg.setTitle(title);
msg.setMessage(message);
msg.setPositiveButton(getString(R.string.ok), null);
msg.show();
new AlertDialog.Builder(ctx)
.setTitle(title)
.setMessage(message)
.setPositiveButton(getString(R.string.ok), null)
.show();
}
@Override

View File

@ -0,0 +1,45 @@
package org.schabi.newpipe.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import androidx.preference.SwitchPreferenceCompat;
import org.schabi.newpipe.R;
public class ExoPlayerSettingsFragment extends BasePreferenceFragment {
@Override
public void onCreatePreferences(@Nullable final Bundle savedInstanceState,
@Nullable final String rootKey) {
addPreferencesFromResourceRegistry();
final String disabledMediaTunnelingAutomaticallyKey =
getString(R.string.disabled_media_tunneling_automatically_key);
final SwitchPreferenceCompat disableMediaTunnelingPref =
(SwitchPreferenceCompat) requirePreference(R.string.disable_media_tunneling_key);
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(requireContext());
final boolean mediaTunnelingAutomaticallyDisabled =
prefs.getInt(disabledMediaTunnelingAutomaticallyKey, -1) == 1;
final String summaryText = getString(R.string.disable_media_tunneling_summary);
disableMediaTunnelingPref.setSummary(mediaTunnelingAutomaticallyDisabled
? summaryText + " " + getString(R.string.disable_media_tunneling_automatic_info)
: summaryText);
disableMediaTunnelingPref.setOnPreferenceChangeListener((Preference p, Object enabled) -> {
if (Boolean.FALSE.equals(enabled)) {
PreferenceManager.getDefaultSharedPreferences(requireContext())
.edit()
.putInt(disabledMediaTunnelingAutomaticallyKey, 0)
.apply();
// the info text might have been shown before
p.setSummary(R.string.disable_media_tunneling_summary);
}
return true;
});
}
}

View File

@ -132,7 +132,6 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
disposables.add(getWholeStreamHistoryDisposable(context, recordManager));
disposables.add(getRemoveOrphanedRecordsDisposable(context, recordManager));
}))
.create()
.show();
}
@ -144,7 +143,6 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
.setPositiveButton(R.string.delete, ((dialog, which) ->
disposables.add(getDeletePlaybackStatesDisposable(context, recordManager))))
.create()
.show();
}
@ -156,7 +154,6 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
.setPositiveButton(R.string.delete, ((dialog, which) ->
disposables.add(getDeleteSearchHistoryDisposable(context, recordManager))))
.create()
.show();
}
}

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.settings;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
@ -15,8 +17,6 @@ import org.schabi.newpipe.util.DeviceUtils;
import java.io.File;
import java.util.Set;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
/*
* Created by k3b on 07.01.2016.
*
@ -61,7 +61,7 @@ public final class NewPipeSettings {
}
// first run migrations, then setDefaultValues, since the latter requires the correct types
SettingMigrations.initMigrations(context, isFirstRun);
SettingMigrations.runMigrationsIfNeeded(context, isFirstRun);
// readAgain is true so that if new settings are added their default value is set
PreferenceManager.setDefaultValues(context, R.xml.main_settings, true);
@ -76,6 +76,8 @@ public final class NewPipeSettings {
saveDefaultVideoDownloadDirectory(context);
saveDefaultAudioDownloadDirectory(context);
disableMediaTunnelingIfNecessary(context, isFirstRun);
}
static void saveDefaultVideoDownloadDirectory(final Context context) {
@ -152,4 +154,49 @@ public final class NewPipeSettings {
return showSearchSuggestions(context, sharedPreferences,
R.string.show_remote_search_suggestions_key);
}
private static void disableMediaTunnelingIfNecessary(@NonNull final Context context,
final boolean isFirstRun) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final String disabledTunnelingKey = context.getString(R.string.disable_media_tunneling_key);
final String disabledTunnelingAutomaticallyKey =
context.getString(R.string.disabled_media_tunneling_automatically_key);
final String blacklistVersionKey =
context.getString(R.string.media_tunneling_device_blacklist_version);
final int lastMediaTunnelingUpdate = prefs.getInt(blacklistVersionKey, 0);
final boolean wasDeviceBlacklistUpdated =
DeviceUtils.MEDIA_TUNNELING_DEVICE_BLACKLIST_VERSION != lastMediaTunnelingUpdate;
final boolean wasMediaTunnelingEnabledByUser =
prefs.getInt(disabledTunnelingAutomaticallyKey, -1) == 0
&& !prefs.getBoolean(disabledTunnelingKey, false);
if (Boolean.TRUE.equals(isFirstRun)
|| (wasDeviceBlacklistUpdated && !wasMediaTunnelingEnabledByUser)) {
setMediaTunneling(context);
}
}
/**
* Check if device does not support media tunneling
* and disable that exoplayer feature if necessary.
* @see DeviceUtils#shouldSupportMediaTunneling()
* @param context
*/
public static void setMediaTunneling(@NonNull final Context context) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!DeviceUtils.shouldSupportMediaTunneling()) {
prefs.edit()
.putBoolean(context.getString(R.string.disable_media_tunneling_key), true)
.putInt(context.getString(
R.string.disabled_media_tunneling_automatically_key), 1)
.putInt(context.getString(R.string.media_tunneling_device_blacklist_version),
DeviceUtils.MEDIA_TUNNELING_DEVICE_BLACKLIST_VERSION)
.apply();
} else {
prefs.edit()
.putInt(context.getString(R.string.media_tunneling_device_blacklist_version),
DeviceUtils.MEDIA_TUNNELING_DEVICE_BLACKLIST_VERSION).apply();
}
}
}

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import org.schabi.newpipe.R;
@ -30,9 +31,9 @@ public final class SettingMigrations {
private static final String TAG = SettingMigrations.class.toString();
private static SharedPreferences sp;
public static final Migration MIGRATION_0_1 = new Migration(0, 1) {
private static final Migration MIGRATION_0_1 = new Migration(0, 1) {
@Override
public void migrate(final Context context) {
public void migrate(@NonNull final Context context) {
// We changed the content of the dialog which opens when sharing a link to NewPipe
// by removing the "open detail page" option.
// Therefore, show the dialog once again to ensure users need to choose again and are
@ -44,9 +45,9 @@ public final class SettingMigrations {
}
};
public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
// The new application workflow introduced in #2907 allows minimizing videos
// while playing to do other stuff within the app.
// For an even better workflow, we minimize a stream when switching the app to play in
@ -63,9 +64,9 @@ public final class SettingMigrations {
}
};
public static final Migration MIGRATION_2_3 = new Migration(2, 3) {
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
// Storage Access Framework implementation was improved in #5415, allowing the modern
// and standard way to access folders and files to be used consistently everywhere.
// We reset the setting to its default value, i.e. "use SAF", since now there are no
@ -79,9 +80,9 @@ public final class SettingMigrations {
}
};
public static final Migration MIGRATION_3_4 = new Migration(3, 4) {
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
// Pull request #3546 added support for choosing the type of search suggestions to
// show, replacing the on-off switch used before, so migrate the previous user choice
@ -108,6 +109,25 @@ public final class SettingMigrations {
}
};
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
protected void migrate(@NonNull final Context context) {
final boolean brightness = sp.getBoolean("brightness_gesture_control", true);
final boolean volume = sp.getBoolean("volume_gesture_control", true);
final SharedPreferences.Editor editor = sp.edit();
editor.putString(context.getString(R.string.right_gesture_control_key),
context.getString(volume
? R.string.volume_control_key : R.string.none_control_key));
editor.putString(context.getString(R.string.left_gesture_control_key),
context.getString(brightness
? R.string.brightness_control_key : R.string.none_control_key));
editor.apply();
}
};
/**
* List of all implemented migrations.
* <p>
@ -119,15 +139,17 @@ public final class SettingMigrations {
MIGRATION_1_2,
MIGRATION_2_3,
MIGRATION_3_4,
MIGRATION_4_5,
};
/**
* Version number for preferences. Must be incremented every time a migration is necessary.
*/
public static final int VERSION = 4;
private static final int VERSION = 5;
public static void initMigrations(final Context context, final boolean isFirstRun) {
public static void runMigrationsIfNeeded(@NonNull final Context context,
final boolean isFirstRun) {
// setup migrations and check if there is something to do
sp = PreferenceManager.getDefaultSharedPreferences(context);
final String lastPrefVersionKey = context.getString(R.string.last_used_preferences_version);
@ -192,7 +214,7 @@ public final class SettingMigrations {
return oldVersion >= currentVersion;
}
protected abstract void migrate(Context context);
protected abstract void migrate(@NonNull Context context);
}

View File

@ -40,6 +40,7 @@ public final class SettingsResourceRegistry {
add(PlayerNotificationSettingsFragment.class, R.xml.player_notification_settings);
add(UpdateSettingsFragment.class, R.xml.update_settings);
add(VideoAudioSettingsFragment.class, R.xml.video_audio_settings);
add(ExoPlayerSettingsFragment.class, R.xml.exoplayer_settings);
}
private SettingRegistryEntry add(

View File

@ -0,0 +1,94 @@
package org.schabi.newpipe.util;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* A list adapter for groups of {@link AudioStream}s (audio tracks).
*/
public class AudioTrackAdapter extends BaseAdapter {
private final AudioTracksWrapper tracksWrapper;
public AudioTrackAdapter(final AudioTracksWrapper tracksWrapper) {
this.tracksWrapper = tracksWrapper;
}
@Override
public int getCount() {
return tracksWrapper.size();
}
@Override
public List<AudioStream> getItem(final int position) {
return tracksWrapper.getTracksList().get(position).getStreamsList();
}
@Override
public long getItemId(final int position) {
return position;
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
final var context = parent.getContext();
final View view;
if (convertView == null) {
view = LayoutInflater.from(context).inflate(
R.layout.stream_quality_item, parent, false);
} else {
view = convertView;
}
final ImageView woSoundIconView = view.findViewById(R.id.wo_sound_icon);
final TextView formatNameView = view.findViewById(R.id.stream_format_name);
final TextView qualityView = view.findViewById(R.id.stream_quality);
final TextView sizeView = view.findViewById(R.id.stream_size);
final List<AudioStream> streams = getItem(position);
final AudioStream stream = streams.get(0);
woSoundIconView.setVisibility(View.GONE);
sizeView.setVisibility(View.VISIBLE);
if (stream.getAudioTrackId() != null) {
formatNameView.setText(stream.getAudioTrackId());
}
qualityView.setText(Localization.audioTrackName(context, stream));
return view;
}
public static class AudioTracksWrapper implements Serializable {
private final List<StreamSizeWrapper<AudioStream>> tracksList;
public AudioTracksWrapper(@NonNull final List<List<AudioStream>> groupedAudioStreams,
@Nullable final Context context) {
this.tracksList = groupedAudioStreams.stream().map(streams ->
new StreamSizeWrapper<>(streams, context)).collect(Collectors.toList());
}
public List<StreamSizeWrapper<AudioStream>> getTracksList() {
return tracksList;
}
public int size() {
return tracksList.size();
}
}
}

View File

@ -36,21 +36,90 @@ public final class DeviceUtils {
private static Boolean isTV = null;
private static Boolean isFireTV = null;
/*
* Devices that do not support media tunneling
/**
* <p>The app version code that corresponds to the last update
* of the media tunneling device blacklist.</p>
* <p>The value of this variable needs to be updated everytime a new device that does not
* support media tunneling to match the <strong>upcoming</strong> version code.</p>
* @see #shouldSupportMediaTunneling()
*/
public static final int MEDIA_TUNNELING_DEVICE_BLACKLIST_VERSION = 994;
// region: devices not supporting media tunneling / media tunneling blacklist
/**
* <p>Formuler Z8 Pro, Z8, CC, Z Alpha, Z+ Neo.</p>
* <p>Blacklist reason: black screen</p>
* <p>Board: HiSilicon Hi3798MV200</p>
*/
// Formuler Z8 Pro, Z8, CC, Z Alpha, Z+ Neo
private static final boolean HI3798MV200 = Build.VERSION.SDK_INT == 24
&& Build.DEVICE.equals("Hi3798MV200");
// Zephir TS43UHD-2
/**
* <p>Zephir TS43UHD-2.</p>
* <p>Blacklist reason: black screen</p>
*/
private static final boolean CVT_MT5886_EU_1G = Build.VERSION.SDK_INT == 24
&& Build.DEVICE.equals("cvt_mt5886_eu_1g");
// Hilife TV
/**
* Hilife TV.
* <p>Blacklist reason: black screen</p>
*/
private static final boolean REALTEKATV = Build.VERSION.SDK_INT == 25
&& Build.DEVICE.equals("RealtekATV");
// Philips QM16XE
/**
* <p>Phillips 4K (O)LED TV.</p>
* Supports custom ROMs with different API levels
*/
private static final boolean PH7M_EU_5596 = Build.VERSION.SDK_INT >= 26
&& Build.DEVICE.equals("PH7M_EU_5596");
/**
* <p>Philips QM16XE.</p>
* <p>Blacklist reason: black screen</p>
*/
private static final boolean QM16XE_U = Build.VERSION.SDK_INT == 23
&& Build.DEVICE.equals("QM16XE_U");
/**
* <p>Sony Bravia VH1.</p>
* <p>Processor: MT5895</p>
* <p>Blacklist reason: fullscreen crash / stuttering</p>
*/
private static final boolean BRAVIA_VH1 = Build.VERSION.SDK_INT == 29
&& Build.DEVICE.equals("BRAVIA_VH1");
/**
* <p>Sony Bravia VH2.</p>
* <p>Blacklist reason: fullscreen crash; this includes model A90J as reported in
* <a href="https://github.com/TeamNewPipe/NewPipe/issues/9023#issuecomment-1387106242">
* #9023</a></p>
*/
private static final boolean BRAVIA_VH2 = Build.VERSION.SDK_INT == 29
&& Build.DEVICE.equals("BRAVIA_VH2");
/**
* <p>Sony Bravia Android TV platform 2.</p>
* Uses a MediaTek MT5891 (MT5596) SoC.
* @see <a href="https://github.com/CiNcH83/bravia_atv2">
* https://github.com/CiNcH83/bravia_atv2</a>
*/
private static final boolean BRAVIA_ATV2 = Build.DEVICE.equals("BRAVIA_ATV2");
/**
* <p>Sony Bravia Android TV platform 3 4K.</p>
* <p>Uses ARM MT5891 and a {@link #BRAVIA_ATV2} motherboard.</p>
*
* @see <a href="https://browser.geekbench.com/v4/cpu/9101105">
* https://browser.geekbench.com/v4/cpu/9101105</a>
*/
private static final boolean BRAVIA_ATV3_4K = Build.DEVICE.equals("BRAVIA_ATV3_4K");
/**
* <p>Panasonic 4KTV-JUP.</p>
* <p>Blacklist reason: fullscreen crash</p>
*/
private static final boolean TX_50JXW834 = Build.DEVICE.equals("TX_50JXW834");
/**
* <p>Bouygtel4K / Bouygues Telecom Bbox 4K.</p>
* <p>Blacklist reason: black screen; reported at
* <a href="https://github.com/TeamNewPipe/NewPipe/pull/10122#issuecomment-1638475769">
* #10122</a></p>
*/
private static final boolean HMB9213NW = Build.DEVICE.equals("HMB9213NW");
// endregion
private DeviceUtils() {
}
@ -211,18 +280,6 @@ public final class DeviceUtils {
context.getResources().getDisplayMetrics());
}
/**
* Some devices have broken tunneled video playback but claim to support it.
* See https://github.com/TeamNewPipe/NewPipe/issues/5911
* @return false if affected device
*/
public static boolean shouldSupportMediaTunneling() {
return !HI3798MV200
&& !CVT_MT5886_EU_1G
&& !REALTEKATV
&& !QM16XE_U;
}
public static boolean isLandscape(final Context context) {
return context.getResources().getDisplayMetrics().heightPixels < context.getResources()
.getDisplayMetrics().widthPixels;
@ -252,4 +309,30 @@ public final class DeviceUtils {
return point.y;
}
}
/**
* <p>Some devices have broken tunneled video playback but claim to support it.</p>
* <p>This can cause a black video player surface while attempting to play a video or
* crashes while entering or exiting the full screen player.
* The issue effects Android TVs most commonly.
* See <a href="https://github.com/TeamNewPipe/NewPipe/issues/5911">#5911</a> and
* <a href="https://github.com/TeamNewPipe/NewPipe/issues/9023">#9023</a> for more info.</p>
* @Note Update {@link #MEDIA_TUNNELING_DEVICE_BLACKLIST_VERSION}
* when adding a new device to the method.
* @return {@code false} if affected device; {@code true} otherwise
*/
public static boolean shouldSupportMediaTunneling() {
// Maintainers note: update MEDIA_TUNNELING_DEVICES_UPDATE_APP_VERSION_CODE
return !HI3798MV200
&& !CVT_MT5886_EU_1G
&& !REALTEKATV
&& !QM16XE_U
&& !BRAVIA_VH1
&& !BRAVIA_VH2
&& !BRAVIA_ATV2
&& !BRAVIA_ATV3_4K
&& !PH7M_EU_5596
&& !TX_50JXW834
&& !HMB9213NW;
}
}

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.util;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
@ -13,6 +15,7 @@ import androidx.preference.PreferenceManager;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.AudioTrackType;
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
import org.schabi.newpipe.extractor.stream.Stream;
import org.schabi.newpipe.extractor.stream.VideoStream;
@ -23,6 +26,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
@ -36,19 +40,40 @@ public final class ListHelper {
// Audio format in order of quality. 0=lowest quality, n=highest quality
private static final List<MediaFormat> AUDIO_FORMAT_QUALITY_RANKING =
List.of(MediaFormat.MP3, MediaFormat.WEBMA, MediaFormat.M4A);
// Audio format in order of efficiency. 0=most efficient, n=least efficient
// Audio format in order of efficiency. 0=least efficient, n=most efficient
private static final List<MediaFormat> AUDIO_FORMAT_EFFICIENCY_RANKING =
List.of(MediaFormat.WEBMA, MediaFormat.M4A, MediaFormat.MP3);
List.of(MediaFormat.MP3, MediaFormat.M4A, MediaFormat.WEBMA);
// Use a Set for better performance
private static final Set<String> HIGH_RESOLUTION_LIST = Set.of("1440p", "2160p");
// Audio track types in order of priotity. 0=lowest, n=highest
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING =
List.of(AudioTrackType.DESCRIPTIVE, AudioTrackType.DUBBED, AudioTrackType.ORIGINAL);
// Audio track types in order of priotity when descriptive audio is preferred.
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE =
List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE);
/**
* List of supported YouTube Itag ids.
* The original order is kept.
* @see {@link org.schabi.newpipe.extractor.services.youtube.ItagItem#ITAG_LIST}
*/
private static final List<Integer> SUPPORTED_ITAG_IDS =
List.of(
17, 36, // video v3GPP
18, 34, 35, 59, 78, 22, 37, 38, // video MPEG4
43, 44, 45, 46, // video webm
171, 172, 139, 140, 141, 249, 250, 251, // audio
160, 133, 134, 135, 212, 136, 298, 137, 299, 266, // video only
278, 242, 243, 244, 245, 246, 247, 248, 271, 272, 302, 303, 308, 313, 315
);
private ListHelper() { }
/**
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
* @param context Android app context
* @param videoStreams list of the video streams to check
* @return index of the video stream with the default index
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
*/
public static int getDefaultResolutionIndex(final Context context,
final List<VideoStream> videoStreams) {
@ -58,11 +83,11 @@ public final class ListHelper {
}
/**
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
* @param context Android app context
* @param videoStreams list of the video streams to check
* @param defaultResolution the default resolution to look for
* @return index of the video stream with the default index
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
*/
public static int getResolutionIndex(final Context context,
final List<VideoStream> videoStreams,
@ -71,10 +96,10 @@ public final class ListHelper {
}
/**
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
* @param context Android app context
* @param videoStreams list of the video streams to check
* @return index of the video stream with the default index
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
*/
public static int getPopupDefaultResolutionIndex(final Context context,
final List<VideoStream> videoStreams) {
@ -84,11 +109,11 @@ public final class ListHelper {
}
/**
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
* @param context Android app context
* @param videoStreams list of the video streams to check
* @param defaultResolution the default resolution to look for
* @return index of the video stream with the default index
* @see #getDefaultResolutionIndex(String, String, MediaFormat, List)
*/
public static int getPopupResolutionIndex(final Context context,
final List<VideoStream> videoStreams,
@ -98,16 +123,36 @@ public final class ListHelper {
public static int getDefaultAudioFormat(final Context context,
final List<AudioStream> audioStreams) {
final MediaFormat defaultFormat = getDefaultFormat(context,
R.string.default_audio_format_key, R.string.default_audio_format_value);
// If the user has chosen to limit resolution to conserve mobile data
// usage then we should also limit our audio usage.
if (isLimitingDataUsage(context)) {
return getMostCompactAudioIndex(defaultFormat, audioStreams);
} else {
return getHighestQualityAudioIndex(defaultFormat, audioStreams);
return getAudioIndexByHighestRank(audioStreams,
getAudioTrackComparator(context).thenComparing(getAudioFormatComparator(context)));
}
public static int getDefaultAudioTrackGroup(final Context context,
final List<List<AudioStream>> groupedAudioStreams) {
if (groupedAudioStreams == null || groupedAudioStreams.isEmpty()) {
return -1;
}
final Comparator<AudioStream> cmp = getAudioTrackComparator(context);
final List<AudioStream> highestRanked = groupedAudioStreams.stream()
.max((o1, o2) -> cmp.compare(o1.get(0), o2.get(0)))
.orElse(null);
return groupedAudioStreams.indexOf(highestRanked);
}
public static int getAudioFormatIndex(final Context context,
final List<AudioStream> audioStreams,
@Nullable final String trackId) {
if (trackId != null) {
for (int i = 0; i < audioStreams.size(); i++) {
final AudioStream s = audioStreams.get(i);
if (s.getAudioTrackId() != null
&& s.getAudioTrackId().equals(trackId)) {
return i;
}
}
}
return getDefaultAudioFormat(context, audioStreams);
}
/**
@ -121,7 +166,7 @@ public final class ListHelper {
*/
@NonNull
public static <S extends Stream> List<S> getStreamsOfSpecifiedDelivery(
final List<S> streamList,
@Nullable final List<S> streamList,
final DeliveryMethod deliveryMethod) {
return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() == deliveryMethod);
@ -136,23 +181,31 @@ public final class ListHelper {
*/
@NonNull
public static <S extends Stream> List<S> getUrlAndNonTorrentStreams(
final List<S> streamList) {
@Nullable final List<S> streamList) {
return getFilteredStreamList(streamList,
stream -> stream.isUrl() && stream.getDeliveryMethod() != DeliveryMethod.TORRENT);
}
/**
* Return a {@link Stream} list which only contains non-torrent streams.
* Return a {@link Stream} list which only contains streams which can be played by the player.
* <br>
* Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}.
* Torrent streams are also removed, because they cannot be retrieved.
*
* @param streamList the original stream list
* @param <S> the item type's class that extends {@link Stream}
* @return a stream list which only contains non-torrent streams
* @param streamList the original stream list
* @param serviceId
* @return a stream list which only contains streams that can be played the player
*/
@NonNull
public static <S extends Stream> List<S> getNonTorrentStreams(
final List<S> streamList) {
public static <S extends Stream> List<S> getPlayableStreams(
@Nullable final List<S> streamList, final int serviceId) {
final int youtubeServiceId = YouTube.getServiceId();
return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT);
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
&& (serviceId != youtubeServiceId
|| stream.getItagItem() == null
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
}
/**
@ -186,6 +239,90 @@ public final class ListHelper {
videoOnlyStreams, ascendingOrder, preferVideoOnlyStreams);
}
/**
* Filter the list of audio streams and return a list with the preferred stream for
* each audio track. Streams are sorted with the preferred language in the first position.
*
* @param context the context to search for the track to give preference
* @param audioStreams the list of audio streams
* @return the sorted, filtered list
*/
public static List<AudioStream> getFilteredAudioStreams(
@NonNull final Context context,
@Nullable final List<AudioStream> audioStreams) {
if (audioStreams == null) {
return Collections.emptyList();
}
final HashMap<String, AudioStream> collectedStreams = new HashMap<>();
final Comparator<AudioStream> cmp = getAudioFormatComparator(context);
for (final AudioStream stream : audioStreams) {
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT) {
continue;
}
final String trackId = Objects.toString(stream.getAudioTrackId(), "");
final AudioStream presentStream = collectedStreams.get(trackId);
if (presentStream == null || cmp.compare(stream, presentStream) > 0) {
collectedStreams.put(trackId, stream);
}
}
// Filter unknown audio tracks if there are multiple tracks
if (collectedStreams.size() > 1) {
collectedStreams.remove("");
}
// Sort collected streams by name
return collectedStreams.values().stream().sorted(getAudioTrackNameComparator(context))
.collect(Collectors.toList());
}
/**
* Group the list of audioStreams by their track ID and sort the resulting list by track name.
*
* @param context app context to get track names for sorting
* @param audioStreams list of audio streams
* @return list of audio streams lists representing individual tracks
*/
public static List<List<AudioStream>> getGroupedAudioStreams(
@NonNull final Context context,
@Nullable final List<AudioStream> audioStreams) {
if (audioStreams == null) {
return Collections.emptyList();
}
final HashMap<String, List<AudioStream>> collectedStreams = new HashMap<>();
for (final AudioStream stream : audioStreams) {
final String trackId = Objects.toString(stream.getAudioTrackId(), "");
if (collectedStreams.containsKey(trackId)) {
collectedStreams.get(trackId).add(stream);
} else {
final List<AudioStream> list = new ArrayList<>();
list.add(stream);
collectedStreams.put(trackId, list);
}
}
// Filter unknown audio tracks if there are multiple tracks
if (collectedStreams.size() > 1) {
collectedStreams.remove("");
}
// Sort tracks alphabetically, sort track streams by quality
final Comparator<AudioStream> nameCmp = getAudioTrackNameComparator(context);
final Comparator<AudioStream> formatCmp = getAudioFormatComparator(context);
return collectedStreams.values().stream()
.sorted((o1, o2) -> nameCmp.compare(o1.get(0), o2.get(0)))
.map(streams -> streams.stream().sorted(formatCmp).collect(Collectors.toList()))
.collect(Collectors.toList());
}
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
@ -199,7 +336,7 @@ public final class ListHelper {
* @return a new stream list filtered using the given predicate
*/
private static <S extends Stream> List<S> getFilteredStreamList(
final List<S> streamList,
@Nullable final List<S> streamList,
final Predicate<S> streamListPredicate) {
if (streamList == null) {
return Collections.emptyList();
@ -210,7 +347,7 @@ public final class ListHelper {
.collect(Collectors.toList());
}
private static String computeDefaultResolution(final Context context, final int key,
private static String computeDefaultResolution(@NonNull final Context context, final int key,
final int value) {
final SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(context);
@ -351,72 +488,22 @@ public final class ListHelper {
return videoStreams;
}
/**
* Get the audio from the list with the highest quality.
* Format will be ignored if it yields no results.
*
* @param format The target format type or null if it doesn't matter
* @param audioStreams List of audio streams
* @return Index of audio stream that produces the most compact results or -1 if not found
*/
static int getHighestQualityAudioIndex(@Nullable final MediaFormat format,
@Nullable final List<AudioStream> audioStreams) {
return getAudioIndexByHighestRank(format, audioStreams,
// Compares descending (last = highest rank)
getAudioStreamComparator(AUDIO_FORMAT_QUALITY_RANKING));
}
/**
* Get the audio from the list with the lowest bitrate and most efficient format.
* Format will be ignored if it yields no results.
*
* @param format The target format type or null if it doesn't matter
* @param audioStreams List of audio streams
* @return Index of audio stream that produces the most compact results or -1 if not found
*/
static int getMostCompactAudioIndex(@Nullable final MediaFormat format,
@Nullable final List<AudioStream> audioStreams) {
return getAudioIndexByHighestRank(format, audioStreams,
// The "reversed()" is important -> Compares ascending (first = highest rank)
getAudioStreamComparator(AUDIO_FORMAT_EFFICIENCY_RANKING).reversed());
}
private static Comparator<AudioStream> getAudioStreamComparator(
final List<MediaFormat> formatRanking) {
return Comparator.nullsLast(Comparator.comparingInt(AudioStream::getAverageBitrate))
.thenComparingInt(stream -> formatRanking.indexOf(stream.getFormat()));
}
/**
* Get the audio-stream from the list with the highest rank, depending on the comparator.
* Format will be ignored if it yields no results.
*
* @param targetedFormat The target format type or null if it doesn't matter
* @param audioStreams List of audio streams
* @param comparator The comparator used for determining the max/best/highest ranked value
* @return Index of audio stream that produces the highest ranked result or -1 if not found
*/
private static int getAudioIndexByHighestRank(@Nullable final MediaFormat targetedFormat,
@Nullable final List<AudioStream> audioStreams,
static int getAudioIndexByHighestRank(@Nullable final List<AudioStream> audioStreams,
final Comparator<AudioStream> comparator) {
if (audioStreams == null || audioStreams.isEmpty()) {
return -1;
}
final AudioStream highestRankedAudioStream = audioStreams.stream()
.filter(audioStream -> targetedFormat == null
|| audioStream.getFormat() == targetedFormat)
.max(comparator)
.orElse(null);
if (highestRankedAudioStream == null) {
// Fallback: Ignore targetedFormat if not null
if (targetedFormat != null) {
return getAudioIndexByHighestRank(null, audioStreams, comparator);
}
// targetedFormat is already null -> return -1
return -1;
}
.max(comparator).orElse(null);
return audioStreams.indexOf(highestRankedAudioStream);
}
@ -604,4 +691,149 @@ public final class ListHelper {
return manager.isActiveNetworkMetered();
}
/**
* Get a {@link Comparator} to compare {@link AudioStream}s by their format and bitrate.
*
* <p>The prefered stream will be ordered last.</p>
*
* @param context app context
* @return Comparator
*/
private static Comparator<AudioStream> getAudioFormatComparator(
final @NonNull Context context) {
final MediaFormat defaultFormat = getDefaultFormat(context,
R.string.default_audio_format_key, R.string.default_audio_format_value);
return getAudioFormatComparator(defaultFormat, isLimitingDataUsage(context));
}
/**
* Get a {@link Comparator} to compare {@link AudioStream}s by their format and bitrate.
*
* <p>The prefered stream will be ordered last.</p>
*
* @param defaultFormat the default format to look for
* @param limitDataUsage choose low bitrate audio stream
* @return Comparator
*/
static Comparator<AudioStream> getAudioFormatComparator(
@Nullable final MediaFormat defaultFormat, final boolean limitDataUsage) {
final List<MediaFormat> formatRanking = limitDataUsage
? AUDIO_FORMAT_EFFICIENCY_RANKING : AUDIO_FORMAT_QUALITY_RANKING;
Comparator<AudioStream> bitrateComparator =
Comparator.comparingInt(AudioStream::getAverageBitrate);
if (limitDataUsage) {
bitrateComparator = bitrateComparator.reversed();
}
return Comparator.comparing(AudioStream::getFormat, (o1, o2) -> {
if (defaultFormat != null) {
return Boolean.compare(o1 == defaultFormat, o2 == defaultFormat);
}
return 0;
}).thenComparing(bitrateComparator).thenComparingInt(
stream -> formatRanking.indexOf(stream.getFormat()));
}
/**
* Get a {@link Comparator} to compare {@link AudioStream}s by their tracks.
*
* <p>Tracks will be compared this order:</p>
* <ol>
* <li>If {@code preferOriginalAudio}: use original audio</li>
* <li>Language matches {@code preferredLanguage}</li>
* <li>
* Track type ranks highest in this order:
* <i>Original</i> > <i>Dubbed</i> > <i>Descriptive</i>
* <p>If {@code preferDescriptiveAudio}:
* <i>Descriptive</i> > <i>Dubbed</i> > <i>Original</i></p>
* </li>
* <li>Language is English</li>
* </ol>
*
* <p>The prefered track will be ordered last.</p>
*
* @param context App context
* @return Comparator
*/
private static Comparator<AudioStream> getAudioTrackComparator(
@NonNull final Context context) {
final SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(context);
final Locale preferredLanguage = Localization.getPreferredLocale(context);
final boolean preferOriginalAudio =
preferences.getBoolean(context.getString(R.string.prefer_original_audio_key),
false);
final boolean preferDescriptiveAudio =
preferences.getBoolean(context.getString(R.string.prefer_descriptive_audio_key),
false);
return getAudioTrackComparator(preferredLanguage, preferOriginalAudio,
preferDescriptiveAudio);
}
/**
* Get a {@link Comparator} to compare {@link AudioStream}s by their tracks.
*
* <p>Tracks will be compared this order:</p>
* <ol>
* <li>If {@code preferOriginalAudio}: use original audio</li>
* <li>Language matches {@code preferredLanguage}</li>
* <li>
* Track type ranks highest in this order:
* <i>Original</i> > <i>Dubbed</i> > <i>Descriptive</i>
* <p>If {@code preferDescriptiveAudio}:
* <i>Descriptive</i> > <i>Dubbed</i> > <i>Original</i></p>
* </li>
* <li>Language is English</li>
* </ol>
*
* <p>The prefered track will be ordered last.</p>
*
* @param preferredLanguage Preferred audio stream language
* @param preferOriginalAudio Get the original audio track regardless of its language
* @param preferDescriptiveAudio Prefer the descriptive audio track if available
* @return Comparator
*/
static Comparator<AudioStream> getAudioTrackComparator(
final Locale preferredLanguage,
final boolean preferOriginalAudio,
final boolean preferDescriptiveAudio) {
final String langCode = preferredLanguage.getISO3Language();
final List<AudioTrackType> trackTypeRanking = preferDescriptiveAudio
? AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE : AUDIO_TRACK_TYPE_RANKING;
return Comparator.comparing(AudioStream::getAudioTrackType, (o1, o2) -> {
if (preferOriginalAudio) {
return Boolean.compare(
o1 == AudioTrackType.ORIGINAL, o2 == AudioTrackType.ORIGINAL);
}
return 0;
}).thenComparing(AudioStream::getAudioLocale,
Comparator.nullsFirst(Comparator.comparing(
locale -> locale.getISO3Language().equals(langCode))))
.thenComparing(AudioStream::getAudioTrackType,
Comparator.nullsFirst(Comparator.comparingInt(trackTypeRanking::indexOf)))
.thenComparing(AudioStream::getAudioLocale,
Comparator.nullsFirst(Comparator.comparing(
locale -> locale.getISO3Language().equals(
Locale.ENGLISH.getISO3Language()))));
}
/**
* Get a {@link Comparator} to compare {@link AudioStream}s by their languages and track types
* for alphabetical sorting.
*
* @param context app context for localization
* @return Comparator
*/
private static Comparator<AudioStream> getAudioTrackNameComparator(
@NonNull final Context context) {
final Locale appLoc = Localization.getAppLocale(context);
return Comparator.comparing(AudioStream::getAudioLocale, Comparator.nullsLast(
Comparator.comparing(locale -> locale.getDisplayName(appLoc))))
.thenComparing(AudioStream::getAudioTrackType);
}
}

View File

@ -11,6 +11,7 @@ import android.text.TextUtils;
import android.util.DisplayMetrics;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import androidx.core.math.MathUtils;
@ -21,6 +22,8 @@ import org.ocpsoft.prettytime.units.Decade;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.AudioTrackType;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -261,6 +264,52 @@ public final class Localization {
}
}
/**
* Get the localized name of an audio track.
*
* <p>Examples of results returned by this method:</p>
* <ul>
* <li>English (original)</li>
* <li>English (descriptive)</li>
* <li>Spanish (dubbed)</li>
* </ul>
*
* @param context the context used to get the app language
* @param track an {@link AudioStream} of the track
* @return the localized name of the audio track
*/
public static String audioTrackName(final Context context, final AudioStream track) {
final String name;
if (track.getAudioLocale() != null) {
name = track.getAudioLocale().getDisplayLanguage(getAppLocale(context));
} else if (track.getAudioTrackName() != null) {
name = track.getAudioTrackName();
} else {
name = context.getString(R.string.unknown_audio_track);
}
if (track.getAudioTrackType() != null) {
final String trackType = audioTrackType(context, track.getAudioTrackType());
if (trackType != null) {
return context.getString(R.string.audio_track_name, name, trackType);
}
}
return name;
}
@Nullable
private static String audioTrackType(final Context context, final AudioTrackType trackType) {
switch (trackType) {
case ORIGINAL:
return context.getString(R.string.audio_track_type_original);
case DUBBED:
return context.getString(R.string.audio_track_type_dubbed);
case DESCRIPTIVE:
return context.getString(R.string.audio_track_type_descriptive);
}
return null;
}
/*//////////////////////////////////////////////////////////////////////////
// Pretty Time
//////////////////////////////////////////////////////////////////////////*/

View File

@ -325,11 +325,11 @@ public final class NavigationHelper {
if (context instanceof Activity) {
new AlertDialog.Builder(context)
.setMessage(R.string.no_player_found)
.setPositiveButton(R.string.install,
(dialog, which) -> ShareUtils.installApp(context,
.setPositiveButton(R.string.install, (dialog, which) ->
ShareUtils.installApp(context,
context.getString(R.string.vlc_package)))
.setNegativeButton(R.string.cancel, (dialog, which)
-> Log.i("NavigationHelper", "You unlocked a secret unicorn."))
.setNegativeButton(R.string.cancel, (dialog, which) ->
Log.i("NavigationHelper", "You unlocked a secret unicorn."))
.show();
} else {
Toast.makeText(context, R.string.no_player_found_toast, Toast.LENGTH_LONG).show();
@ -563,11 +563,8 @@ public final class NavigationHelper {
@Nullable final PlayQueue playQueue,
final boolean switchingPlayers) {
final Intent intent = getOpenIntent(context, url, serviceId,
StreamingService.LinkType.STREAM);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Constants.KEY_TITLE, title);
intent.putExtra(VideoDetailFragment.KEY_SWITCHING_PLAYERS, switchingPlayers);
final Intent intent = getStreamIntent(context, serviceId, url, title)
.putExtra(VideoDetailFragment.KEY_SWITCHING_PLAYERS, switchingPlayers);
if (playQueue != null) {
final String cacheKey = SerializedCache.getInstance().put(playQueue, PlayQueue.class);
@ -680,6 +677,15 @@ public final class NavigationHelper {
return getOpenIntent(context, url, serviceId, StreamingService.LinkType.CHANNEL);
}
public static Intent getStreamIntent(final Context context,
final int serviceId,
final String url,
@Nullable final String title) {
return getOpenIntent(context, url, serviceId, StreamingService.LinkType.STREAM)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(Constants.KEY_TITLE, title);
}
/**
* Finish this <code>Activity</code> as well as all <code>Activities</code> running below it
* and then start <code>MainActivity</code>.

View File

@ -1,69 +0,0 @@
package org.schabi.newpipe.util;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.NonNull;
public final class PendingIntentCompat {
private PendingIntentCompat() {
}
private static int addImmutableFlag(final int flags) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
? flags | PendingIntent.FLAG_IMMUTABLE : flags;
}
/**
* Creates a {@link PendingIntent} to start an activity. It is immutable on API level 23 and
* greater.
*
* @param context The context in which the activity should be started.
* @param requestCode The request code
* @param intent The Intent of the activity to be launched.
* @param flags The flags for the intent.
* @return The pending intent.
* @see PendingIntent#getActivity(Context, int, Intent, int)
*/
@NonNull
public static PendingIntent getActivity(@NonNull final Context context, final int requestCode,
@NonNull final Intent intent, final int flags) {
return PendingIntent.getActivity(context, requestCode, intent, addImmutableFlag(flags));
}
/**
* Creates a {@link PendingIntent} to start a service. It is immutable on API level 23 and
* greater.
*
* @param context The context in which the service should be started.
* @param requestCode The request code
* @param intent The Intent of the service to be launched.
* @param flags The flags for the intent.
* @return The pending intent.
* @see PendingIntent#getService(Context, int, Intent, int)
*/
@NonNull
public static PendingIntent getService(@NonNull final Context context, final int requestCode,
@NonNull final Intent intent, final int flags) {
return PendingIntent.getService(context, requestCode, intent, addImmutableFlag(flags));
}
/**
* Creates a {@link PendingIntent} to perform a broadcast. It is immutable on API level 23 and
* greater.
*
* @param context The context in which the broadcast should be performed.
* @param requestCode The request code
* @param intent The Intent to be broadcast.
* @param flags The flags for the intent.
* @return The pending intent.
* @see PendingIntent#getBroadcast(Context, int, Intent, int)
*/
@NonNull
public static PendingIntent getBroadcast(@NonNull final Context context, final int requestCode,
@NonNull final Intent intent, final int flags) {
return PendingIntent.getBroadcast(context, requestCode, intent, addImmutableFlag(flags));
}
}

View File

@ -224,6 +224,8 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
public static class StreamSizeWrapper<T extends Stream> implements Serializable {
private static final StreamSizeWrapper<Stream> EMPTY =
new StreamSizeWrapper<>(Collections.emptyList(), null);
private static final int SIZE_UNSET = -2;
private final List<T> streamsList;
private final long[] streamSizes;
private final String unknownSize;
@ -235,7 +237,7 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
this.unknownSize = context == null
? "--.-" : context.getString(R.string.unknown_content);
Arrays.fill(streamSizes, -2);
resetSizes();
}
/**
@ -251,7 +253,7 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
final Callable<Boolean> fetchAndSet = () -> {
boolean hasChanged = false;
for (final X stream : streamsWrapper.getStreamsList()) {
if (streamsWrapper.getSizeInBytes(stream) > -2) {
if (streamsWrapper.getSizeInBytes(stream) > SIZE_UNSET) {
continue;
}
@ -269,6 +271,10 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
.onErrorReturnItem(true);
}
public void resetSizes() {
Arrays.fill(streamSizes, SIZE_UNSET);
}
public static <X extends Stream> StreamSizeWrapper<X> empty() {
//noinspection unchecked
return (StreamSizeWrapper<X>) EMPTY;

View File

@ -61,11 +61,12 @@ public final class KoreUtils {
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (!tryOpenIntentInApp(context, intent)) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.kore_not_found)
.setPositiveButton(R.string.install, (dialog, which) -> installKore(context))
.setNegativeButton(R.string.cancel, (dialog, which) -> { });
builder.create().show();
new AlertDialog.Builder(context)
.setMessage(R.string.kore_not_found)
.setPositiveButton(R.string.install, (dialog, which) ->
installKore(context))
.setNegativeButton(R.string.cancel, null)
.show();
}
}
}

View File

@ -169,7 +169,7 @@ public final class InternalUrlsHandler {
.setTitle(R.string.player_stream_failure)
.setMessage(
ErrorPanelHelper.Companion.getExceptionDescription(throwable))
.setPositiveButton(R.string.ok, (v, b) -> { })
.setPositiveButton(R.string.ok, null)
.show();
}));
return true;

View File

@ -54,12 +54,12 @@ public class DownloadInitializer extends Thread {
long lowestSize = Long.MAX_VALUE;
for (int i = 0; i < mMission.urls.length && mMission.running; i++) {
mConn = mMission.openConnection(mMission.urls[i], true, -1, -1);
mConn = mMission.openConnection(mMission.urls[i], true, 0, 0);
mMission.establishConnection(mId, mConn);
dispose();
if (Thread.interrupted()) return;
long length = Utility.getContentLength(mConn);
long length = Utility.getTotalContentLength(mConn);
if (i == 0) {
httpCode = mConn.getResponseCode();
@ -84,14 +84,14 @@ public class DownloadInitializer extends Thread {
}
} else {
// ask for the current resource length
mConn = mMission.openConnection(true, -1, -1);
mConn = mMission.openConnection(true, 0, 0);
mMission.establishConnection(mId, mConn);
dispose();
if (!mMission.running || Thread.interrupted()) return;
httpCode = mConn.getResponseCode();
mMission.length = Utility.getContentLength(mConn);
mMission.length = Utility.getTotalContentLength(mConn);
}
if (mMission.length == 0 || httpCode == 204) {

View File

@ -33,6 +33,7 @@ import androidx.annotation.StringRes;
import androidx.collection.SparseArrayCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Builder;
import androidx.core.app.PendingIntentCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
@ -43,7 +44,6 @@ import org.schabi.newpipe.player.helper.LockManager;
import org.schabi.newpipe.streams.io.StoredDirectoryHelper;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.PendingIntentCompat;
import java.io.File;
import java.io.IOException;
@ -146,7 +146,7 @@ public class DownloadManagerService extends Service {
mOpenDownloadList = PendingIntentCompat.getActivity(this, 0,
openDownloadListIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_UPDATE_CURRENT, false);
icLauncher = BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher);
@ -487,7 +487,7 @@ public class DownloadManagerService extends Service {
private PendingIntent makePendingIntent(String action) {
Intent intent = new Intent(this, DownloadManagerService.class).setAction(action);
return PendingIntentCompat.getService(this, intent.hashCode(), intent,
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_UPDATE_CURRENT, false);
}
private void manageLock(boolean acquire) {

View File

@ -538,7 +538,6 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
builder.setNegativeButton(R.string.ok, (dialog, which) -> dialog.cancel())
.setTitle(mission.storage.getName())
.create()
.show();
}

View File

@ -211,12 +211,11 @@ public class MissionsFragment extends Fragment {
.setTitle(R.string.clear_download_history)
.setMessage(R.string.confirm_prompt)
// Intentionally misusing buttons' purpose in order to achieve good order
.setNegativeButton(R.string.clear_download_history,
(dialog, which) -> mAdapter.clearFinishedDownloads(false))
.setNegativeButton(R.string.clear_download_history, (dialog, which) ->
mAdapter.clearFinishedDownloads(false))
.setNeutralButton(R.string.cancel, null)
.setPositiveButton(R.string.delete_downloaded_files,
(dialog, which) -> showDeleteDownloadedFilesConfirmationPrompt())
.create()
.setPositiveButton(R.string.delete_downloaded_files, (dialog, which) ->
showDeleteDownloadedFilesConfirmationPrompt())
.show();
}
@ -225,9 +224,8 @@ public class MissionsFragment extends Fragment {
new AlertDialog.Builder(mContext)
.setTitle(R.string.delete_downloaded_files_confirm)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok,
(dialog, which) -> mAdapter.clearFinishedDownloads(true))
.create()
.setPositiveButton(R.string.ok, (dialog, which) ->
mAdapter.clearFinishedDownloads(true))
.show();
}

View File

@ -1,11 +1,8 @@
package us.shandian.giga.util;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
@ -29,8 +26,10 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.util.Locale;
import java.util.Random;
import okio.ByteString;
import us.shandian.giga.get.DownloadMission;
public class Utility {
@ -232,6 +231,28 @@ public class Utility {
return -1;
}
/**
* Get the content length of the entire file even if the HTTP response is partial
* (response code 206).
* @param connection http connection
* @return content length
*/
public static long getTotalContentLength(final HttpURLConnection connection) {
try {
if (connection.getResponseCode() == 206) {
final String rangeStr = connection.getHeaderField("Content-Range");
final String bytesStr = rangeStr.split("/", 2)[1];
return Long.parseLong(bytesStr);
} else {
return getContentLength(connection);
}
} catch (Exception err) {
// nothing to do
}
return -1;
}
private static String pad(int number) {
return number < 10 ? ("0" + number) : String.valueOf(number);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/defaultIconTint"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M4,18l8.5,-6L4,6v12zM13,6v12l8.5,-6L13,6z" />
</vector>

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/defaultIconTint"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M11,18L11,6l-8.5,6 8.5,6zM11.5,12l8.5,6L20,6l-8.5,6z" />
</vector>

View File

@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/defaultIconTint"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="flip"
android:pivotX="12"
android:scaleX="-1">
<path
android:fillColor="#FF000000"
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z" />
</group>
</vector>

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/defaultIconTint"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z" />
</vector>

View File

@ -267,23 +267,21 @@
android:layout_height="wrap_content">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:id="@+id/detail_sub_channel_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:contentDescription="@string/detail_sub_channel_thumbnail_view_description"
android:src="@drawable/placeholder_person"
app:shapeAppearance="@style/CircularImageView" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/detail_sub_channel_thumbnail_view"
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/video_item_detail_sub_channel_image_size"
android:layout_height="@dimen/video_item_detail_sub_channel_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_sub_channel_thumbnail_view_description"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/placeholder_person"
android:visibility="gone"
app:shapeAppearance="@style/CircularImageView"
tools:visibility="visible" />
app:shapeAppearance="@style/CircularImageView" />
</FrameLayout>

View File

@ -71,11 +71,45 @@
android:minWidth="150dp"
tools:listitem="@layout/stream_quality_item" />
<Spinner
android:id="@+id/audio_track_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quality_spinner"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="12dp"
android:minWidth="150dp"
tools:visibility="gone" />
<Spinner
android:id="@+id/audio_stream_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_track_spinner"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="12dp"
android:minWidth="150dp"
tools:visibility="gone" />
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/audio_track_present_in_video_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_stream_spinner"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="12dp"
android:gravity="center"
android:text="@string/audio_track_present_in_video"
android:textSize="12sp" />
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/threads_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quality_spinner"
android:layout_below="@+id/audio_track_present_in_video_text"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="6dp"

View File

@ -254,24 +254,22 @@
android:layout_height="wrap_content">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/detail_uploader_thumbnail_view"
android:id="@+id/detail_sub_channel_thumbnail_view"
android:layout_width="@dimen/video_item_detail_uploader_image_size"
android:layout_height="@dimen/video_item_detail_uploader_image_size"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:contentDescription="@string/detail_sub_channel_thumbnail_view_description"
android:src="@drawable/placeholder_person"
app:shapeAppearance="@style/CircularImageView" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/detail_sub_channel_thumbnail_view"
android:id="@+id/detail_uploader_thumbnail_view"
android:layout_width="@dimen/video_item_detail_sub_channel_image_size"
android:layout_height="@dimen/video_item_detail_sub_channel_image_size"
android:layout_gravity="bottom|right"
android:contentDescription="@string/detail_sub_channel_thumbnail_view_description"
android:contentDescription="@string/detail_uploader_thumbnail_view_description"
android:src="@drawable/placeholder_person"
android:visibility="gone"
app:shapeAppearance="@style/CircularImageView"
tools:ignore="RtlHardcoded"
tools:visibility="visible" />
tools:ignore="RtlHardcoded" />
</FrameLayout>

View File

@ -157,6 +157,22 @@
tools:text="The Video Artist LONG very LONG very Long" />
</LinearLayout>
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/audioTrackTextView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginEnd="8dp"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minWidth="0dp"
android:padding="@dimen/player_main_buttons_padding"
android:textColor="@android:color/white"
android:textStyle="bold"
android:visibility="gone"
tools:ignore="HardcodedText,RtlHardcoded"
tools:visibility="visible"
tools:text="English (Original)" />
<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/qualityTextView"
android:layout_width="wrap_content"

View File

@ -18,6 +18,14 @@
android:visible="true"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_audio_track"
android:tooltipText="@string/audio_track"
android:visible="false"
app:showAsAction="ifRoom">
<menu />
</item>
<item
android:id="@+id/action_mute"
android:icon="@drawable/ic_volume_off"

View File

@ -23,7 +23,7 @@
<string name="light_theme_title">فاتح</string>
<string name="network_error">خطأ في الشبكة</string>
<string name="no_player_found">لم يتم العثور على مشغل بث. تثبيت VLC؟</string>
<string name="open_in_browser">فتح في متصفح الويب</string>
<string name="open_in_browser">فتح في المتصفح</string>
<string name="play_audio">الصوت</string>
<string name="play_with_kodi_title">تشغيل بواسطة كودي</string>
<string name="search">البحث</string>
@ -46,7 +46,7 @@
<string name="general_error">خطأ</string>
<string name="parsing_error">تعذر تحليل الموقع</string>
<string name="youtube_signature_deobfuscation_error">تعذر فك تشفير توقيع رابط الفيديو</string>
<string name="main_bg_subtitle">اضغط على العدسة المكبرة للبدء.</string>
<string name="main_bg_subtitle">اضغط على \"العدسة المكبرة\" للبدء.</string>
<string name="subscribe_button_title">اشتراك</string>
<string name="subscribed_button_title">مشترك</string>
<string name="tab_subscriptions">الاشتراكات</string>
@ -91,7 +91,7 @@
<string name="show_age_restricted_content_title">محتوى مقيد للبالغين</string>
<string name="duration_live">بث مباشر</string>
<string name="error_report_title">تقرير عن المشكلة</string>
<string name="disabled">متوقف</string>
<string name="disabled">معطل</string>
<string name="clear">تنظيف</string>
<string name="best_resolution">أفضل دقة</string>
<string name="undo">تراجع</string>
@ -133,7 +133,7 @@
<string name="no_videos">لاتوجد فيديوهات</string>
<string name="start">ابدأ</string>
<string name="pause">إيقاف مؤقت</string>
<string name="delete">حذف</string>
<string name="delete">احذف</string>
<string name="checksum">التوقيع</string>
<string name="ok">حسناً</string>
<string name="msg_name">اسم الملف</string>
@ -158,9 +158,9 @@
<string name="contribution_title">ساهم</string>
<string name="contribution_encouragement">إذا كانت لديك أفكار؛ أو ترجمة، أو تغييرات تخص التصميم، أو تنظيف و تحسين الشفرة البرمجية، أو تعديلات عميقة عليها، فتذكر أنّ مساعدتك دائما موضع ترحيب. وكلما أتممنا شيئا كلما كان ذلك أفضل!</string>
<string name="view_on_github">عرض على GitHub</string>
<string name="donation_title">تبرع</string>
<string name="donation_title">تبرَّع</string>
<string name="donation_encouragement">يتم تطوير NewPipe من قبل متطوعين يقضون وقت فراغهم لتقديم أفضل تجربة لك. حان الوقت لرد المساعدة مع المطورين وجعل NewPipe أكثر و أفضل بينما يستمتعون بفنجان من القهوة.</string>
<string name="give_back">تبرع</string>
<string name="give_back">رد الجميل</string>
<string name="website_title">موقع الويب</string>
<string name="website_encouragement">قم بزيارة موقع NewPipe لمزيد من المعلومات والمستجدات.</string>
<string name="app_license_title">تراخيص NewPipe</string>
@ -174,7 +174,7 @@
<string name="trending">الشائعة</string>
<string name="top_50">أفضل ٥٠</string>
<string name="new_and_hot">جديد وساخن</string>
<string name="play_queue_remove">حذف</string>
<string name="play_queue_remove">أحذف</string>
<string name="play_queue_stream_detail">التفاصيل</string>
<string name="play_queue_audio_settings">إعدادات الصوت</string>
<string name="start_here_on_popup">بدأ التشغيل في نافذة منبثقة</string>
@ -346,13 +346,9 @@
<string name="users">المستخدمين</string>
<string name="unsubscribe">إلغاء الاشتراك</string>
<string name="tab_choose">اختر علامة التبويب</string>
<string name="volume_gesture_control_summary">استخدم إيماءات التحكم في صوت المشغّل</string>
<string name="brightness_gesture_control_title">التحكم بإيماءات السطوع</string>
<string name="brightness_gesture_control_summary">استخدام الإيماءات للتحكم بسطوع المشغّل</string>
<string name="settings_category_updates_title">التحديثات</string>
<string name="file_deleted">تم حذف الملف</string>
<string name="app_update_notification_channel_name">تنبيه تحديث التطبيق</string>
<string name="volume_gesture_control_title">إيماء التحكم بالصوت</string>
<string name="events">الأحداث</string>
<string name="app_update_notification_channel_description">إشعارات لإصدار NewPipe الجديد</string>
<string name="download_to_sdcard_error_title">وحدة التخزين الخارجية غير متوفرة</string>
@ -642,7 +638,7 @@
<string name="auto_device_theme_title">تلقائي (سمة الجهاز)</string>
<string name="night_theme_title">الثيم الليلي</string>
<string name="show_channel_details">إظهار تفاصيل القناة</string>
<string name="disable_media_tunneling_summary">تعطيل نفق الوسائط إذا واجهت شاشة سوداء أو التقطيع في تشغيل الفيديو</string>
<string name="disable_media_tunneling_summary">قم بتعطيل نفق الوسائط إذا واجهت شاشة سوداء أو تقطيع اثناء تشغيل الفيديو.</string>
<string name="disable_media_tunneling_title">تعطيل نفق الوسائط</string>
<string name="metadata_privacy_internal">داخلي</string>
<string name="metadata_privacy_private">خاص</string>
@ -675,7 +671,6 @@
<string name="off">إيقاف</string>
<string name="on">تشغيل</string>
<string name="tablet_mode_title">وضع الجهاز اللوحي</string>
<string name="feed_toggle_show_played_items">إظهار العناصر التي تمت مشاهدتها</string>
<string name="comments_are_disabled">تم تعطيل التعليقات</string>
<string name="dont_show">لا تظهر</string>
<string name="low_quality_smaller">جودة منخفضة (أصغر)</string>
@ -729,7 +724,6 @@
<string name="detail_pinned_comment_view_description">تعليق مثبت</string>
<string name="leak_canary_not_available">LeakCanary غير متوفر</string>
<string name="progressive_load_interval_exoplayer_default">الافتراضي ExoPlayer</string>
<string name="progressive_load_interval_summary">تغيير حجم الفاصل الزمني للتحميل (حاليا %s). قد تؤدي القيمة الأقل إلى تسريع تحميل الفيديو الأولي. تتطلب التغييرات إعادة تشغيل المشغل</string>
<string name="settings_category_player_notification_summary">تكوين إشعار مشغل البث الحالي</string>
<string name="notifications">الإشعارات</string>
<string name="loading_stream_details">تحميل تفاصيل البث…</string>
@ -766,9 +760,6 @@
<string name="unknown_format">تنسيق غير معروف</string>
<string name="unknown_quality">جودة غير معروفة</string>
<string name="progressive_load_interval_title">حجم الفاصل الزمني لتحميل التشغيل</string>
<string name="feed_toggle_show_future_items">عرض العناصر المستقبلية</string>
<string name="feed_toggle_hide_future_items">إخفاء العناصر المستقبلية</string>
<string name="feed_toggle_hide_played_items">إخفاء العناصر التي تمت مشاهدتها</string>
<string name="faq_title">أسئلة مكررة</string>
<string name="faq_description">إذا كنت تواجه مشكلة في استخدام التطبيق ، فتأكد من مراجعة هذه الإجابات للأسئلة الشائعة!</string>
<string name="faq">مشاهدة على الموقع</string>
@ -793,4 +784,36 @@
<string name="remove_duplicates_title">إزالة التكرارات؟</string>
<string name="feed_hide_streams_title">إظهار التدفقات التالية</string>
<string name="feed_show_watched">شاهدت بالكامل</string>
<string name="left_gesture_control_title">إجراء الإيماءة اليسرى</string>
<string name="right_gesture_control_title">اجراء الإيماءة اليمنى</string>
<string name="brightness">السطوع</string>
<string name="none">بدون</string>
<string name="left_gesture_control_summary">اختر إيماءة للنصف الأيسر من شاشة المشغل</string>
<string name="right_gesture_control_summary">اختر إيماءة للنصف الأيمن من شاشة المشغل</string>
<string name="volume">مستوى الصوت</string>
<string name="progressive_load_interval_summary">قم بتغيير حجم الفاصل الزمني للتحميل على المحتويات التدريجية (حاليا %s). قد تؤدي القيمة المنخفضة إلى تسريع التحميل الأولي</string>
<string name="prefer_descriptive_audio_title">تفضل الصوت الوصفي</string>
<string name="play_queue_audio_track">الصوت : %s</string>
<string name="audio_track">المسار الصوتي</string>
<string name="audio_track_present_in_video">يجب أن يكون هناك مسار صوتي موجود بالفعل في هذا البث</string>
<string name="select_audio_track_external_players">حدد مسار الصوت للمشغلات الخارجية</string>
<string name="unknown_audio_track">غير معروف</string>
<string name="settings_category_exoplayer_title">إعدادات ExoPlayer</string>
<string name="settings_category_exoplayer_summary">إدارة بعض إعدادات ExoPlayer. تتطلب هذه التغييرات إعادة تشغيل المشغل لتصبح سارية المفعول</string>
<string name="always_use_exoplayer_set_output_surface_workaround_title">استخدم دائمًا الحل البديل لإعداد سطح إخراج فيديو ExoPlayer</string>
<string name="audio_track_name">%1s %2s</string>
<string name="audio_track_type_original">الافتراضي</string>
<string name="audio_track_type_dubbed">مدبلجة</string>
<string name="audio_track_type_descriptive">وصفي</string>
<string name="prefer_original_audio_summary">حدد المسار الصوتي الأصلي بغض النظر عن اللغة</string>
<string name="prefer_original_audio_title">تفضيل الصوت الأصلي</string>
<string name="prefer_descriptive_audio_summary">حدد مسارًا صوتيًا يحتوي على أوصاف للأشخاص ضعاف البصر إذا كان ذلك متاحًا</string>
<string name="use_exoplayer_decoder_fallback_title">استخدم ميزة فك ترميز وحدة فك التشفير الاحتياطية في ExoPlayer</string>
<string name="use_exoplayer_decoder_fallback_summary">قم بتمكين هذا الخيار إذا كانت لديك مشكلات في تهيئة وحدة فك التشفير ، والتي تعود إلى أجهزة فك التشفير ذات الأولوية الأقل إذا فشلت تهيئة وحدات فك التشفير الأولية. قد ينتج عن ذلك أداء تشغيل ضعيف مقارنة باستخدام وحدات فك التشفير الأساسية</string>
<string name="always_use_exoplayer_set_output_surface_workaround_summary">يقوم هذا الحل البديل بتحرير وإعادة إنشاء نماذج برامج ترميز الفيديو عند حدوث تغيير في السطح، بدلا من تعيين السطح إلى برنامج الترميز مباشرة. تم استخدام هذا الإعداد بالفعل بواسطة ExoPlayer على بعض الأجهزة التي تعاني من هذه المشكلة ، وهذا الإعداد له تأثير فقط على Android 6 والإصدارات الأحدث
\n
\nقد يؤدي تمكين هذا الخيار إلى منع أخطاء التشغيل عند تبديل مشغل الفيديو الحالي أو التبديل إلى وضع ملء الشاشة</string>
<string name="main_tabs_position_summary">انقل محدد علامة التبويب الرئيسي إلى الأسفل</string>
<string name="main_tabs_position_title">موضع علامات التبويب الرئيسية</string>
<string name="disable_media_tunneling_automatic_info">تم تعطيل نفق وسائل الإعلام عن طريق التقصير على جهازك لأن نموذج جهازك معروف بأنه لا يدعمه.</string>
</resources>

View File

@ -4,35 +4,35 @@
<string name="upload_date_text">%1$s tarixində yayımlanıb</string>
<string name="no_player_found">Yayım oynadıcı tapılmadı. \"VLC\" quraşdırılsın\?</string>
<string name="no_player_found_toast">Yayım oynadıcı tapılmadı (Oynatmaq üçün VLC quraşdıra bilərsiniz).</string>
<string name="install">Yüklə</string>
<string name="install">Quraşdır</string>
<string name="cancel">Ləğv et</string>
<string name="open_in_browser">Brauzerdə aç</string>
<string name="share">Paylaş</string>
<string name="download">Endir</string>
<string name="controls_download_desc">Yayım faylını endir</string>
<string name="download">Yüklə</string>
<string name="controls_download_desc">Yayım faylın yüklə</string>
<string name="search">Axtarış</string>
<string name="settings">Tənzimləmələr</string>
<string name="did_you_mean">Bunu demək istəyirdiniz: \"%1$s\"\?</string>
<string name="did_you_mean">\"%1$s\" nəzərdə tuturdunuz\?</string>
<string name="share_dialog_title">ilə paylaş</string>
<string name="use_external_video_player_title">Xarici video oynadıcı istifadə et</string>
<string name="use_external_video_player_summary">Bəzi ayırdetmələrdə səsi silir</string>
<string name="use_external_video_player_summary">Bəzi formatlarda səsi silir</string>
<string name="use_external_audio_player_title">Xarici səs oynadıcı istifadə et</string>
<string name="subscribe_button_title">Abunə Ol</string>
<string name="subscribed_button_title">Abunə olundu</string>
<string name="channel_unsubscribed">Kanal abunəliyi ləğv edildi</string>
<string name="show_info">Məlumat göstər</string>
<string name="tab_subscriptions">Abunələr</string>
<string name="tab_bookmarks">Əlfəcinlənmiş Pleylistlər</string>
<string name="tab_subscriptions">Abunəliklər</string>
<string name="tab_bookmarks">Əlfəcinlənmiş Oynatma Siyahıları</string>
<string name="fragment_feed_title">Yeniliklər</string>
<string name="controls_background_title">Fon</string>
<string name="download_path_title">Video endirmə qovluğu</string>
<string name="download_path_summary">Endirilmiş video fayllar burada saxlanılır</string>
<string name="download_path_dialog_title">Video fayllar üçün endirmə qovluğu seç</string>
<string name="download_path_audio_title">Səs endirmə qovluğu</string>
<string name="download_path_audio_summary">Endirilmiş səs faylları burada saxlanılır</string>
<string name="download_path_audio_dialog_title">Səs faylları üçün endirmə qovluğu seç</string>
<string name="default_resolution_title">Standart ayırdet</string>
<string name="show_higher_resolutions_title">Daha böyük ayırdetmələr göstər</string>
<string name="download_path_title">Video yükləmə qovluğu</string>
<string name="download_path_summary">Yüklənilmiş video fayllar burada saxlanılır</string>
<string name="download_path_dialog_title">Video fayllar üçün yükləmə qovluğu seç</string>
<string name="download_path_audio_title">Səs yükləmə qovluğu</string>
<string name="download_path_audio_summary">Yüklənilmiş səs faylları burada saxlanılır</string>
<string name="download_path_audio_dialog_title">Səs faylları üçün yükləmə qovluğu seç</string>
<string name="default_resolution_title">Standart format</string>
<string name="show_higher_resolutions_title">Daha böyük formatlar göstər</string>
<string name="play_with_kodi_title">\"Kodi\" ilə Oynat</string>
<string name="kore_not_found">Çatışmayan \"Kore\" tətbiqi yüklənilsin\?</string>
<string name="show_play_with_kodi_title">\"Kodi ilə Oynat\" seçimini göstər</string>
@ -61,10 +61,6 @@
<string name="enable_search_history_title">Axtarış tarixçəsi</string>
<string name="show_search_suggestions_summary">Axtarış zamanı göstərmək üçün təklifləri seç</string>
<string name="show_search_suggestions_title">Axtarış təklifləri</string>
<string name="brightness_gesture_control_summary">Oynadıcı parlaqlığını nizamlamaq üçün jestlər istifadə et</string>
<string name="brightness_gesture_control_title">Parlaqlıq jesti idarəetməsi</string>
<string name="volume_gesture_control_summary">Oynadıcı səsini nizamlamaq üçün jestlər istifadə et</string>
<string name="volume_gesture_control_title">Səs səviyyəsi jesti idarəetməsi</string>
<string name="auto_queue_toggle">Avto-növbələ</string>
<string name="auto_queue_title">Növbəti Yayımı Avto-növbələ</string>
<string name="metadata_cache_wipe_complete_notice">Üst məlumat keşi silindi</string>
@ -89,13 +85,13 @@
<string name="notification_action_1_title">İkinci fəaliyyət düyməsi</string>
<string name="notification_action_0_title">Birinci fəaliyyət düyməsi</string>
<string name="show_higher_resolutions_summary">Yalnız bəzi cihazlar 2K/4K videoları oynada bilir</string>
<string name="default_popup_resolution_title">Standart ani görüntü ayırdetməsi</string>
<string name="default_popup_resolution_title">Standart ani görüntü formatı</string>
<string name="controls_add_to_playlist_title">Əlavə Et</string>
<string name="controls_popup_title">Ani Görüntü</string>
<string name="tab_choose">Paneli Seç</string>
<string name="subscription_update_failed">Abunəliyi yeniləmək alınmadı</string>
<string name="subscription_change_failed">Abunəliyi dəyişmək alınmadı</string>
<string name="search_showing_result_for">Nəticələr göstərilir: %s</string>
<string name="search_showing_result_for">%s üçün nəticələr göstərilir</string>
<string name="channels">Kanallar</string>
<string name="video_detail_by">%s tərəfindən</string>
<string name="youtube_restricted_mode_enabled_title">YouTube\'un \"Məhdud Rejimi\"ni aç</string>
@ -429,21 +425,21 @@
<string name="show_thumbnail_summary">Həm kilid ekranı fonu, həm də bildirişlər üçün miniatür istifadə et</string>
<string name="recent">Ən Yeni</string>
<string name="georestricted_content">Bu məzmun ölkənizdə mövcud deyil.</string>
<string name="paid_content">Bu məzmun yalnız ödəniş etmiş istifadəçilər üçün əlçatandır, ona görə də NewPipe tərəfindən yayımlana və ya endirilə bilməz.</string>
<string name="paid_content">Bu məzmun yalnız ödəniş etmiş istifadəçilər üçün əlçatandır, beləliklə, NewPipe tərəfindən yayımlana və ya yüklənilə bilməz.</string>
<string name="auto_device_theme_title">Avtomatik (cihaz teması)</string>
<string name="night_theme_summary">Sevimli gecə temanızı seçin — %s</string>
<string name="detail_pinned_comment_view_description">Sabitlənmiş şərh</string>
<string name="notifications_disabled">Bildirişlər deaktiv edilib</string>
<string name="detail_pinned_comment_view_description">Sancaqlanmış şərh</string>
<string name="notifications_disabled">Bildirişlər qeyri-aktivdir</string>
<string name="get_notified">Bildiriş al</string>
<string name="you_successfully_subscribed">Artıq bu kanala abunə oldunuz</string>
<string name="enumeration_comma">,</string>
<string name="toggle_all">Hamısını dəyişdir</string>
<string name="toggle_all">Hamısın dəyişdir</string>
<string name="msg_name">Fayl adı</string>
<string name="recaptcha_solve">Həll et</string>
<string name="subscriptions_export_unsuccessful">Abunəlikləri ixrac etmək mümkün olmadı</string>
<plurals name="watching">
<item quantity="one">%s izləyici</item>
<item quantity="other">%s izləyici</item>
<item quantity="one">%s baxıcı</item>
<item quantity="other">%s baxıcı</item>
</plurals>
<string name="manual_update_description">Yeni versiyaları əl ilə yoxla</string>
<plurals name="listening">
@ -489,14 +485,12 @@
<string name="feed_load_error_terminated">Müəllifin hesabı bağlanıb.
\nNewPipe gələcəkdə bu axını yükləyə bilməyəcək.
\nBu kanaldan abunəliyi çıxarmaq istəyirsiniz\?</string>
<string name="feed_toggle_show_played_items">Baxılan elementləri göstər</string>
<string name="featured">Seçilmiş</string>
<string name="featured">Seçilən</string>
<string name="drawer_close">Çəkməcəni Bağla</string>
<string name="video_player">Video oynadıcı</string>
<string name="hash_channel_description">Video fayl xülasəsi prosesi üçün bildirişlər</string>
<string name="on"></string>
<string name="notification_scale_to_square_image_title">Miniatürü 1:1 görünüş nisbətinə kəs</string>
<string name="progressive_load_interval_summary">Yükləmə intervalı həcmini dəyişdir (hazırda %s). Daha aşağı dəyər ilkin video yükləməni sürətləndirə bilər. Dəyişikliklər oynadıcını yenidən başlatmağı tələb edir</string>
<string name="show_meta_info_summary">Yayım yaradıcısı, məzmunu və ya axtarış sorğusu haqqında əlavə məlumat olan üst məlumat qutularını gizlətmək üçün söndür</string>
<string name="auto_queue_summary">Əlaqəli yayımı əlavə etməklə (təkrarlanmayan) sonlanacaq oynatma növbəsini davam etdir</string>
<string name="remote_search_suggestions">Kənar axtarış təklifləri</string>
@ -524,8 +518,8 @@
<string name="enable_queue_limit_desc">Eyni vaxtda ancaq bir endirmə həyata keçiriləcək</string>
<string name="account_terminated">Hesab ləğv edildi</string>
<string name="service_provides_reason">%s bu səbəbi təmin edir:</string>
<string name="download_has_started">Endirmə başladı</string>
<string name="description_select_disable">ıqlamadakı mətni seçməyi deaktiv et</string>
<string name="download_has_started">Yükləmə başladı</string>
<string name="description_select_disable">ıqlamadakı mətni seçməyi qeyri-aktiv et</string>
<string name="metadata_category">Kateqoriya</string>
<string name="metadata_privacy_internal">Daxili</string>
<string name="description_select_enable">ıqlamadakı mətni seçməyi aktivləşdir</string>
@ -550,7 +544,7 @@
<item quantity="one">Endirmə tamamlandı</item>
<item quantity="other">%s endirmə tamamlandı</item>
</plurals>
<string name="progressive_load_interval_exoplayer_default">Standart ExoPlayer</string>
<string name="progressive_load_interval_exoplayer_default">ExoPlayer standartı</string>
<string name="feed_use_dedicated_fetch_method_title">Mövcud olduqda xüsusi axından al</string>
<string name="remove_watched_popup_title">Baxılmış videolar silinsin\?</string>
<string name="remove_watched">İzləniləni sil</string>
@ -622,7 +616,7 @@
<string name="export_to">Bura ixrac et</string>
<string name="import_file_title">Faylı idxal et</string>
<string name="subscriptions_import_unsuccessful">Abunəlikləri idxal etmək mümkün olmadı</string>
<string name="start_accept_privacy_policy">Avropa Ümumi Məlumat Mühafizəsi Qaydasına (GDPR) riayət etmək üçün diqqətinizi NewPipe məxfilik siyasətinə cəlb edirik. Zəhmət olmasa, diqqətlə oxuyun. Xəta hesabatın bizə göndərmək üçün qəbul etməlisiniz.</string>
<string name="start_accept_privacy_policy">Avropa Ümumi Məlumat Mühafizəsi Qaydasına (GDPR) riayət etmək üçün diqqətinizi NewPipe məxfilik siyasətinə cəlb edirik. Zəhmət olmasa, diqqətlə oxuyun. Xəta məlumatın bizə göndərmək üçün qəbul etməlisiniz.</string>
<string name="overwrite_unrelated_warning">Bu adda fayl artıq mövcuddur</string>
<string name="download_already_pending">Bu adla gözlənilən bir endirmə var</string>
<string name="error_path_creation">Təyinat qovluğu yaradıla bilməz</string>
@ -673,16 +667,16 @@
<string name="loading_stream_details">Yayım təfərrüatları yüklənir…</string>
<string name="disable_media_tunneling_title">Media tunelini deaktiv et</string>
<string name="crash_the_app">Tətbiq çökdü</string>
<string name="import_youtube_instructions">YouTube abunəliklərini Google takeout\'dan
\nidxal edin:
<string name="import_youtube_instructions">YouTube abunəliklərin Google Takeout-dan
\nidxal et:
\n
\n1. Bu URL\'ə keçin: %1$s
\n2. Soruşulduqda daxil olun
\n3.\"Bütün Məlumatlar Daxildir\",sonra \"Heçbirini Seçmə\", yalnız \"abunəliklər\"i seçin və \"Oldu\" kliklə
\n4. \"Növbəti addım\"üzərinə klikləyin, sonra isə \"İxrac Yarat\" üzərinə klikləyin
\n5. Görünəndən sonra \"Endir\"düyməsini basın
\n6. Aşağıdakı FAYLI İDXAL ET düyməsinə klikləyin və endirilmiş .zip faylını seçin
\n7. [Əgər .zip faylı idxalı uğursuz olsa] .csv faylını çıxarın(adətən\"YouTubevəYouTubeMusic/subscriptions/subscriptions.csv\" altında),aşağıda İDXAL EDİLƏN FAYL-ı klikləyin və çıxarılmış csv faylını seçin</string>
\n1. %1$s URL\'ə keçin:
\n2. Soruşulduqda daxil ol
\n3. \"Bütün Məlumatlar Daxildir\",sonra \"Hamısın Seçmə\", yalnız \"abunəlikləri\" seç və \"Oldu\" kliklə
\n4. \"Növbəti addım\"üzərinə kliklə, sonra isə \"İxrac Yarat\" üzərinə kliklə
\n5. Görünəndən sonra, \"Endirin\"düyməsin bas
\n6. Aşağıda FAYLI İDXAL ET düyməsin kliklə və yüklənilmiş (.zip) faylın seç
\n7. [Əgər .zip faylı idxalı uğursuz olsa] .csv faylın çıxar(adətən\"YouTubeandYouTubeMusic/subscriptions/subscriptions.csv\" altında),aşağıda FAYLI İDXAL ET-ə kliklə və çıxarılan csv faylın seç</string>
<string name="playback_speed_control">Oynatma Sürəti Nizamlamaları</string>
<string name="unhook_checkbox">Ayır (pozuntuya səbəb ola bilər)</string>
<string name="show_error">Xətanı göstər</string>
@ -702,21 +696,18 @@
<string name="no_appropriate_file_manager_message_android_10">Bu əməliyyat üçün uyğun fayl meneceri tapılmadı.
\nZəhmət olmasa ,Yaddaş Giriş Çərçivəsinə uyğun fayl menecerini quraşdırın</string>
<string name="youtube_music_premium_content">Bu video yalnız YouTube Music Premium üzvləri üçün əlçatandır, ona görə də NewPipe tərəfindən yayımlamaq və ya endirmək mümkün deyil.</string>
<string name="description_select_note">İndi açıqlamadakı mətni seçə bilərsiniz. Nəzərə alın ki, seçim rejimində səhifə titrəyə və keçidlər kliklənməyə bilər.</string>
<string name="description_select_note">İndi açıqlamadakı mətni seçə bilərsiniz. Nəzərə alın ki, seçim rejimində səhifə titrəyə və linklər kliklənməyə bilər.</string>
<string name="notification_scale_to_square_image_summary">Bildirişdə göstərilən video miniatürünü 16:9-dan 1:1 görünüş nisbətinə qədər kəs</string>
<string name="notification_actions_summary">Aşağıdakı hər bir bildiriş fəaliyyətini üzərinə toxunaraq redaktə et. Sağdakı təsdiq qutularından istifadə edərək yığcam bildirişdə göstərmək üçün onların üçünü seç</string>
<string name="invalid_source">Belə fayl/məzmun mənbəyi yoxdur</string>
<string name="selected_stream_external_player_not_supported">Seçilmiş yayım xarici oynadıcılar tərəfindən dəstəklənmir</string>
<string name="selected_stream_external_player_not_supported">Seçilən yayım xarici oynadıcılar tərəfindən dəstəklənmir</string>
<string name="streams_not_yet_supported_removed">Yükləyici tərəfindən hələ dəstəklənməyən yayımlar göstərilmir</string>
<string name="no_audio_streams_available_for_external_players">Xarici oynadıcılar üçün heç bir səs yayımı yoxdur</string>
<string name="no_video_streams_available_for_external_players">Xarici oynadıcılar üçün heç bir video yayımı yoxdur</string>
<string name="no_audio_streams_available_for_external_players">Xarici oynadıcılar üçün mövcud səs yayımı yoxdur</string>
<string name="no_video_streams_available_for_external_players">Xarici oynadıcılar üçün mövcud video yayımı yoxdur</string>
<string name="select_quality_external_players">Xarici oynadıcılar üçün keyfiyyət seç</string>
<string name="unknown_format">Naməlum format</string>
<string name="unknown_quality">Naməlum keyfiyyət</string>
<string name="progressive_load_interval_title">Oynatma yükləmə intervalı həcmi</string>
<string name="feed_toggle_show_future_items">Gələcək elementləri göstər</string>
<string name="feed_toggle_hide_played_items">Baxılan elementləri gizlət</string>
<string name="feed_toggle_hide_future_items">Gələcək elementləri gizlət</string>
<string name="faq_description">Tətbiqi istifadə etməkdə çətinlik çəkirsinizsə, ümumi suallara bu cavabları yoxladığınıza əmin olun!</string>
<string name="faq_title">Tez-tez soruşulan suallar</string>
<string name="faq">Veb Saytında bax</string>
@ -741,4 +732,32 @@
<string name="feed_show_partially_watched">Qismən baxılıb</string>
<string name="remove_duplicates_message">Bu pleylistdəki bütün dublikat yayımları silmək istəyirsiniz\?</string>
<string name="feed_show_upcoming">Yaxınlaşan</string>
<string name="left_gesture_control_title">Sol jest hərəkəti</string>
<string name="right_gesture_control_summary">Oynadıcı ekranının sağ yarısı üçün jest seç</string>
<string name="right_gesture_control_title">Sağ jest hərəkəti</string>
<string name="brightness">Parlaqlıq</string>
<string name="volume">Səs səviyyəsi</string>
<string name="none">Heç biri</string>
<string name="left_gesture_control_summary">Oynadıcı ekranının sol yarısı üçün jest seç</string>
<string name="prefer_original_audio_title">Orijinal səsə üstünlük ver</string>
<string name="prefer_original_audio_summary">Dildən asılı olmayaraq orijinal səs axını seç</string>
<string name="prefer_descriptive_audio_title">Təsviri səsə üstünlük ver</string>
<string name="prefer_descriptive_audio_summary">Varsa, görmə qabiliyyəti zəifləyən insanlar üçün təsviri olan səs axını seçin</string>
<string name="play_queue_audio_track">Səs: %s</string>
<string name="audio_track">Səs axını</string>
<string name="audio_track_present_in_video">Səs axını bu yayımda olmalıdır</string>
<string name="select_audio_track_external_players">Xarici oynadıcılar üçün səs axını seç</string>
<string name="unknown_audio_track">Naməlum</string>
<string name="settings_category_exoplayer_title">ExoPlayer tənzimləmələri</string>
<string name="settings_category_exoplayer_summary">Bəzi ExoPlayer tənzimləmələrin idarə et. Bu dəyişiklikləri təsirli etmək üçün oynadıcını yenidən başlatmaq tələb olunur</string>
<string name="use_exoplayer_decoder_fallback_title">ExoPlayer-in çözücü xüsusiyyətin istifadə et</string>
<string name="use_exoplayer_decoder_fallback_summary">Əsas çözücüləri işlətmə uğursuz olarsa, çözücü işlətmək probleminiz varsa (daha aşağı prioritetli çözücülərə düşür), bu seçimi aktiv edin. Bu, əsas çözücülərdən istifadə ilə müqayisədə zəif oynatma performansı ilə nəticələnə bilər</string>
<string name="always_use_exoplayer_set_output_surface_workaround_summary">Bu həll yolu səthi kodlayıcıya birbaşa tənzimləmək əvəzinə, səth dəyişikliyi olarsa video kodlayıcıları buraxır və yenidən işlədir. Artıq ExoPlayer tərəfindən bu problemi olan bəzi cihazlarda istifadə olunur, bu tənzimləmənin təsiri yalnız Android 6 və daha yüksəkdə var.
\n
\nBu seçimi aktivləşdirmə cari video oynadıcı dəyişdiriləndə və ya tam ekrana keçəndə oynatma xətalarının qarşısını ala bilər</string>
<string name="audio_track_type_original">orijinal</string>
<string name="audio_track_type_dubbed">dublyaj edilib</string>
<string name="audio_track_type_descriptive">təsviri</string>
<string name="always_use_exoplayer_set_output_surface_workaround_title">Həmişə ExoPlayer-in video çıxış səthi tənzimləməsin istifadə et</string>
<string name="progressive_load_interval_summary">Qabaqcıl məzmunda yükləmə aralığı həcmin dəyişdir (hazırda %s). Daha aşağı dəyər onların ilkin yüklənilməsin sürətləndirə bilər</string>
</resources>

View File

@ -150,8 +150,6 @@
<string name="playlists">Llistes de reproducción</string>
<string name="tracks">Pistes</string>
<string name="users">Usuarios</string>
<string name="volume_gesture_control_summary">Usa xestos pa controlar el volume del reproductor</string>
<string name="brightness_gesture_control_summary">Usa xestos pa controlar el brillu del reproductor</string>
<string name="restore_defaults">Reafitamientu de valores</string>
<string name="subscribers_count_not_available">El númberu de soscriptores nun ta disponible</string>
<string name="updates_setting_title">Anovamientos</string>
@ -226,8 +224,6 @@
</plurals>
<string name="preferred_player_fetcher_notification_message">Cargando\'l conteníu solicitáu</string>
<string name="privacy_policy_title">Política de privacidá de NewPipe</string>
<string name="volume_gesture_control_title">Control per xestos del volume</string>
<string name="brightness_gesture_control_title">Control per xestos del brillu</string>
<string name="error_file_creation">El ficheru nun pue crease</string>
<string name="error_http_no_content">El sirvidor nun unvia datos</string>
<string name="localization_changes_requires_app_restart">La llingua va camudar namás que se reanicie l\'aplicación.</string>

View File

@ -17,10 +17,6 @@
<string name="no_player_found">Hech qanday translatsiya pleyeri topilmadi. VLC o\'rnatilsinmi\?</string>
<string name="upload_date_text">%1$s tomonidan elon qilingan</string>
<string name="main_bg_subtitle">Boshlash uchun \"Izlash\" tugmasini bosing</string>
<string name="volume_gesture_control_summary">Player tovushini boshqarish uchun imo-ishoralardan foydalanish</string>
<string name="brightness_gesture_control_summary">Player yorqinligini boshqarish uchun imo-ishoralardan foydalaning</string>
<string name="brightness_gesture_control_title">Yorqinlik ishoralarini boshqarish</string>
<string name="volume_gesture_control_title">Ovoz balandligini ishoralarni boshqarish</string>
<string name="auto_queue_toggle">Avto-navbat</string>
<string name="auto_queue_summary">Tegishli stream qo\'shib, ijro etish navbatini tugatishni (takrorlanmaydigan) davom ettirish</string>
<string name="auto_queue_title">avtomatik navbat next stream</string>

Some files were not shown because too many files have changed in this diff Show More