Skip to content

Commit e0af127

Browse files
Fixed crash during backups,
Continue splash screen loading only after all dialogs were closed, Fixed library, Fixed broken database insertions, Experimental settings to try out not finished stuff, Fixed media poster not being clickable, You can now enable tv version in experiments, Create experiments shortcut to be able disable them at any time, Better toolbar on desktop
1 parent 6f589d6 commit e0af127

File tree

28 files changed

+449
-163
lines changed

28 files changed

+449
-163
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ dependencies {
158158
implementation(libs.androidx.browser)
159159
implementation(libs.androidx.webkit)
160160
implementation(libs.fragment.ktx)
161+
implementation(libs.androidx.core.google.shortcuts)
161162
implementation(libs.androidx.preference.ktx)
162163
implementation(libs.xcrash.android.lib)
163164
implementation(libs.deprecated.android.retrostreams)

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@
211211
android:windowSoftInputMode="adjustPan"
212212
android:exported="false" />
213213

214+
<activity
215+
android:name=".ui.mobile.screens.settings.SettingsActivity2"
216+
android:windowSoftInputMode="adjustPan"
217+
android:exported="false" />
218+
214219
<property
215220
android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED"
216221
android:value="true" />

app/src/main/assets/settings.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,33 @@
204204
{ "key": "check_app_update", "type": "action", "title": "Check app update" },
205205

206206
{ "type": "category", "title": "Developers" },
207+
208+
{
209+
"key": "experiments", "type": "screen", "title": "Experiments",
210+
"icon": "ic_experiment_outlined", "items": [
211+
{
212+
"key": "experiment_splash_load_sources", "title": "experiment_splash_load_sources",
213+
"type": "boolean", "boolean_value": false
214+
}, {
215+
"key": "experiment_pip_controls", "title": "experiment_pip_controls",
216+
"type": "boolean", "boolean_value": false
217+
}, {
218+
"key": "experiment_media_play2", "title": "experiment_media_play2",
219+
"type": "boolean", "boolean_value": false
220+
}, {
221+
"key": "experiment_tv_compose", "title": "experiment_tv_compose",
222+
"type": "boolean", "boolean_value": false
223+
}, {
224+
"key": "experiment_settings2", "title": "experiment_settings2",
225+
"type": "boolean", "boolean_value": false
226+
}
227+
]
228+
},
229+
207230
{ "key": "log_network", "type": "boolean", "restart": true, "title": "Verbose network logging" },
208231
{ "key": "start_onboarding", "type": "action", "title": "Start onboarding" },
209232

210-
{ "type": "category", "title": "These buttons are supposed to crash the app. Don't report them!" },
233+
{ "type": "category", "title": "These buttons are supposed to crash the app. Don't report them!" },
211234
{ "key": "try_crash_native", "type": "action", "title": "Throw Native Exception" },
212235
{ "key": "try_crash_native_async", "type": "action", "title": "Throw Async Native Exception" },
213236
{ "key": "try_crash_java", "type": "action", "title": "Throw Java Exception" },

app/src/main/java/com/mrboomdev/awery/app/CrashHandler.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package com.mrboomdev.awery.app
33
import android.content.Context
44
import android.content.Intent
55
import android.util.Log
6-
import android.view.View
76
import android.widget.Toast
87
import androidx.annotation.StringRes
98
import androidx.appcompat.app.AppCompatActivity
10-
import androidx.appcompat.widget.LinearLayoutCompat
119
import androidx.core.content.FileProvider
12-
import androidx.core.view.setMargins
1310
import androidx.core.view.setPadding
1411
import androidx.core.widget.NestedScrollView
1512
import com.google.android.material.bottomsheet.BottomSheetDialog
@@ -28,7 +25,6 @@ import com.mrboomdev.awery.util.exceptions.OkiThrowableMessage
2825
import com.mrboomdev.awery.util.extensions.activity
2926
import com.mrboomdev.awery.util.extensions.dpPx
3027
import com.mrboomdev.awery.util.extensions.fixAndShow
31-
import com.mrboomdev.awery.util.extensions.setMargin
3228
import com.mrboomdev.awery.util.ui.dialog.DialogBuilder
3329
import xcrash.Errno
3430
import xcrash.XCrash
@@ -149,10 +145,10 @@ object CrashHandler {
149145
title = if(files.size == 1) null else "Awery crash report #${index + 1}",
150146
messagePrefixRes = R.string.please_report_bug_app,
151147
file = file,
152-
dismissCallback = {
148+
dismissCallback = if(index == 0) {{
153149
crashLogsDirectory.delete()
154150
continuationCallback()
155-
}
151+
}} else {{}}
156152
)
157153
}
158154
}

