mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-11 02:50:28 +08:00
@@ -9,8 +9,8 @@ android {
|
||||
applicationId 'top.fumiama.copymanga'
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 33
|
||||
versionCode 26
|
||||
versionName '2.0.beta14'
|
||||
versionCode 27
|
||||
versionName '2.0.beta15'
|
||||
resConfigs 'zh', 'zh-rCN'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -41,13 +41,15 @@ open class AutoDownloadHandler(private val url: String, private val jsonClass: C
|
||||
timeThread?.start()
|
||||
}
|
||||
private fun dlThread() {
|
||||
DownloadTools.getHttpContent(url,
|
||||
mainWeakReference?.get()?.getString(R.string.referUrl)!!,
|
||||
mainWeakReference?.get()?.getString(R.string.pc_ua)!!
|
||||
)?.let {
|
||||
DownloadTools.getHttpContent(url, null, mainWeakReference?.get()?.getString(R.string.pc_ua)!!)?.let {
|
||||
if(exit) return
|
||||
val fi = it.inputStream()
|
||||
val pass = setGsonItem(Gson().fromJson(fi.reader(), jsonClass))
|
||||
var pass = true
|
||||
try {
|
||||
pass = setGsonItem(Gson().fromJson(fi.reader(), jsonClass))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
fi.close()
|
||||
if(!pass) {
|
||||
dlThread()
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
package top.fumiama.copymanga.tools.api
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.bumptech.glide.load.model.LazyHeaders
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.tools.http.DownloadTools
|
||||
import top.fumiama.copymanga.ui.settings.SettingsFragment.Companion.settingsPref
|
||||
import java.io.File
|
||||
import java.net.URLEncoder
|
||||
|
||||
object CMApi {
|
||||
var myGlideHeaders: LazyHeaders? = null
|
||||
get() {
|
||||
if(field === null)
|
||||
field = LazyHeaders.Builder()
|
||||
.addHeader("referer", MainActivity.mainWeakReference?.get()?.getString(R.string.referUrl)!!)
|
||||
.addHeader("User-Agent", MainActivity.mainWeakReference?.get()?.getString(R.string.pc_ua)!!)
|
||||
.addHeader("source", "copyApp")
|
||||
.addHeader("webp", "1")
|
||||
.addHeader("region", if(settingsPref?.getBoolean("", false) == false) "1" else "0")
|
||||
.addHeader("platform", "3")
|
||||
.build()
|
||||
MainActivity.mainWeakReference?.get()?.let {
|
||||
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
||||
if(field === null)
|
||||
field = LazyHeaders.Builder()
|
||||
.addHeader("referer", MainActivity.mainWeakReference?.get()?.getString(R.string.referUrl)!!)
|
||||
.addHeader("User-Agent", MainActivity.mainWeakReference?.get()?.getString(R.string.pc_ua)!!)
|
||||
.addHeader("source", "copyApp")
|
||||
.addHeader("webp", "1")
|
||||
.addHeader("region", if(!getBoolean("settings_cat_net", false)) "1" else "0")
|
||||
.addHeader("platform", "3")
|
||||
.build()
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
fun getZipFile(exDir: File?, manga: String, caption: CharSequence, name: CharSequence) = File(exDir, "$manga/$caption/$name.zip")
|
||||
@@ -28,13 +33,17 @@ object CMApi {
|
||||
fun getApiUrl(id: Int, arg1: String?, arg2: String?, arg3: Int? = 0) = MainActivity.mainWeakReference?.get()?.getString(id)?.let { String.format(it, arg1, arg2, arg3) }
|
||||
fun getLoginConnection(username: String, pwd: String, salt: Int) = MainActivity.mainWeakReference?.get()?.getString(R.string.loginApiUrl)?.let {
|
||||
DownloadTools.getConnection(it, "POST")?.apply {
|
||||
doOutput = true
|
||||
setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=utf-8")
|
||||
setRequestProperty("platform", "3")
|
||||
setRequestProperty("accept", "application/json")
|
||||
val r = if(settingsPref?.getBoolean("", false) == false) "1" else "0"
|
||||
val pwdb64 = Base64.encode("$pwd-$salt".toByteArray(), Base64.DEFAULT).decodeToString()
|
||||
outputStream.write("username=${URLEncoder.encode(username)}&password=$pwdb64&salt=$salt&platform=3&authorization=Token+&version=1.4.4&source=copyApp®ion=$r&webp=1".toByteArray())
|
||||
MainActivity.mainWeakReference?.get()?.let {
|
||||
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
||||
doOutput = true
|
||||
setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=utf-8")
|
||||
setRequestProperty("platform", "3")
|
||||
setRequestProperty("accept", "application/json")
|
||||
val r = if(!getBoolean("settings_cat_net_sw_use_foreign", false)) "1" else "0"
|
||||
val pwdb64 = Base64.encode("$pwd-$salt".toByteArray(), Base64.DEFAULT).decodeToString()
|
||||
outputStream.write("username=${URLEncoder.encode(username)}&password=$pwdb64&salt=$salt&platform=3&authorization=Token+&version=1.4.4&source=copyApp®ion=$r&webp=1".toByteArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package top.fumiama.copymanga.tools.http
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.preference.PreferenceManager
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.copymanga.tools.ssl.AllTrustManager
|
||||
import top.fumiama.copymanga.tools.ssl.IgnoreHostNameVerifier
|
||||
import top.fumiama.copymanga.ui.settings.SettingsFragment.Companion.settingsPref
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.net.URLEncoder
|
||||
@@ -40,10 +39,17 @@ object DownloadTools {
|
||||
refer?.let { setRequestProperty("referer", it) }
|
||||
setRequestProperty("source", "copyApp")
|
||||
setRequestProperty("webp", "1")
|
||||
setRequestProperty("region", if(settingsPref?.getBoolean("", false) == false) "1" else "0")
|
||||
MainActivity.mainWeakReference?.get()?.getPreferences(Context.MODE_PRIVATE)?.getString("token", "")?.let {
|
||||
if(it != "") setRequestProperty("authorization", "Token $it")
|
||||
else setRequestProperty("authorization", "Token")
|
||||
MainActivity.mainWeakReference?.get()?.let {
|
||||
PreferenceManager.getDefaultSharedPreferences(it).apply {
|
||||
setRequestProperty("region", if(!getBoolean("settings_cat_net_sw_use_foreign", false)) "1" else "0")
|
||||
}
|
||||
it.getPreferences(Context.MODE_PRIVATE).apply {
|
||||
setRequestProperty("version", getString("app_ver", "1.4.4"))
|
||||
getString("token", "")?.let {
|
||||
if(it != "") setRequestProperty("authorization", "Token $it")
|
||||
else setRequestProperty("authorization", "Token")
|
||||
}
|
||||
}
|
||||
}
|
||||
setRequestProperty("host", url.substringAfter("://").substringBefore("/"))
|
||||
setRequestProperty("platform", "3")
|
||||
|
||||
@@ -9,10 +9,5 @@ import top.fumiama.dmzj.copymanga.R
|
||||
class SettingsFragment: PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.pref_setting, rootKey)
|
||||
if(settingsPref == null) settingsPref = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
var settingsPref: SharedPreferences? = SettingsFragment().context?.let {PreferenceManager.getDefaultSharedPreferences(it)}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package top.fumiama.copymanga.ui.vm
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.AudioManager
|
||||
@@ -13,6 +14,7 @@ import android.view.*
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.bumptech.glide.Glide
|
||||
@@ -29,6 +31,7 @@ import kotlinx.android.synthetic.main.widget_infodrawer.*
|
||||
import kotlinx.android.synthetic.main.widget_titlebar.*
|
||||
import kotlinx.android.synthetic.main.widget_titlebar.view.*
|
||||
import kotlinx.android.synthetic.main.widget_viewmangainfo.*
|
||||
import top.fumiama.copymanga.MainActivity
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import top.fumiama.copymanga.template.general.TitleActivityTemplate
|
||||
import top.fumiama.copymanga.template.http.AutoDownloadThread
|
||||
@@ -41,7 +44,6 @@ import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.lang.ref.WeakReference
|
||||
import top.fumiama.copymanga.ui.settings.SettingsFragment.Companion.settingsPref
|
||||
import java.util.concurrent.FutureTask
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
@@ -89,6 +91,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setContentView(R.layout.activity_viewmanga)
|
||||
super.onCreate(savedInstanceState)
|
||||
val settingsPref = MainActivity.mainWeakReference?.get()?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
||||
va = WeakReference(this)
|
||||
//dlZip2View = intent.getStringExtra("callFrom") == "Dl" || p["dlZip2View"] == "true"
|
||||
//zipFirst = intent.getStringExtra("callFrom") == "zipFirst"
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<string name="TRANSPORT_NULL">无网络</string>
|
||||
|
||||
<string name="pc_ua">Dart/2.16 (dart:io)</string>
|
||||
<string name="app_ver">1.4.4</string>
|
||||
|
||||
<string name="menu_update_time">更新时间</string>
|
||||
<string name="menu_hot">热度</string>
|
||||
|
||||
Reference in New Issue
Block a user