Fixed some images crashing

Added auto pageturn timer
This commit is contained in:
tom5079
2020-08-08 15:55:17 +09:00
parent 647294daf2
commit 9415ab4ef9
13 changed files with 89 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 57
versionName "4.20-hotfix2"
versionName "4.21"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true

View File

@@ -12,7 +12,7 @@
"filters": [],
"properties": [],
"versionCode": 57,
"versionName": "4.20-hotfix2",
"versionName": "4.21",
"enabled": true,
"outputFile": "app-release.apk"
}

View File

@@ -19,6 +19,9 @@
package xyz.quaver.pupil.adapters
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import android.util.Base64
import android.util.SparseBooleanArray
@@ -221,12 +224,16 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
"male" -> {
setChipBackgroundColorResource(R.color.material_blue_700)
setTextColor(ContextCompat.getColor(context, android.R.color.white))
ContextCompat.getDrawable(context, R.drawable.gender_male)
ContextCompat.getDrawable(context, R.drawable.gender_male)?.apply {
colorFilter = PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP)
}
}
"female" -> {
setChipBackgroundColorResource(R.color.material_pink_600)
setTextColor(ContextCompat.getColor(context, android.R.color.white))
ContextCompat.getDrawable(context, R.drawable.gender_female)
ContextCompat.getDrawable(context, R.drawable.gender_female)?.apply {
colorFilter = PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP)
}
}
else -> null
}

View File

