Skip to content

Commit acaaf39

Browse files
author
15dd
committed
v2.3.3
1 parent 47c37db commit acaaf39

19 files changed

+229
-52
lines changed

.idea/deploymentTargetSelector.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

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

app/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ android {
1212
}
1313
}
1414

15-
1615
defaultConfig {
1716
applicationId "com.cyh128.wenku8reader"
1817
minSdk 29
1918
targetSdk 34
20-
versionCode 240403
21-
versionName "2.3.2"
19+
versionCode 240719
20+
versionName "2.3.3"
2221
}
2322

2423
signingConfigs {
@@ -50,17 +49,18 @@ android {
5049

5150
dependencies {
5251

53-
implementation 'androidx.appcompat:appcompat:1.6.1'
54-
implementation 'com.google.android.material:material:1.11.0'
52+
implementation 'androidx.appcompat:appcompat:1.7.0'
53+
implementation 'com.google.android.material:material:1.12.0'
5554
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
5655
implementation 'androidx.recyclerview:recyclerview:1.3.2'
5756
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
58-
implementation 'org.jsoup:jsoup:1.17.2'
57+
implementation 'org.jsoup:jsoup:1.18.1'
5958
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
6059
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
61-
implementation 'com.github.bumptech.glide:glide:4.15.1'
60+
implementation 'com.github.bumptech.glide:glide:4.16.0'
6261
implementation 'androidx.sqlite:sqlite-ktx:2.4.0'
6362
implementation 'com.alibaba:fastjson:2.0.37'
63+
implementation("com.tencent:mmkv:1.3.5")
6464
implementation 'com.github.youlookwhat:ByRecyclerView:1.3.7'
6565
implementation 'com.github.MZCretin:ExpandableTextView:v1.6.1-x'
6666
implementation 'com.github.TutorialsAndroid:crashx:v6.0.19'

app/release/output-metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 240403,
15-
"versionName": "2.3.2",
14+
"versionCode": 240719,
15+
"versionName": "2.3.3",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<activity
4141
android:name="com.cyh128.wenku8reader.activity.LoginInputActivity"
4242
android:theme="@style/Theme.MyApplication"
43-
android:windowSoftInputMode="adjustResize"
43+
android:windowSoftInputMode="adjustPan"
4444
android:screenOrientation="portrait"/>
4545

4646
<activity

app/src/main/java/com/cyh128/wenku8reader/App.kt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.cyh128.wenku8reader.activity.CrashActivity
55
import com.cyh128.wenku8reader.util.GlobalConfig
66
import com.developer.crashx.config.CrashConfig
77
import com.google.android.material.color.DynamicColors
8+
import com.tencent.mmkv.MMKV
89

910
class App : Application() {
1011
override fun onCreate() {
@@ -13,6 +14,7 @@ class App : Application() {
1314
CrashConfig.Builder.create()
1415
.errorActivity(CrashActivity::class.java)
1516
.apply()
17+
MMKV.initialize(this)
1618
}
1719

1820
override fun onTerminate() {

app/src/main/java/com/cyh128/wenku8reader/activity/ContentsActivity.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ class ContentsActivity : AppCompatActivity() {
204204
contentsList = getContents(bookUrl!!) //小说目录
205205

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

252252
@Throws(IOException::class)
253253
private fun getBid() {
254-
//https://www.wenku8.cc/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。因为删除必须用bid
254+
//https://www.wenku8.net/book/xxxx.htm 如果url没有bid,只有aid,那么就根据它的aid在书架中找到它对应的bid。因为删除必须用bid
255255
BookCaseFragment.bookcaseList = bookcase
256256
for (bcc in BookCaseFragment.bookcaseList) {
257257
if (bcc.aid.toInt() == aid) {

app/src/main/java/com/cyh128/wenku8reader/activity/LoginInputActivity.kt

+37-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import android.os.Bundle
88
import android.text.Editable
99
import android.text.TextWatcher
1010
import android.util.Log
11-
import android.view.View
1211
import android.widget.Button
1312
import android.widget.CheckBox
1413
import android.widget.CompoundButton
14+
import androidx.appcompat.app.AlertDialog
1515
import androidx.appcompat.app.AppCompatActivity
1616
import com.cyh128.wenku8reader.R
1717
import com.cyh128.wenku8reader.util.GlobalConfig
@@ -36,6 +36,22 @@ class LoginInputActivity : AppCompatActivity() {
3636
// 以下两行会导致内存泄漏,待改进
3737
// CircularProgressIndicatorSpec spec = new CircularProgressIndicatorSpec(this, null, 0, com.google.android.material.R.style.Widget_Material3_CircularProgressIndicator_ExtraSmall);
3838
// Drawable drawable = IndeterminateDrawable.createCircularDrawable(this, spec);
39+
findViewById<Button>(R.id.register).setOnClickListener {
40+
MaterialAlertDialogBuilder(this)
41+
.setTitle("请前往浏览器注册")
42+
.setMessage("您需要前往浏览器页面注册,注册成功后再将用户名和密码填入输入框中,点击[前往注册]以继续注册")
43+
.setCancelable(false)
44+
.setNegativeButton("取消", null)
45+
.setPositiveButton(
46+
"前往注册"
47+
) { _: DialogInterface?, _: Int ->
48+
val uri: Uri = Uri.parse("https://${GlobalConfig.domain}/register.php") //设置跳转的网站
49+
val intent = Intent(Intent.ACTION_VIEW, uri)
50+
startActivity(intent)
51+
}
52+
.show()
53+
}
54+
3955
signIn = findViewById(R.id.confirm_login)
4056
signIn.setOnClickListener {
4157
signIn.isClickable = false
@@ -85,7 +101,7 @@ class LoginInputActivity : AppCompatActivity() {
85101
MaterialAlertDialogBuilder(this@LoginInputActivity)
86102
.setCancelable(false) //禁止点击其他区域
87103
.setTitle("网络错误")
88-
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查是否正在连接VPN或代理服务器\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n\n请稍后再试")
104+
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查网络ip属地是否为中国大陆\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n4 -> 尝试切换节点\n\n请稍后再试")
89105
.setPositiveButton("明白", null)
90106
.setIcon(R.drawable.warning)
91107
.show()
@@ -103,6 +119,25 @@ class LoginInputActivity : AppCompatActivity() {
103119
username = findViewById(R.id.username)
104120
password = findViewById(R.id.password)
105121
initTextFieldListener() //负责清空错误信息
122+
123+
findViewById<Button>(R.id.b_a_login_input_domain).setOnClickListener {
124+
MaterialAlertDialogBuilder(this)
125+
.setTitle("选择节点")
126+
.setSingleChoiceItems(
127+
arrayOf("www.wenku8.cc","www.wenku8.net"),
128+
run {
129+
if (GlobalConfig.domain == "www.wenku8.cc") return@run 0
130+
else return@run 1
131+
}
132+
) { dialog: DialogInterface, which: Int ->
133+
when(which) {
134+
0 -> GlobalConfig.domain = "www.wenku8.cc"
135+
1 -> GlobalConfig.domain = "www.wenku8.net"
136+
}
137+
dialog.dismiss()
138+
}
139+
.show()
140+
}
106141
}
107142

108143
private fun initTextFieldListener() { //负责清空错误信息

app/src/main/java/com/cyh128/wenku8reader/activity/LoginingActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LoginingActivity : AppCompatActivity() {
6969
MaterialAlertDialogBuilder(this@LoginingActivity)
7070
.setCancelable(false) //禁止点击其他区域
7171
.setTitle("网络错误")
72-
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查是否正在连接VPN或代理服务器\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n\n请稍后再试")
72+
.setMessage("可能是以下原因造成的:\n\n1 -> 请检查网络ip属地是否为中国大陆\n2 -> 未连接上网络\n3 -> 服务器(wenku8.cc)出错,(此网站有时会登不上去)\n4 -> 尝试切换节点\n\n请稍后再试")
7373
.setPositiveButton(
7474
"重启软件"
7575
) { dialogInterface: DialogInterface?, i: Int ->

app/src/main/java/com/cyh128/wenku8reader/activity/SettingActivity.kt

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.cyh128.wenku8reader.activity
33
import android.os.Bundle
44
import android.view.View
55
import android.widget.RadioButton
6+
import android.widget.RadioGroup
67
import androidx.appcompat.app.AppCompatActivity
78
import com.cyh128.wenku8reader.R
89
import com.cyh128.wenku8reader.util.DatabaseHelper
@@ -33,6 +34,18 @@ class SettingActivity : AppCompatActivity() {
3334
// 退出当前页面
3435
finish()
3536
}
37+
38+
findViewById<RadioGroup>(R.id.rg_a_setting_domain).setOnCheckedChangeListener { group, checkedId ->
39+
when(checkedId) {
40+
R.id.radiobutton_new_reader_cc -> GlobalConfig.domain = "www.wenku8.cc"
41+
R.id.radiobutton_old_reader_net -> GlobalConfig.domain = "www.wenku8.net"
42+
}
43+
}
44+
45+
if (GlobalConfig.domain == "www.wenku8.cc")
46+
findViewById<RadioButton>(R.id.radiobutton_new_reader_cc).isChecked = true
47+
else
48+
findViewById<RadioButton>(R.id.radiobutton_old_reader_net).isChecked = true
3649
}
3750

3851
override fun onDestroy() {

app/src/main/java/com/cyh128/wenku8reader/adapter/BookCaseAdapter.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions
1616
import com.cyh128.wenku8reader.R
1717
import com.cyh128.wenku8reader.activity.ContentsActivity
1818
import com.cyh128.wenku8reader.bean.BookcaseBean
19+
import com.cyh128.wenku8reader.util.GlobalConfig
1920
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2021

2122
class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/105779329
@@ -66,7 +67,7 @@ class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/10577932
6667
return@setOnClickListener
6768
}
6869
val url = String.format(
69-
"https://www.wenku8.cc/book/%s.htm",
70+
"https://${GlobalConfig.domain}/book/%s.htm",
7071
novel.bookUrl.substring(
7172
novel.bookUrl.indexOf("aid=") + 4,
7273
novel.bookUrl.indexOf("&")
@@ -98,7 +99,7 @@ class BookCaseAdapter(//https://blog.csdn.net/huweiliyi/article/details/10577932
9899
return@setOnClickListener
99100
}
100101
val url = String.format(
101-
"https://www.wenku8.cc/book/%s.htm",
102+
"https://${GlobalConfig.domain}/book/%s.htm",
102103
novel.bookUrl.substring(
103104
novel.bookUrl.indexOf("aid=") + 4,
104105
novel.bookUrl.indexOf("&")

app/src/main/java/com/cyh128/wenku8reader/fragment/TagSearchFragment.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
99
import com.cyh128.wenku8reader.R
1010
import com.cyh128.wenku8reader.adapter.BookListAdapter
1111
import com.cyh128.wenku8reader.bean.BookListBean
12+
import com.cyh128.wenku8reader.util.GlobalConfig
1213
import com.cyh128.wenku8reader.util.LoginWenku8
1314
import com.cyh128.wenku8reader.util.Wenku8Spider.parseNovelList
1415
import me.jingbin.library.ByRecyclerView
@@ -111,7 +112,7 @@ class TagSearchFragment : Fragment() {
111112
get() {
112113
return try {
113114
val url: String = String.format(
114-
"https://www.wenku8.cc/modules/article/tags.php?t=%s&page=%d&v=%s",
115+
"https://${GlobalConfig.domain}/modules/article/tags.php?t=%s&page=%d&v=%s",
115116
URLEncoder.encode(tag, "gbk"),
116117
++pageindex,
117118
sort

app/src/main/java/com/cyh128/wenku8reader/util/GlobalConfig.kt

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cyh128.wenku8reader.util
22

33
import android.database.sqlite.SQLiteDatabase
4+
import com.tencent.mmkv.MMKV
45

56
object GlobalConfig {
67
//app全局变量存放处
@@ -21,4 +22,12 @@ object GlobalConfig {
2122
lateinit var db: SQLiteDatabase
2223
var isFiveSecondDone = true
2324
var readerMode = 0
25+
26+
27+
private val domainCursor = MMKV.mmkvWithID("domain")
28+
var domain: String
29+
get() = domainCursor.decodeString("domain", "www.wenku8.cc")!!
30+
set(value) {
31+
domainCursor.encode("domain",value)
32+
}
2433
}

app/src/main/java/com/cyh128/wenku8reader/util/LoginWenku8.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object LoginWenku8 {
4040
builder.add(key, paramsMap[key]!!)
4141
}
4242
val formBody: RequestBody = builder.build()
43-
val request: Request = Request.Builder().url("https://www.wenku8.cc/login.php").post(formBody).build()
43+
val request: Request = Request.Builder().url("https://${GlobalConfig.domain}/login.php").post(formBody).build()
4444
val response = okHttpClient.newCall(request).execute()
4545
val html = String(response.body.bytes(), charset("gbk"))
4646
if (!isCorrectUsernameOrPassword(html)) { //判断密码正确

0 commit comments

Comments
 (0)