Merge remote-tracking branch 'origin/master'

pull/67/head
Administrator 5 years ago
commit 9090d77882
  1. 3
      app/src/main/assets/updateLog.md
  2. 2
      app/src/main/java/io/legado/app/App.kt
  3. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  4. 2
      app/src/main/java/io/legado/app/help/ActivityHelp.kt
  5. 2
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  6. 4
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  7. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  8. 5
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  9. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  10. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentSelectActionCallback.kt
  11. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  12. 4
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  13. 2
      app/src/main/java/io/legado/app/ui/book/read/page/DataSource.kt
  14. 2
      app/src/main/java/io/legado/app/ui/book/read/page/PageFactory.kt
  15. 12
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  16. 2
      app/src/main/java/io/legado/app/ui/book/read/page/TextChapter.kt
  17. 2
      app/src/main/java/io/legado/app/ui/book/read/page/TextPage.kt
  18. 2
      app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt
  19. 2
      app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlMesh.java
  20. 2
      app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlPage.kt
  21. 2
      app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlRenderer.kt
  22. 2
      app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlView.kt
  23. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt
  24. 2
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/EventExtensions.kt
  25. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
  26. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt
  27. 6
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  28. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt
  29. 8
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt
  30. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt
  31. 21
      app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt
  32. 18
      app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt
  33. 4
      app/src/main/res/layout/activity_book_read.xml
  34. 12
      app/src/main/res/layout/activity_download.xml
  35. 7
      app/src/main/res/layout/item_download.xml
  36. 2
      app/src/main/res/layout/view_book_page.xml

@ -4,6 +4,9 @@
* 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】,提示存储权限,选择允许即可导入成功。
* 注意:由于安卓10更改了权限策略,还需要给「允许安装其他应用」的权限才能导入源。MIUI11也需要此权限。
**2019/12/23**
* 修复每次打开翻页模式恢复默认的bug
**2019/12/22**
* 更新音频播放界面

@ -18,7 +18,7 @@ import io.legado.app.help.ActivityHelp
import io.legado.app.help.CrashHandler
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.ui.widget.page.ChapterProvider
import io.legado.app.ui.book.read.page.ChapterProvider
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.isNightTheme

@ -14,4 +14,5 @@ object PreferKey {
const val processText = "process_text"
const val cleanCache = "cleanCache"
const val lastGroup = "lastGroup"
const val pageAnim = "pageAnim"
}

