pull/32/head
kunfei 5 years ago
parent 4ce13fb592
commit 1216e42702
  1. 2
      app/src/main/AndroidManifest.xml
  2. 2
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  4. 31
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  5. 4
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt
  6. 2
      app/src/main/java/io/legado/app/ui/readbook/ReadBottomMenu.kt
  7. 2
      app/src/main/res/layout/activity_read.xml
  8. 32
      app/src/main/res/menu/read_book.xml
  9. 2
      app/src/main/res/menu/source_edit.xml

@ -54,7 +54,7 @@
<activity android:name=".ui.bookinfo.BookInfoEditActivity" /> <activity android:name=".ui.bookinfo.BookInfoEditActivity" />
<activity android:name=".ui.sourcedebug.SourceDebugActivity" /> <activity android:name=".ui.sourcedebug.SourceDebugActivity" />
<activity android:name=".ui.booksource.BookSourceActivity" /> <activity android:name=".ui.booksource.BookSourceActivity" />
<activity android:name=".ui.read.ReadActivity" /> <activity android:name=".ui.readbook.ReadBookActivity" />
<activity android:name=".ui.chapterlist.ChapterListActivity" /> <activity android:name=".ui.chapterlist.ChapterListActivity" />
<service android:name=".service.CheckSourceService" /> <service android:name=".service.CheckSourceService" />

@ -21,7 +21,7 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
override val viewModel: BookInfoViewModel override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoViewModel::class.java)
var changeSourceDialog: ChangeSourceDialog? = null private var changeSourceDialog: ChangeSourceDialog? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
setSupportActionBar(toolbar) setSupportActionBar(toolbar)

@ -26,7 +26,7 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.bookinfo.BookInfoActivity import io.legado.app.ui.bookinfo.BookInfoActivity
import io.legado.app.ui.bookshelf.BookshelfActivity import io.legado.app.ui.bookshelf.BookshelfActivity
import io.legado.app.ui.read.ReadActivity import io.legado.app.ui.readbook.ReadBookActivity
import io.legado.app.ui.search.SearchActivity import io.legado.app.ui.search.SearchActivity
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_edittext.view.* import kotlinx.android.synthetic.main.dialog_edittext.view.*
@ -106,7 +106,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
} }
override fun open(book: Book) { override fun open(book: Book) {
context?.startActivity<ReadActivity>(Pair("bookUrl", book.bookUrl)) context?.startActivity<ReadBookActivity>(Pair("bookUrl", book.bookUrl))
} }
override fun openBookInfo(book: Book) { override fun openBookInfo(book: Book) {

@ -1,4 +1,4 @@
package io.legado.app.ui.read package io.legado.app.ui.readbook
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
@ -10,6 +10,8 @@ import androidx.core.view.isVisible
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book
import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.utils.* import io.legado.app.utils.*
@ -18,10 +20,11 @@ import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
class ReadActivity : VMBaseActivity<ReadViewModel>(R.layout.activity_read) { class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_read), ChangeSourceDialog.CallBack {
override val viewModel: ReadViewModel override val viewModel: ReadBookViewModel
get() = getViewModel(ReadViewModel::class.java) get() = getViewModel(ReadBookViewModel::class.java)
private var changeSourceDialog: ChangeSourceDialog? = null
private var menuBarShow: Boolean = false private var menuBarShow: Boolean = false
private lateinit var menuTopIn: Animation private lateinit var menuTopIn: Animation
private lateinit var menuTopOut: Animation private lateinit var menuTopOut: Animation
@ -33,6 +36,10 @@ class ReadActivity : VMBaseActivity<ReadViewModel>(R.layout.activity_read) {
initAnimation() initAnimation()
initView() initView()
viewModel.initData(intent) viewModel.initData(intent)
savedInstanceState?.let {
changeSourceDialog = supportFragmentManager.findFragmentByTag(ChangeSourceDialog.tag) as? ChangeSourceDialog
changeSourceDialog?.callBack = this
}
} }
private fun initAnimation() { private fun initAnimation() {
@ -129,7 +136,7 @@ class ReadActivity : VMBaseActivity<ReadViewModel>(R.layout.activity_read) {
} }
override fun toast(id: Int) { override fun toast(id: Int) {
this@ReadActivity.toast(id) this@ReadBookActivity.toast(id)
} }
override fun dismiss() { override fun dismiss() {
@ -146,7 +153,15 @@ class ReadActivity : VMBaseActivity<ReadViewModel>(R.layout.activity_read) {
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_change_source -> {
if (changeSourceDialog == null) {
viewModel.book?.let {
changeSourceDialog = ChangeSourceDialog.newInstance(it.name, it.author)
changeSourceDialog?.callBack = this
}
}
changeSourceDialog?.show(supportFragmentManager, ChangeSourceDialog.tag)
}
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
@ -185,4 +200,8 @@ class ReadActivity : VMBaseActivity<ReadViewModel>(R.layout.activity_read) {
} }
} }
} }
override fun changeTo(book: Book) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} }

