From bdf4b4b679a71a870a7649ce68daf0ca7161f9c5 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 1 Jan 2022 11:30:18 -0500 Subject: [PATCH] Add AppInfo functions to replace BuildConfig usages in extensions --- app/src/main/java/eu/kanade/tachiyomi/AppInfo.kt | 11 +++++++++++ .../network/interceptor/RateLimitInterceptor.kt | 2 ++ .../interceptor/SpecificHostRateLimitInterceptor.kt | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/AppInfo.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppInfo.kt b/app/src/main/java/eu/kanade/tachiyomi/AppInfo.kt new file mode 100644 index 000000000..5cb55af20 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/AppInfo.kt @@ -0,0 +1,11 @@ +package eu.kanade.tachiyomi + +/** + * Used by extensions. + * + * @since extension-lib 1.3 + */ +object AppInfo { + fun getVersionCode() = BuildConfig.VERSION_CODE + fun getVersionName() = BuildConfig.VERSION_NAME +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt index 241e4923c..a776f2b5f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt @@ -14,6 +14,8 @@ import java.util.concurrent.TimeUnit * permits = 5, period = 1, unit = seconds => 5 requests per second * permits = 10, period = 2, unit = minutes => 10 requests per 2 minutes * + * @since extension-lib 1.3 + * * @param permits {Int} Number of requests allowed within a period of units. * @param period {Long} The limiting duration. Defaults to 1. * @param unit {TimeUnit} The unit of time for the period. Defaults to seconds. diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt index bce9b3f2d..ec7a8fdb1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt @@ -15,6 +15,8 @@ import java.util.concurrent.TimeUnit * httpUrl = "api.manga.com".toHttpUrlOrNull(), permits = 5, period = 1, unit = seconds => 5 requests per second to api.manga.com * httpUrl = "imagecdn.manga.com".toHttpUrlOrNull(), permits = 10, period = 2, unit = minutes => 10 requests per 2 minutes to imagecdn.manga.com * + * @since extension-lib 1.3 + * * @param httpUrl {HttpUrl} The url host that this interceptor should handle. Will get url's host by using HttpUrl.host() * @param permits {Int} Number of requests allowed within a period of units. * @param period {Long} The limiting duration. Defaults to 1.