@@ -51,6 +51,7 @@ import xyz.quaver.pupil.util.download.Cache
import xyz.quaver.pupil.util.download.DownloadWorker
import java.util.*
import kotlin.concurrent.schedule
import kotlin.concurrent.timer
class ReaderActivity : AppCompatActivity() {
@@ -71,6 +72,7 @@ class ReaderActivity : AppCompatActivity() {
}
private val timer = Timer()
private var autoTimer: Timer? = null
private val snapHelper = PagerSnapHelper()
@@ -380,6 +382,30 @@ class ReaderActivity : AppCompatActivity() {
}
}
with(reader_fab_auto) {
setImageResource(R.drawable.clock_start)
setOnClickListener {
if (autoTimer == null) {
autoTimer = timer(initialDelay = 10000L, period = 10000L) {
CoroutineScope(Dispatchers.Main).launch {
with(this@ReaderActivity.reader_recyclerview) {
val lastItem =
(layoutManager as LinearLayoutManager).findLastCompletelyVisibleItemPosition()
if (lastItem < adapter!!.itemCount - 1)
(layoutManager as LinearLayoutManager).scrollToPosition(lastItem + 1)
}
}
}
setImageResource(R.drawable.clock_end)
} else {
autoTimer?.cancel()
autoTimer = null
setImageResource(R.drawable.clock_start)
}
}
}
with(reader_fab_fullscreen) {
setImageResource(R.drawable.ic_fullscreen)
setOnClickListener {

View File

@@ -79,13 +79,16 @@ class SettingsFragment :
}
private fun getDirSize(dir: File) : String {
return getString(R.string.settings_storage_usage,
Runtime.getRuntime().exec("du -hs " + dir.absolutePath).let {
BufferedReader(InputStreamReader(it.inputStream)).use { reader ->
reader.readLine()?.split('\t')?.firstOrNull() ?: "0"
return if (activity != null)
getString(R.string.settings_storage_usage,
Runtime.getRuntime().exec("du -hs " + dir.absolutePath).let {
BufferedReader(InputStreamReader(it.inputStream)).use { reader ->
reader.readLine()?.split('\t')?.firstOrNull() ?: "0"
}
}
}
)
)
else
""
}
override fun onPreferenceClick(preference: Preference?): Boolean {

View File

@@ -0,0 +1,8 @@
<!-- drawable/clock_end.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#fff" android:pathData="M12,1C8.14,1 5,4.14 5,8A7,7 0 0,0 12,15C15.86,15 19,11.87 19,8C19,4.14 15.86,1 12,1M12,3.15C14.67,3.15 16.85,5.32 16.85,8C16.85,10.68 14.67,12.85 12,12.85A4.85,4.85 0 0,1 7.15,8A4.85,4.85 0 0,1 12,3.15M11,5V8.69L14.19,10.53L14.94,9.23L12.5,7.82V5M15,16V19H3V21H15V24L19,20M19,20V24H21V16H19" />
</vector>

View File

@@ -0,0 +1,8 @@
<!-- drawable/clock_start.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#fff" android:pathData="M12,1C8.14,1 5,4.14 5,8A7,7 0 0,0 12,15C15.86,15 19,11.87 19,8C19,4.14 15.86,1 12,1M12,3.15C14.67,3.15 16.85,5.32 16.85,8C16.85,10.68 14.67,12.85 12,12.85A4.85,4.85 0 0,1 7.15,8A4.85,4.85 0 0,1 12,3.15M11,5V8.69L14.19,10.53L14.94,9.23L12.5,7.82V5M4,16V24H6V21H18V24L22,20L18,16V19H6V16" />
</vector>

View File

@@ -82,6 +82,13 @@
app:fab_label="@string/reader_fab_retry"
app:fab_size="mini"/>
<com.github.clans.fab.FloatingActionButton
android:id="@+id/reader_fab_auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_label="@string/reader_fab_auto"
app:fab_size="mini"/>
<com.github.clans.fab.FloatingActionButton
android:id="@+id/reader_fab_fullscreen"
android:layout_width="wrap_content"

View File

@@ -151,4 +151,5 @@
<string name="settings_user_id_toast">ユーザーIDをクリップボードにコピーしました</string>
<string name="reader_error_retry">ダウンロードエラーが発生しました。リトライしますか?</string>
<string name="reader_fab_retry">リトライ</string>
<string name="reader_fab_auto">自動スクロール</string>
</resources>

View File

@@ -151,4 +151,5 @@
<string name="settings_user_id_toast">유저 ID를 클립보드에 복사했습니다</string>
<string name="reader_error_retry">다운로드 에러가 발생했습니. 재시도 하시겠습니까?</string>
<string name="reader_fab_retry">재시도</string>
<string name="reader_fab_auto">자동 스크롤</string>
</resources>

View File

@@ -115,6 +115,7 @@
<string name="reader_go_to_page">Go to page</string>
<string name="reader_fab_fullscreen">Fullscreen</string>>
<string name="reader_fab_retry">Retry</string>
<string name="reader_fab_auto">Automatic scroll</string>
<string name="reader_fab_download">Background download</string>
<string name="reader_fab_download_cancel">Cancel background download</string>
<string name="reader_notification_text">Downloading&#8230;</string>

View File

@@ -33,12 +33,11 @@ fun getGalleryInfo(galleryID: Int) =
//common.js
var adapose = false
const val numberOfFrontends = 3
const val domain = "ltn.hitomi.la"
const val galleryblockdir = "galleryblock"
const val nozomiextension = ".nozomi"
fun subdomainFromGalleryID(g: Int) : String {
fun subdomainFromGalleryID(g: Int, numberOfFrontends: Int) : String {
if (adapose)
return "0"
@@ -53,13 +52,20 @@ fun subdomainFromURL(url: String, base: String? = null) : String {
if (!base.isNullOrBlank())
retval = base
var numberOfFrontends = 3
val b = 16
val r = Regex("""/[0-9a-f]/([0-9a-f]{2})/""")
val m = r.find(url) ?: return retval
val g = m.groupValues[1].toIntOrNull(b) ?: return retval
var g = m.groupValues[1].toIntOrNull(b) ?: return retval
retval = subdomainFromGalleryID(g) + retval
when {
g < 0x30 -> numberOfFrontends = 2
g < 0x09 -> g = 1
}
retval = subdomainFromGalleryID(g, numberOfFrontends) + retval
return retval
}

View File

@@ -80,6 +80,13 @@ class UnitTest {
print(reader)
}
@Test
fun test_getImages() {
val reader = getReader(1702206)
print(urlFromUrlFromHash(1702206, reader.galleryInfo.files.first(), "webp"))
}
@Test
fun test_hiyobi() {
val reader = xyz.quaver.hiyobi.getReader(1664762)