Skip to content

Commit

Permalink
v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
15dd committed Nov 23, 2024
1 parent 9c72c7d commit 829ef78
Show file tree
Hide file tree
Showing 36 changed files with 444 additions and 256 deletions.
4 changes: 2 additions & 2 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 .idea/kotlinc.xml

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

1 change: 0 additions & 1 deletion .idea/misc.xml

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

10 changes: 3 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
applicationId = "com.cyh128.hikari_novel"
minSdk = 24
targetSdk = 35
versionCode = 241117
versionCode = 241123
versionName = "3.3.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -41,7 +41,7 @@ android {

buildTypes {
release {
isMinifyEnabled = true
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("signing")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -74,7 +74,6 @@ android {
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

}

dependencies {
Expand Down Expand Up @@ -141,15 +140,12 @@ dependencies {
implementation("com.geyifeng.immersionbar:immersionbar:3.2.2")

//hilt依赖注入
implementation("com.google.dagger:hilt-android:2.51.1")
implementation("com.google.dagger:hilt-android:2.52")
ksp("com.google.dagger:hilt-android-compiler:2.51")

//json解析
implementation("com.google.code.gson:gson:2.11.0")

//快速切换语言
implementation("com.github.YarikSOffice:lingver:1.3.0")

//事件总线
implementation("com.github.liangjingkanji:Channel:1.1.5")

Expand Down
15 changes: 15 additions & 0 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.7.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.2)" variant="fatal" version="8.7.2">

<issue
id="MissingDefaultResource"
message="The color &quot;nord_outlineVariant&quot; in values-night has no declaration in the base `values` folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier"
errorLine1=" &lt;color name=&quot;nord_outlineVariant&quot;>#90939a&lt;/color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values-night/colors_nord.xml"
line="27"
column="12"/>
</issue>

</issues>
Binary file modified app/release/app-release.apk
Binary file not shown.
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
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": 241018,
"versionName": "3.1.1",
"versionCode": 241123,
"versionName": "3.3.0",
"outputFile": "app-release.apk"
}
],
Expand Down
22 changes: 5 additions & 17 deletions app/src/main/java/com/cyh128/hikari_novel/HikariApp.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package com.cyh128.hikari_novel

import android.app.Application
import com.cyh128.hikari_novel.data.model.Language
import com.cyh128.hikari_novel.data.repository.AppRepository
import com.cyh128.hikari_novel.ui.view.other.CrashActivity
import com.cyh128.hikari_novel.util.LanguageHelper
import com.cyh128.hikari_novel.util.ThemeHelper
import com.developer.crashx.config.CrashConfig
import com.tencent.mmkv.MMKV
import com.yariksoffice.lingver.Lingver
import dagger.hilt.android.HiltAndroidApp
import okhttp3.OkHttpClient
import rxhttp.RxHttpPlugins
import rxhttp.wrapper.cookie.CookieStore
import java.util.Locale
import javax.inject.Inject
import javax.net.ssl.SSLSession


@HiltAndroidApp
class HikariApp : Application() {

Expand All @@ -32,6 +29,10 @@ class HikariApp : Application() {

super.onCreate()

ThemeHelper.setCurrentTheme(appRepository.getAppTheme())
ThemeHelper.setDarkMode(appRepository.getDarkMode())
LanguageHelper.setCurrentLanguage(appRepository.getLanguage())

application = this
val client: OkHttpClient = OkHttpClient.Builder()
.cookieJar(CookieStore()) //保存cookie
Expand All @@ -41,18 +42,5 @@ class HikariApp : Application() {
CrashConfig.Builder.create()
.errorActivity(CrashActivity::class.java)
.apply()

Lingver.init(this)
when (appRepository.getLanguage()) {
Language.FOLLOW_SYSTEM -> Lingver.getInstance().setFollowSystemLocale(this).apply {
if (Lingver.getInstance().getLocale() != Locale.SIMPLIFIED_CHINESE && Lingver.getInstance().getLocale() != Locale.TRADITIONAL_CHINESE) {
Lingver.getInstance().setLocale(this@HikariApp, Locale.SIMPLIFIED_CHINESE)
}
}
Language.ZH_CN -> Lingver.getInstance().setLocale(this, Locale.SIMPLIFIED_CHINESE)
Language.ZH_TW -> Lingver.getInstance().setLocale(this, Locale.TRADITIONAL_CHINESE)
}

ThemeHelper.setCurrentTheme(appRepository.getAppTheme())
}
}
24 changes: 21 additions & 3 deletions app/src/main/java/com/cyh128/hikari_novel/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
package com.cyh128.hikari_novel.base

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.cyh128.hikari_novel.data.model.Event
import com.cyh128.hikari_novel.util.LanguageHelper
import com.cyh128.hikari_novel.util.ThemeHelper
import com.drake.channel.receiveEvent
import java.lang.reflect.ParameterizedType

abstract class BaseActivity<VB: ViewBinding>: AppCompatActivity() {
abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
lateinit var binding: VB

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
LanguageHelper.initLanguage()
ThemeHelper.initActivityThemeAndDarkMode(this)

ThemeHelper.initActivityTheme(this)
receiveEvent<Event>("event_theme_changed", "event_language_changed") {
recreateActivity()
}

super.onCreate(savedInstanceState)

val type = javaClass.genericSuperclass as ParameterizedType
val aClass = type.actualTypeArguments[0] as Class<*>
Expand All @@ -21,4 +31,12 @@ abstract class BaseActivity<VB: ViewBinding>: AppCompatActivity() {
binding = method.invoke(null, layoutInflater) as VB
setContentView(binding.root)
}

private fun recreateActivity() {
val intent = Intent(this, this::class.java)
startActivity(intent)
finish()
overridePendingTransition(0, 0) //TODO 去掉切换动画
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cyh128.hikari_novel.data.model

enum class DarkMode {
System,
Enable,
Disable
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/cyh128/hikari_novel/data/model/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ sealed class Event {

data object HaveAvailableUpdateEvent: Event() //有更新
data object NoAvailableUpdateEvent: Event() //无更新

data object ThemeChangedEvent: Event() //主题颜色改变事件
data object LanguageChantedEvent: Event() //语言改变事件
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.accounts.NetworkErrorException
import android.content.pm.PackageManager
import com.cyh128.hikari_novel.HikariApp
import com.cyh128.hikari_novel.data.model.AppTheme
import com.cyh128.hikari_novel.data.model.DarkMode
import com.cyh128.hikari_novel.data.model.DefaultTab
import com.cyh128.hikari_novel.data.model.Language
import com.cyh128.hikari_novel.data.model.ReaderOrientation
Expand Down Expand Up @@ -69,6 +70,12 @@ class AppRepository @Inject constructor(
appConfig.appTheme = appTheme.ordinal
}

fun getDarkMode() = enumValues<DarkMode>()[appConfig.darkMode]

fun setDarkMode(darkMode: DarkMode) {
appConfig.darkMode = darkMode.ordinal
}

//检查更新
suspend fun checkUpdate(): Result<Boolean> {
network.getData("https://api.github.com/repos/15dd/wenku8reader/releases/latest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.cyh128.hikari_novel.data.source.remote.Network
import com.cyh128.hikari_novel.util.HttpCodeParser
import com.cyh128.hikari_novel.util.Wenku8Parser
import com.cyh128.hikari_novel.util.urlEncode
import com.yariksoffice.lingver.Lingver
import rxhttp.awaitResult
import java.nio.charset.Charset
import java.util.Locale
Expand Down Expand Up @@ -69,7 +68,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getNovelByRanking(ranking: String, index: Int): Result<NovelCoverResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/toplist.php?sort=$ranking&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand Down Expand Up @@ -99,7 +98,7 @@ class Wenku8Repository @Inject constructor(
): Result<NovelCoverResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/tags.php?t=$category&v=$sort&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -125,7 +124,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getNovelInfo(url: String): Result<NovelInfo> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "$url&charset=big5"
charset = "BIG5-HKSCS" //不能使用普通的big5编码,不然无法显示日文
Expand All @@ -151,7 +150,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getChapter(url: String): Result<List<Volume>> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "$url?charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -176,7 +175,7 @@ class Wenku8Repository @Inject constructor(
suspend fun addNovel(aid: String): Result<Boolean> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/addbookcase.php?bid=$aid&charset=big5"
charset = "BIG5-HKSCS"
Expand Down Expand Up @@ -212,7 +211,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getBookshelf(classId: Int = 0): Result<List<BookshelfNovelInfo>> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/bookcase.php?classid=$classId&charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -237,7 +236,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getComment(aid: String, index: Int): Result<CommentResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/reviews.php?aid=$aid&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -262,7 +261,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getReply(url: String, index: Int): Result<ReplyResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "$url&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -286,7 +285,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getRecommend(): Result<List<HomeBlock>> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/index.php?charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -311,7 +310,7 @@ class Wenku8Repository @Inject constructor(
suspend fun novelVote(aid: String): Result<String> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/uservote.php?id=$aid&charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -336,7 +335,7 @@ class Wenku8Repository @Inject constructor(
suspend fun searchNovelByTitle(title: String, index: Int): Result<NovelCoverResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/search.php?searchtype=articlename&searchkey=$title&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand Down Expand Up @@ -368,7 +367,7 @@ class Wenku8Repository @Inject constructor(
suspend fun searchNovelByAuthor(author: String, index: Int): Result<NovelCoverResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/search.php?searchtype=author&searchkey=$author&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand Down Expand Up @@ -405,7 +404,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getUserInfo(): Result<UserInfo> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/userdetail.php?charset=big5"
charset = "BIG5-HKSCS"
Expand All @@ -430,7 +429,7 @@ class Wenku8Repository @Inject constructor(
suspend fun getCompletionNovel(index: Int): Result<NovelCoverResponse> {
val requestUrl: String?
val charset: String?
when(Lingver.getInstance().getLocale()) {
when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> {
requestUrl = "https://${getWenku8Node()}/modules/article/articlelist.php?fullflag=1&page=$index&charset=big5"
charset = "BIG5-HKSCS"
Expand Down Expand Up @@ -458,7 +457,7 @@ class Wenku8Repository @Inject constructor(

//获取小说内容
suspend fun getNovelContent(aid: String, cid: String): Result<ChapterContentResponse> {
val requestUrl = when(Lingver.getInstance().getLocale()) {
val requestUrl = when(Locale.getDefault()) {
Locale.TRADITIONAL_CHINESE -> "action=book&do=text&aid=$aid&cid=$cid&t=1"
else -> "action=book&do=text&aid=$aid&cid=$cid&t=0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cyh128.hikari_novel.data.source.local.mmkv

import com.cyh128.hikari_novel.data.model.AppTheme
import com.cyh128.hikari_novel.data.model.DarkMode
import com.cyh128.hikari_novel.data.model.DefaultTab
import com.cyh128.hikari_novel.data.model.Language
import com.cyh128.hikari_novel.data.model.ReaderOrientation
Expand Down Expand Up @@ -60,4 +61,10 @@ class AppConfig @Inject constructor() {
set(value) {
cursor.encode("app_theme", value)
}

var darkMode: Int
get() = cursor.decodeInt("dark_mode", DarkMode.System.ordinal)
set(value) {
cursor.encode("dark_mode", value)
}
}
Loading

0 comments on commit 829ef78

Please sign in to comment.