Skip to content

Commit

Permalink
multi apk
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Aug 10, 2024
1 parent 8ac3973 commit 7a3a52b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 86 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
id: set_asset_name_mobile
run: |
VERSION_WITHOUT_V=$(echo '${{ github.ref_name }}' | sed 's/^v//')
echo "asset_name=my-tv-0.china-mobile.${VERSION_WITHOUT_V}.apk" >> $GITHUB_ENV
echo "asset_name=my-tv-0.${VERSION_WITHOUT_V}.china-mobile.apk" >> $GITHUB_ENV
- name: Upload Release Asset mobile
uses: actions/upload-release-asset@v1
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
id: set_asset_name_ipv6
run: |
VERSION_WITHOUT_V=$(echo '${{ github.ref_name }}' | sed 's/^v//')
echo "asset_name=my-tv-0.ipv6.${VERSION_WITHOUT_V}.apk" >> $GITHUB_ENV
echo "asset_name=my-tv-0.${VERSION_WITHOUT_V}.ipv6.apk" >> $GITHUB_ENV
- name: Upload Release Asset ipv6
uses: actions/upload-release-asset@v1
Expand Down
1 change: 1 addition & 0 deletions app/assets/common.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/ipv6-url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_CONFIG_URL = "https://live.fanmingming.com/tv/m3u/ipv6.m3u"
File renamed without changes.
1 change: 1 addition & 0 deletions app/assets/mobile-url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_CONFIG_URL = "https://live.fanmingming.com/tv/m3u/itv.m3u"
File renamed without changes.
104 changes: 20 additions & 84 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,46 +73,20 @@ fun getVersionName(): String {
}
}

tasks.register("modifySource") {
doFirst {
val net = project.findProperty("net") ?: ""
println("net: $net")

val channels = when (net) {
"ipv6" -> "R.raw.ipv6"
"mobile" -> "R.raw.itv"
else -> ""
}

if (channels.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
f.writeText(f.readText().replace("R.raw.channels", channels))
}

val url = when (net) {
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
else -> ""
}

if (url.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
}
}
task("modifySource") {
doLast {
val net = project.findProperty("net") ?: ""
println("net: $net")

val channels = when (net) {
"ipv6" -> "R.raw.ipv6"
"mobile" -> "R.raw.itv"
else -> ""
"ipv6" -> "assets/ipv6.txt"
"mobile" -> "assets/mobile.txt"
else -> "assets/common.txt"
}

if (channels.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
f.writeText(f.readText().replace(channels, "R.raw.channels"))
val f = file("src/main/res/raw/channels.txt")
f.writeText(file(channels).readText())
}

val url = when (net) {
Expand All @@ -123,65 +97,27 @@ tasks.register("modifySource") {

if (url.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
}
}
}

tasks.whenTaskAdded {
if (name == "assembleRelease") {
tasks.named("assembleRelease") {
doFirst {
val net = project.findProperty("net") ?: ""
println("net: $net")

val channels = when (net) {
"ipv6" -> "R.raw.ipv6"
"mobile" -> "R.raw.itv"
else -> ""
}

if (channels.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
f.writeText(f.readText().replace("R.raw.channels", channels))
}

val url = when (net) {
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
else -> ""
}

if (url.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
}
dependsOn("modifySource")
doLast {
val net = project.findProperty("net") ?: ""
println("net: $net")

val url = when (net) {
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
else -> ""
}
doLast {
val net = project.findProperty("net") ?: ""
println("net: $net")

val channels = when (net) {
"ipv6" -> "R.raw.ipv6"
"mobile" -> "R.raw.itv"
else -> ""
}

if (channels.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
f.writeText(f.readText().replace(channels, "R.raw.channels"))
}

val url = when (net) {
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
else -> ""
}

if (url.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
}

if (url.isNotEmpty()) {
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
}
}
}
Expand Down

0 comments on commit 7a3a52b

Please sign in to comment.