Skip to content

Commit

Permalink
v2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
15dd committed Jul 19, 2024
1 parent 47c37db commit acaaf39
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 52 deletions.
10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
- <h3>重构</h3>
由于当时写这个软件的时候没什么经验,很多地方的代码连我自己都看不下去了,所以打算重构了,预计24年的暑假应该能写完
<br>
当前重构进度(24.5.31):编写阅读器中 ====>70%
当前重构进度(24.7.19):编写阅读器中 总进度:70%
- <h3>有关源代码</h3>
本项目一开始是用Java写的,但是我后来开始学Kotlin了,为了方便维护软件,我直接用了AS的转换功能。所以设计思想还是Java的,导致有些地方看着怪怪的,比如可以用Kotlin协程的地方却开了个Thread。还有些地方是原本的设计就有问题,我在优化代码的时候,直接把我自己给气笑了,我居然把两个毫不相关的String类型的数据放在同一个`List<String>`里,然后传给一个函数,之后用list.get()这个方法取出想要的数据,而且还有好多地方都是这么写的。虽然也不是不行,但是很难看懂,还麻烦,不好维护。这就是基础不好的后果😭,只能等后期v3.0版本重构了
- <h3>作者的闲话</h3>
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ android {
}
}


defaultConfig {
applicationId "com.cyh128.wenku8reader"
minSdk 29
targetSdk 34
versionCode 240403
versionName "2.3.2"
versionCode 240719
versionName "2.3.3"
}

