Add ability to flag extension as NSFW (#4053)

This commit is contained in:
arkon 2020-08-08 15:59:03 -04:00 committed by GitHub
parent 980a8d2162
commit 149bda765b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 6 deletions

View File

@ -15,12 +15,13 @@ APKS=( ../apk/*".apk"* )
for APK in ${APKS[@]}; do for APK in ${APKS[@]}; do
FILENAME=$(basename ${APK}) FILENAME=$(basename ${APK})
BADGING="$(${TOOLS}/aapt dump badging $APK)" BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)"
PACKAGE=$(echo "$BADGING" | grep package:) PACKAGE=$(echo "$BADGING" | grep package:)
PKGNAME=$(echo $PACKAGE | grep -Po "package: name='\K[^']+") PKGNAME=$(echo $PACKAGE | grep -Po "package: name='\K[^']+")
VCODE=$(echo $PACKAGE | grep -Po "versionCode='\K[^']+") VCODE=$(echo $PACKAGE | grep -Po "versionCode='\K[^']+")
VNAME=$(echo $PACKAGE | grep -Po "versionName='\K[^']+") VNAME=$(echo $PACKAGE | grep -Po "versionName='\K[^']+")
NSFW=$(echo $BADGING | grep -Po "tachiyomi.extension.nsfw' value='\K[^']+")
APPLICATION=$(echo "$BADGING" | grep application:) APPLICATION=$(echo "$BADGING" | grep application:)
LABEL=$(echo $APPLICATION | grep -Po "label='\K[^']+") LABEL=$(echo $APPLICATION | grep -Po "label='\K[^']+")
@ -37,7 +38,8 @@ for APK in ${APKS[@]}; do
--arg lang "$LANG" \ --arg lang "$LANG" \
--argjson code $VCODE \ --argjson code $VCODE \
--arg version "$VNAME" \ --arg version "$VNAME" \
'{name:$name, pkg:$pkg, apk:$apk, lang:$lang, code:$code, version:$version}' --argjson nsfw $NSFW \
'{name:$name, pkg:$pkg, apk:$apk, lang:$lang, code:$code, version:$version, nsfw:$nsfw}'
done | jq -sr '[.[]]' > index.json done | jq -sr '[.[]]' > index.json

View File

@ -7,7 +7,8 @@
<application android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:label="${appName}"> <application android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:label="${appName}">
<meta-data android:name="tachiyomi.extension.class" android:value="${extClass}" /> <meta-data android:name="tachiyomi.extension.class" android:value="${extClass}" />
<meta-data android:name="tachiyomi.extension.nsfw" android:value="${nsfw}" />
</application> </application>
</manifest> </manifest>

View File

@ -75,6 +75,7 @@ ext {
extClass = '.<MySourceName>' extClass = '.<MySourceName>'
extVersionCode = 1 extVersionCode = 1
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"
@ -87,6 +88,7 @@ apply from: "$rootDir/common.gradle"
| `extClass` | Points to the class that implements `Source`. You can use a relative path starting with a dot (the package name is the base path). This is used to find and instantiate the source(s). | | `extClass` | Points to the class that implements `Source`. You can use a relative path starting with a dot (the package name is the base path). This is used to find and instantiate the source(s). |
| `extVersionCode` | The extension version code. This must be a positive integer and incremented with any change to the code. | | `extVersionCode` | The extension version code. This must be a positive integer and incremented with any change to the code. |
| `libVersion` | The version of the [extensions library](https://github.com/tachiyomiorg/extensions-lib) used. | | `libVersion` | The version of the [extensions library](https://github.com/tachiyomiorg/extensions-lib) used. |
| `containsNsfw` | (Optional, defaults to `false`) Flag to indicate that a source contains NSFW content. |
The extension's version name is generated automatically by concatenating `libVersion` and `extVersionCode`. With the example used above, the version would be `1.2.1`. The extension's version name is generated automatically by concatenating `libVersion` and `extVersionCode`. With the example used above, the version would be `1.2.1`.

View File

@ -40,6 +40,7 @@ android {
manifestPlaceholders = [ manifestPlaceholders = [
appName : "Tachiyomi: $extName", appName : "Tachiyomi: $extName",
extClass: extClass, extClass: extClass,
nsfw: project.ext.properties.getOrDefault("containsNsfw", false) ? 1 : 0,
] ]
} }
@ -48,12 +49,12 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility = 1.8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = 1.8 targetCompatibility = JavaVersion.VERSION_1_8
} }
kotlinOptions { kotlinOptions {
jvmTarget = "1.8" jvmTarget = JavaVersion.VERSION_1_8.toString()
} }
} }

View File

@ -7,6 +7,7 @@ ext {
extClass = '.NHFactory' extClass = '.NHFactory'
extVersionCode = 27 extVersionCode = 27
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true
} }
dependencies { dependencies {