Skip to content

Commit

Permalink
v2.2.9
Browse files Browse the repository at this point in the history
新增
1. 看板娘加载背景
修复
1. 设置输入框无法缩回中部
优化
1. 限用MainActivity弱引用
  • Loading branch information
fumiama committed Apr 10, 2024
1 parent 5ea5ad6 commit 43de164
Show file tree
Hide file tree
Showing 23 changed files with 220 additions and 96 deletions.
Binary file removed .github/komako.jpg
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/dictionaries/fumiama.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src=".github/komako.jpg" width = "300" height = "300" alt="Komako"><br>
<img src="app/src/main/res/drawable-nodpi/kohima.webp" width = "256" height = "256" alt="Kohima"><br>
<h1>copymanga 拷贝漫画</h1>
拷贝漫画的第三方APP,优化阅读/下载体验<br><br>

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId 'top.fumiama.copymanga'
minSdkVersion 23
targetSdkVersion 34
versionCode 56
versionName '2.2.8'
versionCode 57
versionName '2.2.9'
resourceConfigurations += ['zh', 'zh-rCN']

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
37 changes: 20 additions & 17 deletions app/src/main/java/top/fumiama/copymanga/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ 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
Expand Down Expand Up @@ -98,22 +97,6 @@ class MainActivity : AppCompatActivity() {
)
setupActionBarWithNavController(navController!!, appBarConfiguration)
nav_view.setupWithNavController(navController!!)
PreferenceManager.getDefaultSharedPreferences(this)?.apply {
if (contains("settings_cat_general_sb_startup_menu")) getString("settings_cat_general_sb_startup_menu", "0")?.toInt()?.let {
if (it > 0) {
Log.d("MyMain", "nav 2 dest $it")
navController!!.navigate(listOf(
R.id.nav_home,
R.id.nav_sort,
R.id.nav_rank,
R.id.nav_sub,
R.id.nav_history,
R.id.nav_new_download,
R.id.nav_settings
)[it])
}
}
}

