Skip to content

Commit

Permalink
feat: allow partial urls
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Jan 2, 2025
1 parent 116de63 commit 38d68a7
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 461 deletions.
1 change: 0 additions & 1 deletion app/src/google/java/ani/dantotsu/others/AppUpdater.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import ani.dantotsu.util.Logger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.time.delay
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonArray
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,10 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Support both schemes -->
<data android:scheme="tachiyomi"/>
<data android:host="add-repo"/>
<data android:scheme="tachiyomi"/>
<data android:scheme="aniyomi"/>
<data android:host="add-repo"/>
<data android:scheme="novelyomi"/>
</intent-filter>
</activity>
<activity
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/java/ani/dantotsu/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,20 @@ class MainActivity : AppCompatActivity() {
if (uri == null) {
throw Exception("Uri is null")
}
if ((uri.scheme == "tachiyomi" || uri.scheme == "aniyomi") && uri.host == "add-repo") {
if ((uri.scheme == "tachiyomi" || uri.scheme == "aniyomi" || uri.scheme == "novelyomi") && uri.host == "add-repo") {
val url = uri.getQueryParameter("url") ?: throw Exception("No url for repo import")
val prefName = if (uri.scheme == "tachiyomi") {
PrefName.MangaExtensionRepos
} else {
PrefName.AnimeExtensionRepos
val (prefName, name) = when (uri.scheme) {
"tachiyomi" -> PrefName.MangaExtensionRepos to "Manga"
"aniyomi" -> PrefName.AnimeExtensionRepos to "Anime"
"novelyomi" -> PrefName.NovelExtensionRepos to "Novel"
else -> throw Exception("Invalid scheme")
}
val savedRepos: Set<String> = PrefManager.getVal(prefName)
val newRepos = savedRepos.toMutableSet()
AddRepositoryBottomSheet.addRepoWarning(this) {
newRepos.add(url)
PrefManager.setVal(prefName, newRepos)
toast("${if (uri.scheme == "tachiyomi") "Manga" else "Anime"} Extension Repo added")
toast("$name Extension Repo added")
}
return
}
Expand All @@ -488,9 +489,9 @@ class MainActivity : AppCompatActivity() {
return@passwordAlertDialog
}
if (PreferencePackager.unpack(decryptedJson)) {
val intent = Intent(this, this.javaClass)
val newIntent = Intent(this, this.javaClass)
this.finish()
startActivity(intent)
startActivity(newIntent)
}
} else {
toast("Password cannot be empty")
Expand All @@ -499,9 +500,9 @@ class MainActivity : AppCompatActivity() {
} else if (name.endsWith(".ani")) {
val decryptedJson = jsonString.toString(Charsets.UTF_8)
if (PreferencePackager.unpack(decryptedJson)) {
val intent = Intent(this, this.javaClass)
val newIntent = Intent(this, this.javaClass)
this.finish()
startActivity(intent)
startActivity(newIntent)
}
} else {
toast("Invalid file type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sealed class NovelExtension {
override val pkgName: String,
override val versionName: String,
override val versionCode: Long,
var repository: String,
val sources: List<AvailableNovelSources>,
val iconUrl: String,
) : NovelExtension()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ani.dantotsu.media.MediaType
import ani.dantotsu.snackString
import ani.dantotsu.util.Logger
import eu.kanade.tachiyomi.extension.InstallStep
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
Expand All @@ -22,7 +23,7 @@ class NovelExtensionManager(private val context: Context) {
/**
* API where all the available Novel extensions can be found.
*/
private val api = NovelExtensionGithubApi()
private val api = ExtensionGithubApi()

/**
* The installer which installs, updates and uninstalls the Novel extensions.
Expand Down Expand Up @@ -70,7 +71,7 @@ class NovelExtensionManager(private val context: Context) {
*/
suspend fun findAvailableExtensions() {
val extensions: List<NovelExtension.Available> = try {
api.findExtensions()
api.findNovelExtensions()
} catch (e: Exception) {
Logger.log("Error finding extensions: ${e.message}")
withUIContext { snackString("Failed to get Novel extensions list") }
Expand Down Expand Up @@ -119,7 +120,7 @@ class NovelExtensionManager(private val context: Context) {
* @param extension The anime extension to be installed.
*/
fun installExtension(extension: NovelExtension.Available): Observable<InstallStep> {
return installer.downloadAndInstall(api.getApkUrl(extension), extension.pkgName,
return installer.downloadAndInstall(api.getNovelApkUrl(extension), extension.pkgName,
extension.name, MediaType.NOVEL)
}

Expand Down
Loading

0 comments on commit 38d68a7

Please sign in to comment.