فهرست منبع

Dependency updates. OkHttp nullability changes

len 7 سال پیش
والد
کامیت
211f7b591b
22فایلهای تغییر یافته به همراه40 افزوده شده و 45 حذف شده
  1. 8 8
      app/build.gradle
  2. 2 2
      app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
  3. 2 2
      app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
  4. 2 2
      app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt
  5. 1 1
      app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt
  6. 1 1
      app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuInterceptor.kt
  7. 2 2
      app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyanimelistApi.kt
  8. 1 1
      app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdateDownloaderService.kt
  9. 2 7
      app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt
  10. 1 1
      app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt
  11. 1 1
      app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt
  12. 1 1
      app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt
  13. 2 2
      app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSource.kt
  14. 3 3
      app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt
  15. 3 3
      app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt
  16. 1 1
      app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt
  17. 1 1
      app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt
  18. 2 2
      app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt
  19. 1 1
      app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt
  20. 1 1
      app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt
  21. 1 1
      app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt
  22. 1 1
      app/src/main/java/eu/kanade/tachiyomi/util/JsoupExtensions.kt

+ 8 - 8
app/build.gradle

@@ -120,17 +120,17 @@ dependencies {
 
     // ReactiveX
     compile 'io.reactivex:rxandroid:1.2.1'
-    compile 'io.reactivex:rxjava:1.2.9'
+    compile 'io.reactivex:rxjava:1.3.0'
     compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
     compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
     compile 'com.github.pwittchen:reactivenetwork:0.7.0'
 
     // Network client
-    compile "com.squareup.okhttp3:okhttp:3.6.0"
-    compile 'com.squareup.okio:okio:1.11.0'
+    compile "com.squareup.okhttp3:okhttp:3.8.0"
+    compile 'com.squareup.okio:okio:1.13.0'
 
     // REST
-    final retrofit_version = '2.2.0'
+    final retrofit_version = '2.3.0'
     compile "com.squareup.retrofit2:retrofit:$retrofit_version"
     compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
     compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
@@ -160,7 +160,7 @@ dependencies {
     compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
 
     // Database
-    compile "com.pushtorefresh.storio:sqlite:1.12.3"
+    compile "com.pushtorefresh.storio:sqlite:1.13.0"
 
     // Model View Presenter
     final nucleus_version = '3.0.0'
@@ -172,8 +172,8 @@ dependencies {
     compile "uy.kohesive.injekt:injekt-core:1.16.1"
 
     // Image library
-    compile 'com.github.bumptech.glide:glide:3.7.0'
-    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
+    compile 'com.github.bumptech.glide:glide:3.8.0'
+    compile 'com.github.bumptech.glide:okhttp3-integration:1.5.0@aar'
     // Transformations
     compile 'jp.wasabeef:glide-transformations:2.0.2'
 
@@ -192,7 +192,7 @@ dependencies {
     compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
     compile 'com.nononsenseapps:filepicker:2.5.2'
     compile 'com.github.amulyakhare:TextDrawable:558677e'
-    compile 'com.afollestad.material-dialogs:core:0.9.4.2'
+    compile 'com.afollestad.material-dialogs:core:0.9.4.5'
     compile 'me.zhanghai.android.systemuihelper:library:1.0.0'
     compile 'de.hdodenhof:circleimageview:2.1.0'
     compile 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.0.4'

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt

@@ -187,12 +187,12 @@ class ChapterCache(private val context: Context) {
             editor = diskCache.edit(key) ?: throw IOException("Unable to edit key")
 
             // Get OutputStream and write image with Okio.
-            response.body().source().saveTo(editor.newOutputStream(0))
+            response.body()!!.source().saveTo(editor.newOutputStream(0))
 
             diskCache.flush()
             editor.commit()
         } finally {
-            response.body().close()
+            response.body()?.close()
             editor?.abortUnlessCommitted()
         }
     }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt

@@ -380,7 +380,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
                 .map { response ->
                     val file = tmpDir.createFile("$filename.tmp")
                     try {
-                        response.body().source().saveTo(file.openOutputStream())
+                        response.body()!!.source().saveTo(file.openOutputStream())
                         val extension = getImageExtension(response, file)
                         file.renameTo("$filename.$extension")
                     } catch (e: Exception) {
@@ -403,7 +403,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
      */
     private fun getImageExtension(response: Response, file: UniFile): String {
         // Read content type if available.
-        val mime = response.body().contentType()?.let { ct -> "${ct.type()}/${ct.subtype()}" }
+        val mime = response.body()?.contentType()?.let { ct -> "${ct.type()}/${ct.subtype()}" }
             // Else guess from the uri.
             ?: context.contentResolver.getType(file.uri)
             // Else read magic numbers.

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt

@@ -26,7 +26,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
     fun addLibManga(track: Track): Observable<Track> {
         return rest.addLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus())
                 .map { response ->
-                    response.body().close()
+                    response.body()?.close()
                     if (!response.isSuccessful) {
                         throw Exception("Could not add manga")
                     }
@@ -38,7 +38,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
         return rest.updateLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus(),
                 track.toAnilistScore())
                 .map { response ->
-                    response.body().close()
+                    response.body()?.close()
                     if (!response.isSuccessful) {
                         throw Exception("Could not update manga")
                     }

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt

@@ -28,7 +28,7 @@ class AnilistInterceptor(private var refreshToken: String?) : Interceptor {
         if (oauth == null || oauth!!.isExpired()) {
             val response = chain.proceed(AnilistApi.refreshTokenRequest(refreshToken!!))
             oauth = if (response.isSuccessful) {
-                Gson().fromJson(response.body().string(), OAuth::class.java)
+                Gson().fromJson(response.body()!!.string(), OAuth::class.java)
             } else {
                 response.close()
                 null

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuInterceptor.kt

@@ -22,7 +22,7 @@ class KitsuInterceptor(val kitsu: Kitsu, val gson: Gson) : Interceptor {
         if (currAuth.isExpired()) {
             val response = chain.proceed(KitsuApi.refreshTokenRequest(refreshToken))
             if (response.isSuccessful) {
-                newAuth(gson.fromJson(response.body().string(), OAuth::class.java))
+                newAuth(gson.fromJson(response.body()!!.string(), OAuth::class.java))
             } else {
                 response.close()
             }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyanimelistApi.kt

@@ -46,7 +46,7 @@ class MyanimelistApi(private val client: OkHttpClient, username: String, passwor
         } else {
             client.newCall(GET(getSearchUrl(query), headers))
                     .asObservable()
-                    .map { Jsoup.parse(it.body().string()) }
+                    .map { Jsoup.parse(it.body()!!.string()) }
                     .flatMap { Observable.from(it.select("entry")) }
                     .filter { it.select("type").text() != "Novel" }
                     .map {
@@ -64,7 +64,7 @@ class MyanimelistApi(private val client: OkHttpClient, username: String, passwor
         return client
                 .newCall(GET(getListUrl(username), headers))
                 .asObservable()
-                .map { Jsoup.parse(it.body().string()) }
+                .map { Jsoup.parse(it.body()!!.string()) }
                 .flatMap { Observable.from(it.select("manga")) }
                 .map {
                     Track.create(TrackManager.MYANIMELIST).apply {

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdateDownloaderService.kt

@@ -86,7 +86,7 @@ class UpdateDownloaderService : IntentService(UpdateDownloaderService::class.jav
             val apkFile = File(externalCacheDir, "update.apk")
 
             if (response.isSuccessful) {
-                response.body().source().saveTo(apkFile)
+                response.body()!!.source().saveTo(apkFile)
             } else {
                 response.close()
                 throw Exception("Unsuccessful response")

+ 2 - 7
app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt

@@ -8,13 +8,10 @@ import okhttp3.Response
 
 class CloudflareInterceptor : Interceptor {
 
-    //language=RegExp
     private val operationPattern = Regex("""setTimeout\(function\(\)\{\s+(var (?:\w,)+f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n""")
     
-    //language=RegExp
     private val passPattern = Regex("""name="pass" value="(.+?)"""")
 
-    //language=RegExp
     private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
 
     @Synchronized
@@ -34,7 +31,7 @@ class CloudflareInterceptor : Interceptor {
             val originalRequest = response.request()
             val url = originalRequest.url()
             val domain = url.host()
-            val content = response.body().string()
+            val content = response.body()!!.string()
 
             // CloudFlare requires waiting 4 seconds before resolving the challenge
             Thread.sleep(4000)
@@ -48,9 +45,7 @@ class CloudflareInterceptor : Interceptor {
             }
 
             val js = operation
-                    //language=RegExp
                     .replace(Regex("""a\.value =(.+?) \+.*"""), "$1")
-                    //language=RegExp
                     .replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
                     .replace("\n", "")
 
@@ -58,7 +53,7 @@ class CloudflareInterceptor : Interceptor {
 
             val answer = "${result + domain.length}"
 
-            val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")
+            val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
                     .newBuilder()
                     .addQueryParameter("jschl_vc", challenge)
                     .addQueryParameter("pass", pass)

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt

@@ -61,7 +61,7 @@ fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListene
             .addNetworkInterceptor { chain ->
                 val originalResponse = chain.proceed(chain.request())
                 originalResponse.newBuilder()
-                        .body(ProgressResponseBody(originalResponse.body(), listener))
+                        .body(ProgressResponseBody(originalResponse.body()!!, listener))
                         .build()
             }
             .build()

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt

@@ -18,7 +18,7 @@ class PersistentCookieStore(context: Context) {
             if (cookies != null) {
                 try {
                     val url = HttpUrl.parse("http://$key")
-                    val nonExpiredCookies = cookies.map { Cookie.parse(url, it) }
+                    val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) }
                             .filter { !it.hasExpired() }
                     cookieMap.put(key, nonExpiredCookies)
                 } catch (e: Exception) {

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/network/ProgressResponseBody.kt

@@ -12,7 +12,7 @@ class ProgressResponseBody(private val responseBody: ResponseBody, private val p
     }
 
     override fun contentType(): MediaType {
-        return responseBody.contentType()
+        return responseBody.contentType()!!
     }
 
     override fun contentLength(): Long {

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSource.kt

@@ -171,7 +171,7 @@ class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
     }
 
     override fun pageListParse(response: Response): List<Page> {
-        val body = response.body().string()
+        val body = response.body()!!.string()
         val url = response.request().url().toString()
 
         val pages = mutableListOf<Page>()
@@ -216,7 +216,7 @@ class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
     }
 
     override fun imageUrlParse(response: Response): String {
-        val body = response.body().string()
+        val body = response.body()!!.string()
         val url = response.request().url().toString()
 
         with(map.pages) {

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt

@@ -85,7 +85,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
     override fun latestUpdatesNextPageSelector() = "#show_more_row"
 
     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
-        val url = HttpUrl.parse("$baseUrl/search_ajax").newBuilder()
+        val url = HttpUrl.parse("$baseUrl/search_ajax")!!.newBuilder()
         if (!query.isEmpty()) url.addQueryParameter("name", query).addQueryParameter("name_cond", "c")
         var genres = ""
         filters.forEach { filter ->
@@ -162,7 +162,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
     }
 
     override fun chapterListParse(response: Response): List<SChapter> {
-        val body = response.body().string()
+        val body = response.body()!!.string()
         val matcher = staffNotice.matcher(body)
         if (matcher.find()) {
             @Suppress("DEPRECATION")
@@ -271,7 +271,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
     }
 
     override fun isAuthenticationSuccessful(response: Response) =
-            response.priorResponse() != null && response.priorResponse().code() == 302
+            response.priorResponse() != null && response.priorResponse()!!.code() == 302
 
     override fun isLogged(): Boolean {
         return network.cookies.get(URI(baseUrl)).any { it.name() == "pass_hash" }

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt

@@ -115,13 +115,13 @@ class Kissmanga : ParsedHttpSource() {
     override fun pageListRequest(chapter: SChapter) = POST(baseUrl + chapter.url, headers)
 
     override fun pageListParse(response: Response): List<Page> {
-        val body = response.body().string()
+        val body = response.body()!!.string()
 
         val pages = mutableListOf<Page>()
 
         // Kissmanga now encrypts the urls, so we need to execute these two scripts in JS.
-        val ca = client.newCall(GET("$baseUrl/Scripts/ca.js", headers)).execute().body().string()
-        val lo = client.newCall(GET("$baseUrl/Scripts/lo.js", headers)).execute().body().string()
+        val ca = client.newCall(GET("$baseUrl/Scripts/ca.js", headers)).execute().body()!!.string()
+        val lo = client.newCall(GET("$baseUrl/Scripts/lo.js", headers)).execute().body()!!.string()
 
         Duktape.create().use {
             it.evaluate(ca)

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt

@@ -55,7 +55,7 @@ class Mangafox : ParsedHttpSource() {
     override fun latestUpdatesNextPageSelector() = "a:has(span.next)"
 
     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
-        val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1").newBuilder().addQueryParameter("name", query)
+        val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1")!!.newBuilder().addQueryParameter("name", query)
         (if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
             when (filter) {
                 is Status -> url.addQueryParameter(filter.id, filter.state.toString())

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt

@@ -57,7 +57,7 @@ class Mangahere : ParsedHttpSource() {
     override fun latestUpdatesNextPageSelector() = "div.next-page > a.next"
 
     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
-        val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1").newBuilder().addQueryParameter("name", query)
+        val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1")!!.newBuilder().addQueryParameter("name", query)
         (if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
             when (filter) {
                 is Status -> url.addQueryParameter("is_completed", arrayOf("", "1", "0")[filter.state])

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt

@@ -54,7 +54,7 @@ class Mangasee : ParsedHttpSource() {
     override fun searchMangaSelector() = "div.requested > div.row"
 
     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
-        val url = HttpUrl.parse("$baseUrl/search/request.php").newBuilder()
+        val url = HttpUrl.parse("$baseUrl/search/request.php")!!.newBuilder()
         if (!query.isEmpty()) url.addQueryParameter("keyword", query)
         val genres = mutableListOf<String>()
         val genresNo = mutableListOf<String>()
@@ -84,7 +84,7 @@ class Mangasee : ParsedHttpSource() {
     }
 
     private fun convertQueryToPost(page: Int, url: String): Pair<FormBody.Builder, String> {
-        val url = HttpUrl.parse(url)
+        val url = HttpUrl.parse(url)!!
         val body = FormBody.Builder().add("page", page.toString())
         for (i in 0..url.querySize() - 1) {
             body.add(url.queryParameterName(i), url.queryParameterValue(i))

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt

@@ -152,7 +152,7 @@ class Mangachan : ParsedHttpSource() {
     }
 
     override fun pageListParse(response: Response): List<Page> {
-        val html = response.body().string()
+        val html = response.body()!!.string()
         val beginIndex = html.indexOf("fullimg\":[") + 10
         val endIndex = html.indexOf(",]", beginIndex)
         val trimmedHtml = html.substring(beginIndex, endIndex).replace("\"", "")

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt

@@ -120,7 +120,7 @@ class Mintmanga : ParsedHttpSource() {
     }
 
     override fun pageListParse(response: Response): List<Page> {
-        val html = response.body().string()
+        val html = response.body()!!.string()
         val beginIndex = html.indexOf("rm_h.init( [")
         val endIndex = html.indexOf("], 0, false);", beginIndex)
         val trimmedHtml = html.substring(beginIndex, endIndex)

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt

@@ -120,7 +120,7 @@ class Readmanga : ParsedHttpSource() {
     }
 
     override fun pageListParse(response: Response): List<Page> {
-        val html = response.body().string()
+        val html = response.body()!!.string()
         val beginIndex = html.indexOf("rm_h.init( [")
         val endIndex = html.indexOf("], 0, false);", beginIndex)
         val trimmedHtml = html.substring(beginIndex, endIndex)

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/util/JsoupExtensions.kt

@@ -22,5 +22,5 @@ fun Element.attrOrText(css: String): String {
  * @param html the body of the response. Use only if the body was read before calling this method.
  */
 fun Response.asJsoup(html: String? = null): Document {
-    return Jsoup.parse(html ?: body().string(), request().url().toString())
+    return Jsoup.parse(html ?: body()!!.string(), request().url().toString())
 }