@ -1,4 +1,4 @@
package io.legado.app.ui.read package io.legado.app.ui.readbook
import android.app.Application import android.app.Application
import android.content.Intent import android.content.Intent
@ -9,7 +9,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
class ReadViewModel(application: Application) : BaseViewModel(application) { class ReadBookViewModel(application: Application) : BaseViewModel(application) {
var book: Book? = null var book: Book? = null
var bookSource: BookSource? = null var bookSource: BookSource? = null

@ -1,4 +1,4 @@
package io.legado.app.ui.read package io.legado.app.ui.readbook
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet

@ -46,7 +46,7 @@
</io.legado.app.ui.widget.TitleBar> </io.legado.app.ui.widget.TitleBar>
<io.legado.app.ui.read.ReadBottomMenu <io.legado.app.ui.readbook.ReadBottomMenu
android:id="@+id/bottom_menu" android:id="@+id/bottom_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

@ -5,64 +5,64 @@
<group android:id="@+id/menuOnLine"> <group android:id="@+id/menuOnLine">
<item <item
android:id="@+id/action_change_source" android:id="@+id/menu_change_source"
android:icon="@drawable/ic_exchange" android:icon="@drawable/ic_exchange"
android:title="@string/change_origin" android:title="@string/change_origin"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_refresh" android:id="@+id/menu_refresh"
android:icon="@drawable/ic_refresh_black_24dp" android:icon="@drawable/ic_refresh_black_24dp"
android:title="@string/refresh" android:title="@string/refresh"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_download" android:id="@+id/menu_download"
android:icon="@drawable/ic_download_line" android:icon="@drawable/ic_download_line"
android:title="@string/download_offline" android:title="@string/download_offline"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/disable_book_source" android:id="@+id/menu_disable_book_source"
android:icon="@drawable/ic_cancel" android:icon="@drawable/ic_cancel"
android:title="@string/disable_book_source" android:title="@string/disable_book_source"
app:showAsAction="never" /> app:showAsAction="never" />
</group> </group>
<group android:id="@+id/menu_text"> <group android:id="@+id/menu_group_text">
<item <item
android:id="@+id/action_set_regex" android:id="@+id/menu_set_regex"
android:icon="@drawable/ic_exchange" android:icon="@drawable/ic_exchange"
android:title="@string/txt_chapter_regex" android:title="@string/txt_chapter_regex"
app:showAsAction="always" /> app:showAsAction="always" />
</group> </group>
<group android:id="@+id/menuLocal"> <group android:id="@+id/menu_group_local">
<item <item
android:id="@+id/action_set_charset" android:id="@+id/menu_set_charset"
android:icon="@drawable/ic_translate" android:icon="@drawable/ic_translate"
android:title="@string/set_charset" android:title="@string/set_charset"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
</group> </group>
<group android:id="@+id/menuShow"> <group android:id="@+id/menu_group_show">
<item <item
android:id="@+id/add_bookmark" android:id="@+id/menu_add_bookmark"
android:icon="@drawable/ic_bookmark" android:icon="@drawable/ic_bookmark"
android:title="@string/bookmark_add" android:title="@string/bookmark_add"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_copy_text" android:id="@+id/menu_copy_text"
android:icon="@drawable/ic_copy" android:icon="@drawable/ic_copy"
android:title="@string/copy_text" android:title="@string/copy_text"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/enable_replace" android:id="@+id/menu_enable_replace"
android:icon="@drawable/ic_find_replace" android:icon="@drawable/ic_find_replace"
android:title="@string/replace_rule_title" android:title="@string/replace_rule_title"
android:checkable="true" android:checkable="true"
@ -70,21 +70,21 @@
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/update_chapter_list" android:id="@+id/menu_update_chapter_list"
android:icon="@drawable/ic_update" android:icon="@drawable/ic_update"
android:title="@string/update_chapter" android:title="@string/update_chapter"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_book_info" android:id="@+id/menu_book_info"
android:icon="@drawable/ic_toc" android:icon="@drawable/ic_toc"
android:title="@string/book_info" android:title="@string/book_info"
app:showAsAction="never" /> app:showAsAction="never" />
</group> </group>
<group android:id="@+id/menu_login"> <group android:id="@+id/menu_group_login">
<item <item
android:id="@+id/action_login" android:id="@+id/menu_login"
android:icon="@drawable/ic_toc" android:icon="@drawable/ic_toc"
android:title="@string/login" android:title="@string/login"
app:showAsAction="never" /> app:showAsAction="never" />

@ -15,7 +15,7 @@
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_login" android:id="@+id/menu_login"
android:title="@string/login" android:title="@string/login"
app:showAsAction="never" /> app:showAsAction="never" />

Loading…
Cancel
Save