Skip to content

Commit

Permalink
Merge pull request #128 from dmzz-yyhyy/data_export
Browse files Browse the repository at this point in the history
添加多数据源切换功能
  • Loading branch information
dmzz-yyhyy authored Nov 10, 2024
2 parents b4a0349 + 2ae38c5 commit c78c10b
Show file tree
Hide file tree
Showing 57 changed files with 825 additions and 140 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 app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
minSdk = 24
targetSdk = 34
// 版本号为x.y.z则versionCode为x*1000000+y*10000+z*100+debug版本号(开发需要时迭代, 两位数)
versionCode = 1_00_00_004
versionCode = 1_00_00_005
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
63 changes: 62 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-optimizationpasses 5
-dontwarn javax.lang.model.SourceVersion
-dontwarn javax.lang.model.element.Element
-dontwarn javax.lang.model.element.ElementKind
Expand All @@ -43,4 +45,63 @@
-dontwarn javax.lang.model.util.Types
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-keep,allowobfuscation,allowshrinking class indi.dmzz_yyhyy.lightnovelreader.data.json.**{ *;}
-keep,allowobfuscation,allowshrinking class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.**{ *;}
-keepclassmembers class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.**{ *;}
-keepnames class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.**{ *;}
-keepclassmembernames class indi.dmzz_yyhyy.lightnovelreader.data.web.exploration.**{ *;}
-keep,allowobfuscation,allowshrinking class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.json.**{ *;}
-keepclassmembers class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.json.**{ *;}
-keepnames class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.json.**{ *;}
-keepclassmembernames class indi.dmzz_yyhyy.lightnovelreader.data.web.exploration.**{ *;}
-keep,allowobfuscation,allowshrinking class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.exploration.**{ *;}
-keepclassmembers class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.exploration.**{ *;}
-keepnames class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.exploration.**{ *;}
-keepclassmembernames class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.exploration.**{ *;}
-keep,allowobfuscation,allowshrinking class indi.dmzz_yyhyy.lightnovelreader.data.web.zaicomic.json.**{ *;}
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { <fields>; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
-if class com.google.gson.reflect.TypeToken
-keep,allowobfuscation class com.google.gson.reflect.TypeToken
-keep,allowobfuscation class * extends com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowoptimization @com.google.gson.annotations.JsonAdapter class *
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.Expose <fields>;
@com.google.gson.annotations.JsonAdapter <fields>;
@com.google.gson.annotations.Since <fields>;
@com.google.gson.annotations.Until <fields>;
}
-keepclassmembers class * extends com.google.gson.TypeAdapter {
<init>();
}
-keepclassmembers class * implements com.google.gson.TypeAdapterFactory {
<init>();
}
-keepclassmembers class * implements com.google.gson.JsonSerializer {
<init>();
}
-keepclassmembers class * implements com.google.gson.JsonDeserializer {
<init>();
}
-if class *
-keepclasseswithmembers,allowobfuscation class <1> {
@com.google.gson.annotations.SerializedName <fields>;
}
-if class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keepclassmembers,allowobfuscation,allowoptimization class <1> {
<init>();
}
Binary file modified app/release/LightNovelReader-1.0.0-release.apk
Binary file not shown.
18 changes: 17 additions & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionCode": 10000005,
"versionName": "1.0.0",
"outputFile": "LightNovelReader-1.0.0-release.apk"
}
],
"elementType": "File",
"baselineProfiles": [
{
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/LightNovelReader-1.0.0-release.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/LightNovelReader-1.0.0-release.dm"
]
}
],
"minSdkVersionForDexing": 24
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import indi.dmzz_yyhyy.lightnovelreader.data.local.room.dao.UserDataDao
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.BooleanUserData
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.FloatUserData
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.IntListUserData
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.IntUserData
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.StringListUserData
import indi.dmzz_yyhyy.lightnovelreader.data.userdata.StringUserData
import javax.inject.Inject
Expand All @@ -16,6 +17,7 @@ class UserDataRepository @Inject constructor(
) {
fun stringUserData(path: String): StringUserData = StringUserData(path, userDataDao)
fun floatUserData(path: String): FloatUserData = FloatUserData(path, userDataDao)
fun intUserData(path: String): IntUserData = IntUserData(path, userDataDao)
fun booleanUserData(path: String): BooleanUserData = BooleanUserData(path, userDataDao)
fun intListUserData(path: String): IntListUserData = IntListUserData(path, userDataDao)
fun stringListUserData(path: String): StringListUserData = StringListUserData(path, userDataDao)
Expand All @@ -32,4 +34,6 @@ class UserDataRepository @Inject constructor(
}
return true
}

