diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 865feb29f..0a1261a13 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,7 +54,7 @@ - + diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index 56d0657ba..92e5c15c3 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt @@ -21,7 +21,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo override val viewModel: BookInfoViewModel get() = getViewModel(BookInfoViewModel::class.java) - var changeSourceDialog: ChangeSourceDialog? = null + private var changeSourceDialog: ChangeSourceDialog? = null override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 8ed1d310b..92a405b4c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -26,7 +26,7 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.bookinfo.BookInfoActivity 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.utils.* import kotlinx.android.synthetic.main.dialog_edittext.view.* @@ -106,7 +106,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b } override fun open(book: Book) { - context?.startActivity(Pair("bookUrl", book.bookUrl)) + context?.startActivity(Pair("bookUrl", book.bookUrl)) } override fun openBookInfo(book: Book) { diff --git a/app/src/main/java/io/legado/app/ui/read/ReadActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt similarity index 80% rename from app/src/main/java/io/legado/app/ui/read/ReadActivity.kt rename to app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index ed29d2692..96857f8cf 100644 --- a/app/src/main/java/io/legado/app/ui/read/ReadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.read +package io.legado.app.ui.readbook import android.os.Bundle import android.view.KeyEvent @@ -10,6 +10,8 @@ import androidx.core.view.isVisible import io.legado.app.App import io.legado.app.R 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.replacerule.ReplaceRuleActivity 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.startActivity -class ReadActivity : VMBaseActivity(R.layout.activity_read) { - override val viewModel: ReadViewModel - get() = getViewModel(ReadViewModel::class.java) +class ReadBookActivity : VMBaseActivity(R.layout.activity_read), ChangeSourceDialog.CallBack { + override val viewModel: ReadBookViewModel + get() = getViewModel(ReadBookViewModel::class.java) + private var changeSourceDialog: ChangeSourceDialog? = null private var menuBarShow: Boolean = false private lateinit var menuTopIn: Animation private lateinit var menuTopOut: Animation @@ -33,6 +36,10 @@ class ReadActivity : VMBaseActivity(R.layout.activity_read) { initAnimation() initView() viewModel.initData(intent) + savedInstanceState?.let { + changeSourceDialog = supportFragmentManager.findFragmentByTag(ChangeSourceDialog.tag) as? ChangeSourceDialog + changeSourceDialog?.callBack = this + } } private fun initAnimation() { @@ -129,7 +136,7 @@ class ReadActivity : VMBaseActivity(R.layout.activity_read) { } override fun toast(id: Int) { - this@ReadActivity.toast(id) + this@ReadBookActivity.toast(id) } override fun dismiss() { @@ -146,7 +153,15 @@ class ReadActivity : VMBaseActivity(R.layout.activity_read) { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { 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) } @@ -185,4 +200,8 @@ class ReadActivity : VMBaseActivity(R.layout.activity_read) { } } } + + override fun changeTo(book: Book) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt similarity index 92% rename from app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt rename to app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index 3d0cc0b59..d793c0cb0 100644 --- a/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.read +package io.legado.app.ui.readbook import android.app.Application 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.model.WebBook -class ReadViewModel(application: Application) : BaseViewModel(application) { +class ReadBookViewModel(application: Application) : BaseViewModel(application) { var book: Book? = null var bookSource: BookSource? = null diff --git a/app/src/main/java/io/legado/app/ui/read/ReadBottomMenu.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBottomMenu.kt similarity index 99% rename from app/src/main/java/io/legado/app/ui/read/ReadBottomMenu.kt rename to app/src/main/java/io/legado/app/ui/readbook/ReadBottomMenu.kt index 196d86e9d..ba13a07aa 100644 --- a/app/src/main/java/io/legado/app/ui/read/ReadBottomMenu.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBottomMenu.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.read +package io.legado.app.ui.readbook import android.content.Context import android.util.AttributeSet diff --git a/app/src/main/res/layout/activity_read.xml b/app/src/main/res/layout/activity_read.xml index a7396af3d..e59480522 100644 --- a/app/src/main/res/layout/activity_read.xml +++ b/app/src/main/res/layout/activity_read.xml @@ -46,7 +46,7 @@ - - + - + - + - + diff --git a/app/src/main/res/menu/source_edit.xml b/app/src/main/res/menu/source_edit.xml index f9831f9a4..f1ee15173 100644 --- a/app/src/main/res/menu/source_edit.xml +++ b/app/src/main/res/menu/source_edit.xml @@ -15,7 +15,7 @@ app:showAsAction="ifRoom" />