Skip to content

Commit 31cdc7a

Browse files
Experiments shortcut for tv,
Correctly load new sources, Debug resources for easier debugging, Fixed crash when trying to exit the player, Fixed crash when trying to restore an CallbackFragment, Fixed crash when trying to open some strange websites, Added back all product flavors, Disable native crash handler for false callbacks, Suggest to share crash message even if only an throwable was provided, Move HomeScreen loadings into HomeViewModel, Properly show episodes count, Allow opening an website if failed to bypass it's security and retry again, Experimental picture in picture controls, Finish PlayerActivity if miniplayer has been dismissed, Launch picture in picture after pressing an home button, Removed unused settings, Fixed about screen crash on some devices, Fixed broken localization on old devices, Restart the whole app after selecting an locale
1 parent 78cf060 commit 31cdc7a

File tree

65 files changed

+1912
-1305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1912
-1305
lines changed

app/build.gradle.kts

Lines changed: 81 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import com.android.build.api.dsl.ApplicationProductFlavor
12
import java.util.Locale
23
import com.squareup.moshi.Moshi
34
import com.squareup.moshi.adapter
45
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
5-
import org.codehaus.groovy.transform.trait.Traits.Implemented
6-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
76

87
plugins {
98
alias(libs.plugins.android.application)
@@ -112,24 +111,6 @@ android {
112111
}
113112
}
114113

115-
flavorDimensions.add("type")
116-
117-
productFlavors {
118-
register("alpha") {
119-
isDefault = true
120-
dimension = "type"
121-
versionNameSuffix = "-alpha"
122-
applicationIdSuffix = ".alpha"
123-
124-
buildConfigField("${packageName}.app.update.UpdatesChannel", "CHANNEL", "${packageName}.app.update.UpdatesChannel.ALPHA")
125-
buildConfigField("String", "FILE_PROVIDER", "\"${packageName}.alpha.FileProvider\"")
126-
buildConfigField("String", "UPDATES_REPOSITORY", "\"itsmechinmoy/awery-updater\"")
127-
128-
manifestPlaceholders["fileProvider"] = "${packageName}.alpha.FileProvider"
129-
manifestPlaceholders["appLabel"] = "Awery Alpha"
130-
}
131-
}
132-
133114
buildFeatures {
134115
viewBinding = true
135116
buildConfig = true
@@ -149,6 +130,43 @@ android {
149130
jvmTarget = "17"
150131
freeCompilerArgs = listOf("-Xcontext-receivers", "-Xmulti-platform", "-opt-in=kotlin.ExperimentalStdlibApi")
151132
}
133+
134+
flavorDimensions += listOf("channel")
135+
136+
productFlavors {
137+
fun ApplicationProductFlavor.createChannelProductFlavor(id: String, title: String) {
138+
dimension = "channel"
139+
versionNameSuffix = "-$id"
140+
applicationIdSuffix = ".$id"
141+
142+
buildConfigField("String", "FILE_PROVIDER",
143+
"\"${packageName}.$id.FileProvider\"")
144+
145+
buildConfigField("${packageName}.app.update.UpdatesChannel", "CHANNEL",
146+
"${packageName}.app.update.UpdatesChannel.${id.uppercase()}")
147+
148+
manifestPlaceholders["fileProvider"] = "${packageName}.$id.FileProvider"
149+
manifestPlaceholders["appLabel"] = "Awery $title"
150+
}
151+
152+
register("alpha") {
153+
createChannelProductFlavor("alpha", "Alpha")
154+
buildConfigField("String", "UPDATES_REPOSITORY", "\"itsmechinmoy/awery-updater\"")
155+
isDefault = true
156+
}
157+
158+
register("beta") {
159+
createChannelProductFlavor("beta", "Beta")
160+
buildConfigField("String", "UPDATES_REPOSITORY", "\"MrBoomDeveloper/Awery\"")
161+
}
162+
163+
register("stable") {
164+
createChannelProductFlavor("stable", "Stable")
165+
buildConfigField("String", "UPDATES_REPOSITORY", "\"MrBoomDeveloper/Awery\"")
166+
manifestPlaceholders["appLabel"] = "Awery"
167+
applicationIdSuffix = null
168+
}
169+
}
152170
}
153171

