diff --git a/app/build.gradle b/app/build.gradle
index 8bd44a700..d99118fc5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -160,8 +160,6 @@ dependencies {
//MarkDown
implementation 'ru.noties.markwon:core:3.0.2'
- //高斯模糊
- implementation 'jp.wasabeef:glide-transformations:4.1.0'
}
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d3eff6243..6d456ff25 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -78,8 +78,7 @@
-
+
diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt
index c30e61a9c..cff1863e7 100644
--- a/app/src/main/java/io/legado/app/base/BaseActivity.kt
+++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt
@@ -19,8 +19,11 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
-abstract class BaseActivity(private val layoutID: Int, private val fullScreen: Boolean = true) :
- AppCompatActivity(),
+abstract class BaseActivity(
+ private val layoutID: Int,
+ private val fullScreen: Boolean = true,
+ private val theme: Theme = Theme.Auto
+) : AppCompatActivity(),
CoroutineScope by MainScope() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -73,10 +76,14 @@ abstract class BaseActivity(private val layoutID: Int, private val fullScreen: B
private fun initTheme() {
ATH.applyBackgroundTint(window.decorView)
- if (ColorUtils.isColorLight(primaryColor)) {
- setTheme(R.style.AppTheme_Light)
- } else {
- setTheme(R.style.AppTheme_Dark)
+ when (theme) {
+ Theme.Dark -> setTheme(R.style.AppTheme_Dark)
+ Theme.Light -> setTheme(R.style.AppTheme_Light)
+ else -> if (ColorUtils.isColorLight(primaryColor)) {
+ setTheme(R.style.AppTheme_Light)
+ } else {
+ setTheme(R.style.AppTheme_Dark)
+ }
}
}
@@ -100,4 +107,8 @@ abstract class BaseActivity(private val layoutID: Int, private val fullScreen: B
currentFocus?.hideSoftInput()
super.finish()
}
+
+ enum class Theme {
+ Dark, Light, Auto
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/base/VMBaseActivity.kt b/app/src/main/java/io/legado/app/base/VMBaseActivity.kt
index 8267a2c8b..65d8e123d 100644
--- a/app/src/main/java/io/legado/app/base/VMBaseActivity.kt
+++ b/app/src/main/java/io/legado/app/base/VMBaseActivity.kt
@@ -2,8 +2,11 @@ package io.legado.app.base
import androidx.lifecycle.ViewModel
-abstract class VMBaseActivity(layoutID: Int, fullScreen: Boolean = true) :
- BaseActivity(layoutID, fullScreen) {
+abstract class VMBaseActivity(
+ layoutID: Int,
+ fullScreen: Boolean = true,
+ theme: Theme = Theme.Auto
+) : BaseActivity(layoutID, fullScreen, theme) {
protected abstract val viewModel: VM
diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt
index 446efc0bf..d4f54bb5d 100644
--- a/app/src/main/java/io/legado/app/constant/PreferKey.kt
+++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt
@@ -13,4 +13,5 @@ object PreferKey {
const val recordLog = "recordLog"
const val processText = "process_text"
const val cleanCache = "cleanCache"
+ const val lastGroup = "lastGroup"
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/about/DonateActivity.kt b/app/src/main/java/io/legado/app/ui/about/DonateActivity.kt
index b5f6c7a8d..32c8d0172 100644
--- a/app/src/main/java/io/legado/app/ui/about/DonateActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/about/DonateActivity.kt
@@ -13,7 +13,6 @@ import io.legado.app.base.BaseActivity
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.ACache
import kotlinx.android.synthetic.main.activity_donate.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.toast
import java.net.URLEncoder
@@ -25,7 +24,6 @@ import java.net.URLEncoder
class DonateActivity : BaseActivity(R.layout.activity_donate) {
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
ATH.applyEdgeEffectColor(scroll_view)
vw_zfb_tz.setOnClickListener { aliDonate(this) }
cv_wx_gzh.setOnClickListener {
diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
index 8e389bb37..47d15704e 100644
--- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
@@ -26,7 +26,6 @@ import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_audio_play.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import org.apache.commons.lang3.time.DateFormatUtils
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick
@@ -43,7 +42,6 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a
private var adjustProgress = false
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
AudioPlay.titleData.observe(this, Observer { title_bar.title = it })
AudioPlay.coverData.observe(this, Observer { upCover(it) })
viewModel.initData(intent)
diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
index 9ed5ffb6d..a7f1aad4a 100644
--- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
@@ -2,11 +2,13 @@ package io.legado.app.ui.book.info
import android.app.Activity
import android.content.Intent
+import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.lifecycle.Observer
import com.bumptech.glide.Glide
+import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions.bitmapTransform
import io.legado.app.R
@@ -15,6 +17,7 @@ import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookGroup
+import io.legado.app.help.BlurTransformation
import io.legado.app.help.ImageLoader
import io.legado.app.help.IntentDataHelp
import io.legado.app.ui.audio.AudioPlayActivity
@@ -26,15 +29,14 @@ import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.utils.getViewModel
import io.legado.app.utils.gone
import io.legado.app.utils.visible
-import jp.wasabeef.glide.transformations.BlurTransformation
import kotlinx.android.synthetic.main.activity_book_info.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
-class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info),
+class BookInfoActivity :
+ VMBaseActivity(R.layout.activity_book_info, theme = Theme.Dark),
GroupSelectDialog.CallBack,
ChapterListAdapter.CallBack,
ChangeSourceDialog.CallBack {
@@ -43,8 +45,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo
get() = getViewModel(BookInfoViewModel::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
- title_bar.getBackground().setAlpha(0)
+ title_bar.background.alpha = 0
viewModel.bookData.observe(this, Observer { showBook(it) })
viewModel.isLoadingData.observe(this, Observer { upLoading(it) })
viewModel.chapterListData.observe(this, Observer { showChapter(it) })
@@ -96,6 +97,11 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo
return super.onMenuOpened(featureId, menu)
}
+ private fun defaultCover(): RequestBuilder {
+ return ImageLoader.load(this, R.drawable.image_cover_default)
+ .apply(bitmapTransform(BlurTransformation(this, 25)))
+ }
+
private fun showBook(book: Book) {
tv_name.text = book.name
tv_author.text = getString(R.string.author_show, book.author)
@@ -110,9 +116,9 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo
.into(iv_cover)
Glide.with(this).load(it)
.transition(DrawableTransitionOptions.withCrossFade(1500))
- .error(R.drawable.image_cover_default)
+ .thumbnail(defaultCover())
.centerCrop()
- .apply(bitmapTransform(BlurTransformation(125, 6)))
+ .apply(bitmapTransform(BlurTransformation(this, 25)))
.into(bg_book) //模糊、渐变、缩小效果
}
val kinds = book.getKindList()
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
index 11c9dc5cf..7b9daf6d2 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
@@ -40,7 +40,6 @@ import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.view_book_page.*
import kotlinx.android.synthetic.main.view_read_menu.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
@@ -66,7 +65,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo
override fun onActivityCreated(savedInstanceState: Bundle?) {
Help.upLayoutInDisplayCutoutMode(window)
- setSupportActionBar(toolbar)
initView()
ReadBook.callBack = this
ReadBook.titleDate.observe(this, Observer { title_bar.title = it })
diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
index 4623579b7..d2cc149e1 100644
--- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
@@ -36,7 +36,6 @@ import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.view_search.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.startService
@@ -57,7 +56,6 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity
private var groupMenu: SubMenu? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
initUriScheme()
initRecyclerView()
initSearchView()
diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
index 4be429d71..edf3057a3 100644
--- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
@@ -121,6 +121,7 @@ class ChangeSourceDialog : DialogFragment(),
override fun changeTo(searchBook: SearchBook) {
val book = searchBook.toBook()
callBack?.oldBook?.let { oldBook ->
+ book.group = oldBook.group
book.durChapterIndex = oldBook.durChapterIndex
book.durChapterPos = oldBook.durChapterPos
book.durChapterTitle = oldBook.durChapterTitle
diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt
index e1175bc6a..86db52459 100644
--- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt
@@ -17,7 +17,6 @@ import io.legado.app.utils.gone
import io.legado.app.utils.visible
import kotlinx.android.synthetic.main.activity_chapter_list.*
import kotlinx.android.synthetic.main.view_tab_layout.*
-import kotlinx.android.synthetic.main.view_title_bar.*
class ChapterListActivity : VMBaseActivity(R.layout.activity_chapter_list) {
override val viewModel: ChapterListViewModel
@@ -26,7 +25,6 @@ class ChapterListActivity : VMBaseActivity(R.layout.activi
private var searchView: SearchView? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
tab_layout.setSelectedTabIndicatorColor(accentColor)
viewModel.bookUrl = intent.getStringExtra("bookUrl")
viewModel.loadBook {
diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
index a926a8ae2..838b5c31d 100644
--- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
@@ -5,7 +5,6 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_config.*
-import kotlinx.android.synthetic.main.view_title_bar.*
class ConfigActivity : VMBaseActivity(R.layout.activity_config) {
override val viewModel: ConfigViewModel
@@ -15,7 +14,6 @@ class ConfigActivity : VMBaseActivity(R.layout.activity_config)
intent.getIntExtra("configType", -1).let {
if (it != -1) viewModel.configType = it
}
- this.setSupportActionBar(toolbar)
when (viewModel.configType) {
ConfigViewModel.TYPE_CONFIG -> {
diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
index 08f03ac8f..a75134288 100644
--- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
@@ -35,7 +35,6 @@ import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_rss_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.view_search.*
-import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
@@ -55,7 +54,6 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r
private var groupMenu: SubMenu? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
- setSupportActionBar(toolbar)
initRecyclerView()
initSearchView()
initLiveDataGroup()
diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
index d516601d9..ab931f3ab 100644
--- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
+++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
@@ -2,21 +2,15 @@ package io.legado.app.ui.widget
import android.content.Context
import android.content.res.ColorStateList
-import android.graphics.Color
-import android.graphics.PorterDuff
-import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.Menu
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.StyleRes
import androidx.appcompat.widget.Toolbar
-import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.material.appbar.AppBarLayout
import io.legado.app.R
-import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.primaryColor
-import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.activity
import io.legado.app.utils.getNavigationBarHeight
import io.legado.app.utils.getStatusBarHeight
@@ -190,50 +184,6 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp)
}
}
-
- val primaryTextColor = if (isInEditMode) Color.BLACK else context.primaryTextColor
- DrawableUtils.setTint(toolbar.overflowIcon, primaryTextColor)
- toolbar.setTitleTextColor(primaryTextColor)
-
- if (navigationIconTint != null) {
- wrapDrawableTint(toolbar.navigationIcon, navigationIconTint, navigationIconTintMode)
- } else {
- wrapDrawableTint(
- toolbar.navigationIcon,
- ColorStateList.valueOf(primaryTextColor),
- navigationIconTintMode
- )
- }
- }
-
- private fun wrapDrawableTint(drawable: Drawable?, tintList: ColorStateList?, tintMode: Int) {
- if (drawable == null || tintList == null) return
- val wrappedDrawable = DrawableCompat.wrap(drawable.mutate())
- DrawableCompat.setTintList(wrappedDrawable, tintList)
- DrawableCompat.setTintMode(wrappedDrawable, intToMode(tintMode))
}
- private fun intToMode(`val`: Int): PorterDuff.Mode {
- when (`val`) {
- 0 -> return PorterDuff.Mode.CLEAR
- 1 -> return PorterDuff.Mode.SRC
- 2 -> return PorterDuff.Mode.DST
- 3 -> return PorterDuff.Mode.SRC_OVER
- 4 -> return PorterDuff.Mode.DST_OVER
- 5 -> return PorterDuff.Mode.SRC_IN
- 6 -> return PorterDuff.Mode.DST_IN
- 7 -> return PorterDuff.Mode.SRC_OUT
- 8 -> return PorterDuff.Mode.DST_OUT
- 9 -> return PorterDuff.Mode.SRC_ATOP
- 10 -> return PorterDuff.Mode.DST_ATOP
- 11 -> return PorterDuff.Mode.XOR
- 16 -> return PorterDuff.Mode.DARKEN
- 17 -> return PorterDuff.Mode.LIGHTEN
- 13 -> return PorterDuff.Mode.MULTIPLY
- 14 -> return PorterDuff.Mode.SCREEN
- 12 -> return PorterDuff.Mode.ADD
- 15 -> return PorterDuff.Mode.OVERLAY
- else -> return PorterDuff.Mode.CLEAR
- }
- }
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml
index fdad506fb..53f69d1fb 100644
--- a/app/src/main/res/layout/activity_book_info.xml
+++ b/app/src/main/res/layout/activity_book_info.xml
@@ -9,9 +9,19 @@
+ app:layout_constraintTop_toTopOf="parent" />
+
+
@@ -152,8 +165,8 @@
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
- app:layout_constraintTop_toBottomOf="@+id/iv_cover"
- app:layout_constraintBottom_toTopOf="@+id/view_other">
+ app:layout_constraintBottom_toTopOf="@+id/view_other"
+ app:layout_constraintTop_toBottomOf="@+id/iv_cover">
+ app:layout_constraintBottom_toTopOf="@+id/fl_action"
+ app:layout_constraintTop_toBottomOf="@+id/view_info">
true
-
-
-