Compare commits

...
14 Commits
21 changed files with 235 additions and 204 deletions

No files matched your search

-6
View File
@@ -1,9 +1,3 @@
[submodule "app/src/main/cpp/libarchive"]
path = app/src/main/cpp/libarchive
url = https://github.com/Ehviewer-Overhauled/libarchive
[submodule "app/src/main/cpp/liblzma"]
path = app/src/main/cpp/liblzma
url = https://github.com/Ehviewer-Overhauled/xz
[submodule "app/src/main/cpp/nettle/nettle"]
path = app/src/main/cpp/nettle/nettle
url = https://github.com/Ehviewer-Overhauled/nettle
+3 -3
View File
@@ -53,8 +53,8 @@ android {
applicationId = "moe.tarsin.ehviewer"
minSdk = 28
targetSdk = 33
versionCode = 180034
versionName = "1.8.7.0-alpha"
versionCode = 180035
versionName = "1.8.7.0"
resourceConfigurations.addAll(
listOf(
"zh",
@@ -211,7 +211,7 @@ dependencies {
implementation("io.coil-kt:coil-compose:2.2.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.5.0-RC")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.5.0")
implementation("org.jsoup:jsoup:1.15.4")
}
@@ -0,0 +1,34 @@
From fc9fb0ea245259e346ab46c334f03b557fe63b6b Mon Sep 17 00:00:00 2001
From: tarsin <yuanqingxiang233@163.com>
Date: Tue, 22 Nov 2022 12:37:12 +0800
Subject: [PATCH] Don't build other binarys
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 01c73cd..b461e68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -592,7 +592,7 @@ check_symbol_exists(getopt_long getopt.h HAVE_GETOPT_LONG)
# xzdec
#############################################################################
-if(HAVE_GETOPT_LONG)
+if(0)
add_executable(xzdec
src/common/sysdefs.h
src/common/tuklib_common.h
@@ -630,7 +630,7 @@ endif()
# xz
#############################################################################
-if(NOT MSVC AND HAVE_GETOPT_LONG)
+if(0)
add_executable(xz
src/common/mythread.h
src/common/sysdefs.h
--
2.39.2
@@ -0,0 +1,38 @@
From 2a67861e6f06794f3671c4988bac12330d8422e3 Mon Sep 17 00:00:00 2001
From: tarsin <yuanqingxiang233@163.com>
Date: Fri, 27 May 2022 23:21:20 +0800
Subject: [PATCH 1/2] Don't build shared lib
---
libarchive/CMakeLists.txt | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt
index ff7ade00..00c2e170 100644
--- a/libarchive/CMakeLists.txt
+++ b/libarchive/CMakeLists.txt
@@ -242,12 +242,6 @@ ELSEIF(ARCHIVE_ACL_SUNOS)
LIST(APPEND libarchive_SOURCES archive_disk_acl_sunos.c)
ENDIF()
-# Libarchive is a shared library
-ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS})
-TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .)
-TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS})
-SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
-
# archive_static is a static library
ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS})
@@ -260,7 +254,7 @@ ENDIF(NOT WIN32 OR CYGWIN)
IF(ENABLE_INSTALL)
# How to install the libraries
- INSTALL(TARGETS archive archive_static
+ INSTALL(TARGETS archive_static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
--
2.39.2
@@ -0,0 +1,25 @@
From c9298fd6dc0a8b04dd4b2247118b9cb895c46e58 Mon Sep 17 00:00:00 2001
From: tarsin <yuanqingxiang233@163.com>
Date: Sat, 23 Jul 2022 16:05:36 +0800
Subject: [PATCH 2/2] Insert link libs
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 713e3bc5..7247640d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -415,7 +415,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
# # endif
ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
-SET(ADDITIONAL_LIBS "")
+SET(ADDITIONAL_LIBS ${LIBARCHIVE_CUSTOM_LIBS})
#
# Find ZLIB
#
--
2.39.2
+29 -12
View File
@@ -1,7 +1,9 @@
project(ehviewer)
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.14)
project(ehviewer C)
include(FetchContent)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -funroll-loops -flto=thin \
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -fvisibility=hidden -fvisibility-inlines-hidden -funroll-loops -flto=thin \
-mllvm -polly \
-mllvm -polly-run-dce \
-mllvm -polly-run-inliner \
@@ -12,6 +14,20 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -fvisibility=hidden -fvisibility-inli
-mllvm -polly-vectorizer=stripmine \
-mllvm -polly-detect-profitability-min-per-loop-insts=40 \
-mllvm -polly-invariant-load-hoisting")
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Change the default path of fetch content to avoid downloading the same dependencies per architecture
get_filename_component(deps "../_deps" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
set(FETCHCONTENT_BASE_DIR ${deps})
FetchContent_Declare(liblzma
GIT_REPOSITORY https://git.tukaani.org/xz.git
GIT_TAG v5.4.1
PATCH_COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/0001-Don-t-build-other-binarys.patch || true
)
FetchContent_MakeAvailable(liblzma)
include_directories(${liblzma_SOURCE_DIR}/src/liblzma/api)
# Build GNUTLS libnettle
add_subdirectory(nettle)
@@ -27,11 +43,7 @@ set(HAVE_NETTLE_PBKDF2_H 1)
set(HAVE_NETTLE_RIPEMD160_H 1)
set(HAVE_NETTLE_SHA_H 1)
# Build liblzma
add_subdirectory(liblzma)
# Configure lzma support for libarchive
include_directories(liblzma/src/liblzma/api)
SET(HAVE_LIBLZMA 1)
SET(HAVE_LZMA_H 1)
SET(HAVE_LZMA_STREAM_ENCODER_MT 1)
@@ -39,12 +51,17 @@ SET(HAVE_LZMADEC_H 1)
SET(HAVE_LIBLZMADEC 1)
# Configure libarchive link's static lib
SET(LIBARCHIVE_CUSTOM_LIBS "liblzma" "nettle")
SET(LIBARCHIVE_CUSTOM_LIBS "nettle" "liblzma")
# Build libarchive
add_subdirectory(libarchive)
FetchContent_Declare(libarchive
GIT_REPOSITORY https://github.com/libarchive/libarchive
GIT_TAG v3.6.2
PATCH_COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/0001-Don-t-build-shared-lib.patch ${CMAKE_CURRENT_LIST_DIR}/0002-Insert-link-libs.patch || true
)
FetchContent_MakeAvailable(libarchive)
include_directories(${libarchive_SOURCE_DIR}/libarchive)
# Build and link our app's native lib
add_library(${PROJECT_NAME} SHARED archive.c fdutils.c gifutils.c natsort/strnatcmp.c)
target_include_directories(${PROJECT_NAME} PUBLIC libarchive/libarchive)
target_link_libraries(${PROJECT_NAME} archive_static log -Wl,--gc-sections)
target_link_libraries(${PROJECT_NAME} archive_static log)
@@ -27,6 +27,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.util.DebugLogger
import com.hippo.Native
import com.hippo.ehviewer.client.EhCookieStore
import com.hippo.ehviewer.client.EhDns
@@ -186,6 +187,7 @@ class EhApplication : Application(), DefaultLifecycleObserver, ImageLoaderFactor
okHttpClient(okHttpClient)
components { add(MergeInterceptor) }
crossfade(300)
if (BuildConfig.DEBUG) logger(DebugLogger())
}.build()
}
@@ -15,7 +15,8 @@ import kotlin.coroutines.Continuation
import kotlin.coroutines.resume
object MergeInterceptor : Interceptor {
private val pendingContinuationMap: HashMap<String, MutableList<Continuation<Unit>>> = hashMapOf()
private val pendingContinuationMap: HashMap<String, MutableList<Continuation<Unit>>> =
hashMapOf()
private val pendingContinuationMapLock = Mutex()
private val notifyScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
override suspend fun intercept(chain: Interceptor.Chain): ImageResult {
@@ -23,18 +24,8 @@ object MergeInterceptor : Interceptor {
val originListener = originRequest.listener
val key = originRequest.data as String
val newRequest = ImageRequest.Builder(originRequest).listener(
{ originListener?.onStart(it) },
{
originListener?.onCancel(it)
notifyScope.launch {
pendingContinuationMapLock.withLock {
// Wake up a pending continuation to continue executing task
val successor = pendingContinuationMap[key]?.removeFirstOrNull()?.apply { resume(Unit) }
// If no successor, delete this entry from hashmap
successor ?: pendingContinuationMap.remove(key)
}
}
},
{},
{}, // Only original request's onStart and onCancel will get called
{ request, result ->
originListener?.onError(request, result)
// Wake all pending continuations since this request is to be failed
@@ -72,4 +63,16 @@ object MergeInterceptor : Interceptor {
return withContext(originRequest.interceptorDispatcher) { chain.proceed(newRequest) }
}
fun onCancel(key: String) {
notifyScope.launch {
pendingContinuationMapLock.withLock {
// Wake up a pending continuation to continue executing task
val successor =
pendingContinuationMap[key]?.removeFirstOrNull()?.apply { resume(Unit) }
// If no successor, delete this entry from hashmap
successor ?: pendingContinuationMap.remove(key)
}
}
}
}
@@ -648,7 +648,8 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
val tag = inflater.inflate(R.layout.item_gallery_tag, awl, false) as TextView
awl.addView(tag)
val tagStr = if (it.startsWith('_')) {
tag.alpha = 0.5f
val alpha = ColorUtils.setAlphaComponent(tag.currentTextColor, 128)
tag.setTextColor(alpha)
it.substring(1)
} else {
it
@@ -10,14 +10,16 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import com.hippo.ehviewer.R
import kotlin.math.ceil
private val colorYellow800 = Color(0xfff9a825)
@Composable
fun SimpleRatingWidget(rating: Float) {
val r = (rating * 2).toInt().coerceAtLeast(0).coerceAtMost(10)
val fullStar = r.floorDiv(2)
val r = ceil(rating * 2).toInt().coerceIn(0, 10)
val fullStar = r / 2
val halfStar = r % 2
val outlineStar = 5 - fullStar - halfStar
val colorYellow800 = Color(0xfff9a825)
Row {
repeat(fullStar) {
Icon(
@@ -1,115 +0,0 @@
/*
* Copyright (C) 2015 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.widget;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import androidx.core.content.ContextCompat;
import com.hippo.ehviewer.R;
import com.hippo.yorozuya.MathUtils;
/**
* 5 stars, from 0 to 10
*/
public class SimpleRatingView extends View {
private Drawable mStarDrawable;
private Drawable mStarHalfDrawable;
private Drawable mStarOutlineDrawable;
private int mRatingSize;
private int mRatingInterval;
private float mRating;
private int mRatingInt;
public SimpleRatingView(Context context) {
super(context);
init(context);
}
public SimpleRatingView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SimpleRatingView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
Resources resources = context.getResources();
mStarDrawable = ContextCompat.getDrawable(context, R.drawable.v_star_x16);
mStarHalfDrawable = ContextCompat.getDrawable(context, R.drawable.v_star_half_x16);
mStarOutlineDrawable = ContextCompat.getDrawable(context, R.drawable.v_star_outline_x16);
mRatingSize = resources.getDimensionPixelOffset(R.dimen.rating_size);
mRatingInterval = resources.getDimensionPixelOffset(R.dimen.rating_interval);
mStarDrawable.setBounds(0, 0, mRatingSize, mRatingSize);
mStarHalfDrawable.setBounds(0, 0, mRatingSize, mRatingSize);
mStarOutlineDrawable.setBounds(0, 0, mRatingSize, mRatingSize);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(mRatingSize * 5 + mRatingInterval * 4, mRatingSize);
}
@Override
protected void onDraw(Canvas canvas) {
int ratingInt = mRatingInt;
int step = mRatingSize + mRatingInterval;
int numStar = ratingInt / 2;
int numStarHalf = ratingInt % 2;
int saved = canvas.save();
while (numStar-- > 0) {
mStarDrawable.draw(canvas);
canvas.translate(step, 0);
}
if (numStarHalf == 1) {
mStarHalfDrawable.draw(canvas);
canvas.translate(step, 0);
}
int numOutline = 5 - numStar - numStarHalf;
while (numOutline-- > 0) {
mStarOutlineDrawable.draw(canvas);
canvas.translate(step, 0);
}
canvas.restoreToCount(saved);
}
public float getRating() {
return mRating;
}
public void setRating(float rating) {
if (mRating != rating) {
mRating = rating;
int ratingInt = MathUtils.clamp((int) Math.ceil(rating * 2), 0, 10);
if (mRatingInt != ratingInt) {
mRatingInt = ratingInt;
invalidate();
}
}
}
}
@@ -0,0 +1,26 @@
package com.hippo.ehviewer.widget
import android.content.Context
import android.util.AttributeSet
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.AbstractComposeView
import com.google.accompanist.themeadapter.material3.Mdc3Theme
import com.hippo.ehviewer.ui.widget.SimpleRatingWidget
class SimpleRatingView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0,
) : AbstractComposeView(context, attrs, defStyle) {
var rating by mutableStateOf(0f)
@Composable
override fun Content() {
Mdc3Theme {
SimpleRatingWidget(rating)
}
}
}
@@ -27,6 +27,7 @@ import coil.size.Size
import com.hippo.drawable.PreciselyClipDrawable
import com.hippo.ehviewer.EhApplication
import com.hippo.ehviewer.R
import com.hippo.ehviewer.coil.MergeInterceptor
private val application = EhApplication.application
private val errorDrawable = AppCompatResources.getDrawable(application, R.drawable.image_failed)
@@ -84,7 +85,10 @@ open class LoadImageView @JvmOverloads constructor(
if (!crossfade) crossfade(false)
listener(
{ setRetry(false) },
{ setRetry(true) },
{
MergeInterceptor.onCancel(url)
setRetry(true)
},
{ _, _ ->
super.setImageDrawable(errorDrawable)
setRetry(true)
@@ -102,7 +106,8 @@ open class LoadImageView @JvmOverloads constructor(
var newDrawable = drawable
if (newDrawable != null) {
if (Integer.MIN_VALUE != mOffsetX) {
newDrawable = PreciselyClipDrawable(newDrawable, mOffsetX, mOffsetY, mClipWidth, mClipHeight)
newDrawable =
PreciselyClipDrawable(newDrawable, mOffsetX, mOffsetY, mClipWidth, mClipHeight)
}
onPreSetImageDrawable(newDrawable, true)
}
@@ -85,7 +85,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.lang.withUIContext
import eu.kanade.tachiyomi.util.system.applySystemAnimatorScale
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
@@ -162,7 +161,6 @@ class ReaderActivity : EhActivity() {
}
}
var mGalleryProvider: PageLoader2? = null
private var mSize: Int = 0
private var mCurrentIndex: Int = 0
private var mSavingPage = -1
private lateinit var builder: EditTextDialogBuilder
@@ -192,9 +190,9 @@ class ReaderActivity : EhActivity() {
return EhUrl.getGalleryDetailUrl(gid, token, 0, false)
}
private fun buildProvider() {
private fun buildProvider(replace: Boolean = false) {
if (mGalleryProvider != null) {
return
if (replace) mGalleryProvider!!.stop() else return
}
if (ACTION_EH == mAction) {
@@ -250,13 +248,17 @@ class ReaderActivity : EhActivity() {
}
}
private fun onInit() {
val intent = intent ?: return
private fun handleIntent(intent: Intent?) {
intent ?: return
mAction = intent.action
mFilename = intent.getStringExtra(KEY_FILENAME)
mUri = intent.data
mGalleryInfo = intent.getParcelableExtraCompat(KEY_GALLERY_INFO)
mPage = intent.getIntExtra(KEY_PAGE, -1)
}
private fun onInit() {
handleIntent(intent)
buildProvider()
}
@@ -270,6 +272,21 @@ class ReaderActivity : EhActivity() {
buildProvider()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
handleIntent(intent)
buildProvider(true)
mGalleryProvider?.let {
lifecycleScope.launchIO {
it.start()
if (it.awaitReady()) withUIContext {
viewer?.setGalleryProvider(it)
moveToPageIndex(0)
}
}
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(KEY_ACTION, mAction)
@@ -299,10 +316,6 @@ class ReaderActivity : EhActivity() {
builder.setPositiveButton(getString(android.R.string.ok), null)
dialog = builder.create()
dialog.setCanceledOnTouchOutside(false)
if (mGalleryProvider == null) {
finish()
return
}
mGalleryProvider.let {
if (it == null) {
@@ -325,9 +338,10 @@ class ReaderActivity : EhActivity() {
dialog.dismiss()
// Get start page
if (mCurrentIndex == 0) mCurrentIndex = if (mPage >= 0) mPage else mGalleryProvider!!.startPage
mSize = mGalleryProvider!!.size
val viewerMode = ReadingModeType.fromPreference(readerPreferences.defaultReadingMode().get())
if (mCurrentIndex == 0)
mCurrentIndex = if (mPage >= 0) mPage else mGalleryProvider!!.startPage
val viewerMode =
ReadingModeType.fromPreference(readerPreferences.defaultReadingMode().get())
binding.actionReadingMode.setImageResource(viewerMode.iconRes)
viewer?.destroy()
viewer = ReadingModeType.toViewer(readerPreferences.defaultReadingMode().get(), this)
@@ -47,7 +47,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
/**
* Currently active item. It can be a chapter page or a chapter transition.
*/
private var currentPage: Any? = null
private var currentPage: ReaderPage? = null
/**
* Viewer chapters to set when the pager enters idle mode. Otherwise, if the view was settling
@@ -153,27 +153,14 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
.firstOrNull { it.item == page }
/**
* Called when a new page (either a [ReaderPage] or [ChapterTransition]) is marked as active
* Called when a new [ReaderPage] is marked as active
*/
private fun onPageChange(position: Int) {
val page = adapter.items.getOrNull(position)
if (page != null && currentPage != page) {
val forward = when {
currentPage is ReaderPage && page is ReaderPage -> {
// if both pages have the same number, it's a split page with an InsertPage
if (page.number == (currentPage as ReaderPage).number) {
// the InsertPage is always the second in the reading direction
false
} else {
page.number > (currentPage as ReaderPage).number
}
}
else -> true
}
val forward = page.number > (currentPage?.number ?: 0)
currentPage = page
when (page) {
is ReaderPage -> onReaderPageSelected(page, forward)
}
onReaderPageSelected(page, forward)
}
}
@@ -206,6 +193,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
private fun setChaptersInternal(chapters: PageLoader) {
logcat { "setChaptersInternal" }
adapter.setChapters(chapters)
refreshAdapter(0)
// Layout the pager once a chapter is being set
if (pager.isGone) {
@@ -251,7 +239,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
*/
protected open fun moveRight() {
if (pager.currentItem != adapter.count - 1) {
val holder = (currentPage as? ReaderPage)?.let { getPageHolder(it) }
val holder = currentPage?.let { getPageHolder(it) }
if (holder != null && config.navigateToPan && holder.canPanRight()) {
holder.panRight()
} else {
@@ -265,7 +253,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
*/
protected open fun moveLeft() {
if (pager.currentItem != 0) {
val holder = (currentPage as? ReaderPage)?.let { getPageHolder(it) }
val holder = currentPage?.let { getPageHolder(it) }
if (holder != null && config.navigateToPan && holder.canPanLeft()) {
holder.panLeft()
} else {
@@ -292,8 +280,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
* Resets the adapter in order to recreate all the views. Used when a image configuration is
* changed.
*/
private fun refreshAdapter() {
val currentItem = pager.currentItem
private fun refreshAdapter(currentItem: Int = pager.currentItem) {
adapter.refresh()
pager.adapter = adapter
pager.setCurrentItem(currentItem, false)
@@ -318,6 +305,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
if (!config.volumeKeysInverted) moveDown() else moveUp()
}
}
KeyEvent.KEYCODE_VOLUME_UP -> {
if (!config.volumeKeysEnabled || activity.menuVisible) {
return false
@@ -325,16 +313,19 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
if (!config.volumeKeysInverted) moveUp() else moveDown()
}
}
KeyEvent.KEYCODE_DPAD_RIGHT -> {
if (isUp) {
if (ctrlPressed) moveToNext() else moveRight()
}
}
KeyEvent.KEYCODE_DPAD_LEFT -> {
if (isUp) {
if (ctrlPressed) moveToPrevious() else moveLeft()
}
}
KeyEvent.KEYCODE_DPAD_DOWN -> if (isUp) moveDown()
KeyEvent.KEYCODE_DPAD_UP -> if (isUp) moveUp()
KeyEvent.KEYCODE_PAGE_DOWN -> if (isUp) moveDown()
@@ -39,8 +39,6 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
if (viewer is R2LPagerViewer) {
items = items.asReversed()
}
notifyDataSetChanged()
}
/**
@@ -60,7 +58,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
}
override fun destroyView(container: ViewGroup, position: Int, view: View) {
val item = items[position]
val item = (view as PagerPageHolder).item
currentChapter?.cancelRequest(item.index)
}
@@ -155,6 +155,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
*/
override fun setGalleryProvider(provider: PageLoader) {
adapter.setChapters(provider)
refreshAdapter(0)
if (recycler.isGone) {
logcat { "Recycler first layout" }
@@ -181,9 +182,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
val item = adapter.items.getOrNull(position)
if (item != null && currentPage != item) {
currentPage = item
when (item) {
is ReaderPage -> onPageSelected(item)
}
onPageSelected(item)
}
}
@@ -265,8 +264,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
* Notifies adapter of changes around the current page to trigger a relayout in the recycler.
* Used when an image configuration is changed.
*/
private fun refreshAdapter() {
val position = layoutManager.findLastEndVisibleItemPosition()
private fun refreshAdapter(position: Int = layoutManager.findLastEndVisibleItemPosition()) {
val positionStart = maxOf(0, position - 3)
val positionEnd = minOf(position + 3, adapter.itemCount - 1)
adapter.refresh()
@@ -15,6 +15,7 @@ import android.net.wifi.WifiManager
import android.os.Build
import android.os.PowerManager
import android.provider.Settings
import android.util.Log
import android.util.TypedValue
import android.view.Display
import android.view.View
@@ -255,7 +256,6 @@ fun Context.createReaderThemeContext(): Context {
TODO()
}
fun logcat(block: () -> String) {
return
TODO()
inline fun Any.logcat(priority: Int = Log.DEBUG, tag: String? = null, message: () -> String) {
Log.println(priority, tag ?: javaClass.simpleName, message())
}
@@ -33,9 +33,9 @@
android:layout_marginTop="2dp"
android:lines="1" />
<com.hippo.ehviewer.widget.SimpleRatingView
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/rating_size"
android:layout_marginTop="2dp" />
<TextView