Skip to content

Commit 5c4ad8e

Browse files
Added ExpandableText.kt,
You've reached end text is now bigger, Added bigger gap at the end of the feed, MediaRoute.kt now shows an poster and item description, Fixed SettingsScreen.kt gap before an header, Don't load adult yomi sources if adult mode is disabled Signed-off-by: MrBoom <[email protected]>
1 parent b8e6044 commit 5c4ad8e

File tree

25 files changed

+961
-101
lines changed

25 files changed

+961
-101
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.mrboomdev.awery.ext.util.exceptions
22

3-
import com.mrboomdev.awery.ext.util.LocaleAware
4-
53
class ExtensionInstallException(
64
message: String? = null,
75
cause: Throwable? = null,
8-
val userReadableMessage: String? = null
9-
) : Exception(message, cause), LocaleAware {
10-
override fun getLocalizedMessage() = userReadableMessage ?: message
6+
val reason: Int
7+
) : Exception(message, cause) {
8+
companion object {
9+
const val REASON_OTHER = 0
10+
const val REASON_UNSUPPORTED = 1
11+
const val REASON_LOW_STORAGE = 2
12+
const val REASON_NSFW_BLOCKED = 3
13+
const val REASON_INVALID = 4
14+
}
1115
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.mrboomdev.awery.ext.util.exceptions
22

3-
import com.mrboomdev.awery.ext.util.LocaleAware
4-
53
class ExtensionLoadException(
64
message: String? = null,
75
cause: Throwable? = null,
8-
val userReadableMessage: String? = null
9-
) : Exception(message, cause), LocaleAware {
10-
override fun getLocalizedMessage() = userReadableMessage ?: message
6+
val reason: Int
7+
) : Exception(message, cause) {
8+
companion object {
9+
const val REASON_OTHER = 0
10+
const val REASON_NSFW_BLOCKED = 1
11+
const val REASON_INVALID = 2
12+
}
1113
}

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ adaptive-navigation = { module = "androidx.compose.material3.adaptive:adaptive-n
3838
# Coil
3939
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" }
4040
coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coil" }
41+
coil-gif = { module = "io.coil-kt.coil3:coil-gif", version.ref = "coil" }
42+
coil-svg = { module = "io.coil-kt.coil3:coil-svg", version.ref = "coil" }
43+
coil-video = { module = "io.coil-kt.coil3:coil-video", version.ref = "coil" }
4144

4245
# Compose
4346
compose-bom = { module = "androidx.compose:compose-bom", version = "2025.03.00" }
@@ -94,6 +97,8 @@ okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version = "4.12
9497
okhttp-dnsoverhttps = { module = "com.squareup.okhttp3:okhttp-dnsoverhttps", version.ref = "okhttp" }
9598

9699
[bundles]
100+
coil = ["coil-compose", "coil-gif", "coil-svg", "coil-video", "coil-network-okhttp"]
101+
97102
okhttp = ["okhttp", "okhttp-brotli", "okhttp-dnsoverhttps", "okhttp-logging"]
98103

99104
exoplayer = ["media3-exoplayer", "media3-exoplayer-dash", "media3-exoplayer-hls",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="48dp"
3+
android:height="48dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="#ffffff"
9+
android:pathData="M205,829L205,118.16L755,118.16L755,829L480,711.16L205,829Z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="48dp"
3+
android:height="48dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="#ffffff"
9+
android:pathData="M326,740.61L326,214.93L740.07,477.77L326,740.61Z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="48dp"
3+
android:height="48dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="#ffffff"
9+
android:pathData="M728.21,879Q680.96,879 647.75,846.1Q614.54,813.21 614.54,766.22Q614.54,759.27 616.04,749.82Q617.54,740.36 620.92,732.9L314.75,554.54Q299.23,571.92 277.62,581.73Q256.02,591.54 233.54,591.54Q186.9,591.54 153.45,558.68Q120,525.83 120,478.9Q120,431.96 153.45,399.21Q186.9,366.46 233.54,366.46Q255.94,366.46 277.47,375.15Q299,383.85 314.46,401.23L620.92,224.4Q617.54,217.08 616.04,208.15Q614.54,199.22 614.54,191.54Q614.54,144.65 647.62,111.82Q680.69,79 727.95,79Q774.11,79 807.36,111.83Q840.61,144.66 840.61,191.55Q840.61,238.96 807.17,271.52Q773.72,304.08 727.08,304.08Q703.24,304.08 682.81,296.5Q662.39,288.92 646.48,271.54L340.69,444.21Q343.08,451.95 344.58,461.85Q346.08,471.76 346.08,479.16Q346.08,486.57 344.58,494.58Q343.08,502.59 340.69,510.33L646.48,685.46Q662.39,670.69 682.31,662.31Q702.23,653.92 727.08,653.92Q773.72,653.92 807.17,686.49Q840.61,719.07 840.61,766.28Q840.61,813.5 807.5,846.25Q774.38,879 728.21,879Z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="#ffffff"
9+
android:pathData="M160,800v-80h110l-16,-14q-52,-46 -73,-105t-21,-119q0,-111 66.5,-197.5T400,170v84q-72,26 -116,88.5T240,482q0,45 17,87.5t53,78.5l10,10v-98h80v240L160,800ZM560,790v-84q72,-26 116,-88.5T720,478q0,-45 -17,-87.5T650,312l-10,-10v98h-80v-240h240v80L690,240l16,14q49,49 71.5,106.5T800,478q0,111 -66.5,197.5T560,790Z"/>
10+
</vector>

shared/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ kotlin {
109109

110110
// Components
111111
implementation(libs.compose.material3)
112-
implementation(libs.coil.compose)
113-
implementation(libs.coil.network.okhttp)
112+
implementation(libs.bundles.coil)
114113
api(libs.sonner)
115114
}
116115
}

shared/src/androidMain/kotlin/com/mrboomdev/awery/platform/Platform.android.kt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.content.Intent
1010
import android.content.SharedPreferences
1111
import android.content.pm.PackageManager
1212
import android.content.res.Configuration
13+
import android.net.Uri
1314
import android.os.Build
1415
import android.os.Handler
1516
import android.os.Looper
@@ -18,7 +19,15 @@ import android.os.StrictMode.ThreadPolicy
1819
import android.os.StrictMode.VmPolicy
1920
import android.util.Log
2021
import android.widget.Toast
22+
import androidx.core.app.ShareCompat.IntentBuilder
2123
import androidx.core.content.getSystemService
24+
import coil3.ImageLoader
25+
import coil3.SingletonImageLoader
26+
import coil3.gif.AnimatedImageDecoder
27+
import coil3.gif.GifDecoder
28+
import coil3.request.crossfade
29+
import coil3.svg.SvgDecoder
30+
import coil3.video.VideoFrameDecoder
2231
import com.google.android.material.color.DynamicColors
2332
import com.mrboomdev.awery.shared.BuildConfig
2433
import com.mrboomdev.awery.utils.SerializableRequired
@@ -33,6 +42,7 @@ private const val TAG = "Platform.android"
3342

3443
actual object Platform: ContextWrapper(null) {
3544
actual val NAME = "Android ${Build.VERSION.RELEASE}"
45+
actual val SUPPORTS_SHARE = true
3646

3747
val MIUI by lazy {
3848
getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false // MIUI
@@ -112,6 +122,25 @@ actual object Platform: ContextWrapper(null) {
112122
super.attachBaseContext(base)
113123
}
114124

125+
actual fun openUrl(string: String) {
126+
startActivity(Intent().apply {
127+
action = Intent.ACTION_VIEW
128+
data = Uri.parse(string)
129+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
130+
})
131+
}
132+
133+
actual fun share(string: String) {
134+
IntentBuilder(this)
135+
.setType("text/plain")
136+
.setText(string)
137+
.createChooserIntent()
138+
.apply {
139+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
140+
startActivity(this)
141+
}
142+
}
143+
115144
/**
116145
* @return true if an system popup just appeared or false otherwise.
117146
*/
@@ -151,5 +180,21 @@ actual object Platform: ContextWrapper(null) {
151180
// A lot of extensions do violate StrictMode, so we simply disable it.
152181
StrictMode.setThreadPolicy(ThreadPolicy.LAX)
153182
StrictMode.setVmPolicy(VmPolicy.LAX)
183+
184+
SingletonImageLoader.setSafe {
185+
ImageLoader.Builder(it)
186+
.components {
187+
add(if(Build.VERSION.SDK_INT >= 28) {
188+
AnimatedImageDecoder.Factory()
189+
} else {
190+
GifDecoder.Factory()
191+
})
192+
193+
add(SvgDecoder.Factory())
194+
add(VideoFrameDecoder.Factory())
195+
}
196+
.crossfade(true)
197+
.build()
198+
}
154199
}
155200
}

shared/src/androidMain/kotlin/com/mrboomdev/awery/sources/yomi/YomiManager.kt

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import com.mrboomdev.awery.ext.util.Image
1717
import com.mrboomdev.awery.ext.util.PendingTask
1818
import com.mrboomdev.awery.ext.util.Progress
1919
import com.mrboomdev.awery.ext.util.exceptions.ExtensionInstallException
20+
import com.mrboomdev.awery.ext.util.exceptions.ExtensionLoadException
21+
import com.mrboomdev.awery.generated.*
2022
import com.mrboomdev.awery.platform.Platform
2123
import com.mrboomdev.awery.platform.Platform.toast
2224
import com.mrboomdev.awery.platform.PlatformImage
@@ -143,6 +145,17 @@ abstract class YomiManager<S>(
143145
val packageInfo = Platform.packageManager.getPackageInfo(
144146
packageName, PackageManager.GET_CONFIGURATIONS or PackageManager.GET_META_DATA
145147
)
148+
149+
val isNsfw = packageInfo.applicationInfo!!.metaData.getInt(nsfwMeta, 0) == 1
150+
151+
if(isNsfw && init && AwerySettings.ADULT_MODE.value.let {
152+
it != AwerySettings.AdultModeValue.ENABLED && it != AwerySettings.AdultModeValue.ONLY
153+
}) { // Adult content is disabled, so we may just skip this source load
154+
throw ExtensionLoadException(
155+
message = "Nsfw is blocked, source load skipped.",
156+
reason = ExtensionLoadException.REASON_NSFW_BLOCKED
157+
)
158+
}
146159

147160
val sources = if(!init) null else try {
148161
checkSupportedVersionBounds(packageInfo.versionName!!)
@@ -153,7 +166,7 @@ abstract class YomiManager<S>(
153166
}
154167

155168
return createSourceWrapper(
156-
isNsfw = packageInfo.applicationInfo!!.metaData.getInt(nsfwMeta, 0) == 1,
169+
isNsfw = isNsfw,
157170
packageInfo = packageInfo,
158171
sources = sources,
159172
exception = t,
@@ -275,31 +288,42 @@ abstract class YomiManager<S>(
275288
}
276289

277290
PackageInstaller.STATUS_FAILURE_BLOCKED -> result = ExtensionInstallException(
278-
"The install has been blocked by your device!", IllegalStateException(message)
291+
"The install has been blocked by your device!", IllegalStateException(message), 0
279292
)
280293

281294
PackageInstaller.STATUS_FAILURE_CONFLICT -> result = ExtensionInstallException(
282-
"An conflict has occurred while trying to install!", IllegalStateException(message)
295+
"An conflict has occurred while trying to install!", IllegalStateException(message), 0
283296
)
284297

285298
PackageInstaller.STATUS_FAILURE_INCOMPATIBLE -> result = ExtensionInstallException(
286-
"Sorry, but your device isn't compatible with this extension!", IllegalStateException(message)
299+
message = "Sorry, but your device isn't compatible with this extension!",
300+
cause = IllegalStateException(message),
301+
reason = ExtensionInstallException.REASON_UNSUPPORTED
287302
)
288303

289304
PackageInstaller.STATUS_FAILURE_INVALID -> result = ExtensionInstallException(
290-
"Extension file appears to be invalid!", IllegalStateException(message)
305+
message = "Extension file appears to be invalid!",
306+
cause = IllegalStateException(message),
307+
reason = ExtensionInstallException.REASON_INVALID
291308
)
292309

293310
PackageInstaller.STATUS_FAILURE_STORAGE -> result = ExtensionInstallException(
294-
"You don't have enough space!", IllegalStateException(message)
311+
message = "You don't have enough space!",
312+
cause = IllegalStateException(message),
313+
reason = ExtensionInstallException.REASON_LOW_STORAGE
295314
)
296315

297316
PackageInstaller.STATUS_FAILURE_TIMEOUT -> result = ExtensionInstallException(
298-
"Your device just got tired and cancelled an install!", IllegalStateException(message)
317+
"Your device just got tired and cancelled an install!", IllegalStateException(message), 0
299318
)
300319

301320
PackageInstaller.STATUS_FAILURE_ABORTED -> result = CancellationException()
302-
else -> result = ExtensionInstallException("Failed to install an extension!", IllegalStateException(message))
321+
322+
else -> result = ExtensionInstallException(
323+
message = "Failed to install an extension!",
324+
cause = IllegalStateException(message),
325+
reason = ExtensionInstallException.REASON_OTHER
326+
)
303327
}
304328
}
305329

0 commit comments

Comments
 (0)