app/src/main/java/com/mrboomdev/awery/app/data/db/item/DBCatalogMedia.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static com.mrboomdev.awery.util.NiceUtils.uniqueStringToList;
77

88
import androidx.annotation.NonNull;
9+
import androidx.annotation.Nullable;
910
import androidx.room.ColumnInfo;
1011
import androidx.room.Entity;
1112
import androidx.room.PrimaryKey;
@@ -35,29 +36,37 @@ public class DBCatalogMedia {
3536
@ColumnInfo(name = "global_id")
3637
@NonNull
3738
public String globalId;
38-
39-
public String titles, description, ids, url;
40-
public String banner, extra, country, authors;
41-
public String duration, type;
39+
@Nullable
40+
public String titles, description, ids, url, banner, extra, country, authors, duration, type;
4241
@ColumnInfo(name = "release_date")
42+
@Nullable
4343
public String releaseDate;
4444
@ColumnInfo(name = "episodes_count")
45+
@Nullable
4546
public String episodesCount;
4647
@ColumnInfo(name = "average_score")
48+
@Nullable
4749
public String averageScore;
50+
@Nullable
4851
public String tags, genres;
52+
@Nullable
4953
public String status;
5054
@ColumnInfo(name = "poster_extra_large")
55+
@Nullable
5156
public String poster;
5257
@ColumnInfo(name = "poster_large")
5358
@Deprecated(forRemoval = true)
59+
@Nullable
5460
public String __DEPRECATED_largePoster;
5561
@ColumnInfo(name = "poster_medium")
5662
@Deprecated(forRemoval = true)
63+
@Nullable
5764
public String __DEPRECATED_mediumPoster;
5865
@ColumnInfo(name = "latest_episode")
66+
@Nullable
5967
public String latestEpisode;
6068
@ColumnInfo(name = "age_rating")
69+
@Nullable
6170
public String ageRating;
6271

6372
public DBCatalogMedia(@NonNull String globalId) {
@@ -152,11 +161,11 @@ public CatalogMedia toCatalogMedia() {
152161
averageScore != null ? Float.parseFloat(averageScore) : null,
153162
parseEnum(status, CatalogMedia.Status.class),
154163

155-
tags != null ? (CatalogTag[]) stream(uniqueStringToList(tags))
156-
.map(CatalogTag::new).toArray() : null,
164+
tags != null ? stream(uniqueStringToList(tags))
165+
.map(CatalogTag::new).toArray(CatalogTag[]::new) : null,
157166

158-
genres == null ? null : (String[]) uniqueStringToList(genres).toArray(),
159-
titles == null ? null : (String[]) uniqueStringToList(titles).toArray(),
167+
genres == null ? null : stream(uniqueStringToList(genres)).toArray(String[]::new),
168+
titles == null ? null : stream(uniqueStringToList(titles)).toArray(String[]::new),
160169
authors == null ? null : ParserAdapter.mapFromString(authors),
161170
ids == null ? null : ParserAdapter.mapFromString(ids));
162171
}

app/src/main/java/com/mrboomdev/awery/app/services/BackupService.kt

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mrboomdev.awery.app.services
22

3+
import android.app.Service
34
import android.content.Intent
45
import android.net.Uri
56
import android.os.IBinder
@@ -10,6 +11,7 @@ import com.mrboomdev.awery.app.App.Companion.toast
1011
import com.mrboomdev.awery.app.AweryLifecycle.Companion.restartApp
1112
import com.mrboomdev.awery.app.AweryLifecycle.Companion.runOnUiThread
1213
import com.mrboomdev.awery.app.CrashHandler
14+
import com.mrboomdev.awery.util.FileType
1315
import com.mrboomdev.awery.util.io.unzipFiles
1416
import com.mrboomdev.awery.util.io.zipFiles
1517
import com.mrboomdev.safeargsnext.owner.SafeArgsService
@@ -23,24 +25,27 @@ private const val TAG = "BackupService"
2325
private val BACKUP_DIRECTORIES = arrayOf("shared_prefs", "databases")
2426

2527
class BackupService : SafeArgsService<BackupService.Args>() {
26-
class Args(val action: Action, val targetUri: Uri)
28+
class Args(val action: Action, val targetUri: Uri, val fileType: FileType = FileType.AWERY_BACKUP)
2729

2830
enum class Action {
2931
BACKUP, RESTORE
3032
}
3133

3234
override fun onStartCommand(args: Args?, flags: Int, startId: Int): Int {
33-
if(args == null) throw NullPointerException("Arguments are required!")
35+
if(args == null) {
36+
stopSelf()
37+
return START_NOT_STICKY
38+
}
3439

3540
when(args.action) {
36-
Action.BACKUP -> startBackup(args.targetUri)
37-
Action.RESTORE -> startRestore(args.targetUri)
41+
Action.BACKUP -> startBackup(args.targetUri, args.fileType)
42+
Action.RESTORE -> startRestore(args.targetUri, args.fileType)
3843
}
3944

4045
return super.onStartCommand(args, flags, startId)
4146
}
4247

43-
private fun startBackup(into: Uri) {
48+
private fun startBackup(into: Uri, fileType: FileType) {
4449
val popup = showLoadingWindow()
4550

4651
CoroutineScope(Dispatchers.IO + CoroutineExceptionHandler { _, t ->
@@ -51,23 +56,29 @@ class BackupService : SafeArgsService<BackupService.Args>() {
5156
stopSelf()
5257
}
5358
}).launch {
54-
zipFiles(HashMap<String, File>().apply {
55-
for(dir in BACKUP_DIRECTORIES) {
56-
val list = File(dataDir, dir).listFiles() ?: continue
59+
when(fileType) {
60+
FileType.AWERY_BACKUP -> {
61+
zipFiles(HashMap<String, File>().apply {
62+
for(dir in BACKUP_DIRECTORIES) {
63+
val list = File(dataDir, dir).listFiles() ?: continue
5764

58-
for(file in list) {
59-
this[dir + "/" + file.name] = file
60-
}
65+
for(file in list) {
66+
this[dir + "/" + file.name] = file
67+
}
68+
}
69+
}, into)
6170
}
62-
}, into)
71+
72+
else -> TODO("Unsupported backup type: $fileType")
73+
}
6374

6475
toast(R.string.backup_success)
6576
runOnUiThread { popup.dismiss() }
6677
stopSelf()
6778
}
6879
}
6980

70-
private fun startRestore(uri: Uri) {
81+
private fun startRestore(uri: Uri, fileType: FileType) {
7182
val window = showLoadingWindow()
7283

7384
CoroutineScope(Dispatchers.IO + CoroutineExceptionHandler { _, t ->
@@ -82,7 +93,11 @@ class BackupService : SafeArgsService<BackupService.Args>() {
8293
File(dataDir, dir).deleteRecursively()
8394
}
8495

85-
unzipFiles(uri, dataDir)
96+
when(fileType) {
97+
FileType.AWERY_BACKUP -> unzipFiles(uri, dataDir)
98+
else -> TODO("Unsupported restore type: $fileType")
99+
}
100+
86101
toast(R.string.restore_success)
87102
restartApp()
88103
stopSelf()

app/src/main/java/com/mrboomdev/awery/extensions/ExtensionsFactory.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,7 @@ private ExtensionsFactory(@NonNull Application context) {
7171

7272
managers.add(new AniyomiManager());
7373
managers.add(new InternalManager());
74-
75-
//managers.add(new TachiyomiManager()); // We doesn't support manga reading at the moment so we can just disable it for now
76-
77-
/*List.of(
78-
,
79-
//
80-
//new CloudstreamManager(),
81-
//new MiruManager(),
82-
//new JsManager(), //J s extensions were a bad decision
83-
);*/
74+
managers.add(new InternalManager());
8475

8576
for(var manager : managers) {
8677
manager.loadAllExtensions(context);

app/src/main/java/com/mrboomdev/awery/extensions/support/internal/InternalManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mrboomdev.awery.extensions.support.internal;
22

3+
import static com.mrboomdev.awery.util.NiceUtils.stream;
4+
35
import androidx.annotation.NonNull;
46

57
import com.mrboomdev.awery.extensions.Extension;
@@ -14,15 +16,15 @@ public class InternalManager extends ExtensionsManager {
1416

1517
@NonNull
1618
private Extension createExtension(@NonNull InternalProviders.InternalProvider provider) {
17-
var extension = new Extension(provider.getName(), provider.getId(), "1.0.0", null);
19+
var extension = new Extension(provider.getId(), provider.getName(), "1.0.0", null);
1820
extension.addProvider(provider);
1921
provider.setup(this, extension);
2022
return extension;
2123
}
2224

2325
@Override
2426
public Extension getExtension(String id) {
25-
return null;
27+
return stream(extensions).filter(it -> id.equals(it.getId())).findAny().orElseThrow();
2628
}
2729

2830
@Override
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mrboomdev.awery.ui.mobile
2+
3+
import androidx.compose.material.MaterialTheme
4+
import androidx.compose.material.darkColors
5+
import androidx.compose.material.lightColors
6+
import androidx.compose.runtime.Composable
7+
import com.mrboomdev.awery.app.ThemeManager
8+
9+
@Composable
10+
fun AweryTheme(content: @Composable () -> Unit) {
11+
MaterialTheme(
12+
colors = if(ThemeManager.isDarkModeEnabled()) darkColors() else lightColors()
13+
) {
14+
content()
15+
}
16+
}

0 commit comments

Comments
 (0)