[Ru]Remanga. Fix issue with merging part of image (#5924)

Co-authored-by: pavkazzz <me@pavkazzz.ru>
This commit is contained in:
Pavka 2021-02-20 00:42:02 +03:00 committed by GitHub
parent d25127f865
commit 98e61270b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 35 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Remanga' extName = 'Remanga'
pkgNameSuffix = 'ru.remanga' pkgNameSuffix = 'ru.remanga'
extClass = '.Remanga' extClass = '.Remanga'
extVersionCode = 17 extVersionCode = 18
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -14,14 +14,10 @@ import android.annotation.SuppressLint
import android.annotation.TargetApi import android.annotation.TargetApi
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.os.Build import android.os.Build
import android.support.v7.preference.EditTextPreference import android.support.v7.preference.EditTextPreference
import android.support.v7.preference.PreferenceScreen import android.support.v7.preference.PreferenceScreen
import android.text.InputType import android.text.InputType
import android.util.Base64
import android.widget.Toast import android.widget.Toast
import com.github.salomonbrys.kotson.fromJson import com.github.salomonbrys.kotson.fromJson
import com.google.gson.Gson import com.google.gson.Gson
@ -53,7 +49,6 @@ import org.jsoup.Jsoup
import rx.Observable import rx.Observable
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.io.ByteArrayOutputStream
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import java.util.Locale import java.util.Locale
@ -329,44 +324,22 @@ class Remanga : ConfigurableSource, HttpSource() {
} }
} catch (e: JsonSyntaxException) { } catch (e: JsonSyntaxException) {
val page = gson.fromJson<SeriesWrapperDto<PaidPageDto>>(body) val page = gson.fromJson<SeriesWrapperDto<PaidPageDto>>(body)
page.content.pages.mapIndexed { i, element -> val result = mutableListOf<Page>()
Page(i, element.joinToString { it.link }) page.content.pages.forEach {
it.forEach {
result.add(Page(result.size, "", it.link))
}
} }
return result
} }
} }
override fun fetchImageUrl(page: Page): Observable<String> { override fun fetchImageUrl(page: Page): Observable<String> = Observable.just(page.imageUrl!!)
val urls = page.url.split(", ")
val res = this.combineImage(urls)
return Observable.just("https://127.0.0.1/?imagebase64,$res")
}
override fun imageUrlRequest(page: Page): Request = throw NotImplementedError("Unused") override fun imageUrlRequest(page: Page): Request = throw NotImplementedError("Unused")
override fun imageUrlParse(response: Response): String = throw NotImplementedError("Unused") override fun imageUrlParse(response: Response): String = throw NotImplementedError("Unused")
private fun combineImage(pages: List<String>): String {
val refererHeaders = headersBuilder().build()
val s = client.newCall(GET(pages[0], refererHeaders)).execute().body()!!.bytes()
val b = BitmapFactory.decodeByteArray(s, 0, s.size)
val cs = Bitmap.createBitmap(b.width, b.height * pages.size, Bitmap.Config.ARGB_8888)
val comboImage = Canvas(cs)
var totalHeight = b.height
comboImage.drawBitmap(b, 0f, 0f, null)
for (i in 1 until pages.size) {
val bytes = client.newCall(GET(pages[i], refererHeaders)).execute().body()!!.bytes()
val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
comboImage.drawBitmap(bitmap, 0f, (b.height * i).toFloat(), null)
totalHeight += bitmap.getHeight()
}
cs.reconfigure(cs.getWidth(), totalHeight, cs.getConfig())
val output = ByteArrayOutputStream()
cs.compress(Bitmap.CompressFormat.JPEG, 100, output)
return Base64.encodeToString(output.toByteArray(), Base64.DEFAULT)
}
override fun imageRequest(page: Page): Request { override fun imageRequest(page: Page): Request {
val refererHeaders = headersBuilder().build() val refererHeaders = headersBuilder().build()
return GET(page.imageUrl!!, refererHeaders) return GET(page.imageUrl!!, refererHeaders)