Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tom5079 committed Sep 8, 2020
1 parent 59347ab commit fe02abc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 34 deletions.
9 changes: 4 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ if (file("google-services.json").exists() && file("src/debug/google-services.jso
}

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "xyz.quaver.pupil"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 57
versionName "5.0-beta5"
versionName "5.0-beta6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -64,7 +64,6 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
//implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC"
implementation 'androidx.core:core:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.preference:preference:1.1.1'
Expand Down Expand Up @@ -97,7 +96,7 @@ dependencies {
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
//implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation "ru.noties.markwon:core:3.1.0"
implementation ("xyz.quaver:libpupil:1.4") {
implementation ("xyz.quaver:libpupil:1.5") {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-serialization-core-jvm'
}
implementation "xyz.quaver:documentfilex:0.2.14"
Expand Down
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"properties": [],
"versionCode": 57,
"versionName": "5.0-beta5",
"versionName": "5.0-beta6",
"enabled": true,
"outputFile": "app-release.apk"
}
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/java/xyz/quaver/pupil/adapters/ReaderAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ import xyz.quaver.Code
import xyz.quaver.hitomi.Reader
import xyz.quaver.hitomi.getReferer
import xyz.quaver.hitomi.imageUrlFromImage
import xyz.quaver.hiyobi.cookie
import xyz.quaver.hiyobi.createImgList
import xyz.quaver.hiyobi.user_agent
import xyz.quaver.io.util.readBytes
import xyz.quaver.pupil.R
import xyz.quaver.pupil.services.DownloadService
Expand Down Expand Up @@ -116,10 +114,7 @@ class ReaderAdapter(private val activity: ReaderActivity,
)
, LazyHeaders.Builder().addHeader("Referer", getReferer(galleryID)).build())
Code.HIYOBI ->
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path, LazyHeaders.Builder()
.addHeader("User-Agent", user_agent)
.addHeader("Cookie", cookie)
.build())
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path)
else -> null
}
holder.view.image.post {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ class DownloadService : Service() {
return@launch
}

if (progress.indexOfKey(galleryID) < 0)
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })

cache.metadata.imageList?.forEachIndexed { index, image ->
progress[galleryID]?.set(index, if (image != null) Float.POSITIVE_INFINITY else 0F)
Expand Down Expand Up @@ -390,6 +389,8 @@ class DownloadService : Service() {
COMMAND_DELETE -> intent.getIntExtra(KEY_ID, -1).let { if (it > 0) delete(it, startId) }
}

startForeground(R.id.downloader_notification_id, serviceNotification.build())

return START_NOT_STICKY
}

Expand All @@ -401,7 +402,6 @@ class DownloadService : Service() {
override fun onBind(p0: Intent?) = binder

override fun onCreate() {
startForeground(R.id.downloader_notification_id, serviceNotification.build())
interceptors[Tag::class] = interceptor
}

Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/xyz/quaver/pupil/util/GalleryList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ class GalleryList(private val file: File, private val list: MutableSet<Int> = mu
fun load() {
synchronized(this) {
list.clear()
list.addAll(
kotlin.runCatching {
Json.decodeFromString<List<Int>>(file.bufferedReader().use { it.readText() })
)
}.onSuccess {
list.addAll(it)
}
}
}

fun save() {
synchronized(this) {
file.writeText(Json.encodeToString(list))
file.writeText(Json.encodeToString(list.toList()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ import xyz.quaver.Code
import xyz.quaver.hitomi.Reader
import xyz.quaver.hitomi.getReferer
import xyz.quaver.hitomi.imageUrlFromImage
import xyz.quaver.hiyobi.cookie
import xyz.quaver.hiyobi.createImgList
import xyz.quaver.hiyobi.user_agent
import xyz.quaver.pupil.R
import xyz.quaver.pupil.client
import xyz.quaver.pupil.interceptors
Expand Down Expand Up @@ -220,8 +218,6 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
}
Code.HIYOBI -> {
url(createImgList(galleryID, reader, lowQuality)[index].path)
addHeader("User-Agent", user_agent)
addHeader("Cookie", cookie)
}
else -> {
//shouldn't be called anyway
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/xyz/quaver/pupil/util/misc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,14 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import okhttp3.OkHttpClient
import okhttp3.Request
import xyz.quaver.Code
import xyz.quaver.hitomi.GalleryBlock
import xyz.quaver.hitomi.Reader
import xyz.quaver.hitomi.getReferer
import xyz.quaver.hitomi.imageUrlFromImage
import xyz.quaver.hiyobi.cookie
import xyz.quaver.hiyobi.createImgList
import xyz.quaver.hiyobi.user_agent
import xyz.quaver.pupil.util.downloader.Cache
import xyz.quaver.pupil.util.downloader.Metadata
import java.util.*
import kotlin.collections.ArrayList

Expand Down Expand Up @@ -134,8 +125,6 @@ val Reader.requestBuilders: List<Request.Builder>
createImgList(galleryID, this, lowQuality).map {
Request.Builder()
.url(it.path)
.header("User-Agent", user_agent)
.header("Cookie", cookie)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/xyz/quaver/pupil/util/update.kt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
.mActions.clear()
notificationManager.notify(R.id.notification_id_import, notification.build())

unregisterReceiver(receiver)
kotlin.runCatching {
unregisterReceiver(receiver)
}
}
}

0 comments on commit fe02abc

Please sign in to comment.