@ -1,7 +1,6 @@
package io.legado.app.help
import android.app.Activity
import io.legado.app.utils.LogUtils
import java.lang.ref.WeakReference
import java.util.*
@ -13,7 +12,6 @@ object ActivityHelp {
private val activities: MutableList<WeakReference<Activity>> = arrayListOf()
fun size(): Int {
LogUtils.d("xxxx", activities.size.toString())
return activities.size
}

@ -26,7 +26,7 @@ import io.legado.app.help.MediaHelp
import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.widget.page.TextChapter
import io.legado.app.ui.book.read.page.TextChapter
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent

@ -11,8 +11,8 @@ import io.legado.app.help.IntentDataHelp
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.WebBook
import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.widget.page.ChapterProvider
import io.legado.app.ui.widget.page.TextChapter
import io.legado.app.ui.book.read.page.ChapterProvider
import io.legado.app.ui.book.read.page.TextChapter
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.Main

@ -29,14 +29,14 @@ import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.config.*
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
import io.legado.app.ui.book.read.page.ChapterProvider
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.ui.book.read.page.delegate.PageDelegate
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
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.ui.replacerule.edit.ReplaceEditDialog
import io.legado.app.ui.widget.page.ChapterProvider
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.widget.page.delegate.PageDelegate
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.dialog_download_choice.view.*

@ -11,6 +11,7 @@ import androidx.core.view.get
import androidx.fragment.app.DialogFragment
import io.legado.app.R
import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey
import io.legado.app.help.ImageLoader
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.dialogs.selector
@ -66,7 +67,7 @@ class ReadStyleDialog : DialogFragment() {
}
private fun initData() {
requireContext().getPrefInt("pageAnim").let {
requireContext().getPrefInt(PreferKey.pageAnim).let {
if (it >= 0 && it < rg_page_anim.childCount) {
rg_page_anim.check(rg_page_anim[it].id)
}
@ -179,7 +180,7 @@ class ReadStyleDialog : DialogFragment() {
rg_page_anim.onCheckedChange { _, checkedId ->
for (i in 0 until rg_page_anim.childCount) {
if (checkedId == rg_page_anim[i].id) {
requireContext().putPrefInt("pageAnim", i)
requireContext().putPrefInt(PreferKey.pageAnim, i)
val activity = activity
if (activity is ReadBookActivity) {
activity.page_view.upPageAnim(i)

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.text.Spannable
import android.text.SpannableStringBuilder

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.view.ActionMode
import android.view.Menu

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.annotation.SuppressLint
import android.content.Context

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.annotation.SuppressLint
import android.content.Context
@ -133,10 +133,12 @@ class ContentView : FrameLayout {
fun scrollTo(pos: Int?) {
if (pos != null) {
content_text_view.post {
if (content_text_view.layout.lineCount >= pos) {
content_text_view.scrollTo(0, content_text_view.layout.getLineTop(pos))
}
}
}
}
fun scrollToBottom() {
content_text_view.post {

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
interface DataSource {
val isScrollDelegate: Boolean

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
abstract class PageFactory<DATA>(protected val dataSource: DataSource) {

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.annotation.SuppressLint
import android.content.Context
@ -6,11 +6,13 @@ import android.graphics.Canvas
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.FrameLayout
import io.legado.app.constant.PreferKey
import io.legado.app.help.ReadBookConfig
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.widget.page.curl.CurlView
import io.legado.app.ui.widget.page.delegate.*
import io.legado.app.ui.book.read.page.curl.CurlView
import io.legado.app.ui.book.read.page.delegate.*
import io.legado.app.utils.activity
import io.legado.app.utils.getPrefInt
class PageView(context: Context, attrs: AttributeSet) :
FrameLayout(context, attrs),
@ -37,7 +39,7 @@ class PageView(context: Context, attrs: AttributeSet) :
upBg()
setWillNotDraw(false)
pageFactory = TextPageFactory(this)
upPageAnim()
upPageAnim(context.getPrefInt(PreferKey.pageAnim))
curPage?.callBack = this
}
@ -88,7 +90,7 @@ class PageView(context: Context, attrs: AttributeSet) :
}
}
fun upPageAnim(pageAnim: Int = 0) {
fun upPageAnim(pageAnim: Int) {
if (curlView != null) {
removeView(curlView)
curlView = null

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.text.SpannableStringBuilder
import kotlin.math.min

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import android.text.Spannable
import android.text.SpannableStringBuilder

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page
package io.legado.app.ui.book.read.page
import io.legado.app.service.help.ReadBook

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.curl;
package io.legado.app.ui.book.read.page.curl;
import android.graphics.Bitmap;
import android.graphics.Color;

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.curl
package io.legado.app.ui.book.read.page.curl
import android.graphics.Bitmap
import android.graphics.Canvas

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.curl
package io.legado.app.ui.book.read.page.curl
import android.graphics.Color
import android.graphics.PointF

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.curl
package io.legado.app.ui.book.read.page.curl
import android.content.Context
import android.graphics.PixelFormat

@ -1,9 +1,9 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import android.graphics.Matrix
import android.graphics.drawable.GradientDrawable
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.PageView
class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.view.MotionEvent

@ -1,7 +1,7 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.view.MotionEvent
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.utils.screenshot
import kotlin.math.abs

@ -1,7 +1,7 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.PageView
class NoAnimPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
override fun onScrollStart() {

@ -1,4 +1,4 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Bitmap
import android.graphics.Canvas
@ -9,8 +9,8 @@ import android.widget.Scroller
import androidx.annotation.CallSuper
import androidx.interpolator.view.animation.FastOutLinearInInterpolator
import com.google.android.material.snackbar.Snackbar
import io.legado.app.ui.widget.page.ContentView
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.ContentView
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.utils.screenshot
import io.legado.app.utils.snackbar
import kotlin.math.abs

@ -1,9 +1,9 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import android.graphics.Matrix
import android.view.MotionEvent
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.utils.screenshot
import kotlin.math.abs

@ -1,10 +1,10 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import android.view.MotionEvent
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.widget.page.curl.CurlPage
import io.legado.app.ui.widget.page.curl.CurlView
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.ui.book.read.page.curl.CurlPage
import io.legado.app.ui.book.read.page.curl.CurlView
import io.legado.app.utils.screenshot
import kotlin.math.abs

@ -1,8 +1,8 @@
package io.legado.app.ui.widget.page.delegate
package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import android.graphics.Matrix
import io.legado.app.ui.widget.page.PageView
import io.legado.app.ui.book.read.page.PageView
class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {

@ -1,16 +1,35 @@
package io.legado.app.ui.download
import android.os.Bundle
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.data.entities.Book
import kotlinx.android.synthetic.main.activity_download.*
class DownloadActivity : BaseActivity(R.layout.activity_download) {
lateinit var adapter: DownloadAdapter
private var bookshelfLiveData: LiveData<List<Book>>? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
initRecyclerView()
initLiveData()
}
private fun initRecyclerView() {
recycler_view.layoutManager = LinearLayoutManager(this)
adapter = DownloadAdapter(this)
recycler_view.adapter = adapter
}
private fun initLiveData() {
bookshelfLiveData?.removeObservers(this)
bookshelfLiveData?.observe(this, Observer {
adapter.setItems(it)
})
}
}

@ -0,0 +1,18 @@
package io.legado.app.ui.download
import android.content.Context
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book
class DownloadAdapter(context: Context) :
SimpleRecyclerAdapter<Book>(context, R.layout.item_download) {
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
}
}

@ -4,13 +4,13 @@
android:layout_height="match_parent"
android:orientation="vertical">
<io.legado.app.ui.widget.page.ContentView
<io.legado.app.ui.book.read.page.ContentView
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
<io.legado.app.ui.widget.page.PageView
<io.legado.app.ui.book.read.page.PageView
android:id="@+id/page_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

@ -1,7 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/download_offline" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

@ -27,7 +27,7 @@
</LinearLayout>
<io.legado.app.ui.widget.page.ContentTextView
<io.legado.app.ui.book.read.page.ContentTextView
android:id="@+id/content_text_view"
android:layout_width="match_parent"
android:layout_height="0dp"

Loading…
Cancel
Save