1
0
mirror of https://github.com/fumiama/copymanga.git synced 2026-06-10 10:24:29 +08:00

2.0.beta9

1. api改为云函数反代
2. 记录漫画与章节的阅读进度
3. 详情页显示章节
4. 修复流量警告不再提醒无效
This commit is contained in:
fumiama
2022-01-19 21:24:46 +08:00
parent 5811a4da13
commit 683c4eda8c
14 changed files with 301 additions and 81 deletions

View File

@@ -21,6 +21,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.drawerlayout.widget.DrawerLayout
import androidx.navigation.NavController
@@ -36,7 +37,6 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.nav_header_main.*
import top.fumiama.dmzj.copymanga.R
import top.fumiama.copymanga.tools.file.PropertiesTools
import top.fumiama.copymanga.tools.api.UITools
import top.fumiama.copymanga.ui.download.DownloadFragment
import top.fumiama.copymanga.update.Update
@@ -50,7 +50,6 @@ class MainActivity : AppCompatActivity() {
var navController: NavController? = null
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var p: PropertiesTools
private lateinit var headPic: File
override fun onCreate(savedInstanceState: Bundle?) {
@@ -75,7 +74,6 @@ class MainActivity : AppCompatActivity() {
setupActionBarWithNavController(navController!!, appBarConfiguration)
nav_view.setupWithNavController(navController!!)
p = PropertiesTools(File(filesDir, "database.prop"))
headPic = File(getExternalFilesDir(""), "headPic")
mainWeakReference = WeakReference(this)
drawer_layout.addDrawerListener(object : DrawerLayout.DrawerListener {
@@ -121,7 +119,7 @@ class MainActivity : AppCompatActivity() {
}
true
}
p["navTextInfo"].let { if (it != "null") navtinfo.text = it }
navtinfo.text = getPreferences(MODE_PRIVATE).getString("navTextInfo", getString(R.string.navTextInfo))
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
@@ -239,7 +237,7 @@ class MainActivity : AppCompatActivity() {
private fun checkUpdate(ignoreSkip: Boolean) {
Thread{
Update.checkUpdate(this, p, UITools(this), ignoreSkip)
Update.checkUpdate(this, UITools(this), ignoreSkip)
}.start()
}
@@ -259,7 +257,10 @@ class MainActivity : AppCompatActivity() {
MaterialDialog(this).show {
input(prefill = (it as TextView).text) { _, charSequence ->
it.text = charSequence
p["navTextInfo"] = charSequence.toString()
getPreferences(MODE_PRIVATE).edit {
putString("navTextInfo", charSequence.toString())
apply()
}
}
positiveButton(android.R.string.ok)
title(R.string.navTextInfoInputHint)

View File

@@ -3,20 +3,18 @@ package top.fumiama.copymanga.template.general
import android.app.Activity
import android.os.Bundle
import android.view.View
import top.fumiama.copymanga.tools.file.PropertiesTools
import androidx.core.content.edit
import top.fumiama.copymanga.tools.api.UITools
import java.io.File
import java.lang.ref.WeakReference
open class ActivityTemplate:Activity() {
lateinit var p: PropertiesTools
lateinit var toolsBox: UITools
val p = IntPref()
val pb = BoolPref()
private val allFullScreen
get() = p["allFullScreen"] == "true"
get() = getPreferences(MODE_PRIVATE).getBoolean("allFullScreen", false)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
p = PropertiesTools(File("$filesDir/settings.properties"))
toolsBox = UITools(this)
}
@@ -25,4 +23,20 @@ open class ActivityTemplate:Activity() {
if(allFullScreen) window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
}
inner class IntPref {
operator fun get(key: String) = getPreferences(MODE_PRIVATE).getInt(key, -5)
operator fun set(key: String, value: Int) = getPreferences(MODE_PRIVATE).edit {
putInt(key, value)
apply()
}
}
inner class BoolPref {
operator fun get(key: String) = getPreferences(MODE_PRIVATE).getBoolean(key, false)
operator fun set(key: String, value: Boolean) = getPreferences(MODE_PRIVATE).edit {
putBoolean(key, value)
apply()
}
}
}

View File

@@ -1,11 +1,13 @@
package top.fumiama.copymanga.ui.book
import android.content.Context.MODE_PRIVATE
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.View
import androidx.navigation.Navigation
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.line_booktandb.*
import top.fumiama.dmzj.copymanga.R
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
@@ -33,12 +35,16 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
menuMain?.let { setMenuVisible(it) }
toolbar.title = bookHandler.book?.results?.comic?.name
}
setStartRead()
}
override fun onDestroy() {
super.onDestroy()
mainWeakReference?.get()?.menuMain?.let { setMenuInvisible(it) }
bookHandler.destroy()
bookHandler.ads.forEach {
it.exit = true
}
}
override fun onPause() {
@@ -46,6 +52,25 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
mainWeakReference?.get()?.menuMain?.let { setMenuInvisible(it) }
}
fun setStartRead() {
mainWeakReference?.get()?.apply {
bookHandler.book?.results?.comic?.name?.let {
getPreferences(MODE_PRIVATE).getInt(it, -1).let { p ->
this@BookFragment.lbbstart.apply {
var i = 0
if(p >= 0) {
text = bookHandler.chapterNames[p]
i = p
}
setOnClickListener {
bookHandler.callViewManga(i)
}
}
}
}
}
}
private fun setMenuInvisible(menu: Menu){
menu.findItem(R.id.action_download)?.isVisible = false
}
@@ -68,19 +93,12 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
val bundle = Bundle()
bundle.putString("path", arguments?.getString("path")?:"null")
bundle.putString("name", bookHandler.book?.results?.comic?.name)
val groups = bookHandler.book?.results?.groups
var keys = arrayOf<String>()
var gpws = arrayOf<String>()
var cnts = intArrayOf()
groups?.values?.forEach {
keys += it.name
gpws += it.path_word
cnts += it.count
Log.d("MyBF", "Add caption: ${it.name} @ ${it.path_word} of ${it.count}")
if(bookHandler.vols != null) {
bundle.putBoolean("loadJson", true)
}
bundle.putStringArray("group", gpws)
bundle.putStringArray("groupNames", keys)
bundle.putIntArray("count", cnts)
bundle.putStringArray("group", bookHandler.gpws)
bundle.putStringArray("groupNames", bookHandler.keys)
bundle.putIntArray("count", bookHandler.cnts)
rootView?.let { Navigation.findNavController(it).navigate(R.id.action_nav_book_to_nav_group, bundle) }
}
}

View File

@@ -1,5 +1,7 @@
package top.fumiama.copymanga.ui.book
import android.content.Context.MODE_PRIVATE
import android.content.Intent
import android.os.Bundle
import android.os.Looper
import android.os.Message
@@ -7,28 +9,41 @@ import android.util.Log
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.core.content.edit
import androidx.navigation.Navigation
import com.bumptech.glide.Glide
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.request.RequestOptions
import com.google.gson.Gson
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.button_tbutton.view.*
import kotlinx.android.synthetic.main.card_book.*
import kotlinx.android.synthetic.main.fragment_book.*
import kotlinx.android.synthetic.main.line_2chapters.view.*
import kotlinx.android.synthetic.main.line_bookinfo.*
import kotlinx.android.synthetic.main.line_bookinfo_text.*
import kotlinx.android.synthetic.main.line_booktandb.*
import kotlinx.android.synthetic.main.line_caption.view.*
import kotlinx.android.synthetic.main.line_chapter.view.*
import kotlinx.android.synthetic.main.widget_downloadbar.*
import top.fumiama.dmzj.copymanga.R
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
import top.fumiama.copymanga.json.BookInfoStructure
import top.fumiama.copymanga.json.ChapterStructure
import top.fumiama.copymanga.json.ThemeStructure
import top.fumiama.copymanga.json.VolumeStructure
import top.fumiama.copymanga.template.http.AutoDownloadHandler
import top.fumiama.copymanga.template.http.AutoDownloadThread
import top.fumiama.copymanga.tools.api.CMApi
import top.fumiama.copymanga.tools.api.GlideBlurTransformation
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment.Companion.json
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
import java.io.File
import java.lang.Thread.sleep
import java.lang.ref.WeakReference
class BookHandler(that: WeakReference<BookFragment>, path: String)
class BookHandler(that: WeakReference<BookFragment>, private val path: String)
: AutoDownloadHandler(
that.get()?.getString(R.string.bookInfoApiUrl)?.let { String.format(it, path) } ?: "",
BookInfoStructure::class.java,
@@ -43,6 +58,12 @@ class BookHandler(that: WeakReference<BookFragment>, path: String)
var book: BookInfoStructure? = null
var fbibinfo:View? = null
var complete = false
var ads = emptyArray<AutoDownloadThread>()
var gpws = arrayOf<String>()
var keys = arrayOf<String>()
var cnts = intArrayOf()
var vols: Array<VolumeStructure>? = null
var chapterNames = arrayOf<String>()
private val divider get() = that?.layoutInflater?.inflate(R.layout.div_h, that.fbl, false)
private var fbtinfo: View? = null
@@ -55,7 +76,6 @@ class BookHandler(that: WeakReference<BookFragment>, path: String)
3 -> fbibinfo?.let { setInfoHeight(it) }
4 -> setThemes()
5 -> setOverScale()
6 -> endSetLayouts()
}
}
@@ -80,12 +100,20 @@ class BookHandler(that: WeakReference<BookFragment>, path: String)
super.doWhenFinishDownload()
if(exit) return
inflateComponents()
Thread{ for (i in 1..6) sendEmptyMessage(i) }.start()
book?.results?.groups?.values?.forEach{
keys += it.name
gpws += it.path_word
cnts += it.count
Log.d("MyBFH", "Add caption: ${it.name} @ ${it.path_word} of ${it.count}")
}
initComicData()
Thread{ for (i in 1..5) sendEmptyMessage(i) }.start()
}
private fun endSetLayouts(){
that?.fbloading?.visibility = View.GONE
complete = true
that?.setStartRead()
Log.d("MyBH", "Set complete: true")
}
@@ -192,9 +220,63 @@ class BookHandler(that: WeakReference<BookFragment>, path: String)
that?.apply {
book?.results?.comic?.apply {
author?.let { setTheme(getString(R.string.author), it, R.id.action_nav_book_to_nav_author) }
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
theme?.let { setTheme(getString(R.string.caption), it, R.id.action_nav_book_to_nav_caption) }
}
}
Thread{
while (vols == null && !exit) sleep(1000)
if(exit) return@Thread
that?.apply {
book?.results?.apply {
mainWeakReference?.get()?.runOnUiThread{
ViewMangaActivity.fileArray = arrayOf()
ViewMangaActivity.urlArray = arrayOf()
vols?.forEachIndexed { iv, v ->
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
val t = layoutInflater.inflate(R.layout.line_caption, fbl, false)
t.tcptn.text = keys[iv]
fbl.addView(t)
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
var line: View? = null
val last = v.results.list.size - 1
v.results.list.onEachIndexed { i, it ->
ViewMangaActivity.urlArray += CMApi.getApiUrl(R.string.chapterInfoApiUrl, comic.path_word, it.uuid)?:""
ViewMangaActivity.fileArray += CMApi.getZipFile(context?.getExternalFilesDir(""), comic.name, keys[iv], it.name)
chapterNames += it.name
if(line == null) {
if(i == last) {
line = layoutInflater.inflate(R.layout.line_chapter, that.fbl, false)
line?.lcc?.apply {
lct.text = it.name
setOnClickListener { callViewManga(i) }
}
fbl?.addView(line)
} else {
line = layoutInflater.inflate(R.layout.line_2chapters, that.fbl, false)
line?.l2cl?.apply {
lct.text = it.name
setOnClickListener { callViewManga( i) }
}
}
} else line?.l2cr?.apply {
lct.text = it.name
setOnClickListener { callViewManga(i) }
fbl?.addView(line)
line = null
}
}
}
// padding
val line = layoutInflater.inflate(R.layout.line_chapter, that.fbl, false)
line.lci.visibility = View.INVISIBLE
line.isClickable = false
fbl?.addView(line)
endSetLayouts()
}
}
}
}.start()
}
private fun loadVolume(name: String, path: String, nav: Int){
@@ -204,4 +286,100 @@ class BookHandler(that: WeakReference<BookFragment>, path: String)
bundle.putString("path", path)
that?.rootView?.let { Navigation.findNavController(it).navigate(nav, bundle) }
}
private fun initComicData() {
var volumes = emptyArray<VolumeStructure>()
val counts = cnts.clone()
gpws.forEachIndexed { i, gpw ->
Log.d("MyBFH", "下载:$gpw")
var offset = 0
val times = counts[i] / 100
val remain = counts[i] % 100
val re = arrayOfNulls<VolumeStructure>(if(remain != 0) (times+1) else (times))
Log.d("MyBFH", "${i}卷共${if(times == 0) 1 else times}次加载")
do {
counts[i] = counts[i] - 100
CMApi.getApiUrl(R.string.groupInfoApiUrl, path, gpw, offset)?.let {
if(ComicDlFragment.exit) return
val ad = AutoDownloadThread(it) { result ->
Log.d("MyBFH", "${i}卷返回")
val r =
Gson().fromJson(result?.decodeToString(), VolumeStructure::class.java)
re[r.results.offset / 100] = r
}
ads += ad
ad.start()
offset += 100
}
} while (counts[i] > 0)
Thread {
var c = 0
while (c++ < 80) {
sleep(1000)
if(ComicDlFragment.exit) return@Thread
if(re.all { it != null }) break
}
if(re.size > 1) {
val r = re[0]
var s = emptyArray<ChapterStructure>()
re.forEach {
it?.results?.list?.forEach {
s += it
}
}
r?.results?.list = s
r?.apply { volumes += this }
} else re[0]?.apply { volumes += this }
}.start()
}
Thread {
var c = 0
while (c < 80 && volumes.size != gpws.size) {
sleep(1000)
if(ComicDlFragment.exit) return@Thread
Log.d("MyBFH", "已有:${volumes.size} 共:${gpws.size}")
c++
}
if (volumes.size == gpws.size) {
mainWeakReference?.get()?.runOnUiThread {
saveVolumes(volumes)
}
}
}.start()
}
private fun saveVolumes(volumes: Array<VolumeStructure>) {
that?.context?.getExternalFilesDir("")?.let { home ->
book?.results?.comic?.name?.let { name ->
val mangaFolder = File(home, name)
if(!mangaFolder.exists()) mangaFolder.mkdirs()
json = Gson().toJson(volumes)
File(mangaFolder, "info.json").writeText(json!!)
File(mangaFolder, "grps.json").writeText(Gson().toJson(keys))
}
}
vols = volumes
}
fun callViewManga(pos: Int) {
book?.results?.comic?.name?.let {
mainWeakReference?.get()?.getPreferences(MODE_PRIVATE)?.edit {
putInt(it, pos)
apply()
}
}
ViewMangaActivity.dlhandler = null
ViewMangaActivity.position = pos
val zipf = ViewMangaActivity.fileArray[pos]
if (zipf.exists()) {
ViewMangaActivity.zipFile = zipf
that?.startActivity(
Intent(that.context, ViewMangaActivity::class.java)
.putExtra("callFrom", "zipFirst").putExtra("function", "log")
)
} else {
ViewMangaActivity.zipFile = null
that?.startActivity(Intent(that.context, ViewMangaActivity::class.java).putExtra("function", "log"))
}
}
}

