mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-05 07:20:23 +08:00
v2.0.beta20
新增 1. 卡片式漫画下载页 修复 1. 深色模式下状态栏不变色
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId 'top.fumiama.copymanga'
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 33
|
||||
versionCode 31
|
||||
versionName '2.0.beta19'
|
||||
versionCode 32
|
||||
versionName '2.0.beta20'
|
||||
resConfigs 'zh', 'zh-rCN'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -74,7 +74,7 @@ class MainActivity : AppCompatActivity() {
|
||||
R.id.nav_rank,
|
||||
R.id.nav_sub,
|
||||
R.id.nav_history,
|
||||
R.id.nav_download,
|
||||
R.id.nav_new_download,
|
||||
R.id.nav_settings
|
||||
), drawer_layout
|
||||
)
|
||||
|
||||
@@ -93,13 +93,17 @@ class CardList(
|
||||
if(!exitCardList) cardFrame.let {
|
||||
it.tic.text = name
|
||||
if(!file.exists()){
|
||||
that?.context?.let { context ->
|
||||
if(!exitCardList && head != null)
|
||||
Glide.with(context).load(
|
||||
GlideUrl(CMApi.proxy?.wrap(head)?:head, CMApi.myGlideHeaders)
|
||||
).into(it.imic)
|
||||
if(head != null) {
|
||||
that?.context?.let { context ->
|
||||
if(!exitCardList)
|
||||
Glide.with(context).load(
|
||||
GlideUrl(CMApi.proxy?.wrap(head)?:head, CMApi.myGlideHeaders)
|
||||
).into(it.imic)
|
||||
}
|
||||
} else {
|
||||
if(!exitCardList) it.imic.setImageResource(R.drawable.img_defmask)
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
val img = File(file, "head.jpg")
|
||||
if(img.exists()) it.imic.setImageURI(Uri.fromFile(img))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.android.synthetic.main.line_lazybooklines.*
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.json.BookListStructure
|
||||
import top.fumiama.copymanga.json.HistoryBookListStructure
|
||||
import top.fumiama.copymanga.json.TypeBookListStructure
|
||||
@@ -98,7 +100,11 @@ open class InfoCardLoader(inflateRes:Int, private val navId:Int, private val isT
|
||||
|
||||
open fun setListeners(){}
|
||||
|
||||
open fun onLoadFinish(){}
|
||||
open fun onLoadFinish(){
|
||||
MainActivity.mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
@@ -27,13 +27,6 @@ open class StatusCardFlow(private val api: Int, nav: Int) : InfoCardLoader(R.lay
|
||||
setHot(line_finish_pop)
|
||||
}
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
open fun setUpdate(that: View) {
|
||||
that.apply {
|
||||
apt.setText(R.string.menu_update_time)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package top.fumiama.copymanga.ui.book
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
@@ -8,6 +9,7 @@ import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.model.GlideUrl
|
||||
@@ -21,6 +23,7 @@ import kotlinx.android.synthetic.main.line_bookinfo.*
|
||||
import kotlinx.android.synthetic.main.line_bookinfo_text.*
|
||||
import kotlinx.android.synthetic.main.line_caption.view.*
|
||||
import kotlinx.android.synthetic.main.line_chapter.view.*
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||
import top.fumiama.copymanga.json.BookInfoStructure
|
||||
import top.fumiama.copymanga.json.ChapterStructure
|
||||
@@ -51,7 +54,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
||||
return re
|
||||
}
|
||||
var book: BookInfoStructure? = null
|
||||
var complete = false
|
||||
private var complete = false
|
||||
var ads = emptyArray<AutoDownloadThread>()
|
||||
var gpws = arrayOf<String>()
|
||||
var keys = arrayOf<String>()
|
||||
@@ -363,6 +366,20 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
||||
json = Gson().toJson(volumes)
|
||||
File(mangaFolder, "info.json").writeText(json!!)
|
||||
File(mangaFolder, "grps.json").writeText(Gson().toJson(keys))
|
||||
that?.apply {
|
||||
File(mangaFolder, "head.jpg").let { head ->
|
||||
val fo = head.outputStream()
|
||||
try {
|
||||
imic.drawable.toBitmap().compress(Bitmap.CompressFormat.JPEG, 90, fo)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
mainWeakReference?.get()?.apply {
|
||||
Toast.makeText(this, R.string.download_cover_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
fo.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vols = volumes
|
||||
|
||||
@@ -11,11 +11,4 @@ import top.fumiama.dmzj.copymanga.R
|
||||
class HistoryFragment : InfoCardLoader(R.layout.fragment_history, R.id.action_nav_history_to_nav_book, isHistoryBook = true) {
|
||||
override fun getApiUrl() =
|
||||
getString(R.string.historyApiUrl).format(CMApi.myHostApiUrl, page * 21)
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
MainActivity.mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,4 @@ import top.fumiama.dmzj.copymanga.R
|
||||
class NewestFragment : InfoCardLoader(R.layout.fragment_newest, R.id.action_nav_newest_to_nav_book, true) {
|
||||
override fun getApiUrl() =
|
||||
getString(R.string.newestApiUrl).format(CMApi.myHostApiUrl, page * 21)
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,13 +36,6 @@ class RankFragment : InfoCardLoader(R.layout.fragment_rank, R.id.action_nav_rank
|
||||
})
|
||||
}
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun setSortValue(value: Int) {
|
||||
sortValue = value
|
||||
Thread{
|
||||
|
||||
@@ -11,11 +11,4 @@ import top.fumiama.dmzj.copymanga.R
|
||||
class RecFragment : InfoCardLoader(R.layout.fragment_recommend, R.id.action_nav_recommend_to_nav_book, true) {
|
||||
override fun getApiUrl() =
|
||||
getString(R.string.recommendApiUrl).format(CMApi.myHostApiUrl, page * 21)
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,13 +46,6 @@ class SortFragment : InfoCardLoader(R.layout.fragment_sort, R.id.action_nav_sort
|
||||
}.start()
|
||||
}
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpdate(){
|
||||
if(ad?.exit == true) return
|
||||
line_sort_time.apt.setText(R.string.menu_update_time)
|
||||
|
||||
@@ -40,11 +40,4 @@ class TopicFragment : InfoCardLoader(R.layout.fragment_topic, R.id.action_nav_to
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
override fun onLoadFinish() {
|
||||
super.onLoadFinish()
|
||||
mainWeakReference?.get()?.runOnUiThread {
|
||||
if(ad?.exit == false) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,8 @@ import top.fumiama.copymanga.ui.vm.ViewMangaActivity
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
private var nullZipDirStr = emptyArray<String>()
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
if(isFirstInflate) {
|
||||
@@ -69,7 +67,7 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.ic_launcher_foreground).setMessage("删除?")
|
||||
.setTitle("提示").setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
if (chosenFile.exists()) rmrf(chosenFile)
|
||||
if (chosenFile.exists()) recursiveRemove(chosenFile)
|
||||
scanFile(cd)
|
||||
}.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.show()
|
||||
@@ -81,10 +79,10 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
}
|
||||
|
||||
|
||||
fun rmrf(f: File) {
|
||||
private fun recursiveRemove(f: File) {
|
||||
if (f.isDirectory) f.listFiles()?.let {
|
||||
for (i in it)
|
||||
if (i.isDirectory) rmrf(i)
|
||||
if (i.isDirectory) recursiveRemove(i)
|
||||
else i.delete()
|
||||
}
|
||||
f.delete()
|
||||
@@ -110,57 +108,6 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
findNavController().navigate(R.id.action_nav_download_self, bundle)
|
||||
}
|
||||
|
||||
private fun findNullWebpZipFileInDir(f: File){
|
||||
if (f.isDirectory) f.listFiles()?.let {
|
||||
for (i in it)
|
||||
if (i.isDirectory) findNullWebpZipFileInDir(i)
|
||||
else if(!checkZip(i)) nullZipDirStr += i.path.substringAfterLast(context?.getExternalFilesDir("").toString())
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkZip(f: File): Boolean{
|
||||
return try {
|
||||
val exist = f.exists()
|
||||
if (!exist) true
|
||||
else {
|
||||
var re = true
|
||||
val zip = ZipInputStream(f.inputStream().buffered())
|
||||
var entry = zip.nextEntry
|
||||
while (entry != null) {
|
||||
if (!entry.isDirectory){
|
||||
if(zip.read() == -1 && entry.size == 0L){
|
||||
re = false
|
||||
break
|
||||
}
|
||||
}
|
||||
entry = zip.nextEntry
|
||||
}
|
||||
zip.closeEntry()
|
||||
zip.close()
|
||||
re
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(context, "读取${f.name}错误!", Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorZip(msg: CharSequence) = AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.ic_launcher_foreground)
|
||||
.setTitle("找到以下错误文件,是否删除?")
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(android.R.string.ok){_, _ -> deleteErrorZip()}
|
||||
.setNegativeButton(android.R.string.cancel){_, _ ->}
|
||||
.show()
|
||||
|
||||
private fun deleteErrorZip(){
|
||||
val exf = context?.getExternalFilesDir("")
|
||||
for(i in nullZipDirStr){
|
||||
val f = File(exf, i)
|
||||
if(f.exists()) f.delete()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFloat(oldString: String): Float {
|
||||
val newString = StringBuffer()
|
||||
var matcher = Pattern.compile("\\d+.+\\d+").matcher(oldString)
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package top.fumiama.copymanga.ui.download
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import kotlinx.android.synthetic.main.line_lazybooklines.*
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.template.general.MangaPagesFragmentTemplate
|
||||
import top.fumiama.copymanga.template.ui.CardList
|
||||
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.io.File
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownload) {
|
||||
private var sortedBookList: List<File>? = null
|
||||
private val oldDlCardName = MainActivity.mainWeakReference?.get()?.getString(R.string.old_download_card_name)!!
|
||||
private val extDir = MainActivity.mainWeakReference?.get()?.getExternalFilesDir("")
|
||||
init {
|
||||
pageHandler = object : PageHandler {
|
||||
override fun addPage() {
|
||||
if(!isEnd) {
|
||||
if(sortedBookList == null) {
|
||||
Log.d("MyNDF", "Sorting books...")
|
||||
sortedBookList = extDir?.listFiles()?.sorted()
|
||||
}
|
||||
Log.d("MyNDF", "Start drawing cards")
|
||||
cardList.addCard(oldDlCardName, path = oldDlCardName)
|
||||
sortedBookList?.let {
|
||||
for(i in it.listIterator(page)) {
|
||||
if(cardList.exitCardList) return
|
||||
page++ // page is actually count
|
||||
val chosenJson = File(i, "info.bin")
|
||||
val newJson = File(i, "info.json")
|
||||
val bookSize = (sizeOf(i)/1048576).toInt()
|
||||
when{
|
||||
chosenJson.exists() -> continue // unsupported old folder
|
||||
newJson.exists() -> {
|
||||
if(cardList.exitCardList) return
|
||||
cardList.addCard(i.name, " ${bookSize}MB")
|
||||
}
|
||||
}
|
||||
}
|
||||
if(page >= it.size) {
|
||||
isEnd = true
|
||||
}
|
||||
}
|
||||
}
|
||||
onLoadFinish()
|
||||
}
|
||||
|
||||
override fun initCardList(weakReference: WeakReference<Fragment>) {
|
||||
cardList = CardList(weakReference, cardWidth, cardHeight, cardPerRow)
|
||||
cardList.initClickListeners = object : CardList.InitClickListeners {
|
||||
override fun prepareListeners(v: View, name: String, path: String?, chapterUUID: String?, pn: Int?) {
|
||||
v.setOnClickListener {
|
||||
if(name==oldDlCardName && path == oldDlCardName) {
|
||||
findNavController().navigate(R.id.action_nav_new_download_to_nav_download)
|
||||
return@setOnClickListener
|
||||
}
|
||||
callDownloadFragment(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setListeners() {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun callDownloadFragment(name: String){
|
||||
val bundle = Bundle()
|
||||
Log.d("MyNDF", "Call dl and is new.")
|
||||
bundle.putBoolean("loadJson", true)
|
||||
bundle.putString("name", name)
|
||||
ComicDlFragment.json = File(File(extDir, name), "info.json").readText()
|
||||
Log.d("MyNDF", "root view: $rootView")
|
||||
Log.d("MyNDF", "action_nav_new_download_to_nav_group")
|
||||
findNavController().navigate(R.id.action_nav_new_download_to_nav_group, bundle)
|
||||
}
|
||||
|
||||
private fun onLoadFinish() {
|
||||
MainActivity.mainWeakReference?.get()?.runOnUiThread {
|
||||
if(!cardList.exitCardList) mypl.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun sizeOf(f: File):Long{
|
||||
var size = 0L
|
||||
if (f.isDirectory) f.listFiles()?.apply {
|
||||
for (i in this)
|
||||
size += if (i.isDirectory) sizeOf(i) else i.length()
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-nodpi/img_defmask.webp
Normal file
BIN
app/src/main/res/drawable-nodpi/img_defmask.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
10
app/src/main/res/layout/fragment_newdownload.xml
Normal file
10
app/src/main/res/layout/fragment_newdownload.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
layout="@layout/line_lazybooklines"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -35,7 +35,7 @@
|
||||
android:id="@+id/menugroup_dl"
|
||||
android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/nav_download"
|
||||
android:id="@+id/nav_new_download"
|
||||
android:icon="@drawable/ic_menu_download"
|
||||
android:title="@string/menu_download" />
|
||||
</group>
|
||||
|
||||
@@ -110,6 +110,27 @@
|
||||
app:popExitAnim="@anim/slide_in_right_exit"/>
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_new_download"
|
||||
android:name="top.fumiama.copymanga.ui.download.NewDownloadFragment"
|
||||
android:label="@string/menu_download"
|
||||
tools:layout="@layout/fragment_newdownload" >
|
||||
<action
|
||||
android:id="@+id/action_nav_new_download_to_nav_group"
|
||||
app:destination="@id/nav_group"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_out_left_exit"
|
||||
app:popExitAnim="@anim/slide_in_right_exit"/>
|
||||
<action
|
||||
android:id="@+id/action_nav_new_download_to_nav_download"
|
||||
app:destination="@id/nav_download"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_out_left_exit"
|
||||
app:popExitAnim="@anim/slide_in_right_exit"/>
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_settings"
|
||||
android:name="top.fumiama.copymanga.ui.settings.SettingsFragment"
|
||||
|
||||
15
app/src/main/res/values-night/colors.xml
Normal file
15
app/src/main/res/values-night/colors.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#2ca9e1</color>
|
||||
<color name="colorPrimaryDark">#000000</color>
|
||||
<color name="colorAccent">#00a3af</color>
|
||||
<color name="colorBg">#c1e4e9</color>
|
||||
<color name="colorBlue">#f2faff</color>
|
||||
<color name="colorBlue1">#00beff</color>
|
||||
<color name="colorBlue2">#81caf8</color>
|
||||
<color name="colorBlue3">#c7eaff</color>
|
||||
<color name="colorGreen">#BFEA88</color>
|
||||
<color name="textInputLayout">#ffffff</color>
|
||||
<color name="colorRed">#F6837A</color>
|
||||
<color name="searchBarPrimaryColor">#E1E1E1</color>
|
||||
</resources>
|
||||
@@ -34,6 +34,7 @@
|
||||
<string name="text_null">N/A</string>
|
||||
<string name="null_book">获取图书信息失败</string>
|
||||
<string name="web_error">网络错误</string>
|
||||
<string name="download_cover_error">保存封面出错</string>
|
||||
|
||||
<string name="mainPageApiUrl">https://%1$s/api/v3/h5/homeIndex?platform=3</string>
|
||||
<string name="referUrl">https://%1$s</string>
|
||||
@@ -124,4 +125,6 @@
|
||||
<string name="login_null_username">用户名为空</string>
|
||||
<string name="login_null_pwd">密码为空</string>
|
||||
<string name="login_get_conn_failed">连接失败</string>
|
||||
|
||||
<string name="old_download_card_name">前往旧版下载</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user