Merge pull request #18 from gedoor/master

update from master
pull/19/head
Antecer 6 years ago committed by GitHub
commit 7c3045dce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/.gitignore
  2. 5
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  3. 5
      app/src/main/java/io/legado/app/data/entities/Book.kt
  4. 23
      app/src/main/java/io/legado/app/data/entities/Chapter.kt
  5. 23
      app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt
  6. 5
      app/src/main/java/io/legado/app/data/entities/Rule.kt
  7. 2
      app/src/main/java/io/legado/app/data/entities/Source.kt
  8. 3
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  9. 5
      app/src/main/java/io/legado/app/ui/main/MainModel.kt
  10. 9
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  11. 1
      app/src/main/res/values/strings.xml

1
app/.gitignore vendored

@ -1 +1,2 @@
/build /build
/schemas

@ -8,9 +8,12 @@ import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase import androidx.sqlite.db.SupportSQLiteDatabase
import io.legado.app.data.dao.BookDao import io.legado.app.data.dao.BookDao
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.Chapter
import io.legado.app.data.entities.ReplaceRule
import javax.xml.transform.Source
@Database(entities = [Book::class], version = 1, exportSchema = true) @Database(entities = [Book::class, Chapter::class, ReplaceRule::class, Source::class], version = 1, exportSchema = true)
// @TypeConverters(Converters::class) // @TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {

@ -1,6 +1,5 @@
package io.legado.app.data.entities package io.legado.app.data.entities
import android.annotation.SuppressLint
import android.os.Parcelable import android.os.Parcelable
import androidx.room.* import androidx.room.*
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
@ -14,7 +13,7 @@ data class Book(@PrimaryKey
var tag: String = "", var tag: String = "",
var author: String? = null, var author: String? = null,
var coverUrl: String? = null, var coverUrl: String? = null,
var customCoverUrl: String? = null, var userCoverUrl: String? = null,
var introduction: String? = null, var introduction: String? = null,
var charset: String? = null, var charset: String? = null,
var type: Int = 0, // 0: text, 1: audio var type: Int = 0, // 0: text, 1: audio
@ -26,7 +25,7 @@ data class Book(@PrimaryKey
var durChapterPage: Int = 0, var durChapterPage: Int = 0,
var totalChapterNum: Int = 0, var totalChapterNum: Int = 0,
var hasNewChapter: Boolean = false, var hasNewChapter: Boolean = false,
var allowUpdate: Boolean = true var canUpdate: Boolean = true
) : Parcelable { ) : Parcelable {
fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0) fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0)

@ -0,0 +1,23 @@
package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "chapters",
indices = [(Index(value = ["url"]))])
data class Chapter(@PrimaryKey
var url: String = "",
var name: String = "",
var bookUrl: String = "",
var index: Int = 0,
var resourceUrl: String? = null,
var tag: String? = null,
var start: Long? = null,
var end: Long? = null
) : Parcelable

@ -0,0 +1,23 @@
package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "replace_rules",
indices = [(Index(value = ["id"]))])
data class ReplaceRule(@PrimaryKey
val id: Int = 0,
val summary: String? = null,
val pattern: String? = null,
val replacement: String? = null,
val scope: String? = null,
val isEnabled: Boolean? = null,
val isRegex: Boolean? = null,
val order: Int = 0
) : Parcelable

@ -0,0 +1,5 @@
package io.legado.app.data.entities
class Rule {
}

@ -0,0 +1,2 @@
package io.legado.app.data.entities

@ -7,6 +7,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.lifecycle.ViewModelProviders
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.longSnackbar import io.legado.app.utils.longSnackbar
@ -19,7 +20,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
fab.setOnClickListener { it.longSnackbar(R.string.app_name) } fab.setOnClickListener { it.longSnackbar(R.string.app_name) }
@ -33,6 +33,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
toggle.syncState() toggle.syncState()
nav_view.setNavigationItemSelectedListener(this) nav_view.setNavigationItemSelectedListener(this)
val mainViewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
} }
override fun onBackPressed() { override fun onBackPressed() {

@ -0,0 +1,5 @@
package io.legado.app.ui.main
class MainModel {
}

@ -0,0 +1,9 @@
package io.legado.app.ui.main
import android.app.Application
import androidx.lifecycle.AndroidViewModel
class MainViewModel(application: Application) : AndroidViewModel(application) {
}

@ -13,4 +13,5 @@
<string name="menu_tools">Tools</string> <string name="menu_tools">Tools</string>
<string name="menu_share">Share</string> <string name="menu_share">Share</string>
<string name="menu_send">Send</string> <string name="menu_send">Send</string>
<string name="action">Replace with your own action</string>
</resources> </resources>

Loading…
Cancel
Save