Compare commits

...
5 Commits
Author SHA1 Message Date
tarsin d61df599e8 Release 1.8.6.1
Releases / Build (push) Has been cancelled
2023-02-18 10:38:33 +08:00
tarsin 989a0a01c1 Fix quicksearch progress 2023-02-18 10:37:57 +08:00
tarsin 12108645e9 Fix a stupid memleak 2023-02-18 10:37:45 +08:00
FooIbar 4910ec194d Fix search keyword in tag mode 2023-02-18 10:37:29 +08:00
FooIbar f730f43945 Fix comment last edited time parsing 2023-02-18 10:37:14 +08:00
5 changed files with 77 additions and 80 deletions

No files matched your search

+2 -2
View File
@@ -34,8 +34,8 @@ android {
applicationId = "moe.tarsin.ehviewer"
minSdk = 28
targetSdk = 33
versionCode = 180032
versionName = "1.8.6.0"
versionCode = 180033
versionName = "1.8.6.1"
resourceConfigurations.addAll(
listOf(
"zh",
@@ -376,15 +376,15 @@ object GalleryDetailParser {
}
// time
val c3 = JsoupUtils.getElementByClass(element, "c3")
var temp = c3!!.ownText()
if (temp.endsWith(':')) {
temp = temp.substring("Posted on ".length, temp.length - " by:".length)
val temp = c3!!.ownText()
val time = if (temp.endsWith(':')) {
// user
comment.user = c3.child(0).text()
temp.substring("Posted on ".length, temp.length - " by:".length)
} else {
temp = temp.substring("Posted on ".length)
temp.substring("Posted on ".length)
}
comment.time = Instant.from(WEB_COMMENT_DATE_FORMAT.parse(temp)).toEpochMilli()
comment.time = Instant.from(WEB_COMMENT_DATE_FORMAT.parse(time)).toEpochMilli()
// comment
val c6 = JsoupUtils.getElementByClass(element, "c6")
// fix underline support
@@ -407,7 +407,7 @@ object GalleryDetailParser {
val e = c8.children().first()
if (e != null) {
comment.lastEdited =
Instant.from(WEB_COMMENT_DATE_FORMAT.parse(temp)).toEpochMilli()
Instant.from(WEB_COMMENT_DATE_FORMAT.parse(e.text())).toEpochMilli()
}
}
comment
@@ -74,7 +74,9 @@ import com.hippo.ehviewer.client.EhRequest
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.client.data.GalleryInfo
import com.hippo.ehviewer.client.data.ListUrlBuilder
import com.hippo.ehviewer.client.data.ListUrlBuilder.Companion.MODE_NORMAL
import com.hippo.ehviewer.client.data.ListUrlBuilder.Companion.MODE_SUBSCRIPTION
import com.hippo.ehviewer.client.data.ListUrlBuilder.Companion.MODE_TAG
import com.hippo.ehviewer.client.data.ListUrlBuilder.Companion.MODE_TOPLIST
import com.hippo.ehviewer.client.data.ListUrlBuilder.Companion.MODE_WHATS_HOT
import com.hippo.ehviewer.client.exception.EhException
@@ -98,13 +100,14 @@ import com.hippo.widget.FabLayout
import com.hippo.widget.FabLayout.OnClickFabListener
import com.hippo.widget.FabLayout.OnExpandListener
import com.hippo.yorozuya.AnimationUtils
import com.hippo.yorozuya.MathUtils
import com.hippo.yorozuya.SimpleAnimatorListener
import com.hippo.yorozuya.StringUtils
import com.hippo.yorozuya.ViewUtils
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.lang.withUIContext
import kotlinx.coroutines.delay
import rikka.core.res.resolveColor
import java.io.File
import java.time.LocalDateTime
@@ -216,6 +219,13 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
else -> throw IllegalStateException("Wrong KEY_ACTION:${args?.getString(KEY_ACTION)} when handle args!")
}
val goto = args?.getString(KEY_GOTO)
goto?.let {
lifecycleScope.launchUI {
delay(100)
mHelper?.goTo(it, true)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -288,25 +298,6 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
})
}
private fun wrapTagKeyword(keyword: String?): String {
var keyword = keyword
keyword = keyword!!.trim { it <= ' ' }
val index1 = keyword.indexOf(':')
if (index1 == -1 || index1 >= keyword.length - 1) {
// Can't find :, or : is the last char
return keyword
}
if (keyword[index1 + 1] == '"') {
// The char after : is ", the word must be quoted
return keyword
}
val index2 = keyword.indexOf(' ')
return if (index2 <= index1) {
// Can't find space, or space is before :
keyword
} else keyword.substring(0, index1 + 1) + "\"" + keyword.substring(index1 + 1) + "$\""
}
// Update search bar title, drawer checked item
private fun onUpdateUrlBuilder() {
_binding ?: return
@@ -332,8 +323,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
// Update search edit text
if (!mIsTopList) {
if (mode == ListUrlBuilder.MODE_TAG) {
keyword = wrapTagKeyword(keyword)
if (mode == MODE_TAG) {
keyword = wrapTagKeyword(keyword!!)
}
setSearchBarText(keyword)
}
@@ -547,7 +538,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
qsDrawerAdapter.setHasStableIds(true)
drawerBinding.recyclerViewDrawer.adapter = qsDrawerAdapter
if (!mIsTopList) {
val itemTouchHelper = ItemTouchHelper(GalleryListQSItemTouchHelperCallback(qsDrawerAdapter))
val itemTouchHelper =
ItemTouchHelper(GalleryListQSItemTouchHelperCallback(qsDrawerAdapter))
itemTouchHelper.attachToRecyclerView(drawerBinding.recyclerViewDrawer)
drawerBinding.tip.visibility = View.VISIBLE
drawerBinding.recyclerViewDrawer.visibility = View.GONE
@@ -995,7 +987,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
val oldMode = mUrlBuilder.mode
// If it's MODE_SUBSCRIPTION, keep it
val newMode =
if (oldMode == MODE_SUBSCRIPTION) MODE_SUBSCRIPTION else ListUrlBuilder.MODE_NORMAL
if (oldMode == MODE_SUBSCRIPTION) MODE_SUBSCRIPTION else MODE_NORMAL
mUrlBuilder.reset()
mUrlBuilder.mode = newMode
mUrlBuilder.keyword = query
@@ -1155,8 +1147,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
val goto = if (i != -1) q.name!!.substring(i + 1) else null
val args = ListUrlBuilder().apply {
set(q)
setIndex(goto)
}.toStartArgs()
}.toStartArgs().apply { putString(KEY_GOTO, goto) }
navigate(R.id.galleryListScene, args, true)
setState(STATE_NORMAL)
closeDrawer(GravityCompat.END)
@@ -1431,6 +1422,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
companion object {
const val KEY_ACTION = "action"
const val KEY_GOTO = "goto"
const val ACTION_HOMEPAGE = "action_homepage"
const val ACTION_SUBSCRIPTION = "action_subscription"
const val ACTION_WHATS_HOT = "action_whats_hot"
@@ -1444,38 +1436,6 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
private const val STATE_SEARCH = 2
private const val STATE_SEARCH_SHOW_LIST = 3
private const val ANIMATE_TIME = 300L
private fun getSuitableTitleForUrlBuilder(
resources: Resources, urlBuilder: ListUrlBuilder, appName: Boolean
): String? {
val keyword = urlBuilder.keyword
val category = urlBuilder.category
return if (ListUrlBuilder.MODE_NORMAL == urlBuilder.mode && EhUtils.NONE == category &&
TextUtils.isEmpty(keyword) && urlBuilder.advanceSearch == -1 && urlBuilder.minRating == -1 && urlBuilder.pageFrom == -1 && urlBuilder.pageTo == -1
) {
resources.getString(if (appName) R.string.app_name else R.string.homepage)
} else if (MODE_SUBSCRIPTION == urlBuilder.mode && EhUtils.NONE == category &&
TextUtils.isEmpty(keyword) && urlBuilder.advanceSearch == -1 && urlBuilder.minRating == -1 && urlBuilder.pageFrom == -1 && urlBuilder.pageTo == -1
) {
resources.getString(R.string.subscription)
} else if (MODE_WHATS_HOT == urlBuilder.mode) {
resources.getString(R.string.whats_hot)
} else if (MODE_TOPLIST == urlBuilder.mode) {
when (urlBuilder.keyword) {
"11" -> resources.getString(R.string.toplist_alltime)
"12" -> resources.getString(R.string.toplist_pastyear)
"13" -> resources.getString(R.string.toplist_pastmonth)
"15" -> resources.getString(R.string.toplist_yesterday)
else -> null
}
} else if (!TextUtils.isEmpty(keyword)) {
keyword
} else if (MathUtils.hammingWeight(category) == 1) {
EhUtils.getCategory(category)
} else {
null
}
}
fun ListUrlBuilder.toStartArgs(): Bundle {
val args = Bundle()
args.putString(KEY_ACTION, ACTION_LIST_URL_BUILDER)
@@ -1484,3 +1444,39 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
}
}
}
private fun getSuitableTitleForUrlBuilder(
resources: Resources, urlBuilder: ListUrlBuilder, appName: Boolean
): String? {
val keyword = urlBuilder.keyword
val category = urlBuilder.category
val mode = urlBuilder.mode
return if (mode == MODE_WHATS_HOT) {
resources.getString(R.string.whats_hot)
} else if (!keyword.isNullOrEmpty()) {
when (mode) {
MODE_TOPLIST -> {
when (keyword) {
"11" -> resources.getString(R.string.toplist_alltime)
"12" -> resources.getString(R.string.toplist_pastyear)
"13" -> resources.getString(R.string.toplist_pastmonth)
"15" -> resources.getString(R.string.toplist_yesterday)
else -> null
}
}
MODE_TAG -> wrapTagKeyword(keyword)
else -> keyword
}
} else if (category == EhUtils.NONE && urlBuilder.advanceSearch == -1) {
when (mode) {
MODE_NORMAL -> resources.getString(if (appName) R.string.app_name else R.string.homepage)
MODE_SUBSCRIPTION -> resources.getString(R.string.subscription)
else -> null
}
} else if (category.countOneBits() == 1) {
EhUtils.getCategory(category)
} else {
null
}
}
@@ -127,6 +127,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
fun setSearchBarText(text: String?) {
binding.toolbar.text = text
binding.searchview.setText(text)
}
fun setEditTextHint(hint: String?) {
@@ -168,18 +169,6 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
mAllowEmptySearch = allowEmptySearch
}
private fun wrapTagKeyword(keyword: String): String {
return if (keyword.endsWith(':')) {
keyword
} else if (keyword.contains(' ')) {
val tag = keyword.substringAfter(':')
val prefix = keyword.dropLast(tag.length)
"$prefix\"$tag$\" "
} else {
"$keyword$ "
}
}
interface SuggestionProvider {
fun providerSuggestions(text: String): List<Suggestion>?
@@ -268,7 +257,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
edittext.let {
val keywords = it.text.toString().substringBeforeLast(' ', "")
val keyword = wrapTagKeyword(mKeyword)
val newKeywords = if (keywords.isNotEmpty()) "$keywords $keyword" else keyword
val newKeywords = if (keywords.isNotEmpty()) "$keywords $keyword " else "$keyword "
it.setText(newKeywords)
it.setSelection(newKeywords.length)
}
@@ -370,3 +359,15 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
}
}
}
fun wrapTagKeyword(keyword: String): String {
return if (keyword.endsWith(':')) {
keyword
} else if (keyword.contains(' ')) {
val tag = keyword.substringAfter(':')
val prefix = keyword.dropLast(tag.length)
"$prefix\"$tag$\""
} else {
"$keyword$"
}
}
+1 -1
View File
@@ -56,8 +56,8 @@ class Image private constructor(private val src: CloseableSource) {
(mObtainedDrawable as? AnimatedImageDrawable)?.stop()
(mObtainedDrawable as? BitmapDrawable)?.bitmap?.recycle()
mObtainedDrawable?.callback = null
mObtainedDrawable = null
(mObtainedDrawable as? AnimatedImageDrawable)?.let { src.close() }
mObtainedDrawable = null
}
companion object {