Skip to content

Commit 0fb2e8d

Browse files
committed
Add Google Cast support for full flavor
1 parent e4d11d7 commit 0fb2e8d

15 files changed

Lines changed: 622 additions & 10 deletions

File tree

.github/workflows/build-release-apk.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ jobs:
9595
echo "Missing one or more NewPipe Material release signing secrets" >&2
9696
exit 1
9797
fi
98-
./gradlew clean assembleRelease --stacktrace
98+
./gradlew clean assembleFullRelease --stacktrace
9999
100100
- name: Verify release APK identity
101101
run: |
102102
set -euo pipefail
103-
APK_PATH="$(find app/build/outputs/apk/release -name '*.apk' | head -n 1)"
103+
APK_PATH="$(find app/build/outputs/apk/full/release -name '*.apk' | head -n 1)"
104104
test -n "$APK_PATH"
105105
AAPT="$ANDROID_HOME/build-tools/$(ls "$ANDROID_HOME/build-tools" | sort -V | tail -n 1)/aapt"
106106
"$AAPT" dump badging "$APK_PATH" | tee "$RUNNER_TEMP/release-apk-badging.txt"
@@ -110,8 +110,8 @@ jobs:
110110
- name: "Rename APK"
111111
id: release_info
112112
run: |
113-
VERSION_NAME="$(jq -r ".elements[0].versionName" "app/build/outputs/apk/release/output-metadata.json")"
114-
VERSION_CODE="$(jq -r ".elements[0].versionCode" "app/build/outputs/apk/release/output-metadata.json")"
113+
VERSION_NAME="$(jq -r ".elements[0].versionName" "app/build/outputs/apk/full/release/output-metadata.json")"
114+
VERSION_CODE="$(jq -r ".elements[0].versionCode" "app/build/outputs/apk/full/release/output-metadata.json")"
115115
RELEASE_TAG="v${VERSION_NAME}"
116116
117117
if [ "$GITHUB_EVENT_NAME" = "push" ] && [ "$GITHUB_REF_NAME" != "$RELEASE_TAG" ]; then
@@ -120,10 +120,10 @@ jobs:
120120
fi
121121
122122
APK_NAME="NewPipeMaterial_v${VERSION_NAME}.apk"
123-
APK_PATH="app/build/outputs/apk/release/${APK_NAME}"
123+
APK_PATH="app/build/outputs/apk/full/release/${APK_NAME}"
124124
CHANGELOG_PATH="fastlane/metadata/android/en-US/changelogs/${VERSION_CODE}.txt"
125125
126-
mv app/build/outputs/apk/release/*.apk "$APK_PATH"
126+
mv app/build/outputs/apk/full/release/*.apk "$APK_PATH"
127127
128128
echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
129129
echo "version_code=$VERSION_CODE" >> "$GITHUB_OUTPUT"

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ jobs:
9191
javap -verbose -classpath external/NewPipeExtractor/extractor/build/classes/java/main org.schabi.newpipe.extractor.NewPipe | grep "major version: 65"
9292
9393
- name: Build debug APK and run jvm tests
94-
run: ./gradlew clean assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint
94+
run: ./gradlew clean assembleFullDebug assembleFdroidDebug lintFullDebug lintFdroidDebug testFullDebugUnitTest testFdroidDebugUnitTest --stacktrace -DskipFormatKtlint
9595

9696
- name: Verify debug APK identity
9797
run: |
98-
APK_PATH="$(find app/build/outputs/apk/debug -name '*.apk' | head -n 1)"
98+
APK_PATH="$(find app/build/outputs/apk/full/debug -name '*.apk' | head -n 1)"
9999
test -n "$APK_PATH"
100100
AAPT="$ANDROID_HOME/build-tools/$(ls "$ANDROID_HOME/build-tools" | sort -V | tail -n 1)/aapt"
101101
"$AAPT" dump badging "$APK_PATH" | tee "$RUNNER_TEMP/debug-apk-badging.txt"
@@ -106,7 +106,7 @@ jobs:
106106
uses: actions/upload-artifact@v7
107107
with:
108108
name: newpipe-material-debug-apk
109-
path: app/build/outputs/apk/debug/*.apk
109+
path: app/build/outputs/apk/full/debug/*.apk
110110

111111
test-android:
112112
runs-on: ubuntu-latest

app/build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ configure<ApplicationExtension> {
8989
}
9090
}
9191

92+
flavorDimensions += "distribution"
93+
productFlavors {
94+
create("full") {
95+
dimension = "distribution"
96+
buildConfigField("boolean", "CAST_ENABLED", "true")
97+
}
98+
create("fdroid") {
99+
dimension = "distribution"
100+
buildConfigField("boolean", "CAST_ENABLED", "false")
101+
}
102+
}
103+
92104
buildTypes {
93105
debug {
94106
isDebuggable = true
@@ -209,7 +221,7 @@ tasks.register<CheckDependenciesOrder>("checkDependenciesOrder") {
209221
}
210222

211223
afterEvaluate {
212-
tasks.named("preDebugBuild").configure {
224+
tasks.matching { it.name.matches(Regex("pre.*DebugBuild")) }.configureEach {
213225
if (!System.getProperties().containsKey("skipFormatKtlint")) {
214226
dependsOn("formatKtlint")
215227
}
@@ -253,6 +265,9 @@ dependencies {
253265
implementation(libs.google.android.material)
254266
implementation(libs.androidx.webkit)
255267

268+
// Google Cast (GitHub/full builds only; fdroid must remain Cast-SDK-free)
269+
add("fullImplementation", libs.google.cast.framework)
270+
256271
// Coroutines interop
257272
implementation(libs.kotlinx.coroutines.rx3)
258273

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.schabi.newpipe.cast;
2+
3+
import android.content.Context;
4+
import android.view.View;
5+
import android.widget.TextView;
6+
7+
import androidx.annotation.NonNull;
8+
9+
import org.schabi.newpipe.extractor.stream.StreamInfo;
10+
11+
final class CastControllerFactory {
12+
private CastControllerFactory() {
13+
}
14+
15+
@NonNull
16+
static CastController create(@NonNull final Context context) {
17+
return new NoOpCastController();
18+
}
19+
20+
private static final class NoOpCastController implements CastController {
21+
@Override
22+
public void bindButton(@NonNull final TextView button,
23+
@NonNull final Runnable onLocalPlaybackShouldPause) {
24+
button.setVisibility(View.GONE);
25+
button.setEnabled(false);
26+
}
27+
28+
@Override
29+
public void setCurrentStreamInfo(@NonNull final StreamInfo info) {
30+
// F-Droid builds intentionally have no Cast SDK dependency or runtime behavior.
31+
}
32+
33+
@Override
34+
public void release() {
35+
// No-op.
36+
}
37+
}
38+
}

app/src/full/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<application>
3+
<meta-data
4+
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
5+
android:value="org.schabi.newpipe.cast.NewPipeCastOptionsProvider" />
6+
</application>
7+
</manifest>

0 commit comments

Comments
 (0)