mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-10 10:24:29 +08:00
v2.3.3
新增 1. 设置“沉浸式系统栏”开关 (#71) 2. 旧版下载 删除所有空漫画 按钮 修复 1. 我的下载 反转排序失灵 升级 1. google material -> 1.12.0 2. google gson -> 2.11.0
This commit is contained in:
@@ -55,6 +55,7 @@ import top.fumiama.copymanga.tools.ui.UITools
|
||||
import top.fumiama.copymanga.ui.book.BookFragment.Companion.bookHandler
|
||||
import top.fumiama.copymanga.ui.cardflow.rank.RankFragment
|
||||
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||
import top.fumiama.copymanga.ui.download.DownloadFragment
|
||||
import top.fumiama.copymanga.ui.download.NewDownloadFragment
|
||||
import top.fumiama.copymanga.update.Update
|
||||
import top.fumiama.copymanga.user.Member
|
||||
@@ -197,6 +198,17 @@ class MainActivity : AppCompatActivity() {
|
||||
RankFragment.wr?.get()?.showSexInfo(toolsBox)
|
||||
true
|
||||
}
|
||||
R.id.action_del -> {
|
||||
if (DownloadFragment.wd != null) {
|
||||
val dl = AlertDialog.Builder(this)
|
||||
dl.setMessage(R.string.delele_all_empty_manga)
|
||||
dl.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
DownloadFragment.wd?.get()?.removeAllEmpty()
|
||||
}
|
||||
dl.show()
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
@@ -261,36 +273,49 @@ class MainActivity : AppCompatActivity() {
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = true
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
R.id.nav_book -> {
|
||||
Log.d("MyMA", "enter book")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = true
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
R.id.nav_group -> {
|
||||
Log.d("MyMA", "enter group")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = true
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
R.id.nav_new_download -> {
|
||||
Log.d("MyMA", "enter new_download")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = true
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
R.id.nav_rank -> {
|
||||
Log.d("MyMA", "enter rank")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = true
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
R.id.nav_download -> {
|
||||
Log.d("MyMA", "enter old download")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = true
|
||||
}
|
||||
else -> {
|
||||
Log.d("MyMA", "enter others")
|
||||
menuMain?.findItem(R.id.action_info)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_download)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_sort)?.isVisible = false
|
||||
menuMain?.findItem(R.id.action_del)?.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,4 +91,44 @@ class MangaDlTools {
|
||||
fun handleMessage(index: Int, isSuccess: Boolean, message: String)
|
||||
fun handleMessage(index: Int, downloaded: Int, total: Int, isSuccess: Boolean, message: String)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getNonEmptyMangaList(sortedBookList: List<File>?, setProgress: ((Int) -> Unit)? = null): List<File>? {
|
||||
val cache = hashMapOf<String, Boolean>()
|
||||
val size = sortedBookList?.size?:0
|
||||
if(size <= 0) return null
|
||||
return sortedBookList?.filter {
|
||||
setProgress?.let { it(100*cache.size/size) }
|
||||
it.absolutePath.let { path ->
|
||||
if (cache.containsKey(path)) cache[path]!!
|
||||
else {
|
||||
val b = (it.listFiles { f ->
|
||||
return@listFiles f.isDirectory && f.listFiles()?.isNotEmpty() ?: false
|
||||
}?.size ?: 0) > 0
|
||||
cache[path] = b
|
||||
b
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getEmptyMangaList(sortedBookList: List<File>?, setProgress: ((Int) -> Unit)? = null): List<File>? {
|
||||
val cache = hashMapOf<String, Boolean>()
|
||||
val size = sortedBookList?.size?:0
|
||||
if(size <= 0) return null
|
||||
return sortedBookList?.filter {
|
||||
setProgress?.let { it(100*cache.size/size) }
|
||||
it.absolutePath.let { path ->
|
||||
if (cache.containsKey(path)) cache[path]!!
|
||||
else {
|
||||
val b = (it.listFiles { f ->
|
||||
return@listFiles f.isDirectory && f.listFiles()?.isNotEmpty() ?: false
|
||||
}?.size ?: 0) <= 0
|
||||
cache[path] = b
|
||||
b
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,27 +13,44 @@ import kotlinx.android.synthetic.main.fragment_download.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.manga.MangaDlTools
|
||||
import top.fumiama.copymanga.manga.Reader
|
||||
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
||||
import top.fumiama.copymanga.tools.file.FileUtils
|
||||
import top.fumiama.copymanga.tools.ui.Navigate
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.io.File
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
wd = WeakReference(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
wd = null
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
if(isFirstInflate) {
|
||||
arguments?.getString("title")?.let {
|
||||
activity?.toolbar?.title = it
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
scanFile(arguments?.getString("file")?.let { File(it) }?:context?.getExternalFilesDir("")?:run {
|
||||
findNavController().popBackStack()
|
||||
return@launch
|
||||
})
|
||||
}
|
||||
initScan()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initScan() {
|
||||
lifecycleScope.launch {
|
||||
scanFile(arguments?.getString("file")?.let { File(it) }?:context?.getExternalFilesDir("")?:run {
|
||||
findNavController().popBackStack()
|
||||
return@launch
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,4 +145,21 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
||||
//Log.d("MyDLL2", newString.toString().toFloat().toString())
|
||||
return if(newString.isEmpty()) 0f else newString.toString().toFloat()
|
||||
}
|
||||
|
||||
fun removeAllEmpty() {
|
||||
MainActivity.mainWeakReference?.get()?.getExternalFilesDir("")?.listFiles()?.toList().let {
|
||||
var removed = false
|
||||
MangaDlTools.getEmptyMangaList(it)?.forEach { f ->
|
||||
if (f.exists()) {
|
||||
FileUtils.recursiveRemove(f)
|
||||
removed = true
|
||||
}
|
||||
}
|
||||
if (removed) initScan()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var wd: WeakReference<DownloadFragment>? = null
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||
import top.fumiama.copymanga.manga.MangaDlTools
|
||||
import top.fumiama.copymanga.manga.Reader
|
||||
import top.fumiama.copymanga.template.general.MangaPagesFragmentTemplate
|
||||
import top.fumiama.copymanga.template.ui.CardList
|
||||
@@ -72,28 +73,12 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
|
||||
sortedBookList = extDir?.listFiles()?.toList()
|
||||
var size = sortedBookList?.size?:0
|
||||
if (size > 0) {
|
||||
if (isReverse) {
|
||||
Log.d("MyNDF", "reversed...")
|
||||
sortedBookList = sortedBookList?.asReversed()
|
||||
}
|
||||
setProgress(40)
|
||||
if (!showAll) {
|
||||
val cache = hashMapOf<String, Boolean>()
|
||||
sortedBookList = sortedBookList?.filter {
|
||||
setProgress(40+20*cache.size/size)
|
||||
it.absolutePath.let { path ->
|
||||
if (cache.containsKey(path)) cache[path]!!
|
||||
else {
|
||||
val b = (it.listFiles { f ->
|
||||
return@listFiles f.isDirectory && f.listFiles()?.isNotEmpty() ?: false
|
||||
}?.size ?: 0) > 0
|
||||
cache[path] = b
|
||||
b
|
||||
}
|
||||
}
|
||||
sortedBookList = MangaDlTools.getNonEmptyMangaList(sortedBookList) {
|
||||
setProgress(40+20*it/100)
|
||||
}
|
||||
}
|
||||
setProgress(60)
|
||||
setProgress(40)
|
||||
size = sortedBookList?.size?:0
|
||||
val cache = hashMapOf<String, String>()
|
||||
sortedBookList = sortedBookList?.sortedBy {
|
||||
@@ -107,6 +92,11 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
|
||||
}
|
||||
}
|
||||
}
|
||||
setProgress(60)
|
||||
if (isReverse) {
|
||||
Log.d("MyNDF", "reversed...")
|
||||
sortedBookList = sortedBookList?.asReversed()
|
||||
}
|
||||
setProgress(80)
|
||||
}
|
||||
isContentChanged = false
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="?attr/colorOnSurface"
|
||||
android:pathData="M790.976 190.72a32 32 0 0 1 45.259-.021 457.25 457.25 0 0 1 134.432 324.416 457.25 457.25 0 0 1-134.294 324.277 32 32 0 1 1-45.258-45.248 393.26 393.26 0 0 0 115.552-279.03 393.26 393.26 0 0 0-115.68-279.146 32 32 0 0 1 0-45.259zm-603.36.128a32 32 0 0 1 45.27 45.248 393.26 393.26 0 0 0-115.553 279.019A393.26 393.26 0 0 0 232.8 794.059a32 32 0 0 1-45.28 45.237A457.25 457.25 0 0 1 53.333 515.115a457.25 457.25 0 0 1 134.294-324.267zm143.179 95.019a32 32 0 0 1 .032 45.248A255.04 255.04 0 0 0 256 512a255.05 255.05 0 0 0 75.147 181.184 32 32 0 1 1-45.216 45.301A319.04 319.04 0 0 1 192 512a319.04 319.04 0 0 1 93.547-226.09 32 32 0 0 1 45.248-.033zm407.36-.267A319.04 319.04 0 0 1 832 512a319.04 319.04 0 0 1-93.653 226.208 32 32 0 0 1-45.28-45.237A255.05 255.05 0 0 0 768 512a255.05 255.05 0 0 0-75.072-181.12 32 32 0 1 1 45.227-45.27zM566.752 384c70.656 0 115.915 57.173 115.915 130.923 0 58.005-47.947 116.789-140.096 181.237a53.33 53.33 0 0 1-61.142 0c-92.149-64.448-140.096-123.232-140.096-181.237 0-73.75 45.259-130.923 115.926-130.923 21.632 0 37.514 5.995 54.741 18.421C529.227 389.995 545.11 384 566.741 384zm0 64c-8.32 0-14.56 3.328-27.52 14.539l-6.336 5.504a32 32 0 0 1-41.77 0l-6.337-5.504c-12.96-11.2-19.2-14.539-27.52-14.539-31.616 0-51.936 25.675-51.936 66.923 0 29.941 34.411 72.938 106.667 124.48 72.256-51.542 106.667-94.539 106.667-124.48 0-41.248-20.32-66.923-51.926-66.923z"/>
|
||||
android:pathData="M791 191a32 32 0 0 1 45 0 457 457 0 0 1 135 324 457 457 0 0 1-135 324 32 32 0 1 1-45-45 393 393 0 0 0 116-279 393 393 0 0 0-116-279 32 32 0 0 1 0-45m-603 0a32 32 0 0 1 45 45 393 393 0 0 0-116 279 393 393 0 0 0 116 279 32 32 0 0 1-45 45A457 457 0 0 1 53 515a457 457 0 0 1 135-324m143 95a32 32 0 0 1 0 45 255 255 0 0 0-75 181 255 255 0 0 0 75 181 32 32 0 1 1-45 46 319 319 0 0 1-94-227 319 319 0 0 1 94-226 32 32 0 0 1 45 0m407 0a319 319 0 0 1 94 226 319 319 0 0 1-94 226 32 32 0 0 1-45-45 255 255 0 0 0 75-181 255 255 0 0 0-75-181 32 32 0 1 1 45-45zm-171 98c70 0 116 57 116 131q-1 86-140 181a53 53 0 0 1-62 0q-139-95-140-181c0-74 46-131 116-131q31 0 55 18a87 87 0 0 1 55-18zm0 64c-9 0-15 3-28 15l-6 5a32 32 0 0 1-42 0l-6-5c-13-12-19-15-28-15-31 0-52 26-52 67q-1 46 107 124 108-78 107-124c0-41-21-67-52-67"
|
||||
tools:ignore="VectorPath" />
|
||||
</vector>
|
||||
10
app/src/main/res/drawable-anydpi/ic_menu_del.xml
Normal file
10
app/src/main/res/drawable-anydpi/ic_menu_del.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="?attr/colorOnSurface"
|
||||
android:pathData="M202.667 256H160a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.667v565.333A53.333 53.333 0 0 0 320 874.667h384a53.333 53.333 0 0 0 53.333-53.334V352a32 32 0 0 1 64 0v469.333c0 64.8-52.533 117.334-117.333 117.334H320c-64.8 0-117.333-52.534-117.333-117.334zm224-106.667a32 32 0 0 1 0-64h170.666a32 32 0 0 1 0 64zm-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0zm170.666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0z"/>
|
||||
</vector>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_download"
|
||||
@@ -17,8 +16,15 @@
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_info"
|
||||
android:id="@+id/action_del"
|
||||
android:icon="@drawable/ic_menu_del"
|
||||
android:orderInCategory="300"
|
||||
android:title="@string/action_del"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_info"
|
||||
android:orderInCategory="400"
|
||||
android:title="@string/action_info"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<string name="action_info">关于</string>
|
||||
<string name="action_download">下载</string>
|
||||
<string name="action_sort">整理</string>
|
||||
<string name="action_del">删除</string>
|
||||
|
||||
<string name="menu_home">主页</string>
|
||||
<string name="menu_sort">分类</string>
|
||||
@@ -33,6 +34,7 @@
|
||||
<string name="err_pick_img">选取图片失败</string>
|
||||
<string name="err_crop_img">裁剪图片失败</string>
|
||||
<string name="download_apk_fail">下载更新失败</string>
|
||||
<string name="delele_all_empty_manga">删除所有空漫画?</string>
|
||||
|
||||
<string name="login">登录</string>
|
||||
<string name="logout">注销</string>
|
||||
|
||||
Reference in New Issue
Block a user