diff --git a/app/build.gradle b/app/build.gradle index bb872aa8d..2ef18021d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,6 @@ android { } } } - archivesBaseName = "kotatsu_${gitCommits}" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -38,6 +37,7 @@ android { applicationIdSuffix = '.debug' } release { + multiDexEnabled false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 5cf66e087..57fe6234e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -9,4 +9,5 @@ -keep class org.koitharu.kotatsu.core.db.entity.* { *; } -keepclassmembers public class * extends org.koitharu.kotatsu.core.parser.MangaRepository { public (...); -} \ No newline at end of file +} +-dontwarn okhttp3.internal.platform.ConscryptPlatform \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonFrameLayout.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonFrameLayout.kt index 9668aede0..9d6ce8365 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonFrameLayout.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonFrameLayout.kt @@ -1,41 +1,17 @@ package org.koitharu.kotatsu.ui.reader.wetoon import android.content.Context -import android.graphics.RectF import android.util.AttributeSet import android.widget.FrameLayout -import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView -import kotlinx.android.synthetic.main.item_page_webtoon.view.* import org.koitharu.kotatsu.R class WebtoonFrameLayout @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr) { - private val pan = RectF() - - private val target by lazy { - findViewById(R.id.ssiv) + private val target: WebtoonImageView by lazy { + findViewById(R.id.ssiv) } - fun dispatchVerticalScroll(dy: Int): Int { - target.getPanRemaining(pan) - val c = target.center ?: return 0 - val s = target.scale - return when { - dy > 0 -> { - val delta = minOf(pan.bottom.toInt(), dy) - c.offset(0f, delta.toFloat() / s) - target.setScaleAndCenter(s, c) - delta - } - dy < 0 -> { - val delta = minOf(pan.top.toInt(), -dy) - c.offset(0f, -delta.toFloat() / s) - target.setScaleAndCenter(s, c) - -delta - } - else -> 0 - } - } + fun dispatchVerticalScroll(dy: Int) = target.dispatchVerticalScroll(dy) } \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonImageView.kt b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonImageView.kt new file mode 100644 index 000000000..7749de6e5 --- /dev/null +++ b/app/src/main/java/org/koitharu/kotatsu/ui/reader/wetoon/WebtoonImageView.kt @@ -0,0 +1,43 @@ +package org.koitharu.kotatsu.ui.reader.wetoon + +import android.content.Context +import android.graphics.PointF +import android.graphics.RectF +import android.util.AttributeSet +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import org.koitharu.kotatsu.utils.ext.toIntUp + +class WebtoonImageView : SubsamplingScaleImageView { + + constructor(context: Context?) : super(context) + constructor(context: Context?, attr: AttributeSet?) : super(context, attr) + + private val pan = RectF() + private val ct = PointF() + + fun dispatchVerticalScroll(dy: Int): Int { + if (!isReady) { + return 0 + } + getPanRemaining(pan) + // pan.offset(0f, -nonConsumedScroll.toFloat()) + ct.set(width / 2f, height / 2f) + viewToSourceCoord(ct.x, ct.y, ct) ?: return 0 + val s = scale + return when { + dy > 0 -> { + val delta = minOf(pan.bottom.toIntUp(), dy) + ct.offset(0f, delta.toFloat() / s) + setScaleAndCenter(s, ct) + delta + } + dy < 0 -> { + val delta = minOf(pan.top.toInt(), -dy) + ct.offset(0f, -delta.toFloat() / s) + setScaleAndCenter(s, ct) + -delta + } + else -> 0 + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/PrimitiveExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/PrimitiveExt.kt index c2a8c4c16..b6fd83b6b 100644 --- a/app/src/main/java/org/koitharu/kotatsu/utils/ext/PrimitiveExt.kt +++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/PrimitiveExt.kt @@ -22,4 +22,13 @@ fun Number.format(decimals: Int = 0, decPoint: Char = '.', thousandsSep: Char? = is Double -> formatter.format(this.toDouble()) else -> formatter.format(this.toLong()) } +} + +fun Float.toIntUp(): Int { + val intValue = toInt() + return if (this == intValue.toFloat()) { + intValue + } else { + intValue + 1 + } } \ No newline at end of file diff --git a/app/src/main/res/layout/item_page_webtoon.xml b/app/src/main/res/layout/item_page_webtoon.xml index dafa8e98b..36fd63de9 100644 --- a/app/src/main/res/layout/item_page_webtoon.xml +++ b/app/src/main/res/layout/item_page_webtoon.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> -