mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-08 00:40:29 +08:00
web1.4
1. 修复详情页无下载按钮 2. 增加音量键翻页 3. 增加按钮拖动
This commit is contained in:
3
app/.gitignore
vendored
3
app/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/build
|
||||
/build
|
||||
/release
|
||||
@@ -11,8 +11,8 @@ android {
|
||||
applicationId "top.fumiama.copymanga"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 10
|
||||
versionName '1.3.2'
|
||||
versionCode 11
|
||||
versionName '1.3.3'
|
||||
resConfigs "zh", "zh-rCN"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -42,6 +42,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}*/
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -53,11 +57,11 @@ dependencies {
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.viewpager2:viewpager2:1.0.0'
|
||||
//implementation 'com.google.android.material:material:1.2.1'
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
//implementation 'com.liaoinstan.springview:library:1.7.0'
|
||||
}
|
||||
@@ -94,8 +98,8 @@ andResGuard {
|
||||
"*.gif",
|
||||
]
|
||||
sevenzip {
|
||||
artifact = 'com.tencent.mm:SevenZip:1.2.20'
|
||||
//path = "/usr/local/bin/7za"
|
||||
//artifact = 'com.tencent.mm:SevenZip:1.2.21'
|
||||
path = "7za"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
BIN
app/release/app-release.apk
Normal file
BIN
app/release/app-release.apk
Normal file
Binary file not shown.
18
app/release/output-metadata.json
Normal file
18
app/release/output-metadata.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 2,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "top.fumiama.copymanga",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 11,
|
||||
"versionName": "1.3.3",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
javascript:
|
||||
if (typeof (loaded) == "undefined"){
|
||||
var loaded = true;
|
||||
function scanChapters(chapter){
|
||||
var chapterList = chapter.getElementsByClassName("table-all")[0].getElementsByTagName("a");
|
||||
function scanChapters(chapter) {
|
||||
var chapterList = chapter.getElementsByClassName("tab-pane fade show active")[0].getElementsByTagName("ul")[0].getElementsByTagName("a");
|
||||
var chapterArr = Array();
|
||||
for(var i = 0; i < chapterList.length; i++){
|
||||
chapterArr.push(JSON.constructor());
|
||||
@@ -11,7 +11,7 @@ if (typeof (loaded) == "undefined"){
|
||||
}
|
||||
return chapterArr;
|
||||
}
|
||||
function modify(){
|
||||
function modify() {
|
||||
var url = location.href;
|
||||
if(url.indexOf("/chapter/")>0){
|
||||
var imglist = document.getElementsByClassName("container-fluid comicContent")[0].getElementsByTagName("li");
|
||||
@@ -22,7 +22,7 @@ if (typeof (loaded) == "undefined"){
|
||||
var liststr = document.title.split(" - ")[1] + " " + location.href.substring(location.href.lastIndexOf("/")+1) + "\n" + nextChapter + "\n" + prevChapter;
|
||||
for(var i = 0; i < imglist.length; i++) liststr += "\n" + imglist[i].getElementsByTagName("img")[0].dataset.src;
|
||||
GM.loadChapter(liststr);
|
||||
}else {
|
||||
} else {
|
||||
var json = Array();
|
||||
var chapters = document.getElementsByClassName("upLoop")[0].children;
|
||||
var newObj = null;
|
||||
|
||||
@@ -21,6 +21,7 @@ import kotlinx.android.synthetic.main.widget_titlebar.*
|
||||
import top.fumiama.copymanga.R
|
||||
import top.fumiama.copymanga.activity.MainActivity.Companion.mh
|
||||
import top.fumiama.copymanga.data.ComicStructure
|
||||
import top.fumiama.copymanga.databinding.ActivityDlBinding
|
||||
import top.fumiama.copymanga.handler.DlHandler
|
||||
import top.fumiama.copymanga.tool.MangaDlTools
|
||||
import top.fumiama.copymanga.tool.MangaDlTools.Companion.wmdlt
|
||||
@@ -30,8 +31,6 @@ import top.fumiama.copymanga.view.LazyScrollView
|
||||
import java.io.File
|
||||
import java.lang.Thread.sleep
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
|
||||
class DlActivity : Activity() {
|
||||
private var tbtncnt = 0
|
||||
@@ -55,7 +54,8 @@ class DlActivity : Activity() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_dl)
|
||||
val binding = ActivityDlBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
mh?.saveUrlsOnly = true
|
||||
mangaDlTools = MangaDlTools(this)
|
||||
handler.sendEmptyMessage(-2) //setLayouts
|
||||
|
||||
@@ -2,16 +2,15 @@ package top.fumiama.copymanga.activity
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Toast
|
||||
import kotlinx.android.synthetic.main.activity_dlist.*
|
||||
import kotlinx.android.synthetic.main.widget_titlebar.*
|
||||
import top.fumiama.copymanga.R
|
||||
import top.fumiama.copymanga.databinding.ActivityDlistBinding
|
||||
import top.fumiama.copymanga.handler.DlLHandler
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
@@ -23,7 +22,8 @@ class DlListActivity:Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_dlist)
|
||||
val binding = ActivityDlistBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
ttitle.text = intent.getStringExtra("title")
|
||||
handler = DlLHandler(Looper.myLooper()!!, this)
|
||||
handler?.obtainMessage(3, currentDir)?.sendToTarget() //call scanFile
|
||||
|
||||
@@ -3,13 +3,17 @@ package top.fumiama.copymanga.activity
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebView
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import top.fumiama.copymanga.R
|
||||
import top.fumiama.copymanga.databinding.ActivityMainBinding
|
||||
import top.fumiama.copymanga.handler.MainHandler
|
||||
import top.fumiama.copymanga.tool.SetDraggable
|
||||
import top.fumiama.copymanga.tool.ToolsBox
|
||||
import top.fumiama.copymanga.view.JSWebView
|
||||
import top.fumiama.copymanga.web.JS
|
||||
@@ -19,11 +23,13 @@ import java.lang.ref.WeakReference
|
||||
|
||||
class MainActivity: Activity() {
|
||||
var wh: JSWebView? = null
|
||||
var toolsBox: ToolsBox? = null
|
||||
var uploadMessageAboveL: ValueCallback<Array<Uri>>? = null
|
||||
private var toolsBox: ToolsBox? = null
|
||||
@SuppressLint("JavascriptInterface")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
val binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
wm = WeakReference(this)
|
||||
mh = MainHandler(Looper.myLooper()!!)
|
||||
@@ -43,6 +49,7 @@ class MainActivity: Activity() {
|
||||
wh?.loadJSInterface(JSHidden())
|
||||
}
|
||||
}
|
||||
SetDraggable().with(this).onto(fab)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
@@ -50,6 +57,41 @@ class MainActivity: Activity() {
|
||||
else super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == FILE_CHOOSER_RESULT_CODE) { //处理返回的图片,并进行上传
|
||||
if (uploadMessageAboveL == null) return
|
||||
else {
|
||||
if(resultCode == RESULT_OK) {
|
||||
data?.apply {
|
||||
if(uploadMessageAboveL != null) {
|
||||
onActivityResultAboveL(requestCode, resultCode, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onActivityResultAboveL(requestCode: Int, resultCode: Int, intent: Intent) {
|
||||
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null) return
|
||||
else {
|
||||
if (resultCode == RESULT_OK) {
|
||||
intent.clipData?.apply {
|
||||
var results = arrayOf<Uri>()
|
||||
for(i in 0..itemCount) {
|
||||
val item = getItemAt(i)
|
||||
results += item.uri
|
||||
}
|
||||
intent.dataString?.apply {
|
||||
uploadMessageAboveL?.onReceiveValue(results)
|
||||
uploadMessageAboveL = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onFabClicked(v: View){
|
||||
DlListActivity.currentDir = getExternalFilesDir("")
|
||||
startActivity(
|
||||
@@ -58,7 +100,16 @@ class MainActivity: Activity() {
|
||||
)
|
||||
}
|
||||
|
||||
fun openImageChooserActivity() {
|
||||
//调用自己的图库
|
||||
val i = Intent(Intent.ACTION_GET_CONTENT)
|
||||
i.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
i.type = "image/*"
|
||||
startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILE_CHOOSER_RESULT_CODE)
|
||||
}
|
||||
|
||||
companion object{
|
||||
const val FILE_CHOOSER_RESULT_CODE = 1
|
||||
var wm: WeakReference<MainActivity>? = null
|
||||
var mh: MainHandler? = null
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.*
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -25,6 +26,7 @@ import kotlinx.android.synthetic.main.widget_titlebar.*
|
||||
import kotlinx.android.synthetic.main.widget_viewmangainfo.*
|
||||
import top.fumiama.copymanga.R
|
||||
import top.fumiama.copymanga.activity.MainActivity.Companion.wm
|
||||
import top.fumiama.copymanga.databinding.ActivityViewmangaBinding
|
||||
import top.fumiama.copymanga.handler.TimeThread
|
||||
import top.fumiama.copymanga.tool.PropertiesTools
|
||||
import top.fumiama.copymanga.tool.ToolsBox
|
||||
@@ -35,23 +37,23 @@ import java.util.*
|
||||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
|
||||
class ViewMangaActivity : Activity() {
|
||||
var count = 0
|
||||
lateinit var handler: Handler
|
||||
lateinit var tt: TimeThread
|
||||
lateinit var toolsBox: ToolsBox
|
||||
|
||||
var count = 0
|
||||
var clicked = false
|
||||
private var isInSeek = false
|
||||
private var useFullScreen = false
|
||||
var r2l = true
|
||||
var infoDrawerDelta = 0f
|
||||
|
||||
private lateinit var p: PropertiesTools
|
||||
private var isInSeek = false
|
||||
private var currentItem = 0
|
||||
private var notUseVP = true
|
||||
//private var q = 90
|
||||
var infoDrawerDelta = 0f
|
||||
lateinit var toolsBox: ToolsBox
|
||||
private lateinit var p: PropertiesTools
|
||||
private var mangaZip = zipFile
|
||||
val dlZip2View = mangaZip != null
|
||||
private val volTurnPage get() = p["volturn"] == "true"
|
||||
var pageNum = 1
|
||||
get() {
|
||||
field = getPageNumber()
|
||||
@@ -75,22 +77,18 @@ class ViewMangaActivity : Activity() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_viewmanga)
|
||||
val binding = ActivityViewmangaBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
toolsBox = ToolsBox(WeakReference(this))
|
||||
va = WeakReference(this)
|
||||
p = PropertiesTools(File("$filesDir/settings.properties"))
|
||||
useFullScreen = p["useFullScreen"] != "true"
|
||||
r2l = p["r2l"] == "true"
|
||||
//toolsBox = ToolsBox(WeakReference(this))
|
||||
notUseVP = p["noAnimation"] == "true"
|
||||
handler = MyHandler(infcard, toolsBox)
|
||||
//if (p["quality"] == "null") p["quality"] = "90"
|
||||
//else q = p["quality"].toInt()
|
||||
tt = TimeThread(handler, 22)
|
||||
tt.canDo = true
|
||||
tt.start()
|
||||
ttitle.text = titleText
|
||||
//isearch.visibility = View.VISIBLE
|
||||
Log.d("MyVM", "dlZip2View: $dlZip2View, mangaZip: $mangaZip")
|
||||
if(dlZip2View && mangaZip?.exists() != true) toolsBox.toastError("已经到头了~")
|
||||
else {
|
||||
@@ -118,11 +116,25 @@ class ViewMangaActivity : Activity() {
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (useFullScreen) {
|
||||
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
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) window.setDecorFitsSystemWindows(false)
|
||||
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
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) window.setDecorFitsSystemWindows(false)
|
||||
}
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
var flag = false
|
||||
if(volTurnPage) when(keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||
scrollBack()
|
||||
flag = true
|
||||
}
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||
scrollForward()
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
return if(flag) true else super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
private fun getPageNumber(): Int {
|
||||
@@ -139,18 +151,7 @@ class ViewMangaActivity : Activity() {
|
||||
if (position >= count || position < 0) return null
|
||||
else {
|
||||
val zip = ZipFile(mangaZip)
|
||||
//if (q == 100)
|
||||
return BitmapFactory.decodeStream(zip.getInputStream(zip.getEntry("${position}.webp")))
|
||||
/*else {
|
||||
val out = ByteArrayOutputStream()
|
||||
try {
|
||||
BitmapFactory.decodeStream(zip.getInputStream(zip.getEntry("${position}.jpg")))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return null
|
||||
}?.compress(Bitmap.CompressFormat.JPEG, q, out)
|
||||
return BitmapFactory.decodeStream(ByteArrayInputStream(out.toByteArray()))
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +176,7 @@ class ViewMangaActivity : Activity() {
|
||||
prepareInfoBar(count)
|
||||
if (notUseVP) loadOneImg() else prepareIdBtVH()
|
||||
toolsBox.dp2px(67)?.let { setIdPosition(it) }
|
||||
prepareIdBtFullScreen()
|
||||
prepareIdBtVolTurn()
|
||||
prepareIdBtVP()
|
||||
prepareIdBtLR()
|
||||
}
|
||||
@@ -220,7 +221,6 @@ class ViewMangaActivity : Activity() {
|
||||
if (!isInSeek) hideObjs()
|
||||
updateSeekText()
|
||||
updateSeekProgress()
|
||||
sendProgress()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@@ -265,13 +265,11 @@ class ViewMangaActivity : Activity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareIdBtFullScreen() {
|
||||
idtbfullscreen.isChecked = !useFullScreen
|
||||
idtbfullscreen.setOnClickListener {
|
||||
if (idtbfullscreen.isChecked) p["useFullScreen"] =
|
||||
"true"
|
||||
else p["useFullScreen"] = "false"
|
||||
Toast.makeText(this, "下次浏览生效", Toast.LENGTH_SHORT).show()
|
||||
private fun prepareIdBtVolTurn() {
|
||||
idtbvolturn.isChecked = volTurnPage
|
||||
idtbvolturn.setOnClickListener {
|
||||
if (idtbvolturn.isChecked) p["volturn"] = "true"
|
||||
else p["volturn"] = "false"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,10 +303,6 @@ class ViewMangaActivity : Activity() {
|
||||
pageNum++
|
||||
}
|
||||
|
||||
private fun sendProgress() {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateSeekText() {
|
||||
inftxtprogress.text = "$pageNum/$count"
|
||||
|
||||
@@ -7,45 +7,55 @@ import java.io.InputStream
|
||||
import java.util.*
|
||||
|
||||
class PropertiesTools(private val f: File):Properties() {
|
||||
private val propfile:File
|
||||
get() {
|
||||
private var cache = hashMapOf<String, String>()
|
||||
|
||||
init {
|
||||
if(!f.exists()) {
|
||||
if(f.parentFile?.exists() != true) f.parentFile?.mkdirs()
|
||||
if(f.parentFile?.canWrite() != true) f.parentFile?.setWritable(true)
|
||||
createNew(f)
|
||||
}else if(f.isDirectory) {
|
||||
} else if(f.isDirectory) {
|
||||
if(f.parentFile?.canWrite() != true) f.parentFile?.setWritable(true)
|
||||
f.delete()
|
||||
createNew(f)
|
||||
}
|
||||
if(f.parentFile?.canWrite() != true) f.parentFile?.setWritable(true)
|
||||
if(f.parentFile?.canRead() != true) f.parentFile?.setReadable(true)
|
||||
return f
|
||||
}
|
||||
private fun createNew(f: File){
|
||||
|
||||
private fun createNew(f: File) {
|
||||
f.createNewFile()
|
||||
val o = f.outputStream()
|
||||
this.storeToXML(o, "store")
|
||||
Log.d("MyPT", "Generate new prop.")
|
||||
o.close()
|
||||
}
|
||||
|
||||
private fun loadFromXml(`in`: InputStream?): PropertiesTools {
|
||||
this.loadFromXML(`in`)
|
||||
return this
|
||||
}
|
||||
|
||||
private fun setProp(key: String?, value: String?): PropertiesTools {
|
||||
this.setProperty(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
operator fun get(key: String): String{
|
||||
val i = propfile.inputStream()
|
||||
val re = this.loadFromXml(i).getProperty(key)?:"null"
|
||||
Log.d("MyPT", "Get $key = $re")
|
||||
i.close()
|
||||
return re
|
||||
return if(cache.containsKey(key)) cache[key]?:"null"
|
||||
else {
|
||||
val i = f.inputStream()
|
||||
val re = this.loadFromXml(i).getProperty(key)?:"null"
|
||||
Log.d("MyPT", "Read $key = $re")
|
||||
i.close()
|
||||
cache[key] = re
|
||||
re
|
||||
}
|
||||
}
|
||||
operator fun set(key: String, value: String){
|
||||
val o = propfile.outputStream()
|
||||
|
||||
operator fun set(key: String, value: String) {
|
||||
cache[key] = value
|
||||
val o = f.outputStream()
|
||||
this.setProp(key, value).storeToXML(o, "store")
|
||||
Log.d("MyPT", "Set $key = $value")
|
||||
o.close()
|
||||
|
||||
62
app/src/main/java/top/fumiama/copymanga/tool/SetDraggable.kt
Normal file
62
app/src/main/java/top/fumiama/copymanga/tool/SetDraggable.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
package top.fumiama.copymanga.tool
|
||||
|
||||
import android.content.Context
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import kotlin.math.abs
|
||||
|
||||
class SetDraggable {
|
||||
private var screenWidth = 0
|
||||
private var screenHeight = 0
|
||||
fun with(context: Context): SetDraggable {
|
||||
val dm = context.resources.displayMetrics
|
||||
screenWidth = dm.widthPixels
|
||||
screenHeight = dm.heightPixels
|
||||
return this
|
||||
}
|
||||
|
||||
fun onto(target: View) {
|
||||
var lastX = 0
|
||||
var lastY = 0
|
||||
var firstX = 0
|
||||
var firstY = 0
|
||||
target.setOnTouchListener { v: View, event: MotionEvent ->
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
lastX = event.rawX.toInt()
|
||||
lastY = event.rawY.toInt()
|
||||
firstX = lastX
|
||||
firstY = lastY
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val dx = event.rawX.toInt() - lastX
|
||||
val dy = event.rawY.toInt() - lastY
|
||||
var left = v.left + dx
|
||||
var top = v.top + dy
|
||||
var right = v.right + dx
|
||||
var bottom = v.bottom + dy
|
||||
if (left < 0) {
|
||||
left = 0
|
||||
right = left + v.width
|
||||
}
|
||||
if (right > screenWidth) {
|
||||
right = screenWidth
|
||||
left = right - v.width
|
||||
}
|
||||
if (top < 0) {
|
||||
top = 0
|
||||
bottom = top + v.height
|
||||
}
|
||||
if (bottom > screenHeight) {
|
||||
bottom = screenHeight
|
||||
top = bottom - v.height
|
||||
}
|
||||
v.layout(left, top, right, bottom)
|
||||
lastX = event.rawX.toInt()
|
||||
lastY = event.rawY.toInt()
|
||||
}
|
||||
}
|
||||
abs(firstX - lastX) > 3 || abs(firstY - lastY) > 3 //移动微小则判断为点击
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package top.fumiama.copymanga.web
|
||||
|
||||
import android.webkit.JsPromptResult
|
||||
import android.webkit.JsResult
|
||||
import android.net.Uri
|
||||
import android.webkit.*
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebView
|
||||
import top.fumiama.copymanga.activity.MainActivity.Companion.mh
|
||||
import top.fumiama.copymanga.activity.MainActivity.Companion.wm
|
||||
|
||||
class WebChromeClient:WebChromeClient() {
|
||||
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||
@@ -43,4 +43,16 @@ class WebChromeClient:WebChromeClient() {
|
||||
result?.confirm()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onShowFileChooser(
|
||||
webView: WebView?,
|
||||
filePathCallback: ValueCallback<Array<Uri>>?,
|
||||
fileChooserParams: FileChooserParams?
|
||||
): Boolean {
|
||||
wm?.get()?.apply {
|
||||
uploadMessageAboveL = filePathCallback
|
||||
openImageChooserActivity()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<top.fumiama.copymanga.view.ChapterToggleButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<top.fumiama.copymanga.view.ChapterToggleButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:id="@+id/tbtn"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/divider"
|
||||
android:layout_height="1dp"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:id="@+id/ltbtn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:id="@+id/onecons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:id="@+id/csdwn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -39,7 +41,7 @@
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/idtbfullscreen"
|
||||
android:id="@+id/idtbvolturn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="8dp"
|
||||
@@ -47,8 +49,8 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/toggle_button"
|
||||
android:textOff="全屏开"
|
||||
android:textOn="全屏关"
|
||||
android:textOff="音量翻页关"
|
||||
android:textOn="音量翻页开"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/idtbvh"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -64,8 +66,8 @@
|
||||
android:textOff="横向"
|
||||
android:textOn="竖向"
|
||||
app:layout_constraintEnd_toStartOf="@id/idtbvp"
|
||||
app:layout_constraintStart_toEndOf="@+id/idtbfullscreen"
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbfullscreen" />
|
||||
app:layout_constraintStart_toEndOf="@+id/idtbvolturn"
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbvolturn" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/idtbvp"
|
||||
@@ -77,7 +79,7 @@
|
||||
android:textOn="动画关"
|
||||
app:layout_constraintEnd_toStartOf="@+id/idtblr"
|
||||
app:layout_constraintStart_toEndOf="@id/idtbvh"
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbfullscreen" />
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbvolturn" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/idtblr"
|
||||
@@ -89,7 +91,7 @@
|
||||
android:textOn="←后 前→"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/idtbvp"
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbfullscreen" />
|
||||
app:layout_constraintTop_toTopOf="@+id/idtbvolturn" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,6 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">拷贝漫画</string>
|
||||
<string name="web_home">https://copymanga.net</string>
|
||||
<string name="web_home">https://www.copymanga.com/h5/init</string>
|
||||
<string name="web_home_www">https://www.copymanga.net</string>
|
||||
<string name="web_comic_detail_pc">https://www.copymanga.net/comic</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user