mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-09 17:50:28 +08:00
v2.2.9
新增 1. 看板娘加载背景 修复 1. 设置输入框无法缩回中部 优化 1. 限用MainActivity弱引用
This commit is contained in:
BIN
.github/komako.jpg
vendored
BIN
.github/komako.jpg
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 121 KiB |
1
.idea/dictionaries/fumiama.xml
generated
1
.idea/dictionaries/fumiama.xml
generated
@@ -5,6 +5,7 @@
|
||||
<w>downloaders</w>
|
||||
<w>grps</w>
|
||||
<w>imgs</w>
|
||||
<w>kohima</w>
|
||||
<w>lowpan</w>
|
||||
<w>mangacopy</w>
|
||||
<w>mangafuna</w>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
|
||||
@@ -69,6 +69,7 @@ open class MangaPagesFragmentTemplate(inflateRes:Int, private val isLazy: Boolea
|
||||
return
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
showKanban()
|
||||
withContext(Dispatchers.IO) {
|
||||
delay(600)
|
||||
setLayouts()
|
||||
@@ -100,6 +101,7 @@ open class MangaPagesFragmentTemplate(inflateRes:Int, private val isLazy: Boolea
|
||||
initCardList(WeakReference(this@MangaPagesFragmentTemplate))
|
||||
managePage()
|
||||
setListeners()
|
||||
hideKanban()
|
||||
}
|
||||
|
||||
private suspend fun managePage() {
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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?,
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
@@ -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(
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -26,8 +26,8 @@ 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
|
||||
@@ -35,8 +35,9 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
|
||||
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() {
|
||||
@@ -221,9 +222,11 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
|
||||
isContentChanged = true
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
showKanban()
|
||||
reset()
|
||||
delay(600)
|
||||
addPage()
|
||||
hideKanban()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) }
|
||||
@@ -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
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package top.fumiama.copymanga.ui.settings
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.annotation.Keep
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.EditTextPreferenceDialogFragmentCompat
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -17,6 +12,7 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import top.fumiama.copymanga.tools.ui.UITools
|
||||
import top.fumiama.copymanga.views.AutoHideEditTextPreferenceDialogFragmentCompat
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
|
||||
class SettingsFragment: PreferenceFragmentCompat() {
|
||||
@@ -41,50 +37,11 @@ class SettingsFragment: PreferenceFragmentCompat() {
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||
if (preference is EditTextPreference) {
|
||||
Log.d("MySF", "preference is EditTextPreference")
|
||||
val f = EditTextPreferenceDialogFragmentCompat.newInstance(preference.key)
|
||||
val f = view?.let { AutoHideEditTextPreferenceDialogFragmentCompat.newInstance(it, preference.key) }?:return
|
||||
f.setTargetFragment(this, 0)
|
||||
f.show(parentFragmentManager, null)
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
var diff = 0
|
||||
var cnt = 0
|
||||
while (diff == 0 && cnt++ < 20) {
|
||||
delay(50)
|
||||
if (f.dialog == null) continue
|
||||
val v = view?:return@withContext
|
||||
// https://github.com/mikepenz/MaterialDrawer/blob/aa9136fb4f5b3a80460fe5f47213985026d20c88/library/src/main/java/com/mikepenz/materialdrawer/util/KeyboardUtil.java
|
||||
val r = Rect()
|
||||
//r will be populated with the coordinates of your view that area still visible.
|
||||
v.getWindowVisibleDisplayFrame(r)
|
||||
//get screen height and calculate the difference with the usable area from the r
|
||||
val height = v.context.resources.displayMetrics.heightPixels
|
||||
diff = height - r.bottom
|
||||
Log.d("MySF", "diff: $diff")
|
||||
}
|
||||
Log.d("MySF", "diff out while: $diff")
|
||||
if (diff <= 0) return@withContext
|
||||
Log.d("MySF", "f.dialog is ${f.dialog}")
|
||||
withContext(Dispatchers.Main) {
|
||||
f.dialog?.window?.apply {
|
||||
val attr = attributes
|
||||
Log.d("MySF", "animate from ${attr.y} to ${attr.y-diff/2}")
|
||||
ObjectAnimator.ofInt(WindowAttributeSetter(this), "y", attr.y, attr.y-diff/2).setDuration(233).start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
|
||||
inner class WindowAttributeSetter(private val window: Window) {
|
||||
@Keep
|
||||
fun setY(y: Int) {
|
||||
val attr = window.attributes
|
||||
attr.y = y
|
||||
Log.d("MySF", "set y to $y")
|
||||
window.attributes = attr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package top.fumiama.copymanga.views
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.annotation.Keep
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.EditTextPreferenceDialogFragmentCompat
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class AutoHideEditTextPreferenceDialogFragmentCompat(private val settingsFragmentView: View): EditTextPreferenceDialogFragmentCompat() {
|
||||
var exit = false
|
||||
override fun show(manager: FragmentManager, tag: String?) {
|
||||
super.show(manager, tag)
|
||||
lifecycleScope.launch { goUp() }
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
exit = true
|
||||
}
|
||||
private suspend fun goUp() = withContext(Dispatchers.IO) {
|
||||
var round = 0
|
||||
while(!exit) {
|
||||
var diff = round
|
||||
while (!exit && ((round == 0 && diff == 0) || (round > 0 && diff != 0))) {
|
||||
delay(200)
|
||||
if (dialog == null) continue
|
||||
// https://github.com/mikepenz/MaterialDrawer/blob/aa9136fb4f5b3a80460fe5f47213985026d20c88/library/src/main/java/com/mikepenz/materialdrawer/util/KeyboardUtil.java
|
||||
val r = Rect()
|
||||
//r will be populated with the coordinates of your view that area still visible.
|
||||
settingsFragmentView.getWindowVisibleDisplayFrame(r)
|
||||
//get screen height and calculate the difference with the usable area from the r
|
||||
val height = settingsFragmentView.context.resources.displayMetrics.heightPixels
|
||||
diff = height - r.bottom
|
||||
Log.d("MySF", "diff: $diff")
|
||||
}
|
||||
Log.d("MySF", "diff out while: $diff")
|
||||
if (diff <= 0 && round == 0) return@withContext
|
||||
Log.d("MySF", "f.dialog is $dialog")
|
||||
withContext(Dispatchers.Main) {
|
||||
dialog?.window?.apply {
|
||||
val attr = attributes
|
||||
if (diff != 0) {
|
||||
Log.d("MySF", "animate from ${attr.y} to ${attr.y-diff/2}")
|
||||
ObjectAnimator.ofInt(WindowAttributeSetter(this), "y", attr.y, attr.y-diff/2).setDuration(233).start()
|
||||
} else {
|
||||
Log.d("MySF", "animate from ${attr.y} to 0")
|
||||
ObjectAnimator.ofInt(WindowAttributeSetter(this), "y", attr.y, 0).setDuration(233).start()
|
||||
round = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
round++
|
||||
}
|
||||
}
|
||||
inner class WindowAttributeSetter(private val window: Window) {
|
||||
@Keep
|
||||
fun setY(y: Int) {
|
||||
val attr = window.attributes
|
||||
attr.y = y
|
||||
Log.d("MySF", "set y to $y")
|
||||
window.attributes = attr
|
||||
}
|
||||
}
|
||||
companion object {
|
||||
fun newInstance(view: View, key: String?): AutoHideEditTextPreferenceDialogFragmentCompat {
|
||||
val fragment = AutoHideEditTextPreferenceDialogFragmentCompat(view)
|
||||
val b = Bundle(1)
|
||||
b.putString(ARG_KEY, key)
|
||||
fragment.setArguments(b)
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-nodpi/kohima.webp
Normal file
BIN
app/src/main/res/drawable-nodpi/kohima.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
@@ -7,14 +7,30 @@
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/app_bar_main">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cmaini"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:alpha="0.6"
|
||||
android:scaleType="fitEnd"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/kohima"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -26,7 +26,10 @@
|
||||
android:id="@+id/fbtab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_scrollFlags="scroll"/>
|
||||
android:background="@android:color/transparent"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
app:layout_scrollFlags="scroll"
|
||||
app:tabBackground="@android:color/transparent" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
@@ -141,6 +141,8 @@
|
||||
<string name="settings_cat_general_et_summary_app_version">默认&appver;</string>
|
||||
<string name="settings_cat_general_sb_card_per_row">每行加载卡片数偏移</string>
|
||||
<string name="settings_cat_general_sm_card_per_row">默认为0表示无偏移, 在此基础上加减</string>
|
||||
<string name="settings_cat_general_sw_disable_kanban_animation">不显示看板娘动画</string>
|
||||
<string name="settings_cat_general_sm_disable_kanban_animation">如加载卡顿可考虑开启此选项</string>
|
||||
|
||||
<string name="settings_cat_net">网络</string>
|
||||
<string name="settings_cat_net_sb_title_image_resolution">图片分辨率</string>
|
||||
|
||||
@@ -14,15 +14,12 @@
|
||||
app:entries="@array/menus"
|
||||
app:entryValues="@array/menu_ids"
|
||||
android:defaultValue="0"/>
|
||||
<SeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:max="8"
|
||||
<SwitchPreferenceCompat
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="settings_cat_general_sb_card_per_row"
|
||||
app:min="-8"
|
||||
app:showSeekBarValue="true"
|
||||
app:summary="@string/settings_cat_general_sm_card_per_row"
|
||||
app:title="@string/settings_cat_general_sb_card_per_row" />
|
||||
app:key="settings_cat_general_sw_disable_kanban_animation"
|
||||
app:selectable="true"
|
||||
app:summary="@string/settings_cat_general_sm_disable_kanban_animation"
|
||||
app:title="@string/settings_cat_general_sw_disable_kanban_animation" />
|
||||
<EditTextPreference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -34,6 +31,15 @@
|
||||
app:enableCopying="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="settings_cat_general_et_app_version" />
|
||||
<SeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:max="8"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="settings_cat_general_sb_card_per_row"
|
||||
app:min="-8"
|
||||
app:showSeekBarValue="true"
|
||||
app:summary="@string/settings_cat_general_sm_card_per_row"
|
||||
app:title="@string/settings_cat_general_sb_card_per_row" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
|
||||
Reference in New Issue
Block a user