headPic = File(getExternalFilesDir(""), "headPic")
drawer_layout.addDrawerListener(object : DrawerLayout.DrawerListener {
Expand Down Expand Up @@ -161,6 +144,26 @@ class MainActivity : AppCompatActivity() {
}
}

override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
PreferenceManager.getDefaultSharedPreferences(this)?.apply {
if (contains("settings_cat_general_sb_startup_menu")) getString("settings_cat_general_sb_startup_menu", "0")?.toInt()?.let {
if (it > 0) {
Log.d("MyMain", "nav 2 dest $it")
navController!!.navigate(listOf(
R.id.nav_home,
R.id.nav_sort,
R.id.nav_rank,
R.id.nav_sub,
R.id.nav_history,
R.id.nav_new_download,
R.id.nav_settings
)[it])
}
}
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.main, menu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ open class MangaPagesFragmentTemplate(inflateRes:Int, private val isLazy: Boolea
return
}
lifecycleScope.launch {
showKanban()
withContext(Dispatchers.IO) {
delay(600)
setLayouts()
Expand Down Expand Up @@ -100,6 +101,7 @@ open class MangaPagesFragmentTemplate(inflateRes:Int, private val isLazy: Boolea
initCardList(WeakReference(this@MangaPagesFragmentTemplate))
managePage()
setListeners()
hideKanban()
}

private suspend fun managePage() {
Expand All @@ -116,9 +118,11 @@ open class MangaPagesFragmentTemplate(inflateRes:Int, private val isLazy: Boolea
override fun onRefresh() {
lifecycleScope.launch {
withContext(Dispatchers.IO) {
showKanban()
reset()
delay(600)
addPage()
hideKanban()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
package top.fumiama.copymanga.template.general

import android.animation.ObjectAnimator
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.animation.doOnEnd
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.content_main.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity
import top.fumiama.copymanga.tools.ui.UITools
import java.util.concurrent.atomic.AtomicBoolean

open class NoBackRefreshFragment(private val layoutToLoad: Int): Fragment() {
private var _rootView: View? = null
val rootView: View get() = _rootView!!
var isFirstInflate = true
var navBarHeight = 0
private val disableAnimation = MainActivity.mainWeakReference?.get()?.let {
PreferenceManager.getDefaultSharedPreferences(it)
}?.getBoolean("settings_cat_general_sw_disable_kanban_animation", false)?:false
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -31,7 +43,40 @@ open class NoBackRefreshFragment(private val layoutToLoad: Int): Fragment() {
}
override fun onDestroy() {
super.onDestroy()
Thread { runBlocking { hideKanban() } }.start()
_rootView = null
isFirstInflate = true
Log.d("MyNBRF", "destroyed")
}
suspend fun showKanban() = withContext(Dispatchers.Main) {
if (disableAnimation) return@withContext
(activity?:(MainActivity.mainWeakReference?.get()))?.apply {cmaini?.post {
if(cmaini?.visibility == View.GONE) {
Log.d("MyNBRF", "show: start, set h: ${window?.decorView?.height}")
cmaini?.translationY = window?.decorView?.height?.toFloat()?:0f
cmaini?.visibility = View.VISIBLE
ObjectAnimator.ofFloat(cmaini, "translationY", cmaini?.translationY?:0f, 0f).setDuration(300).start()
}
}
}?:Log.d("MyNBRF", "show: null kanban ImgView")
Log.d("MyNBRF", "show: end")
}
private var isHideRunning = AtomicBoolean()
suspend fun hideKanban() = withContext(Dispatchers.Main) {
if (disableAnimation) return@withContext
(activity?:(MainActivity.mainWeakReference?.get()))?.apply { cmaini?.post {
if(!isHideRunning.get() && cmaini?.visibility == View.VISIBLE) {
isHideRunning.set(true)
Log.d("MyNBRF", "hide: start, set h: ${window?.decorView?.height}")
ObjectAnimator.ofFloat(cmaini, "translationY", 0f, window?.decorView?.height?.toFloat()?:0f).setDuration(300).also {
it.doOnEnd {
cmaini?.visibility = View.GONE
isHideRunning.set(false)
Log.d("MyNBRF", "hide: set gone")
}
}.start()
}
} }?:Log.d("MyNBRF", "hide: null kanban ImgView")
Log.d("MyNBRF", "hide: end")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ open class InfoCardLoader(inflateRes:Int, private val navId:Int, private val isT
lifecycleScope.launch {
withContext(Dispatchers.IO) {
delay(timeMillis)
showKanban()
reset()
addPage()
hideKanban()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.line_finish.*
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.tools.api.CMApi
import top.fumiama.dmzj.copymanga.R

Expand All @@ -24,7 +23,7 @@ open class ThemeCardFlow(private val api: Int, nav: Int) : StatusCardFlow(0, nav
arguments?.apply {
getString("path")?.apply { theme = this }
getString("name")?.apply {
mainWeakReference?.get()?.toolbar?.title = this
activity?.toolbar?.title = this
}
}
}
Expand All @@ -38,7 +37,7 @@ open class ThemeCardFlow(private val api: Int, nav: Int) : StatusCardFlow(0, nav
override fun onResume() {
super.onResume()
arguments?.getString("name")?.apply {
mainWeakReference?.get()?.toolbar?.title = this
activity?.toolbar?.title = this
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.json.ThemeStructure
import top.fumiama.copymanga.manga.Reader
import top.fumiama.copymanga.tools.api.CMApi
import top.fumiama.copymanga.tools.ui.GlideBlurTransformation
import top.fumiama.copymanga.tools.ui.GlideHideLottieViewListener
import top.fumiama.copymanga.tools.ui.Navigate
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
import top.fumiama.dmzj.copymanga.R
import java.lang.ref.WeakReference

Expand Down Expand Up @@ -123,7 +121,7 @@ class BookHandler(private val th: WeakReference<BookFragment>): Handler(Looper.m
that?.apply {
// tic?.text = book?.name
// tic?.visibility = View.GONE
mainWeakReference?.get()?.toolbar?.title = book?.name
activity?.toolbar?.title = book?.name
btauth?.text = that?.getString(R.string.text_format_region)?.format(book?.region?:"未知")
bttag?.text = that?.getString(R.string.text_format_img_type)?.format(book?.imageType?:"未知")
bthit?.text = that?.getString(R.string.text_format_hit)?.format(book?.popular?:-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import top.fumiama.copymanga.json.VolumeStructure
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
import top.fumiama.dmzj.copymanga.R
import java.io.File
import java.lang.Thread.sleep
import java.lang.ref.WeakReference

class ComicDlFragment: NoBackRefreshFragment(R.layout.fragment_dlcomic) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import kotlinx.android.synthetic.main.widget_downloadbar.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.json.ChapterStructure
import top.fumiama.copymanga.json.ComicStructureOld
import top.fumiama.copymanga.json.VolumeStructure
Expand Down Expand Up @@ -126,6 +125,7 @@ class ComicDlHandler(looper: Looper, private val th: WeakReference<ComicDlFragme
}
complete = true
}
that?.hideKanban()
}
private suspend fun addDiv() = withContext(Dispatchers.Main) {
that?.ldwn?.addView(
Expand Down Expand Up @@ -191,7 +191,7 @@ class ComicDlHandler(looper: Looper, private val th: WeakReference<ComicDlFragme
val widthData = toolsBox.calcWidthFromDpRoot(8, 64)
btnNumPerRow = widthData[0]
btnw = widthData[1]
dl = mainWeakReference?.get()?.let { Dialog(it) }
dl = that?.activity?.let { Dialog(it) }
dl?.setContentView(R.layout.dialog_unzipping)
that?.dlsdwn?.viewTreeObserver?.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener{
override fun onGlobalLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import kotlinx.android.synthetic.main.fragment_download.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.manga.Reader
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
import top.fumiama.copymanga.tools.file.FileUtils
Expand All @@ -27,7 +26,7 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
super.onViewCreated(view, savedInstanceState)
if(isFirstInflate) {
arguments?.getString("title")?.let {
mainWeakReference?.get()?.toolbar?.title = it
activity?.toolbar?.title = it
}
lifecycleScope.launch {
scanFile(arguments?.getString("file")?.let { File(it) }?:context?.getExternalFilesDir("")?:run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.manga.Reader
import top.fumiama.copymanga.template.general.MangaPagesFragmentTemplate
import top.fumiama.copymanga.template.ui.CardList
Expand All @@ -26,17 +26,18 @@ import java.lang.ref.WeakReference
@OptIn(ExperimentalStdlibApi::class)
class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownload, forceLoad = true) {
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("")
private val oldDlCardName = mainWeakReference?.get()?.getString(R.string.old_download_card_name)!!
private val extDir = mainWeakReference?.get()?.getExternalFilesDir("")
private var isReverse = false
private var isContentChanged = false
private var exit = false
private var showAll = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
wn = WeakReference(this)
val settingsPref = MainActivity.mainWeakReference?.get()?.let { PreferenceManager.getDefaultSharedPreferences(it) }
showAll = settingsPref?.getBoolean("settings_cat_md_sw_show_0m_manga", false)?:false
showAll = activity?.let {
PreferenceManager.getDefaultSharedPreferences(it)
}?.getBoolean("settings_cat_md_sw_show_0m_manga", false)?:false
}

override fun onPause() {
Expand Down Expand Up @@ -221,9 +222,11 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
isContentChanged = true
lifecycleScope.launch {
withContext(Dispatchers.IO) {
showKanban()
reset()
delay(600)
addPage()
hideKanban()
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/top/fumiama/copymanga/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import kotlinx.android.synthetic.main.viewpage_horizonal.view.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import top.fumiama.copymanga.MainActivity
import top.fumiama.copymanga.MainActivity.Companion.ime
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.json.BookListStructure
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
import top.fumiama.copymanga.template.http.PausableDownloader
Expand All @@ -46,9 +46,9 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if(isFirstInflate) {
val tb = mainWeakReference?.get()?.toolsBox
val netInfo = tb?.netInfo
if(netInfo != null && netInfo != tb.transportStringNull && netInfo != tb.transportStringError)
val tb = (activity as MainActivity).toolsBox
val netInfo = tb.netInfo
if(netInfo != tb.transportStringNull && netInfo != tb.transportStringError)
MainActivity.member?.apply { lifecycleScope.launch {
info().let { l ->
if (l.code != 200 && l.code != 449) {
Expand Down Expand Up @@ -163,7 +163,7 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
setOnTouchListener { _, e ->
Log.d("MyHF", "fhns on touch")
if (e.action == MotionEvent.ACTION_UP && mSearchEditText?.text?.isNotEmpty() == true) {
ime?.hideSoftInputFromWindow(mainWeakReference?.get()?.window?.decorView?.windowToken, 0)
ime?.hideSoftInputFromWindow(activity?.window?.decorView?.windowToken, 0)
}
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ class HomeHandler(private val that: WeakReference<HomeFragment>) : AutoDownloadH
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
when (msg.what) {
-1 -> homeF?.swiperefresh?.isRefreshing = msg.obj as Boolean
-1 -> {
homeF?.apply {
swiperefresh?.isRefreshing = msg.obj as Boolean
lifecycleScope.launch { if(msg.obj as Boolean) showKanban() else hideKanban() }
}
}
//0 -> setLayouts()
1 -> inflateCardLines()
2 -> homeF?.swiperefresh?.let { setSwipe(it) }
Expand Down Expand Up @@ -274,6 +279,7 @@ class HomeHandler(private val that: WeakReference<HomeFragment>) : AutoDownloadH
Log.d("MyHFH", "Refresh items.")
homeF?.lifecycleScope?.launch {
withContext(Dispatchers.IO) {
homeF?.showKanban()
fhib?.isAutoPlay = false
fhib?.adapter?.notifyDataSetChanged()
index = null
Expand Down
Loading

0 comments on commit 43de164

Please sign in to comment.