Skip to content

Commit 7a3a52b

Browse files
committed
multi apk
1 parent 8ac3973 commit 7a3a52b

File tree

7 files changed

+25
-86
lines changed

7 files changed

+25
-86
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
id: set_asset_name_mobile
9393
run: |
9494
VERSION_WITHOUT_V=$(echo '${{ github.ref_name }}' | sed 's/^v//')
95-
echo "asset_name=my-tv-0.china-mobile.${VERSION_WITHOUT_V}.apk" >> $GITHUB_ENV
95+
echo "asset_name=my-tv-0.${VERSION_WITHOUT_V}.china-mobile.apk" >> $GITHUB_ENV
9696
9797
- name: Upload Release Asset mobile
9898
uses: actions/upload-release-asset@v1
@@ -124,7 +124,7 @@ jobs:
124124
id: set_asset_name_ipv6
125125
run: |
126126
VERSION_WITHOUT_V=$(echo '${{ github.ref_name }}' | sed 's/^v//')
127-
echo "asset_name=my-tv-0.ipv6.${VERSION_WITHOUT_V}.apk" >> $GITHUB_ENV
127+
echo "asset_name=my-tv-0.${VERSION_WITHOUT_V}.ipv6.apk" >> $GITHUB_ENV
128128
129129
- name: Upload Release Asset ipv6
130130
uses: actions/upload-release-asset@v1

app/assets/common.txt

+1
Large diffs are not rendered by default.

app/assets/ipv6-url.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEFAULT_CONFIG_URL = "https://live.fanmingming.com/tv/m3u/ipv6.m3u"
File renamed without changes.

app/assets/mobile-url.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEFAULT_CONFIG_URL = "https://live.fanmingming.com/tv/m3u/itv.m3u"
File renamed without changes.

app/build.gradle.kts

+20-84
Original file line numberDiff line numberDiff line change
@@ -73,46 +73,20 @@ fun getVersionName(): String {
7373
}
7474
}
7575

76-
tasks.register("modifySource") {
77-
doFirst {
78-
val net = project.findProperty("net") ?: ""
79-
println("net: $net")
80-
81-
val channels = when (net) {
82-
"ipv6" -> "R.raw.ipv6"
83-
"mobile" -> "R.raw.itv"
84-
else -> ""
85-
}
86-
87-
if (channels.isNotEmpty()) {
88-
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
89-
f.writeText(f.readText().replace("R.raw.channels", channels))
90-
}
91-
92-
val url = when (net) {
93-
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
94-
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
95-
else -> ""
96-
}
97-
98-
if (url.isNotEmpty()) {
99-
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
100-
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
101-
}
102-
}
76+
task("modifySource") {
10377
doLast {
10478
val net = project.findProperty("net") ?: ""
10579
println("net: $net")
10680

10781
val channels = when (net) {
108-
"ipv6" -> "R.raw.ipv6"
109-
"mobile" -> "R.raw.itv"
110-
else -> ""
82+
"ipv6" -> "assets/ipv6.txt"
83+
"mobile" -> "assets/mobile.txt"
84+
else -> "assets/common.txt"
11185
}
11286

11387
if (channels.isNotEmpty()) {
114-
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
115-
f.writeText(f.readText().replace(channels, "R.raw.channels"))
88+
val f = file("src/main/res/raw/channels.txt")
89+
f.writeText(file(channels).readText())
11690
}
11791

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

12498
if (url.isNotEmpty()) {
12599
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
126-
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
100+
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
127101
}
128102
}
129103
}
130104

131105
tasks.whenTaskAdded {
132106
if (name == "assembleRelease") {
133-
tasks.named("assembleRelease") {
134-
doFirst {
135-
val net = project.findProperty("net") ?: ""
136-
println("net: $net")
137-
138-
val channels = when (net) {
139-
"ipv6" -> "R.raw.ipv6"
140-
"mobile" -> "R.raw.itv"
141-
else -> ""
142-
}
143-
144-
if (channels.isNotEmpty()) {
145-
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
146-
f.writeText(f.readText().replace("R.raw.channels", channels))
147-
}
148-
149-
val url = when (net) {
150-
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
151-
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
152-
else -> ""
153-
}
154-
155-
if (url.isNotEmpty()) {
156-
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
157-
f.writeText(f.readText().replace("DEFAULT_CONFIG_URL = \"\"", url))
158-
}
107+
dependsOn("modifySource")
108+
doLast {
109+
val net = project.findProperty("net") ?: ""
110+
println("net: $net")
111+
112+
val url = when (net) {
113+
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
114+
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
115+
else -> ""
159116
}
160-
doLast {
161-
val net = project.findProperty("net") ?: ""
162-
println("net: $net")
163-
164-
val channels = when (net) {
165-
"ipv6" -> "R.raw.ipv6"
166-
"mobile" -> "R.raw.itv"
167-
else -> ""
168-
}
169-
170-
if (channels.isNotEmpty()) {
171-
val f = file("src/main/java/com/lizongying/mytv0/models/TVList.kt")
172-
f.writeText(f.readText().replace(channels, "R.raw.channels"))
173-
}
174-
175-
val url = when (net) {
176-
"ipv6" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/ipv6.m3u\""
177-
"mobile" -> "DEFAULT_CONFIG_URL = \"https://live.fanmingming.com/tv/m3u/itv.m3u\""
178-
else -> ""
179-
}
180-
181-
if (url.isNotEmpty()) {
182-
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
183-
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
184-
}
117+
118+
if (url.isNotEmpty()) {
119+
val f = file("src/main/java/com/lizongying/mytv0/SP.kt")
120+
f.writeText(f.readText().replace(url, "DEFAULT_CONFIG_URL = \"\""))
185121
}
186122
}
187123
}

0 commit comments

Comments
 (0)