1
0
mirror of https://github.com/fumiama/copymanga.git synced 2026-06-06 07:50:23 +08:00

v2.0.beta19

fix #25
修复
1. 阅览漫画导航栏异常
2. 下载页滚动异常
3. 竖向阅读加载时间过长
4. 获取图书信息有时失败(fix #26)
This commit is contained in:
源文雨
2023-09-05 14:40:35 +08:00
parent 49b3f7a1c7
commit 0e5547d586
14 changed files with 69 additions and 31 deletions

View File

@@ -3,19 +3,22 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 33
defaultConfig {
compileSdk 33
applicationId 'top.fumiama.copymanga'
minSdkVersion 23
targetSdkVersion 33
versionCode 30
versionName '2.0.beta18'
versionCode 31
versionName '2.0.beta19'
resConfigs 'zh', 'zh-rCN'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
aaptOptions {
cruncherEnabled = false
}
buildTypes {
release {
minifyEnabled true

View File

@@ -43,7 +43,7 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<activity
android:name="top.fumiama.copymanga.ui.vm.ViewMangaActivity"
android:theme="@style/AppTheme.Default"/>
android:theme="@style/AppTheme.NoActionBar"/>
</application>
</manifest>

View File

@@ -13,7 +13,7 @@ class AutoDownloadThread(private val url: String, private val whenFinish: (resul
var c = 0
while (!exit && re == null && c++ < 3){
re = DownloadTools.getHttpContent(url,
mainWeakReference?.get()?.getString(R.string.referUrl)!!.format(CMApi.myHostApiUrl),
mainWeakReference?.get()?.getString(R.string.referer)!!,
mainWeakReference?.get()?.getString(R.string.pc_ua)!!
)
}

View File

@@ -11,17 +11,18 @@ import java.io.File
import java.net.URLEncoder
object CMApi {
var proxy = if(Proxy.useProxy) Proxy() else null
var proxy = if(Proxy.useImageProxy) Proxy(R.string.imgProxyApiUrl, R.string.imgProxyApiPrefix, R.string.imgProxyKeyID) else null
var myGlideHeaders: LazyHeaders? = null
get() {
MainActivity.mainWeakReference?.get()?.let {
PreferenceManager.getDefaultSharedPreferences(it).apply {
if(field === null)
field = LazyHeaders.Builder()
.addHeader("referer", MainActivity.mainWeakReference?.get()?.getString(R.string.referUrl)!!)
.addHeader("referer", MainActivity.mainWeakReference?.get()?.getString(R.string.referer)!!)
.addHeader("User-Agent", MainActivity.mainWeakReference?.get()?.getString(R.string.pc_ua)!!)
.addHeader("source", "copyApp")
.addHeader("webp", "1")
.addHeader("version", MainActivity.mainWeakReference?.get()?.getString(R.string.app_ver)!!)
.addHeader("region", if(!getBoolean("settings_cat_net", false)) "1" else "0")
.addHeader("platform", "3")
.build()

View File

@@ -4,6 +4,7 @@ import android.content.Context
import android.util.Log
import androidx.preference.PreferenceManager
import top.fumiama.copymanga.MainActivity
import top.fumiama.dmzj.copymanga.R
import java.net.HttpURLConnection
import java.net.URL
import java.util.concurrent.Callable
@@ -27,10 +28,9 @@ object DownloadTools {
setRequestProperty("region", if(!getBoolean("settings_cat_net_sw_use_foreign", false)) "1" else "0")
}
it.getPreferences(Context.MODE_PRIVATE).apply {
setRequestProperty("version", getString("app_ver", "2.0.7"))
getString("token", "")?.let {
if(it != "") setRequestProperty("authorization", "Token $it")
else setRequestProperty("authorization", "Token ")
setRequestProperty("version", it.getString(R.string.app_ver))
getString("token", "")?.let { tk ->
setRequestProperty("authorization", "Token $tk")
}
}
}

View File

@@ -3,32 +3,44 @@ package top.fumiama.copymanga.tools.http
import android.util.Log
import androidx.preference.PreferenceManager
import top.fumiama.copymanga.MainActivity
import top.fumiama.dmzj.copymanga.R
import java.net.URLEncoder
import java.nio.charset.Charset
class Proxy(private val code: String) {
constructor(): this(
class Proxy(id: Int, apiPrefixID: Int, keyID: Int? = null) {
private val code = keyID?.let { k ->
MainActivity.mainWeakReference?.get()?.let {
PreferenceManager.getDefaultSharedPreferences(it).let {sp ->
sp.getString("settings_cat_net_et_img_proxy_code", "")
}
}?:""
)
PreferenceManager.getDefaultSharedPreferences(it).getString(it.getString(k), null)
}
}
private val proxyApiUrl = MainActivity.mainWeakReference?.get()?.getString(id)
private val apiPrefix = MainActivity.mainWeakReference?.get()?.getString(apiPrefixID)?:"<no prefix>"
fun wrap(u: String): String {
return MainActivity.mainWeakReference?.get()?.getString(R.string.imgProxyApiUrl)
?.format(code, URLEncoder.encode(u, Charset.defaultCharset().name()))
?:u
if(!u.startsWith(apiPrefix)) return u
if(code != null) {
return proxyApiUrl?.format(code, URLEncoder.encode(u, Charset.defaultCharset().name()))?:u
}
return proxyApiUrl?.format(URLEncoder.encode(u, Charset.defaultCharset().name()))?:u
}
companion object {
val useProxy: Boolean
val useImageProxy: Boolean
get() {
MainActivity.mainWeakReference?.get()?.let {
PreferenceManager.getDefaultSharedPreferences(it).apply {
val b = getBoolean("settings_cat_net_sw_use_img_proxy", false)
Log.d("MyProxy", "use proxy: $b")
Log.d("MyProxy", "use image proxy: $b")
return b
}
}
return false
}
val useApiProxy: Boolean
get() {
MainActivity.mainWeakReference?.get()?.let {
PreferenceManager.getDefaultSharedPreferences(it).apply {
val b = getBoolean("settings_cat_net_sw_use_api_proxy", false)
Log.d("MyProxy", "use api proxy: $b")
return b
}
}

View File

@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.line_booktandb.*
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.manga.Reader
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
import top.fumiama.dmzj.copymanga.R
import java.lang.Thread.sleep
import java.lang.ref.WeakReference
@@ -19,6 +20,8 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
ComicDlFragment.exit = false
if(isFirstInflate) {
bookHandler = BookHandler(WeakReference(this), arguments?.getString("path")?:"null")
Thread{

View File

@@ -316,6 +316,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
ads += ad
ad.start()
offset += 100
sleep(1000)
}
} while (counts[i] > 0)
Thread {
@@ -325,7 +326,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
if(ComicDlFragment.exit) return@Thread
if(re.all { it != null }) break
}
if(re.size > 1) {
if(re.isNotEmpty()) {
val r = re[0]
var s = emptyArray<ChapterStructure>()
re.forEach {

View File

@@ -87,11 +87,11 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
val types = arrayOf("", "name", "author", "local")
var i = 0
override fun onMicClick() {
val typenames = resources.getStringArray(R.array.search_types)
val typeNames = resources.getStringArray(R.array.search_types)
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AlertDialogTheme))
.setTitle(R.string.set_search_types)
.setIcon(R.mipmap.ic_launcher)
.setSingleChoiceItems(ArrayAdapter(context, R.layout.line_choice_list, typenames), i){ d, p ->
.setSingleChoiceItems(ArrayAdapter(context, R.layout.line_choice_list, typeNames), i){ d, p ->
adapter.type = types[p]
i = p
d.cancel()

View File

@@ -196,6 +196,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
private fun doPrepareWebImg() {
getImgUrlArray()?.apply {
if(cut) {
Log.d("MyVM", "is cut, load all pages...")
handler.sendEmptyMessage(7) //showDl
isCut = BooleanArray(size)
val analyzedCnt = BooleanArray(size)
@@ -217,6 +218,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
if(b) indexMap += -(index+1)
}
handler.sendEmptyMessage(15) //hideDl
Log.d("MyVM", "load all pages finished")
}
count = size
runOnUiThread { prepareItems() }
@@ -347,7 +349,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
private fun loadImgUrlInto(imgView: ScaleImageView, url: String, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
Log.d("MyVM", "Load from adt: $url")
AutoDownloadThread(url) {
AutoDownloadThread(CMApi.proxy?.wrap(url)?:url) {
it?.let { loadImg(imgView, BitmapFactory.decodeByteArray(it, 0, it.size), isLast, useCut, isLeft) }
}.start()
}

View File

@@ -3,4 +3,4 @@
android:id="@+id/mylv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/global_content_padding_bottom"/>
android:nestedScrollingEnabled="true" />

View File

@@ -57,6 +57,12 @@
<string name="historyApiUrl">https://%1$s/api/v3/member/browse/comics?limit=21&amp;offset=%2$d&amp;platform=3</string>
<string name="imgProxyApiUrl">https://copymanga.azurewebsites.net/api/img?code=%1$s&amp;url=%2$s</string>
<string name="imgProxyApiPrefix">https://hi77-overseas.mangafuna.xyz/</string>
<string name="imgProxyKeyID">settings_cat_net_et_img_proxy_code</string>
<!--
<string name="apiProxyApiUrl">https://copymanga.azurewebsites.net/api/api?url=%1$s</string>
<string name="apiProxyApiPrefix">https://api.mangacopy.com/api/</string>
-->
<string name="complete">已完结</string>
@@ -99,6 +105,8 @@
<string name="settings_cat_net_sm_use_foreign">不管使用什么线路, API访问均是海外, 只有图片CDN可能会变化也可能不变, 请酌情选择使用</string>
<string name="settings_cat_net_et_title_api_url">请求API网址</string>
<string name="settings_cat_net_et_summary_api_url">一般无需更改,除非拷贝漫画官方更改网址,默认:&hosturl;</string>
<string name="settings_cat_net_sw_use_api_proxy">使用API代理重启生效</string>
<string name="settings_cat_net_sm_use_api_proxy">作者自建的API代理可缓解国内图书详情加载问题但不保证100%解决,也不保证一直可用</string>
<string name="settings_cat_net_sw_use_img_proxy">使用图床代理(重启生效)</string>
<string name="settings_cat_net_sm_use_img_proxy">作者自建的图床代理可缓解国内图片无法加载问题但不保证100%解决,也不保证一直可用</string>
<string name="settings_cat_net_et_title_img_proxy">图床代理密钥(重启生效)</string>

View File

@@ -13,7 +13,7 @@
<!--
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
-->
-->
</style>
<style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.DayNight">

View File

@@ -21,6 +21,14 @@
app:enableCopying="true"
app:iconSpaceReserved="false"
app:key="settings_cat_net_et_api_url" />
<!--
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="settings_cat_net_sw_use_api_proxy"
app:selectable="true"
app:summary="@string/settings_cat_net_sm_use_api_proxy"
app:title="@string/settings_cat_net_sw_use_api_proxy" />
-->
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="settings_cat_net_sw_use_img_proxy"