154172
dependencies {
@@ -157,7 +175,7 @@ dependencies {
157175
implementation(libs.androidx.appcompat)
158176
implementation(libs.androidx.browser)
159177
implementation(libs.androidx.webkit)
160-
implementation(libs.fragment.ktx)
178+
implementation(libs.androidx.fragment)
161179
implementation(libs.androidx.core.google.shortcuts)
162180
implementation(libs.androidx.preference.ktx)
163181
implementation(libs.xcrash.android.lib)
@@ -187,9 +205,9 @@ dependencies {
187205

188206
// Compose
189207
implementation(platform(libs.androidx.compose.bom))
190-
implementation(libs.androidx.compose.activity)
191-
implementation(libs.compose.ui)
192-
implementation(libs.androidx.compose.material)
208+
implementation(libs.compose.android.activity)
209+
implementation(libs.compose.android.ui)
210+
implementation(libs.compose.android.material)
193211
implementation(libs.androidx.navigation.compose)
194212
implementation(libs.compose.tv.material)
195213
implementation(libs.compose.tv.foundation)
@@ -245,7 +263,7 @@ dependencies {
245263
implementation(libs.kotlinx.serialization.protobuf)
246264

247265
// Debugging
248-
implementation(libs.androidx.compose.ui.tooling)
266+
implementation(libs.compose.android.ui.tooling)
249267
debugImplementation(libs.leakcanary.android)
250268
}
251269

@@ -264,15 +282,14 @@ fun String.toCamelCase(): String {
264282
}
265283

266284
fun formatKey(o: Setting, usedKeys: MutableSet<String>): String {
267-
var result = " public static final "
285+
var result = "\tpublic static final "
268286

269287
if(o.type == "select" && o.items != null) {
270-
val enumName = o.key!!.uppercase(Locale.ENGLISH).toCamelCase() + "_Values"
288+
val enumName = o.key!!.uppercase().toCamelCase() + "_Values"
271289

272-
result = "\n" + result
273-
result += "EnumSetting<$enumName> ${o.key.uppercase(Locale.ENGLISH)} = new EnumSetting<>(\"${o.key}\", $enumName.class);\n\n"
290+
result += "EnumSetting<$enumName> ${o.key.uppercase()} =\n\t\t\tnew EnumSetting<>(\"${o.key}\", $enumName.class);\n\n"
274291

275-
result += " public enum $enumName implements EnumWithKey {\n "
292+
result += "\tpublic enum $enumName implements EnumWithKey {\n\t\t"
276293

277294
val iterator = o.items.iterator()
278295

@@ -284,22 +301,22 @@ fun formatKey(o: Setting, usedKeys: MutableSet<String>): String {
284301
"\nYou have to remove one of them for app to work properly.")
285302
}
286303

287-
result += item.key!!.uppercase(Locale.ENGLISH) + "(\"${item.key}\")"
304+
result += item.key!!.uppercase() + "(\"${item.key}\")"
288305

289306
if(iterator.hasNext()) {
290-
result += ", "
307+
result += ",\n\t\t"
291308
}
292309
}
293310

294-
result += ";\n\n private final String key;\n\n ${enumName}(String key) {\n"
295-
result += " this.key = key;\n }\n\n @Override\n public String getKey() {\n"
296-
result += " return key;\n }\n }\n"
311+
result += ";\n\n\t\tprivate final String key;\n\n\t\t${enumName}(String key) {\n"
312+
result += "\t\t\tthis.key = key;\n\t\t}\n\n\t\t@Override\n\t\tpublic String getKey() {\n"
313+
result += "\t\t\treturn key;\n\t\t}\n\t}\n\n"
297314

298315
return result
299316
}
300317

301318
if(listOf("action", "select", "multiselect").contains(o.type)) {
302-
return result + "String ${o.key!!.uppercase(Locale.ENGLISH)} = \"${o.key}\";\n"
319+
return result + "String ${o.key!!.uppercase()} = \"${o.key}\";\n"
303320
}
304321

305322
when(o.type) {
@@ -308,7 +325,7 @@ fun formatKey(o: Setting, usedKeys: MutableSet<String>): String {
308325
"boolean", "screen_boolean" -> result += "Boolean"
309326
}
310327

311-
result += "Setting ${o.key!!.uppercase(Locale.ENGLISH)} = () -> \"${o.key}\";\n"
328+
result += "Setting ${o.key!!.uppercase()} = () -> \"${o.key}\";\n"
312329
return result
313330
}
314331

@@ -318,22 +335,20 @@ fun collectKeys(from: Setting, usedKeys: MutableSet<String>): String {
318335
"\nYou have to remove one of them for app to work properly.")
319336
}
320337

321-
val builder = StringBuilder()
322-
323-
when(from.type) {
324-
"screen" -> {
325-
if(from.items != null) {
326-
for(item in from.items) {
327-
builder.append(collectKeys(item, usedKeys))
338+
return buildString {
339+
when(from.type) {
340+
"screen" -> {
341+
if(from.items != null) {
342+
for(item in from.items) {
343+
append(collectKeys(item, usedKeys))
344+
}
328345
}
329346
}
330-
}
331347

332-
"string", "integer", "boolean", "action",
333-
"select", "select_integer", "multiselect" -> builder.append(formatKey(from, usedKeys))
348+
"string", "integer", "boolean", "action",
349+
"select", "select_integer", "multiselect" -> append(formatKey(from, usedKeys))
350+
}
334351
}
335-
336-
return builder.toString()
337352
}
338353

339354
data class Setting(val key: String?, val type: String?, val items: List<Setting>?)
@@ -343,20 +358,23 @@ fun generateSettingsClass(dir: File) {
343358
val settings = Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build().adapter<Setting>().fromJson(
344359
file("$projectDir/src/main/assets/settings.json").readText())!!
345360

346-
val builder = StringBuilder()
347-
.append("package com.mrboomdev.awery.generated;\n")
348-
.append("\n")
349-
.append("import com.mrboomdev.awery.app.data.settings.NicePreferences.*;\n")
350-
.append("\n")
351-
.append("/**\n")
352-
.append(" * Auto-generated class created during the compilation. Please, do not edit it.\n")
353-
.append(" * @author MrBoomDev\n")
354-
.append(" */\n")
355-
.append("public class AwerySettings {\n")
356-
.append(collectKeys(settings, HashSet()))
357-
.append("}")
358-
359-
File(dir, "AwerySettings.java").writeText(builder.toString())
361+
File(dir, "AwerySettings.java").writeText(buildString {
362+
append("package com.mrboomdev.awery.generated;\n")
363+
append("\n")
364+
append("import com.mrboomdev.awery.app.data.settings.NicePreferences.*;\n")
365+
append("import com.mrboomdev.awery.app.data.settings.NicePreferences;\n")
366+
append("import com.mrboomdev.awery.app.data.settings.SettingsItem;\n")
367+
append("\n")
368+
append("// Auto-generated class created during the compilation. Please, do not edit it.\n")
369+
append("public class AwerySettings {\n")
370+
371+
append("\tpublic static SettingsItem get(String key) {\n")
372+
append("\t\treturn NicePreferences.getSettingsMap().findItem(key);\n")
373+
append("\t}\n\n")
374+
375+
append(collectKeys(settings, HashSet()))
376+
append("}")
377+
})
360378
}
361379

362380
tasks.register("generateClasses") {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mrboomdev.awery
2+
3+
import com.mrboomdev.awery.R as RealR
4+
5+
object AweryDebug {
6+
@Suppress("ClassName")
7+
object R {
8+
object drawable {
9+
val sample_banner
10+
get() = RealR.drawable.sample_banner
11+
12+
val sample_poster
13+
get() = RealR.drawable.sample_poster
14+
}
15+
}
16+
}
697 KB
Loading
606 KB
Loading

app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070

7171
<intent-filter>
7272
<action android:name="android.intent.action.MAIN" />
73-
7473
<category android:name="android.intent.category.LAUNCHER" />
7574
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
7675
</intent-filter>
@@ -157,7 +156,20 @@
157156
<activity
158157
android:name=".ui.tv.TvMainActivity"
159158
android:windowSoftInputMode="adjustPan"
160-
android:exported="true" />
159+
android:exported="false" />
160+
161+
<activity
162+
android:name=".ui.tv.TvExperimentsActivity"
163+
android:label="Awery Experiments"
164+
android:windowSoftInputMode="adjustPan"
165+
android:exported="true"
166+
android:enabled="false">
167+
168+
<intent-filter>
169+
<action android:name="android.intent.action.MAIN" />
170+
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
171+
</intent-filter>
172+
</activity>
161173

162174
<activity
163175
android:name=".ui.mobile.screens.search.SearchActivity"
@@ -253,5 +265,6 @@
253265
</provider>
254266

255267
<receiver android:name=".sources.yomi.YomiManager$PackageManagerReceiver" />
268+
<receiver android:name=".ui.mobile.screens.player.PlayerPip$Receiver" />
256269
</application>
257270
</manifest>

app/src/main/assets/settings.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,32 +138,19 @@
138138
"key": "player_dim_screen", "type": "boolean", "boolean_value": true,
139139
"title": "dim_screen", "icon": "ic_brightness_medium_outlined",
140140
"description": "After clicking on the screen, black overlay will be shown on top of the video."
141-
}, {
142-
"type": "screen", "show_if": "never",
143-
"title": "subtitles", "icon": "ic_subtitles_filled",
144-
"items": [
145-
{
146-
"key": "subtitles_text_size", "type": "integer", "title": "subtitles_size",
147-
"from": 2, "to": 100, "integer_value": 14
148-
}, {
149-
"key": "subtitles_background_opacity", "type": "integer", "title": "subtitles_back_opacity",
150-
"from": 0, "to": 100, "integer_value": 85
151-
}
152-
]
153141
}, {
154142
"key": "player_system_subtitles", "type": "action",
155143
"title": "subtitles", "icon": "ic_subtitles_filled"
144+
}, {
145+
"key": "pip_on_background", "type": "boolean", "boolean_value": true,
146+
"icon": "ic_pip_outlined", "title": "Switch to Picture in Picture mode after minimizing"
156147
}
157148
]
158149
}, {
159150
"type": "screen", "show_if": "debug",
160151
"title": "reader", "icon": "ic_menu_book_filled",
161152
"items": [
162-
{
163-
"key": "bruh", "type": "action", "behaviour": "none",
164-
"title": "Sorry bro, but you currently can't read those chinese comics.",
165-
"description": "Come here later..."
166-
}
153+
167154
]
168155
}, {
169156
"type": "screen", "title": "storage", "icon": "ic_storage",
@@ -214,9 +201,6 @@
214201
}, {
215202
"key": "experiment_pip_controls", "title": "Picture in picture player controls",
216203
"type": "boolean", "boolean_value": false
217-
}, {
218-
"key": "experiment_media_play2", "title": "Use new MediaPlayFragment instead",
219-
"type": "boolean", "boolean_value": false
220204
}, {
221205
"key": "experiment_tv_compose", "title": "Launch TV activity on startup",
222206
"type": "boolean", "boolean_value": false

0 commit comments

Comments
 (0)