Add option to force e-hentai thumb server
This commit is contained in:
1 parent
d0ecac07aa
commit
b5b096aeae
5 files changed
+20
-6
No files matched your search
@@ -32,6 +32,7 @@ object Settings : DataStorePreferences(null) {
|
||||
var thumbResolution by intFromStrPref("thumb_resolution", 0)
|
||||
var readCacheSize by intFromStrPref("read_cache_size", 640)
|
||||
var launchPage by intFromStrPref("launch_page", 0)
|
||||
var forceEhThumb by boolPref("force_eh_thumb", false)
|
||||
var showComments by boolPref("show_gallery_comments", true)
|
||||
var requestNews by boolPref("request_news", false).observed { updateWhenRequestNewsChanges() }
|
||||
var hideHvEvents by boolPref("hide_hv_events", false)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.client
|
||||
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.GalleryPreview
|
||||
import com.hippo.ehviewer.client.data.NormalGalleryPreview
|
||||
@@ -26,21 +27,24 @@ import com.hippo.ehviewer.client.data.NormalGalleryPreview
|
||||
|
||||
private const val URL_PREFIX_THUMB_E = "https://ehgt.org/"
|
||||
private const val URL_PREFIX_THUMB_EX = "https://s.exhentai.org/"
|
||||
private const val URL_PREFIX_LARGE_THUMB_EX = URL_PREFIX_THUMB_EX + "t/"
|
||||
|
||||
fun getImageKey(gid: Long, index: Int): String {
|
||||
return "image:$gid:$index"
|
||||
}
|
||||
|
||||
fun getThumbKey(url: String): String {
|
||||
return url.removePrefix(URL_PREFIX_THUMB_E).removePrefix(URL_PREFIX_THUMB_EX).removePrefix("t/")
|
||||
return url.removePrefix(URL_PREFIX_THUMB_E).removePrefix(URL_PREFIX_LARGE_THUMB_EX).removePrefix(URL_PREFIX_THUMB_EX)
|
||||
}
|
||||
|
||||
val GalleryPreview.url
|
||||
get() = if (this is NormalGalleryPreview) {
|
||||
if (EhUtils.isExHentai) URL_PREFIX_THUMB_EX + imageKey else URL_PREFIX_THUMB_E + imageKey
|
||||
get() = if (exThumb) {
|
||||
if (this is NormalGalleryPreview) URL_PREFIX_THUMB_EX else URL_PREFIX_LARGE_THUMB_EX
|
||||
} else {
|
||||
if (EhUtils.isExHentai) URL_PREFIX_THUMB_EX + "t/" + imageKey else URL_PREFIX_THUMB_E + imageKey
|
||||
}
|
||||
URL_PREFIX_THUMB_E
|
||||
} + imageKey
|
||||
|
||||
val GalleryInfo.thumbUrl
|
||||
get() = if (EhUtils.isExHentai) URL_PREFIX_THUMB_EX + "t/" + thumbKey!! else URL_PREFIX_THUMB_E + thumbKey!!
|
||||
get() = (if (exThumb) URL_PREFIX_LARGE_THUMB_EX else URL_PREFIX_THUMB_E) + thumbKey!!
|
||||
|
||||
val exThumb get() = EhUtils.isExHentai && !Settings.forceEhThumb
|
||||
@@ -240,6 +240,11 @@ fun EhScreen() {
|
||||
entryValueRes = R.array.thumb_resolution_entry_values,
|
||||
value = thumbResolution,
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(id = R.string.settings_eh_force_eh_thumb),
|
||||
summary = stringResource(id = R.string.settings_eh_force_eh_thumb_summary),
|
||||
value = Settings::forceEhThumb,
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(id = R.string.settings_eh_show_gallery_pages),
|
||||
summary = stringResource(id = R.string.settings_eh_show_gallery_pages_summary),
|
||||
|
||||
@@ -321,6 +321,8 @@
|
||||
<string name="settings_eh_thumb_resolution">缩略图分辨率</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">%s,指定分辨率可能使获取缩略图失败</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">自动</string>
|
||||
<string name="settings_eh_force_eh_thumb">强制使用 e-hentai 缩略图服务器</string>
|
||||
<string name="settings_eh_force_eh_thumb_summary">若 exhentai 缩略图加载失败可尝试此项</string>
|
||||
<string name="settings_eh_show_jpn_title">显示日文标题</string>
|
||||
<string name="settings_eh_show_jpn_title_summary">需同时在 EHentai 网站设置中启用 Japanese Title</string>
|
||||
<string name="settings_eh_show_gallery_pages">显示画廊页数</string>
|
||||
|
||||
@@ -363,6 +363,8 @@
|
||||
<string name="settings_eh_thumb_resolution">Thumb resolution</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">Currently %s. Certain resolutions might cause getting thumb failed</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">Auto</string>
|
||||
<string name="settings_eh_force_eh_thumb">Force e-hentai thumb server</string>
|
||||
<string name="settings_eh_force_eh_thumb_summary">Try this if you have trouble loading thumbs from exhentai</string>
|
||||
<string name="settings_eh_show_jpn_title">Show Japanese title</string>
|
||||
<string name="settings_eh_show_jpn_title_summary">Require enabling Japanese Title in Settings on EHentai website</string>
|
||||
<string name="settings_eh_show_gallery_pages">Show gallery pages</string>
|
||||
|
||||
Reference in new issue
Block a user