From e9a1bf22b1e737b3938279c8c1062500001a3461 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:53:23 +0800 Subject: [PATCH] Tweak archive download and image limit reset --- .../com/hippo/ehviewer/client/EhEngine.kt | 14 +++------ .../ehviewer/client/exception/EhException.kt | 4 +++ .../exception/InsufficientFundsException.kt | 5 +++ .../ehviewer/client/parser/ArchiveParser.kt | 13 ++++++-- .../ehviewer/client/parser/HomeParser.kt | 11 +++---- .../ehviewer/ui/scene/GalleryDetailScene.kt | 31 ++++++++----------- .../hippo/ehviewer/ui/settings/EhScreen.kt | 11 ++++--- app/src/main/res/values-zh-rCN/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 10 files changed, 51 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/com/hippo/ehviewer/client/exception/InsufficientFundsException.kt diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt index f273ade05..570127a5a 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt @@ -35,7 +35,6 @@ import com.hippo.ehviewer.client.parser.GalleryPageApiParser import com.hippo.ehviewer.client.parser.GalleryPageParser import com.hippo.ehviewer.client.parser.GalleryTokenApiParser import com.hippo.ehviewer.client.parser.HomeParser -import com.hippo.ehviewer.client.parser.Limits import com.hippo.ehviewer.client.parser.ProfileParser import com.hippo.ehviewer.client.parser.RateGalleryResult import com.hippo.ehviewer.client.parser.SignInParser @@ -306,14 +305,11 @@ object EhEngine { return null } - suspend fun resetImageLimits(): Limits? { - return ehRequest(EhUrl.URL_HOME) { - formBody { - add("act", "limits") - add("reset", "Reset Limit") - } - }.executeAndParsingWith(HomeParser::parseResetLimits) - } + suspend fun resetImageLimits() = ehRequest(EhUrl.URL_HOME) { + formBody { + add("reset_imagelimit", "Reset Limit") + } + }.executeAndParsingWith(HomeParser::parseResetLimits) suspend fun modifyFavorites(url: String, gidArray: LongArray, dstCat: Int): FavoritesParser.Result { val catStr: String = when (dstCat) { diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt index fec2cbb93..7d5124fb9 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt @@ -15,7 +15,11 @@ */ package com.hippo.ehviewer.client.exception +import androidx.annotation.StringRes +import splitties.init.appCtx + open class EhException : Exception { constructor(detailMessage: String?) : super(detailMessage) constructor(detailMessage: String?, cause: Throwable?) : super(detailMessage, cause) + constructor(@StringRes message: Int) : super(appCtx.getString(message)) } diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/InsufficientFundsException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/InsufficientFundsException.kt new file mode 100644 index 000000000..fdc8b1fdb --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/InsufficientFundsException.kt @@ -0,0 +1,5 @@ +package com.hippo.ehviewer.client.exception + +import com.hippo.ehviewer.R + +class InsufficientFundsException : EhException(R.string.insufficient_funds) diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt index effed80a8..c195faa57 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt @@ -15,6 +15,7 @@ */ package com.hippo.ehviewer.client.parser +import com.hippo.ehviewer.client.exception.InsufficientFundsException import com.hippo.ehviewer.client.exception.NoHAtHClientException import org.jsoup.Jsoup @@ -27,8 +28,10 @@ object ArchiveParser { Regex("