View File

@@ -28,7 +28,12 @@ class ComicDlFragment: NoBackRefreshFragment(R.layout.fragment_dlcomic) {
arguments?.getBoolean("callFromOldDL", false) == true -> initOldComicData()
arguments?.getBoolean("loadJson", false) == true -> context?.getExternalFilesDir("")?.let { home ->
arguments?.getString("name")?.let {
start2load(loadFromJson(), true, loadGroupsFromFile(File(home, "$it/grps.json")))
Thread{
sleep(600)
mainWeakReference?.get()?.runOnUiThread {
start2load(loadFromJson(), true, loadGroupsFromFile(File(home, "$it/grps.json")))
}
}.start()
}
}
else -> initComicData(

View File

@@ -28,7 +28,6 @@ import top.fumiama.copymanga.json.ComicStructureOld
import top.fumiama.copymanga.json.VolumeStructure
import top.fumiama.copymanga.tools.api.CMApi
import top.fumiama.copymanga.tools.http.MangaDlTools
import top.fumiama.copymanga.tools.file.PropertiesTools
import top.fumiama.copymanga.tools.api.UITools
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment.Companion.json
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
@@ -45,7 +44,6 @@ class ComicDlHandler(looper: Looper, that: WeakReference<ComicDlFragment>, priva
var complete = false
private val that = that.get()
private val toolsBox = UITools(that.get()?.context)
private val p = PropertiesTools(File("${that.get()?.context?.filesDir}/settings.properties"))
private var btnNumPerRow = 4
private var btnw = 0
private var cdwnWidth = 0

View File

@@ -16,7 +16,6 @@ import top.fumiama.copymanga.json.Chapter2Return
import top.fumiama.copymanga.json.ChapterWithContent
import top.fumiama.copymanga.json.ComicStructure
import top.fumiama.copymanga.template.http.AutoDownloadHandler
import top.fumiama.copymanga.tools.file.PropertiesTools
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.comicName
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.pn
import top.fumiama.copymanga.views.ScaleImageView
@@ -26,7 +25,6 @@ import java.lang.Thread.sleep
import java.lang.ref.WeakReference
import java.text.SimpleDateFormat
import java.util.*
import java.util.zip.ZipInputStream
class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
url, Chapter2Return::class.java, Looper.myLooper()!!
@@ -59,7 +57,6 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
else -> ""
}
}
var progressLog: PropertiesTools? = null
@SuppressLint("SimpleDateFormat", "SetTextI18n")
override fun handleMessage(msg: Message) {
@@ -159,7 +156,6 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
@ExperimentalStdlibApi
private fun prepareManga(){
comicName = manga?.results?.comic?.name
progressLog = PropertiesTools(File("${wv.get()?.filesDir}/progress/${manga?.results?.comic?.name}"))
wv.get()?.count = manga?.results?.chapter?.size?:0
wv.get()?.initManga()
wv.get()?.vprog?.visibility = View.GONE

View File

@@ -12,6 +12,7 @@ import android.util.Log
import android.view.*
import android.widget.SeekBar
import android.widget.Toast
import androidx.core.content.edit
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.bumptech.glide.Glide
@@ -41,7 +42,6 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.InputStream
import java.lang.Thread.sleep
import java.lang.ref.WeakReference
import java.util.*
import java.util.concurrent.FutureTask
@@ -90,21 +90,20 @@ class ViewMangaActivity : TitleActivityTemplate() {
setContentView(R.layout.activity_viewmanga)
super.onCreate(savedInstanceState)
va = WeakReference(this)
//progressLog = PropertiesTools(File("$filesDir/progress/${chapter2Return?.results?.chapter?.comic_id}"))
//dlZip2View = intent.getStringExtra("callFrom") == "Dl" || p["dlZip2View"] == "true"
//zipFirst = intent.getStringExtra("callFrom") == "zipFirst"
cut = p["useCut"] == "true"
r2l = p["r2l"] == "true"
verticalLoadMaxCount = if (p["verticalMax"] != "null") p["verticalMax"].toInt() else 20
isVertical = p["vertical"] == "true"
notUseVP = p["noVP"] == "true" || isVertical
cut = pb["useCut"]
r2l = pb["r2l"]
verticalLoadMaxCount = p["verticalMax"].let { if(it > 0) it else 20 }
isVertical = pb["vertical"]
notUseVP = pb["noVP"] || isVertical
//url = intent.getStringExtra("url")
handler = VMHandler(this, if(urlArray.isNotEmpty()) urlArray[position] else "")
if (p["quality"] != "null") q = p["quality"].toInt()
p["quality"].let { q = if (it > 0) it else 100 }
tt = TimeThread(handler, 22)
tt.canDo = true
tt.start()
volTurnPage = p["volturn"] == "true"
volTurnPage = pb["volturn"]
am = getSystemService(Service.AUDIO_SERVICE) as AudioManager
Log.d("MyVM", "Now ZipFile is $zipFile")
@@ -155,7 +154,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
pageNum = pn
pn = -1
}
sendProgress()
setProgress()
}
private fun preDownloadChapterPages() {
@@ -220,6 +219,9 @@ class ViewMangaActivity : TitleActivityTemplate() {
@ExperimentalStdlibApi
fun initManga(){
handler.manga?.results?.chapter?.uuid?.let {
pn = getPreferences(MODE_PRIVATE).getInt(it, pn)
}
if (zipFile?.exists() != true) doPrepareWebImg()
else prepareItems()
if (!isVertical) restorePN()
@@ -227,7 +229,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
@ExperimentalStdlibApi
private fun prepareImgFromWeb() {
if(toolsBox.netinfo == "移动数据") alertCellar()
if(!noCellarAlert && toolsBox.netinfo == "移动数据") alertCellar()
else handler.startLoad()
}
@@ -431,18 +433,21 @@ class ViewMangaActivity : TitleActivityTemplate() {
}
}
private fun sendProgress() {
handler.progressLog?.let {
//it["chapterId"] = hm.chapterId.toString()
it["page"] = pageNum.toString()
//it["name"] = inftitle.ttitle.text
private fun setProgress() {
handler.manga?.results?.chapter?.uuid?.let {
getPreferences(MODE_PRIVATE).edit {
//it["chapterId"] = hm.chapterId.toString()
putInt(it, pageNum)
//it["name"] = inftitle.ttitle.text
apply()
}
}
}
private fun prepareIdBtCut() {
idtbcut.isChecked = cut
idtbcut.setOnClickListener {
p["useCut"] = if (idtbcut.isChecked) "true" else "false"
pb["useCut"] = idtbcut.isChecked
Toast.makeText(this, "下次浏览生效", Toast.LENGTH_SHORT).show()
}
}
@@ -450,8 +455,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
private fun prepareIdBtLR() {
idtblr.isChecked = r2l
idtblr.setOnClickListener {
if (idtblr.isChecked) p["r2l"] = "true"
else p["r2l"] = "false"
pb["r2l"] = idtblr.isChecked
Toast.makeText(this, "下次浏览生效", Toast.LENGTH_SHORT).show()
}
}
@@ -459,8 +463,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
private fun prepareIdBtVP() {
idtbvp.isChecked = notUseVP
idtbvp.setOnClickListener {
if (idtbvp.isChecked) p["noVP"] = "true"
else p["noVP"] = "false"
pb["noVP"] = idtbvp.isChecked
Toast.makeText(this, "下次浏览生效", Toast.LENGTH_SHORT).show()
}
}
@@ -487,7 +490,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
if (!isInSeek) hideObjs()
updateSeekText()
updateSeekProgress()
sendProgress()
setProgress()
}
@SuppressLint("SetTextI18n")
@@ -555,7 +558,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
}
}
idtbvh.setOnClickListener {
p["vertical"] = if (idtbvh.isChecked) "true" else "false"
pb["vertical"] = idtbvh.isChecked
Toast.makeText(this, "下次浏览生效", Toast.LENGTH_SHORT).show()
}
}

View File

@@ -1,12 +1,14 @@
package top.fumiama.copymanga.update
import android.app.Activity
import android.content.Context.MODE_PRIVATE
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.core.content.FileProvider
import androidx.core.content.edit
import kotlinx.android.synthetic.main.dialog_progress.view.*
import top.fumiama.copymanga.tools.file.PropertiesTools
import top.fumiama.copymanga.tools.api.UITools
@@ -15,7 +17,7 @@ import java.io.File
import java.security.MessageDigest
object Update {
fun checkUpdate(activity: Activity, p: PropertiesTools, toolsBox: UITools, ignoreSkip: Boolean = false) = activity.apply{
fun checkUpdate(activity: Activity, toolsBox: UITools, ignoreSkip: Boolean = false) = activity.apply{
val client = Client("copymanga.v6.army", 12315)
val progressBar = layoutInflater.inflate(R.layout.dialog_progress, null, false)
val progressHandler = object : Client.Progress{
@@ -28,7 +30,7 @@ object Update {
val msg = kanban[packageManager.getPackageInfo(packageName, 0).versionCode]
if(msg != "null") {
val verNum = msg.substringBefore('\n').toIntOrNull()
val skipNum = p["skipVersion"].let { if(it != "null") it.toInt() else 0 }
val skipNum = activity.getPreferences(MODE_PRIVATE).getInt("skipVersion", 0)
Log.d("MyUP", "Ver:$verNum, skip: $skipNum")
if(verNum != null) {
@@ -63,7 +65,12 @@ object Update {
client.progress = null
}
}.start()
}, { p["skipVersion"] = verNum.toString() })
}, {
activity.getPreferences(MODE_PRIVATE).edit {
putInt("skipVersion", verNum)
apply()
}
})
}
} else runOnUiThread {
toolsBox.buildInfo("看板", msg.substringAfter('\n'), "知道了")

View File

@@ -24,7 +24,6 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/nav_header_vertical_spacing"
android:onClick="onNavTInfoClicked"
android:text="@string/navTextInfo"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@@ -30,24 +30,22 @@
<string name="null_book">获取图书信息失败</string>
<string name="web_error">网络错误</string>
<string name="mainPageApiUrl">https://api.copymanga.com/api/v3/h5/homeIndex?platform=3</string>
<string name="mainPageApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/h5/homeIndex?platform=3&amp;format=json</string>
<string name="referUrl">"https://api.copymanga.com"</string>
<string name="recentUpdateApiUrl">https://nnv3api.dmzj1.com/novel/recentUpdate/%1$d.json</string>
<string name="rankApiUrl">https://api.copymanga.com/api/v3/ranks?limit=21&amp;offset=%1$d&amp;date_type=%2$s&amp;platform=3</string>
<string name="searchApiUrl">https://api.copymanga.com/api/v3/search/comic?limit=21&amp;offset=%1$d&amp;q=%2$s&amp;q_type=%3$s&amp;platform=3</string>
<string name="filterApiUrl">https://api.copymanga.com/api/v3/h5/filterIndex/comic/tags?platform=3</string>
<string name="sortApiUrl">https://api.copymanga.com/api/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;theme=%3$s&amp;platform=3</string>
<string name="bookInfoApiUrl">https://api.copymanga.com/api/v3/comic2/%1$s?platform=3</string>
<string name="groupInfoApiUrl">https://api.copymanga.com/api/v3/comic/%1$s/group/%2$s/chapters?limit=100&amp;offset=%3$d&amp;platform=3</string>
<string name="chapterInfoApiUrl">https://api.copymanga.com/api/v3/comic/%1$s/chapter2/%2$s?platform=3</string>
<string name="chapterTxtUrl">https://nnv3api.dmzj1.com/novel/download/%1$d_%2$d_%3$d.txt</string>
<string name="topicApiUrl">https://api.copymanga.com/api/v3/topic/%1$s?platform=3</string>
<string name="topicContentApiUrl">https://api.copymanga.com/api/v3/topic/%1$s/contents?type=%2$d&amp;limit=21&amp;offset=%3$d&amp;platform=3</string>
<string name="recommendApiUrl">https://api.copymanga.com/api/v3/recs?pos=3200102&amp;limit=21&amp;offset=%1$d&amp;platform=3</string>
<string name="newestApiUrl">https://api.copymanga.com/api/v3/update/newest?limit=21&amp;offset=%1$d&amp;platform=3</string>
<string name="finishApiUrl">https://api.copymanga.com/api/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;top=finish&amp;platform=3</string>
<string name="authorApiUrl">https://api.copymanga.com/api/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;author=%3$s&amp;platform=3</string>
<string name="captionApiUrl">https://api.copymanga.com/api/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;theme=%3$s&amp;platform=3</string>
<string name="rankApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/ranks?limit=21&amp;offset=%1$d&amp;date_type=%2$s&amp;platform=3&amp;format=json</string>
<string name="searchApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/search/comic?limit=21&amp;offset=%1$d&amp;q=%2$s&amp;q_type=%3$s&amp;platform=3&amp;format=json</string>
<string name="filterApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/h5/filterIndex/comic/tags?platform=3&amp;format=json</string>
<string name="sortApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;theme=%3$s&amp;platform=3&amp;format=json</string>
<string name="bookInfoApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comic2/%1$s?platform=3&amp;format=json</string>
<string name="groupInfoApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comic/%1$s/group/%2$s/chapters?limit=100&amp;offset=%3$d&amp;platform=3&amp;format=json</string>
<string name="chapterInfoApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comic/%1$s/chapter2/%2$s?platform=3&amp;format=json</string>
<string name="topicApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/topic/%1$s?platform=3&amp;format=json</string>
<string name="topicContentApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/topic/%1$s/contents?type=%2$d&amp;limit=21&amp;offset=%3$d&amp;platform=3&amp;format=json</string>
<string name="recommendApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/recs?pos=3200102&amp;limit=21&amp;offset=%1$d&amp;platform=3&amp;format=json</string>
<string name="newestApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/update/newest?limit=21&amp;offset=%1$d&amp;platform=3&amp;format=json</string>
<string name="finishApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;top=finish&amp;platform=3&amp;format=json</string>
<string name="authorApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;author=%3$s&amp;platform=3&amp;format=json</string>
<string name="captionApiUrl">https://copymanga.azurewebsites.net/api/api?/v3/comics?limit=21&amp;offset=%1$d&amp;ordering=%2$s&amp;theme=%3$s&amp;platform=3&amp;format=json</string>
<string name="complete">已完结</string>