mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-13 04:13:14 +08:00
v2.0.beta19
fix #25 修复 1. 阅览漫画导航栏异常 2. 下载页滚动异常 3. 竖向阅读加载时间过长 4. 获取图书信息有时失败(fix #26)
This commit is contained in:
@@ -3,19 +3,22 @@ apply plugin: 'kotlin-android'
|
|||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
compileSdk 33
|
||||||
applicationId 'top.fumiama.copymanga'
|
applicationId 'top.fumiama.copymanga'
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode 30
|
versionCode 31
|
||||||
versionName '2.0.beta18'
|
versionName '2.0.beta19'
|
||||||
resConfigs 'zh', 'zh-rCN'
|
resConfigs 'zh', 'zh-rCN'
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aaptOptions {
|
||||||
|
cruncherEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
||||||
<activity
|
<activity
|
||||||
android:name="top.fumiama.copymanga.ui.vm.ViewMangaActivity"
|
android:name="top.fumiama.copymanga.ui.vm.ViewMangaActivity"
|
||||||
android:theme="@style/AppTheme.Default"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class AutoDownloadThread(private val url: String, private val whenFinish: (resul
|
|||||||
var c = 0
|
var c = 0
|
||||||
while (!exit && re == null && c++ < 3){
|
while (!exit && re == null && c++ < 3){
|
||||||
re = DownloadTools.getHttpContent(url,
|
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)!!
|
mainWeakReference?.get()?.getString(R.string.pc_ua)!!
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,17 +11,18 @@ import java.io.File
|
|||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
|
|
||||||
object CMApi {
|
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
|
var myGlideHeaders: LazyHeaders? = null
|
||||||
get() {
|
get() {
|
||||||
MainActivity.mainWeakReference?.get()?.let {
|
MainActivity.mainWeakReference?.get()?.let {
|
||||||
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
||||||
if(field === null)
|
if(field === null)
|
||||||
field = LazyHeaders.Builder()
|
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("User-Agent", MainActivity.mainWeakReference?.get()?.getString(R.string.pc_ua)!!)
|
||||||
.addHeader("source", "copyApp")
|
.addHeader("source", "copyApp")
|
||||||
.addHeader("webp", "1")
|
.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("region", if(!getBoolean("settings_cat_net", false)) "1" else "0")
|
||||||
.addHeader("platform", "3")
|
.addHeader("platform", "3")
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import top.fumiama.copymanga.MainActivity
|
import top.fumiama.copymanga.MainActivity
|
||||||
|
import top.fumiama.dmzj.copymanga.R
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.concurrent.Callable
|
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")
|
setRequestProperty("region", if(!getBoolean("settings_cat_net_sw_use_foreign", false)) "1" else "0")
|
||||||
}
|
}
|
||||||
it.getPreferences(Context.MODE_PRIVATE).apply {
|
it.getPreferences(Context.MODE_PRIVATE).apply {
|
||||||
setRequestProperty("version", getString("app_ver", "2.0.7"))
|
setRequestProperty("version", it.getString(R.string.app_ver))
|
||||||
getString("token", "")?.let {
|
getString("token", "")?.let { tk ->
|
||||||
if(it != "") setRequestProperty("authorization", "Token $it")
|
setRequestProperty("authorization", "Token $tk")
|
||||||
else setRequestProperty("authorization", "Token ")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,32 +3,44 @@ package top.fumiama.copymanga.tools.http
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import top.fumiama.copymanga.MainActivity
|
import top.fumiama.copymanga.MainActivity
|
||||||
import top.fumiama.dmzj.copymanga.R
|
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
class Proxy(private val code: String) {
|
class Proxy(id: Int, apiPrefixID: Int, keyID: Int? = null) {
|
||||||
constructor(): this(
|
private val code = keyID?.let { k ->
|
||||||
MainActivity.mainWeakReference?.get()?.let {
|
MainActivity.mainWeakReference?.get()?.let {
|
||||||
PreferenceManager.getDefaultSharedPreferences(it).let {sp ->
|
PreferenceManager.getDefaultSharedPreferences(it).getString(it.getString(k), null)
|
||||||
sp.getString("settings_cat_net_et_img_proxy_code", "")
|
}
|
||||||
}
|
}
|
||||||
}?:""
|
private val proxyApiUrl = MainActivity.mainWeakReference?.get()?.getString(id)
|
||||||
)
|
private val apiPrefix = MainActivity.mainWeakReference?.get()?.getString(apiPrefixID)?:"<no prefix>"
|
||||||
|
|
||||||
fun wrap(u: String): String {
|
fun wrap(u: String): String {
|
||||||
return MainActivity.mainWeakReference?.get()?.getString(R.string.imgProxyApiUrl)
|
if(!u.startsWith(apiPrefix)) return u
|
||||||
?.format(code, URLEncoder.encode(u, Charset.defaultCharset().name()))
|
if(code != null) {
|
||||||
?:u
|
return proxyApiUrl?.format(code, URLEncoder.encode(u, Charset.defaultCharset().name()))?:u
|
||||||
|
}
|
||||||
|
return proxyApiUrl?.format(URLEncoder.encode(u, Charset.defaultCharset().name()))?:u
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val useProxy: Boolean
|
val useImageProxy: Boolean
|
||||||
get() {
|
get() {
|
||||||
MainActivity.mainWeakReference?.get()?.let {
|
MainActivity.mainWeakReference?.get()?.let {
|
||||||
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
||||||
val b = getBoolean("settings_cat_net_sw_use_img_proxy", false)
|
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
|
return b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.line_booktandb.*
|
|||||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||||
import top.fumiama.copymanga.manga.Reader
|
import top.fumiama.copymanga.manga.Reader
|
||||||
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
||||||
|
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||||
import top.fumiama.dmzj.copymanga.R
|
import top.fumiama.dmzj.copymanga.R
|
||||||
import java.lang.Thread.sleep
|
import java.lang.Thread.sleep
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
@@ -19,6 +20,8 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
ComicDlFragment.exit = false
|
||||||
|
|
||||||
if(isFirstInflate) {
|
if(isFirstInflate) {
|
||||||
bookHandler = BookHandler(WeakReference(this), arguments?.getString("path")?:"null")
|
bookHandler = BookHandler(WeakReference(this), arguments?.getString("path")?:"null")
|
||||||
Thread{
|
Thread{
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
ads += ad
|
ads += ad
|
||||||
ad.start()
|
ad.start()
|
||||||
offset += 100
|
offset += 100
|
||||||
|
sleep(1000)
|
||||||
}
|
}
|
||||||
} while (counts[i] > 0)
|
} while (counts[i] > 0)
|
||||||
Thread {
|
Thread {
|
||||||
@@ -325,7 +326,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
if(ComicDlFragment.exit) return@Thread
|
if(ComicDlFragment.exit) return@Thread
|
||||||
if(re.all { it != null }) break
|
if(re.all { it != null }) break
|
||||||
}
|
}
|
||||||
if(re.size > 1) {
|
if(re.isNotEmpty()) {
|
||||||
val r = re[0]
|
val r = re[0]
|
||||||
var s = emptyArray<ChapterStructure>()
|
var s = emptyArray<ChapterStructure>()
|
||||||
re.forEach {
|
re.forEach {
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
|
|||||||
val types = arrayOf("", "name", "author", "local")
|
val types = arrayOf("", "name", "author", "local")
|
||||||
var i = 0
|
var i = 0
|
||||||
override fun onMicClick() {
|
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))
|
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AlertDialogTheme))
|
||||||
.setTitle(R.string.set_search_types)
|
.setTitle(R.string.set_search_types)
|
||||||
.setIcon(R.mipmap.ic_launcher)
|
.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]
|
adapter.type = types[p]
|
||||||
i = p
|
i = p
|
||||||
d.cancel()
|
d.cancel()
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
private fun doPrepareWebImg() {
|
private fun doPrepareWebImg() {
|
||||||
getImgUrlArray()?.apply {
|
getImgUrlArray()?.apply {
|
||||||
if(cut) {
|
if(cut) {
|
||||||
|
Log.d("MyVM", "is cut, load all pages...")
|
||||||
handler.sendEmptyMessage(7) //showDl
|
handler.sendEmptyMessage(7) //showDl
|
||||||
isCut = BooleanArray(size)
|
isCut = BooleanArray(size)
|
||||||
val analyzedCnt = BooleanArray(size)
|
val analyzedCnt = BooleanArray(size)
|
||||||
@@ -217,6 +218,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
if(b) indexMap += -(index+1)
|
if(b) indexMap += -(index+1)
|
||||||
}
|
}
|
||||||
handler.sendEmptyMessage(15) //hideDl
|
handler.sendEmptyMessage(15) //hideDl
|
||||||
|
Log.d("MyVM", "load all pages finished")
|
||||||
}
|
}
|
||||||
count = size
|
count = size
|
||||||
runOnUiThread { prepareItems() }
|
runOnUiThread { prepareItems() }
|
||||||
@@ -347,7 +349,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
|
|
||||||
private fun loadImgUrlInto(imgView: ScaleImageView, url: String, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
|
private fun loadImgUrlInto(imgView: ScaleImageView, url: String, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
|
||||||
Log.d("MyVM", "Load from adt: $url")
|
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) }
|
it?.let { loadImg(imgView, BitmapFactory.decodeByteArray(it, 0, it.size), isLast, useCut, isLeft) }
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
android:id="@+id/mylv"
|
android:id="@+id/mylv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingBottom="@dimen/global_content_padding_bottom"/>
|
android:nestedScrollingEnabled="true" />
|
||||||
|
|||||||
@@ -57,6 +57,12 @@
|
|||||||
<string name="historyApiUrl">https://%1$s/api/v3/member/browse/comics?limit=21&offset=%2$d&platform=3</string>
|
<string name="historyApiUrl">https://%1$s/api/v3/member/browse/comics?limit=21&offset=%2$d&platform=3</string>
|
||||||
|
|
||||||
<string name="imgProxyApiUrl">https://copymanga.azurewebsites.net/api/img?code=%1$s&url=%2$s</string>
|
<string name="imgProxyApiUrl">https://copymanga.azurewebsites.net/api/img?code=%1$s&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>
|
<string name="complete">已完结</string>
|
||||||
|
|
||||||
@@ -99,6 +105,8 @@
|
|||||||
<string name="settings_cat_net_sm_use_foreign">不管使用什么线路, API访问均是海外, 只有图片CDN可能会变化(也可能不变), 请酌情选择使用</string>
|
<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_title_api_url">请求API网址</string>
|
||||||
<string name="settings_cat_net_et_summary_api_url">一般无需更改,除非拷贝漫画官方更改网址,默认:&hosturl;</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_sw_use_img_proxy">使用图床代理(重启生效)</string>
|
||||||
<string name="settings_cat_net_sm_use_img_proxy">作者自建的图床代理,可缓解国内图片无法加载问题,但不保证100%解决,也不保证一直可用</string>
|
<string name="settings_cat_net_sm_use_img_proxy">作者自建的图床代理,可缓解国内图片无法加载问题,但不保证100%解决,也不保证一直可用</string>
|
||||||
<string name="settings_cat_net_et_title_img_proxy">图床代理密钥(重启生效)</string>
|
<string name="settings_cat_net_et_title_img_proxy">图床代理密钥(重启生效)</string>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<!--
|
<!--
|
||||||
<item name="android:windowTranslucentStatus">true</item>
|
<item name="android:windowTranslucentStatus">true</item>
|
||||||
<item name="android:windowTranslucentNavigation">true</item>
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
-->
|
-->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.DayNight">
|
<style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.DayNight">
|
||||||
|
|||||||
@@ -21,6 +21,14 @@
|
|||||||
app:enableCopying="true"
|
app:enableCopying="true"
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="settings_cat_net_et_api_url" />
|
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
|
<SwitchPreferenceCompat
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:key="settings_cat_net_sw_use_img_proxy"
|
app:key="settings_cat_net_sw_use_img_proxy"
|
||||||
|
|||||||
Reference in New Issue
Block a user