Skip to content

Commit

Permalink
Show all contributors from GitHub in settings,
Browse files Browse the repository at this point in the history
Fixed bug when you couldn't play any media,
Fixed browser crash,
File picker for browser,
Allow swiping down image preview to dismiss it,
Implement SafeArgs in most places,
Fixed pull request test build script,
A little refactor for ui elements,
Use icons instead of labels in the desktop toolbar,
Escape special characters in strings.xml
  • Loading branch information
MrBoomDeveloper committed Nov 9, 2024
1 parent 61d9f5e commit 225acb4
Show file tree
Hide file tree
Showing 92 changed files with 564 additions and 11,451 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build Modern Production APK
run: ./gradlew assembleProdModernRelease
- name: Build Production APK
run: ./gradlew assembleProdRelease
8 changes: 5 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import java.util.Locale
import com.squareup.moshi.Moshi
import com.squareup.moshi.adapter
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
alias(libs.plugins.android.application)
Expand Down Expand Up @@ -145,7 +146,7 @@ android {

kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf("-Xcontext-receivers", "-Xmulti-platform")
freeCompilerArgs = listOf("-Xcontext-receivers", "-Xmulti-platform", "-opt-in=kotlin.ExperimentalStdlibApi")
}
}

Expand Down Expand Up @@ -179,6 +180,7 @@ dependencies {
implementation(libs.glide.imageViewFactory)
implementation(libs.konfetti.xml)
implementation(libs.animatedBottomBar)
implementation(libs.hauler)
implementation(project(":ui"))

// Compose
Expand Down Expand Up @@ -210,8 +212,8 @@ dependencies {

// Image Loading
api(libs.glide)
implementation(libs.glide.annotations)
ksp(libs.glide.compiler)
implementation(libs.glide.annotations)
implementation(libs.glide)
implementation(libs.glide.okhttp3)

Expand All @@ -234,9 +236,9 @@ dependencies {

// Serialization
implementation(files("../libs/safe-args-next.aar"))
ksp(libs.moshi.kotlin.codegen)
implementation(libs.moshi)
implementation(libs.moshi.kotlin)
ksp(libs.moshi.kotlin.codegen)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.serialization.json.okio)
implementation(libs.kotlinx.serialization.protobuf)
Expand Down
35 changes: 16 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
tools:targetApi="tiramisu">

<activity
android:name=".ui.activity.SplashActivity"
android:name=".ui.mobile.screens.SplashActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:theme="@style/Theme.Awery.Splash"
android:exported="true">
Expand All @@ -77,7 +77,8 @@
</activity>

<activity
android:name=".ui.activity.IntentHandlerActivity"
android:name=".ui.mobile.screens.IntentHandlerActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:theme="@style/Theme.Awery.Splash"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
Expand Down Expand Up @@ -139,7 +140,7 @@
</activity>

<activity
android:name=".ui.activity.player.PlayerActivity"
android:name=".ui.mobile.screens.player.PlayerActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:supportsPictureInPicture="true"
android:launchMode="singleTask"
Expand All @@ -149,7 +150,7 @@
tools:ignore="DiscouragedApi" />

<activity
android:name=".ui.activity.MainActivity"
android:name=".ui.mobile.screens.catalog.MainActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

Expand All @@ -159,53 +160,54 @@
android:exported="true" />

<activity
android:name=".ui.activity.search.SearchActivity"
android:name=".ui.mobile.screens.search.SearchActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.search.MultiSearchActivity"
android:name=".ui.mobile.screens.search.MultiSearchActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.BrowserActivity"
android:name=".ui.mobile.screens.BrowserActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.LoginActivity"
android:name=".ui.mobile.screens.LoginActivity"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleInstance"
android:exported="false" />

<activity
android:name=".ui.activity.MediaActivity"
android:name=".ui.mobile.screens.media.MediaActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.settings.setup.SetupActivity"
android:name=".ui.mobile.screens.setup.SetupActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.GalleryActivity"
android:name=".ui.mobile.screens.GalleryActivity"
android:windowSoftInputMode="adjustPan"
android:theme="@style/Theme.Draggable"
android:exported="false" />

<activity
android:name=".ui.activity.settings.AboutActivity"
android:name=".ui.mobile.screens.settings.AboutActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true" />

<activity
android:name=".ui.activity.ReaderActivity"
android:name=".ui.mobile.screens.ReaderActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

<activity
android:name=".ui.activity.settings.SettingsActivity"
android:name=".ui.mobile.screens.settings.SettingsActivity"
android:windowSoftInputMode="adjustPan"
android:exported="false" />

Expand All @@ -217,11 +219,6 @@
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<service
android:name=".app.services.DownloadService"
android:foregroundServiceType="dataSync"
android:exported="false" />

<service
android:name=".app.services.BackupService"
android:foregroundServiceType="dataSync"
Expand Down
30 changes: 16 additions & 14 deletions app/src/main/java/com/mrboomdev/awery/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ import com.mrboomdev.awery.app.AweryLifecycle.Companion.anyContext
import com.mrboomdev.awery.app.AweryLifecycle.Companion.appContext
import com.mrboomdev.awery.app.AweryLifecycle.Companion.getAnyActivity
import com.mrboomdev.awery.app.AweryLifecycle.Companion.runOnUiThread
import com.mrboomdev.awery.app.ThemeManager.isDarkModeEnabled
import com.mrboomdev.awery.app.data.Constants
import com.mrboomdev.awery.app.data.db.AweryDB
import com.mrboomdev.awery.app.data.db.item.DBCatalogList
import com.mrboomdev.awery.app.data.settings.NicePreferences.getPrefs
import com.mrboomdev.awery.extensions.data.CatalogList
import com.mrboomdev.awery.generated.AwerySettings
import com.mrboomdev.awery.generated.AwerySettings.NavigationStyle_Values
import com.mrboomdev.awery.ui.activity.BrowserActivity
import com.mrboomdev.awery.ui.activity.settings.SettingsActivity
import com.mrboomdev.awery.ui.mobile.screens.BrowserActivity
import com.mrboomdev.awery.ui.mobile.screens.settings.SettingsActivity
import com.mrboomdev.awery.util.extensions.configuration
import com.mrboomdev.awery.util.extensions.startActivity
import com.mrboomdev.awery.util.ui.dialog.DialogBuilder
Expand Down Expand Up @@ -223,7 +224,6 @@ class App : Application() {
}

@JvmStatic
@Deprecated("")
fun getResourceId(type: Class<*>, res: String?): Int {
if(res == null) return 0

Expand All @@ -247,6 +247,10 @@ class App : Application() {
}
}

inline fun <reified T> getResourceId(res: String?): Int {
return getResourceId(T::class.java, res)
}

@JvmStatic
fun i18n(clazz: Class<*>, string: String?): String? {
val id = getResourceId(clazz, string)
Expand Down Expand Up @@ -398,19 +402,17 @@ class App : Application() {
return
}

val customTabsIntent = CustomTabsIntent.Builder()
.setColorScheme(
if(ThemeManager.isDarkModeEnabled()) CustomTabsIntent.COLOR_SCHEME_DARK
else CustomTabsIntent.COLOR_SCHEME_LIGHT).build()

customTabsIntent.intent.setData(Uri.parse(url))

val resolvedActivity = customTabsIntent.intent
.resolveActivity(context.packageManager)
val customTabsIntent = CustomTabsIntent.Builder().apply {
setColorScheme(
if(isDarkModeEnabled()) CustomTabsIntent.COLOR_SCHEME_DARK
else CustomTabsIntent.COLOR_SCHEME_LIGHT)
}.build().apply {
intent.data = Uri.parse(url)
}

if(resolvedActivity != null) {
customTabsIntent.intent.resolveActivity(context.packageManager)?.also {
context.startActivity(customTabsIntent.intent, customTabsIntent.startAnimationBundle)
} else {
} ?: run {
Log.e(TAG, "No external browser was found, launching a internal one.")
context.startActivity(BrowserActivity::class, BrowserActivity.Extras(url))
}
Expand Down
55 changes: 24 additions & 31 deletions app/src/main/java/com/mrboomdev/awery/app/AweryGlideModule.kt
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
package com.mrboomdev.awery.app;

import android.content.Context;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.AppGlideModule;
import com.mrboomdev.awery.util.io.HttpClient;

import java.io.InputStream;
package com.mrboomdev.awery.app

import android.content.Context
import com.bumptech.glide.Glide
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.Registry
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.module.AppGlideModule
import com.mrboomdev.awery.util.io.HttpClient.client
import java.io.InputStream

@GlideModule
public class AweryGlideModule extends AppGlideModule {

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
class AweryGlideModule : AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) {
super.applyOptions(context, builder)

var diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MiB
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "img", diskCacheSizeBytes));
val diskCacheSizeBytes = 1024 * 1024 * 100 // 100 MiB
builder.setDiskCache(InternalCacheDiskCacheFactory(context, "img", diskCacheSizeBytes.toLong()))
}

@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
registry.replace(
GlideUrl.class,
InputStream.class,
new OkHttpUrlLoader.Factory(HttpClient.getClient())
);
GlideUrl::class.java,
InputStream::class.java,
OkHttpUrlLoader.Factory(client)
)

super.registerComponents(context, glide, registry);
super.registerComponents(context, glide, registry)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ open class AweryLifecycle private constructor() : ActivityLifecycleCallbacks {
}

private var app: App? = null

@JvmStatic
var appContext: App
get() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/mrboomdev/awery/app/AweryLocales.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.LocaleManagerCompat
import androidx.core.os.LocaleListCompat
import com.mrboomdev.awery.R
import com.mrboomdev.awery.app.App.Companion.getResourceId
import com.mrboomdev.awery.util.Selection
import com.mrboomdev.awery.util.extensions.applyCopy
import com.mrboomdev.awery.util.extensions.getResourceId
import com.mrboomdev.awery.util.extensions.startActivity
import com.mrboomdev.awery.util.ui.dialog.SelectionDialog
import org.xmlpull.v1.XmlPullParser
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mrboomdev.awery.app.data.settings;

import com.mrboomdev.awery.ui.activity.settings.SettingsDataHandler;
import com.mrboomdev.awery.ui.mobile.screens.settings.SettingsDataHandler;
import com.mrboomdev.awery.util.Selection;

import kotlin.NotImplementedError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import androidx.annotation.NonNull;

import com.mrboomdev.awery.ui.activity.settings.SettingsDataHandler;
import com.mrboomdev.awery.ui.mobile.screens.settings.SettingsDataHandler;
import com.mrboomdev.awery.util.Parser;
import com.mrboomdev.awery.util.Selection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.mrboomdev.awery.extensions.support.yomi.aniyomi.AniyomiManager;
import com.mrboomdev.awery.extensions.support.yomi.tachiyomi.TachiyomiManager;
import com.mrboomdev.awery.generated.AwerySettings;
import com.mrboomdev.awery.ui.activity.settings.TabsSettings;
import com.mrboomdev.awery.ui.mobile.screens.settings.TabsSettings;
import com.mrboomdev.awery.util.Selection;
import com.mrboomdev.awery.util.async.AsyncFuture;
import com.mrboomdev.awery.util.exceptions.ZeroResultsException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.mrboomdev.awery.app.App.i18n;
import static com.mrboomdev.awery.app.AweryLifecycle.getAnyContext;
import static com.mrboomdev.awery.app.data.settings.NicePreferences.getPrefs;

import android.content.Context;
import android.graphics.drawable.Drawable;
Expand All @@ -14,8 +13,8 @@

import com.mrboomdev.awery.R;
import com.mrboomdev.awery.app.App;
import com.mrboomdev.awery.ui.activity.settings.SettingsActions;
import com.mrboomdev.awery.ui.activity.settings.SettingsDataHandler;
import com.mrboomdev.awery.ui.mobile.screens.settings.SettingsActions;
import com.mrboomdev.awery.ui.mobile.screens.settings.SettingsDataHandler;
import com.mrboomdev.awery.util.Parser;
import com.mrboomdev.awery.util.Selection;
import com.squareup.moshi.Json;
Expand Down Expand Up @@ -246,10 +245,6 @@ public <T> T parseJsonValue(Class<T> clazz) throws IOException {
return Parser.fromString(clazz, getStringValue());
}

public <T> T parseJsonValue(Parser.Adapter<T> adapter) throws IOException {
return Parser.fromString(adapter, getStringValue());
}

/**
* Call before showing any data to a user
* @author MrBoomDev
Expand Down
Loading

0 comments on commit 225acb4

Please sign in to comment.