signingConfigs {
Expand Down Expand Up @@ -50,17 +49,18 @@ android {

dependencies {

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'org.jsoup:jsoup:1.18.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.github.bumptech.glide:glide:4.15.1'
implementation 'com.github.bumptech.glide:glide:4.16.0'
implementation 'androidx.sqlite:sqlite-ktx:2.4.0'
implementation 'com.alibaba:fastjson:2.0.37'
implementation("com.tencent:mmkv:1.3.5")
implementation 'com.github.youlookwhat:ByRecyclerView:1.3.7'
implementation 'com.github.MZCretin:ExpandableTextView:v1.6.1-x'
implementation 'com.github.TutorialsAndroid:crashx:v6.0.19'
Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 240403,
"versionName": "2.3.2",
"versionCode": 240719,
"versionName": "2.3.3",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<activity
android:name="com.cyh128.wenku8reader.activity.LoginInputActivity"
android:theme="@style/Theme.MyApplication"
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait"/>

<activity
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/cyh128/wenku8reader/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.cyh128.wenku8reader.activity.CrashActivity
import com.cyh128.wenku8reader.util.GlobalConfig
import com.developer.crashx.config.CrashConfig
import com.google.android.material.color.DynamicColors
import com.tencent.mmkv.MMKV

class App : Application() {
override fun onCreate() {
Expand All @@ -13,6 +14,7 @@ class App : Application() {
CrashConfig.Builder.create()
.errorActivity(CrashActivity::class.java)
.apply()
MMKV.initialize(this)
}

override fun onTerminate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ class ContentsActivity : AppCompatActivity() {
contentsList = getContents(bookUrl!!) //小说目录

//获取这本书的aid和bid====================================================================================================
//aid获取 https://www.wenku8.cc/book/xxxx.htm
//aid获取 https://www.wenku8.net/book/xxxx.htm
aid = bookUrl!!.substring(bookUrl!!.indexOf("book/") + 5, bookUrl!!.indexOf(".htm"))
.toInt()
//bid获取 https://www.wenku8.cc/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。删除必须用bid
//bid获取 https://www.wenku8.net/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。删除必须用bid
getBid()
//end===================================================================================================================
isInBookcase() //判断这本书是否已在书架中
Expand Down Expand Up @@ -251,7 +251,7 @@ class ContentsActivity : AppCompatActivity() {

@Throws(IOException::class)
private fun getBid() {
//https://www.wenku8.cc/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。因为删除必须用bid
//https://www.wenku8.net/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。因为删除必须用bid
BookCaseFragment.bookcaseList = bookcase
for (bcc in BookCaseFragment.bookcaseList) {
if (bcc.aid.toInt() == aid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.CheckBox
import android.widget.CompoundButton
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.cyh128.wenku8reader.R
import com.cyh128.wenku8reader.util.GlobalConfig
Expand All @@ -36,6 +36,22 @@ class LoginInputActivity : AppCompatActivity() {
// 以下两行会导致内存泄漏,待改进
// CircularProgressIndicatorSpec spec = new CircularProgressIndicatorSpec(this, null, 0, com.google.android.material.R.style.Widget_Material3_CircularProgressIndicator_ExtraSmall);
// Drawable drawable = IndeterminateDrawable.createCircularDrawable(this, spec);
findViewById<Button>(R.id.register).setOnClickListener {
MaterialAlertDialogBuilder(this)
.setTitle("请前往浏览器注册")
.setMessage("您需要前往浏览器页面注册,注册成功后再将用户名和密码填入输入框中,点击[前往注册]以继续注册")
.setCancelable(false)
.setNegativeButton("取消", null)
.setPositiveButton(
"前往注册"
) { _: DialogInterface?, _: Int ->
val uri: Uri = Uri.parse("https://${GlobalConfig.domain}/register.php") //设置跳转的网站
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
.show()
}

signIn = findViewById(R.id.confirm_login)
signIn.setOnClickListener {
signIn.isClickable = false
Expand Down Expand Up @@ -85,7 +101,7 @@ class LoginInputActivity : AppCompatActivity() {
MaterialAlertDialogBuilder(this@LoginInputActivity)
.setCancelable(false) //禁止点击其他区域
.setTitle("网络错误")
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查是否正在连接VPN或代理服务器\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n\n请稍后再试")
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查网络ip属地是否为中国大陆\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n4 -> 尝试切换节点\n\n请稍后再试")
.setPositiveButton("明白", null)
.setIcon(R.drawable.warning)
.show()
Expand All @@ -103,6 +119,25 @@ class LoginInputActivity : AppCompatActivity() {
username = findViewById(R.id.username)
password = findViewById(R.id.password)
initTextFieldListener() //负责清空错误信息

findViewById<Button>(R.id.b_a_login_input_domain).setOnClickListener {
MaterialAlertDialogBuilder(this)
.setTitle("选择节点")
.setSingleChoiceItems(
arrayOf("www.wenku8.cc","www.wenku8.net"),
run {
if (GlobalConfig.domain == "www.wenku8.cc") return@run 0
else return@run 1
}
) { dialog: DialogInterface, which: Int ->
when(which) {
0 -> GlobalConfig.domain = "www.wenku8.cc"
1 -> GlobalConfig.domain = "www.wenku8.net"
}
dialog.dismiss()
}
.show()
}
}

private fun initTextFieldListener() { //负责清空错误信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LoginingActivity : AppCompatActivity() {
MaterialAlertDialogBuilder(this@LoginingActivity)
.setCancelable(false) //禁止点击其他区域
.setTitle("网络错误")
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查是否正在连接VPN或代理服务器\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n\n请稍后再试")
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查网络ip属地是否为中国大陆\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n4 -> 尝试切换节点\n\n请稍后再试")
.setPositiveButton(
"重启软件"
) { dialogInterface: DialogInterface?, i: Int ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.cyh128.wenku8reader.activity
import android.os.Bundle
import android.view.View
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.app.AppCompatActivity
import com.cyh128.wenku8reader.R
import com.cyh128.wenku8reader.util.DatabaseHelper
Expand Down Expand Up @@ -33,6 +34,18 @@ class SettingActivity : AppCompatActivity() {
// 退出当前页面
finish()
}

findViewById<RadioGroup>(R.id.rg_a_setting_domain).setOnCheckedChangeListener { group, checkedId ->
when(checkedId) {
R.id.radiobutton_new_reader_cc -> GlobalConfig.domain = "www.wenku8.cc"
R.id.radiobutton_old_reader_net -> GlobalConfig.domain = "www.wenku8.net"
}
}

if (GlobalConfig.domain == "www.wenku8.cc")
findViewById<RadioButton>(R.id.radiobutton_new_reader_cc).isChecked = true
else
findViewById<RadioButton>(R.id.radiobutton_old_reader_net).isChecked = true
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions
import com.cyh128.wenku8reader.R
import com.cyh128.wenku8reader.activity.ContentsActivity
import com.cyh128.wenku8reader.bean.BookcaseBean
import com.cyh128.wenku8reader.util.GlobalConfig
import com.google.android.material.dialog.MaterialAlertDialogBuilder

class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/105779329
Expand Down Expand Up @@ -66,7 +67,7 @@ class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/10577932
return@setOnClickListener
}
val url = String.format(
"https://www.wenku8.cc/book/%s.htm",
"https://${GlobalConfig.domain}/book/%s.htm",
novel.bookUrl.substring(
novel.bookUrl.indexOf("aid=") + 4,
novel.bookUrl.indexOf("&")
Expand Down Expand Up @@ -98,7 +99,7 @@ class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/10577932
return@setOnClickListener
}
val url = String.format(
"https://www.wenku8.cc/book/%s.htm",
"https://${GlobalConfig.domain}/book/%s.htm",
novel.bookUrl.substring(
novel.bookUrl.indexOf("aid=") + 4,
novel.bookUrl.indexOf("&")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.cyh128.wenku8reader.R
import com.cyh128.wenku8reader.adapter.BookListAdapter
import com.cyh128.wenku8reader.bean.BookListBean
import com.cyh128.wenku8reader.util.GlobalConfig
import com.cyh128.wenku8reader.util.LoginWenku8
import com.cyh128.wenku8reader.util.Wenku8Spider.parseNovelList
import me.jingbin.library.ByRecyclerView
Expand Down Expand Up @@ -111,7 +112,7 @@ class TagSearchFragment : Fragment() {
get() {
return try {
val url: String = String.format(
"https://www.wenku8.cc/modules/article/tags.php?t=%s&page=%d&v=%s",
"https://${GlobalConfig.domain}/modules/article/tags.php?t=%s&page=%d&v=%s",
URLEncoder.encode(tag, "gbk"),
++pageindex,
sort
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cyh128.wenku8reader.util

import android.database.sqlite.SQLiteDatabase
import com.tencent.mmkv.MMKV

object GlobalConfig {
//app全局变量存放处
Expand All @@ -21,4 +22,12 @@ object GlobalConfig {
lateinit var db: SQLiteDatabase
var isFiveSecondDone = true
var readerMode = 0


private val domainCursor = MMKV.mmkvWithID("domain")
var domain: String
get() = domainCursor.decodeString("domain", "www.wenku8.cc")!!
set(value) {
domainCursor.encode("domain",value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object LoginWenku8 {
builder.add(key, paramsMap[key]!!)
}
val formBody: RequestBody = builder.build()
val request: Request = Request.Builder().url("https://www.wenku8.cc/login.php").post(formBody).build()
val request: Request = Request.Builder().url("https://${GlobalConfig.domain}/login.php").post(formBody).build()
val response = okHttpClient.newCall(request).execute()
val html = String(response.body.bytes(), charset("gbk"))
if (!isCorrectUsernameOrPassword(html)) { //判断密码正确
Expand Down
Loading

0 comments on commit acaaf39

Please sign in to comment.