forked from WeslleieCah/tachiyomi-extensions-1.x
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 51f9bcd
Showing
82 changed files
with
1,482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/* | ||
!/.idea/codeStyleSettings.xml | ||
!/.idea/inspectionProfiles/ | ||
!/.idea/fileTemplates/ | ||
.DS_Store | ||
build | ||
/captures | ||
.externalNativeBuild | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:3.3.0-rc03" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
mavenCentral() | ||
maven { url "https://dl.bintray.com/inorichi/maven" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.gradle/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object Config { | ||
const val compileSdk = 28 | ||
const val minSdk = 21 | ||
const val targetSdk = 28 | ||
const val versionName = "1.0" | ||
const val versionCode = 1 | ||
const val applicationId = "tachiyomi.app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import org.gradle.api.artifacts.ProjectDependency | ||
import org.gradle.api.artifacts.dsl.DependencyHandler | ||
import org.gradle.kotlin.dsl.DependencyHandlerScope | ||
import org.gradle.kotlin.dsl.project | ||
|
||
object Deps { | ||
|
||
object kotlin { | ||
const val version = "1.3.11" | ||
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$version" | ||
} | ||
|
||
object coroutines { | ||
private const val version = "1.0.1" | ||
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version" | ||
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version" | ||
const val rx2 = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$version" | ||
} | ||
|
||
const val autoservice = "com.google.auto.service:auto-service:1.0-rc4" | ||
|
||
const val kotlinpoet = "com.squareup:kotlinpoet:1.0.0" | ||
|
||
const val tachiyomiCore = "tachiyomi.sourceapi:core:1.0" | ||
const val sourceApi = "tachiyomi.sourceapi:source-api:1.0" | ||
|
||
const val okhttp = "com.squareup.okhttp3:okhttp:3.12.0" | ||
const val jsoup = "org.jsoup:jsoup:1.11.3" | ||
const val gson = "com.google.code.gson:gson:2.8.5" | ||
const val kotson = "com.github.salomonbrys.kotson:kotson:2.5.0" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.extra | ||
import java.security.MessageDigest | ||
|
||
data class Extension( | ||
val name: String, | ||
val versionCode: Int, | ||
val libVersion: String, | ||
val lang: String, | ||
val deepLinks: List<DeepLink> = emptyList(), | ||
val sourceDir: String = "main", | ||
val id: Long = generateSourceId(name, lang), | ||
val flavor: String = getFlavorName(sourceDir, lang) | ||
) | ||
|
||
data class DeepLink( | ||
val host: String, | ||
val scheme: String = "https", | ||
val pathPattern: String = "", | ||
val path: String = "" | ||
) | ||
|
||
fun Project.register(extensions: List<Extension>) { | ||
extra["extensionList"] = extensions | ||
apply { | ||
from("$rootDir/extensions/common.gradle") | ||
from("$rootDir/extensions/aptmanifest.gradle") | ||
} | ||
} | ||
|
||
fun Project.register(vararg extensions: Extension) { | ||
register(extensions.toList()) | ||
} | ||
|
||
private fun getFlavorName(sourceDir: String, lang: String): String { | ||
return if (sourceDir == "main") lang else "$sourceDir-$lang" | ||
} | ||
|
||
private fun generateSourceId(name: String, lang: String, versionId: Int = 1): Long { | ||
val key = "${name.toLowerCase()}/$lang/$versionId" | ||
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray()) | ||
return (0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) } | ||
.reduce(Long::or) and Long.MAX_VALUE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
import groovy.util.Node | ||
import groovy.util.NodeList | ||
import groovy.util.XmlNodePrinter | ||
import groovy.util.XmlParser | ||
import org.gradle.api.GradleException | ||
import java.io.File | ||
import java.io.PrintWriter | ||
|
||
@Suppress("unused") | ||
object ManifestGenerator { | ||
|
||
@JvmStatic | ||
fun process(index: String, manifest: String, extension: Extension) { | ||
val indexFile = File(index) | ||
val manifestFile = File(manifest) | ||
|
||
if (!indexFile.exists() || !manifestFile.exists()) { | ||
throw GradleException("Can't find index or manifest file for ${extension.name}") | ||
} | ||
|
||
val extClass = indexFile.readLines().first() | ||
val parser = XmlParser().parse(manifestFile) | ||
|
||
// Get package name and append the language | ||
val packageEnding = extension.flavor.replace("-", ".").toLowerCase() | ||
val applicationId = extClass.substringBeforeLast(".") + ".$packageEnding" | ||
parser.attributes()["package"] = applicationId | ||
|
||
val app = (parser["application"] as NodeList).first() as Node | ||
|
||
// Add source class metadata | ||
Node(app, "meta-data", mapOf( | ||
"android:name" to "source.class", | ||
"android:value" to extClass | ||
)) | ||
|
||
// Add deeplinks if needed | ||
addDeepLinks(app, extension.deepLinks) | ||
|
||
XmlNodePrinter(manifestFile.printWriter()).print(parser) | ||
} | ||
|
||
private fun addDeepLinks(app: Node, deeplinks: List<DeepLink>) { | ||
if (deeplinks.isEmpty()) return | ||
|
||
val activity = Node(app, "activity", mapOf( | ||
"android:name" to "tachiyomix.deeplink.SourceDeepLinkActivity", | ||
"android:theme" to "@android:style/Theme.NoDisplay" | ||
)) | ||
|
||
val filter = Node(activity, "intent-filter") | ||
Node(filter, "action", mapOf("android:name" to "android.intent.action.VIEW")) | ||
Node(filter, "category", mapOf("android:name" to "android.intent.category.DEFAULT")) | ||
Node(filter, "category", mapOf("android:name" to "android.intent.category.BROWSABLE")) | ||
|
||
deeplinks.forEach { link -> | ||
val data = mutableMapOf<String, String>() | ||
if (link.scheme.isNotEmpty()) { | ||
data["android:scheme"] = link.scheme | ||
} | ||
if (link.host.isNotEmpty()) { | ||
data["android:host"] = link.host | ||
} | ||
if (link.pathPattern.isNotEmpty()) { | ||
data["android:pathPattern"] = link.pathPattern | ||
} | ||
if (link.path.isNotEmpty()) { | ||
data["android:path"] = link.path | ||
} | ||
|
||
Node(filter, "data", data) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.gradle.api.artifacts.dsl.DependencyHandler | ||
import org.gradle.kotlin.dsl.DependencyHandlerScope | ||
import org.gradle.kotlin.dsl.project | ||
|
||
object Proj { | ||
const val annotation = ":annotations" | ||
const val compiler = ":compiler" | ||
const val deeplink = ":deeplink" | ||
const val defaultRes = ":defaultRes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
id("com.android.library") | ||
} | ||
|
||
android { | ||
compileSdkVersion(Config.compileSdk) | ||
|
||
libraryVariants.all { | ||
generateBuildConfigProvider?.configure { | ||
enabled = false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest package="tachiyomix.deeplink" /> |
35 changes: 35 additions & 0 deletions
35
deeplink/src/main/java/tachiyomix/deeplink/SourceDeepLinkActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tachiyomix.deeplink; | ||
|
||
import android.app.Activity; | ||
import android.content.ActivityNotFoundException; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
public class SourceDeepLinkActivity extends Activity { | ||
|
||
private static final String TAG = "SourceDeepLinkActivity"; | ||
|
||
static final String ACTION = "tachiyomi.action.HANDLE_LINK"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
Intent intent = getIntent(); | ||
|
||
Intent forward = new Intent(ACTION); | ||
forward.setData(intent.getData()); | ||
forward.putExtra(Intent.EXTRA_REFERRER, getPackageName()); | ||
|
||
try { | ||
startActivity(forward); | ||
} catch (ActivityNotFoundException e) { | ||
Log.e(TAG, e.toString()); | ||
} | ||
|
||
finish(); | ||
System.exit(0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest package="tachiyomix.defaultres" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
id("com.android.library") | ||
} | ||
|
||
android { | ||
compileSdkVersion(Config.compileSdk) | ||
|
||
sourceSets { | ||
named("main") { | ||
manifest.srcFile("AndroidManifest.xml") | ||
res.setSrcDirs(listOf("res")) | ||
} | ||
} | ||
|
||
libraryVariants.all { | ||
generateBuildConfigProvider?.configure { | ||
enabled = false | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="tachiyomix"> | ||
|
||
<uses-feature android:name="tachiyomix" /> | ||
|
||
<application | ||
android:icon="@mipmap/ic_launcher" | ||
android:allowBackup="false" | ||
android:label="${appName}"> | ||
|
||
<meta-data | ||
android:name="source.id" | ||
android:value="${sourceId}" /> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
listOf("en", "es").map { lang -> | ||
Extension( | ||
name = "MangaDex", | ||
versionCode = 44, | ||
libVersion = "1.0", | ||
lang = lang, | ||
deepLinks = listOf( | ||
DeepLink( | ||
host = "mangadex.org", | ||
scheme = "https", | ||
pathPattern = "/title/.*" | ||
), | ||
DeepLink( | ||
host = "mangadex.org", | ||
scheme = "https", | ||
pathPattern = "/chapter/.*" | ||
) | ||
) | ||
) | ||
}.also(::register) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.