1
0
mirror of https://github.com/fumiama/copymanga.git synced 2026-06-07 16:20:24 +08:00
修复
1. 从详情页进入标签再返回后阅读空漫画闪退
2. 无法阅读/下载服务器返回size与实际不一致的漫画(奈奈与薰的SM日记 第一话)
优化
1. 动态设置沉浸状态栏高度
This commit is contained in:
源文雨
2023-11-30 01:36:36 +09:00
parent 74f68f8907
commit 32ecebb1ad
8 changed files with 46 additions and 50 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId 'top.fumiama.copymanga'
minSdkVersion 23
targetSdkVersion 34
versionCode 40
versionName '2.0.4'
versionCode 41
versionName '2.0.5'
resConfigs 'zh', 'zh-rCN'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -60,8 +60,8 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
testImplementation 'junit:junit:4.13.2'
implementation "androidx.preference:preference-ktx:1.2.1"
implementation 'com.afollestad.material-dialogs:input:3.3.0'

View File

@@ -76,8 +76,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
//translucentStatusBar()
//coordiv.layoutParams.height = getStatusBarHeight()
coordiv.layoutParams.height = UITools.getStatusBarHeight(this)
navController = findNavController(R.id.nav_host_fragment)
appBarConfiguration = AppBarConfiguration(
@@ -323,33 +322,6 @@ class MainActivity : AppCompatActivity() {
.start(this)
}
/*private fun translucentStatusBar() {
//添加Flag把状态栏设为可绘制模式
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
//如果为全透明模式取消设置Window半透明的Flag
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
//设置状态栏为透明
window.statusBarColor = Color.TRANSPARENT
//设置window的状态栏不可见
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//view不根据系统窗口来调整自己的布局
val mContentView: ViewGroup = window.findViewById(Window.ID_ANDROID_CONTENT) as ViewGroup
val mChildView: View = mContentView.getChildAt(0)
ViewCompat.requestApplyInsets(mChildView)
coordiv.layoutParams.height = getStatusBarHeight()
}*/
/*private fun getStatusBarHeight() =
resources.getDimensionPixelOffset(
resources.getIdentifier(
"status_bar_height",
"dimen",
"android"
)
)*/
private fun checkUpdate(ignoreSkip: Boolean) {
Thread{
Update.checkUpdate(this, toolsBox, ignoreSkip)

View File

@@ -21,14 +21,22 @@ class MangaDlTools {
fun downloadChapterInVol(url: CharSequence, chapterName: CharSequence, group: CharSequence, index: Int){
Log.d("MyMDT", "下载:$url, index$index")
AutoDownloadThread(url.toString()){
Gson().fromJson(it?.decodeToString(), Chapter2Return::class.java)?.let {
if(it.results.chapter.words.size != it.results.chapter.size) downloadChapterInVol(url, chapterName, group, index)
else getChapterInfo(it, index, chapterName, group)
AutoDownloadThread(url.toString()){ data ->
Gson().fromJson(data?.decodeToString(), Chapter2Return::class.java)?.let {
getChapterInfo(it, index, chapterName, group)
}
}.start()
}
@Synchronized private fun prepareDownloadListener() {
pool?.setOnDownloadListener { fileName: String, isSuccess: Boolean ->
indexMap[fileName]?.let { onDownloadedListener?.handleMessage(it, isSuccess) }
}
pool?.setOnPageDownloadListener { fileName: String, downloaded: Int, total: Int, isSuccess: Boolean ->
indexMap[fileName]?.let { onDownloadedListener?.handleMessage(it, downloaded, total, isSuccess) }
}
}
@Synchronized private fun setPool(comicName: String, group: CharSequence) {
if(pool == null || grp != group) {
pool = DownloadPool(File(
@@ -36,6 +44,7 @@ class MangaDlTools {
"$comicName/$group"
).absolutePath)
grp = group
prepareDownloadListener()
}
}
@@ -49,12 +58,6 @@ class MangaDlTools {
setPool(chapter2Return.results.comic.name, group)
setIndexMap(f, index)
pool?.plusAssign(DownloadPool.Quest(f, getMangaUrls(chapter2Return)))
pool?.setOnDownloadListener { fileName: String, isSuccess: Boolean ->
indexMap[fileName]?.let { onDownloadedListener?.handleMessage(it, isSuccess) }
}
pool?.setOnPageDownloadListener { fileName: String, downloaded: Int, total: Int, isSuccess: Boolean ->
indexMap[fileName]?.let { onDownloadedListener?.handleMessage(it, downloaded, total, isSuccess) }
}
}
}
@@ -62,10 +65,17 @@ class MangaDlTools {
var re: Array<String> = arrayOf()
val hm: HashMap<Int, String> = hashMapOf()
val chapter = chapter2Return.results.chapter
for(i in 0 until chapter.size) {
if(chapter.words.size < chapter.contents.size) {
chapter.words = chapter.words.toMutableList().apply {
chapter.contents.indices.forEach {
if(!contains(it)) plusAssign(it)
}
}.toIntArray()
}
for(i in 0 until chapter.contents.size) {
hm[chapter.words[i]] = chapter.contents[i].url
}
for(i in 0 until chapter.size){
for(i in 0 until chapter.contents.size){
re += hm[i]?:""
}
return re

View File

@@ -75,7 +75,7 @@ open class AutoDownloadHandler(private val url: String, private val jsonClass: C
if(exit) return
if(it == null) {
if (cnt++>3) return
sleep(1000)
sleep(2000)
dlThread()
return
}
@@ -102,7 +102,7 @@ open class AutoDownloadHandler(private val url: String, private val jsonClass: C
if(g.code == 200) sendEmptyMessage(0)
else onError()
Log.d("MyADH", "[${g.code}]${g.message}")
} else if(checkTimes++ > 10) timeThread?.canDo = false
} else if(checkTimes++ > 3) timeThread?.canDo = false
}
private fun setLayouts() {
if(getGsonItem() == null) download()

View File

@@ -133,5 +133,14 @@ class UITools(that: Context?, w: WeakReference<Activity>? = null) {
0
}
}
fun getStatusBarHeight(context: Context): Int {
val resources = context.resources
val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
return if (resourceId > 0) {
resources.getDimensionPixelSize(resourceId)
} else {
0
}
}
}
}

View File

@@ -96,7 +96,9 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
i = p
}
setOnClickListener {
Reader.viewMangaAt(comic.name, i, bookHandler!!.urlArray)
bookHandler?.urlArray?.let {
Reader.viewMangaAt(comic.name, i, it)
}
}
}
}

View File

@@ -135,9 +135,12 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
override fun setGsonItem(gsonObj: Any): Boolean {
super.setGsonItem(gsonObj)
val m = gsonObj as Chapter2Return
if(m.results.chapter.words.size != m.results.chapter.size) {
if(m.results.chapter.words.size != m.results.chapter.contents.size) {
return false
}
if(m.results.chapter.words.size != m.results.chapter.size) {
m.results.chapter.size = m.results.chapter.words.size // 有时 size 不对
}
manga = m
return true
}

View File

@@ -47,7 +47,7 @@ class SimpleKanban(private val client: Client, private val pwd: String) { //mu
operator fun get(version: Int): String =
if(client.initConnect()) {
client.sendMessage("${pwd}get${version}quit")
client.sendMessage("${pwd}get39quit")
client.receiveRawMessage(36) //Welcome to simple kanban server. get
val r = try {
val firstRecv = client.receiveRawMessage(4)