fun remove(path: String) = userDataDao.remove(path)
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,6 @@ class BookshelfRepository @Inject constructor(
}
return true
}

fun clear() = bookshelfDao.clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package indi.dmzz_yyhyy.lightnovelreader.data.exploration
data class ExplorationBooksRow(
val title: String,
val bookList: List<ExplorationDisplayBook>,
val expandable: Boolean,
val expandable: Boolean = false,
val expandedPageDataSourceId: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import indi.dmzz_yyhyy.lightnovelreader.data.bookshelf.BookshelfSortType
import java.time.LocalDateTime

data class AppUserDataJson(
@SerializedName("type")
val type: String,
@SerializedName("id")
val id: Int? = null,
@SerializedName("data")
val data: List<AppUserDataContent>
) {
companion object {
Expand Down Expand Up @@ -38,7 +41,9 @@ data class AppUserDataContent(
)

class AppUserDataJsonBuilder {
@SerializedName("id")
private var id: Int? = null
@SerializedName("data")
private var data: MutableList<AppUserDataContent> = mutableListOf()

fun build(): AppUserDataJson = AppUserDataJson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import indi.dmzz_yyhyy.lightnovelreader.data.bookshelf.BookshelfBookMetadata
import java.time.LocalDateTime

data class BookShelfBookMetadataData(
@SerializedName("id")
val id: Int,
@SerializedName("last_update")
val lastUpdate: LocalDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import indi.dmzz_yyhyy.lightnovelreader.data.book.UserReadingData
import java.time.LocalDateTime

data class BookUserData(
@SerializedName("id")
val id: Int,
@SerializedName("last_read_time")
val lastReadTime: LocalDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import indi.dmzz_yyhyy.lightnovelreader.data.bookshelf.Bookshelf
import indi.dmzz_yyhyy.lightnovelreader.data.bookshelf.BookshelfSortType

data class BookshelfData(
@SerializedName("id")
val id: Int,
@SerializedName("name")
val name: String,
@SerializedName("sort_type")
val sortType: BookshelfSortType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package indi.dmzz_yyhyy.lightnovelreader.data.json

import com.google.gson.annotations.SerializedName
import indi.dmzz_yyhyy.lightnovelreader.data.local.room.entity.UserDataEntity

data class UserDataData(
@SerializedName("path")
val path: String,
@SerializedName("group")
val group: String,
@SerializedName("type")
val type: String,
@SerializedName("value")
val value: String
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class LocalBookDataSource @Inject constructor(
it.readCompletedChapterIds
)
}

fun updateUserReadingData(id: Int, update: (UserReadingData) -> UserReadingData) {
val userReadingData = userReadingDataDao.getEntityWithoutFlow(id)?.let {
UserReadingData(
Expand All @@ -58,6 +59,7 @@ class LocalBookDataSource @Inject constructor(
return@let data
})
}

fun getAllUserReadingData(): List<UserReadingData> =
userReadingDataDao.getAll().map {
UserReadingData(
Expand All @@ -71,4 +73,11 @@ class LocalBookDataSource @Inject constructor(
it.readCompletedChapterIds
)
}

fun clear() {
userReadingDataDao.clear()
bookInformationDao.clear()
bookVolumesDao.clear()
chapterContentDao.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ abstract class LightNovelReaderDatabase : RoomDatabase() {
LightNovelReaderDatabase::class.java,
"light_novel_reader_database")
.addMigrations(MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9)
.allowMainThreadQueries()
.build()
INSTANCE = instance
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ interface BookInformationDao {
suspend fun has(id: Int): Boolean {
return get(id) != null
}

@Query("delete from book_information")
fun clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ interface BookVolumesDao {
})
}
}

@Query("delete from volume")
fun clearVolumes()

@Query("delete from chapter_information")
fun clearChapterInformation()

@Transaction
fun clear() {
clearVolumes()
clearChapterInformation()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,16 @@ interface BookshelfDao {

@Query("select id from book_shelf_book_metadata")
fun getAllBookshelfBookIdsFlow(): Flow<List<Int>>

@Query("delete from book_shelf")
fun clearBookshelf()

@Query("delete from book_shelf_book_metadata")
fun clearBookshelfBookMetadata()

@Transaction
fun clear() {
clearBookshelf()
clearBookshelfBookMetadata()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ interface ChapterContentDao {

@Query("select * from chapter_content where id = :id")
suspend fun get(id: Int): ChapterContent?

@Query("delete from chapter_content")
fun clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ interface UserDataDao {
fun getEntity(path: String): UserDataEntity?
@Query("select * from user_data where `group` = :group")
fun getGroupValues(group: String): List<UserDataEntity>
@Query("delete from user_data where path = :path")
fun remove(path: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ interface UserReadingDataDao {

@Query("select * from user_reading_data where id = :id")
fun getEntityWithoutFlow(id: Int): UserReadingDataEntity?

@Query("delete from user_reading_data")
fun clear()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package indi.dmzz_yyhyy.lightnovelreader.data.userdata

import indi.dmzz_yyhyy.lightnovelreader.data.local.room.dao.UserDataDao
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class IntUserData (
override val path: String,
private val userDataDao: UserDataDao
) : UserData<Int>(path) {
override fun set(value: Int) {
userDataDao.update(path, group, "Int", value.toString())
}

override fun get(): Int? {
return userDataDao.get(path)?.toInt()
}

override fun getFlow(): Flow<Int?> {
return userDataDao.getFlow(path).map { it?.toInt() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8.exploration.expanedpage.
import indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8.exploration.expanedpage.filter.FirstLetterSingleChoiceFilter
import indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8.exploration.expanedpage.filter.PublishingHouseSingleChoiceFilter
import indi.dmzz_yyhyy.lightnovelreader.utils.update
import indi.dmzz_yyhyy.lightnovelreader.utils.wenku8.wenku8Api
import java.net.URLEncoder
import java.time.LocalDate
import java.time.LocalDateTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package indi.dmzz_yyhyy.lightnovelreader.utils.wenku8
package indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8

import indi.dmzz_yyhyy.lightnovelreader.utils.autoReconnectionPost
import indi.dmzz_yyhyy.lightnovelreader.utils.update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationBooksRow
import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationDisplayBook
import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationPage
import indi.dmzz_yyhyy.lightnovelreader.data.web.exploration.ExplorationPageDataSource
import indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8.wenku8Cookie
import indi.dmzz_yyhyy.lightnovelreader.utils.autoReconnectionGet
import indi.dmzz_yyhyy.lightnovelreader.utils.wenku8.wenku8Cookie
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationBooksRow
import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationDisplayBook
import indi.dmzz_yyhyy.lightnovelreader.data.exploration.ExplorationPage
import indi.dmzz_yyhyy.lightnovelreader.data.web.exploration.ExplorationPageDataSource
import indi.dmzz_yyhyy.lightnovelreader.data.web.wenku8.wenku8Cookie
import indi.dmzz_yyhyy.lightnovelreader.utils.autoReconnectionGet
import indi.dmzz_yyhyy.lightnovelreader.utils.wenku8.wenku8Cookie
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down
Loading

0 comments on commit c78c10b

Please sign in to comment.