优化共享元素动画
This commit is contained in:
13 files changed
+84
-39
No files matched your search
@@ -586,7 +586,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
get() = appCtx.getPrefBoolean(PreferKey.delayBookLoadEnable, true)
|
get() = appCtx.getPrefBoolean(PreferKey.delayBookLoadEnable, true)
|
||||||
|
|
||||||
val sharedElementEnterTransitionEnable
|
val sharedElementEnterTransitionEnable
|
||||||
get() = appCtx.getPrefBoolean(PreferKey.sharedElementEnterTransitionEnable, true)
|
get() = appCtx.getPrefBoolean(PreferKey.sharedElementEnterTransitionEnable, false)
|
||||||
|
|
||||||
var searchScope: String
|
var searchScope: String
|
||||||
get() = appCtx.getPrefString("searchScope") ?: ""
|
get() = appCtx.getPrefString("searchScope") ?: ""
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ object ReadBookConfig {
|
|||||||
var bgMeanColor: Int = 0
|
var bgMeanColor: Int = 0
|
||||||
val textColor: Int get() = durConfig.curTextColor()
|
val textColor: Int get() = durConfig.curTextColor()
|
||||||
val textShadowColor: Int get() = durConfig.curTextShadowColor()
|
val textShadowColor: Int get() = durConfig.curTextShadowColor()
|
||||||
|
val menuColor: Int get() = durConfig.curMenuAc()
|
||||||
init {
|
init {
|
||||||
initConfigs()
|
initConfigs()
|
||||||
initShareConfig()
|
initShareConfig()
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
||||||
if (AppConfig.sharedElementEnterTransitionEnable) {
|
|
||||||
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
||||||
setExitSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
setExitSharedElementCallback(MaterialContainerTransformSharedElementCallback())
|
||||||
val transform = MaterialContainerTransform().apply {
|
val transform = MaterialContainerTransform().apply {
|
||||||
@@ -297,11 +297,11 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
window.sharedElementEnterTransition = transform
|
window.sharedElementEnterTransition = transform
|
||||||
window.sharedElementReturnTransition = transform
|
window.sharedElementReturnTransition = transform
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (AppConfig.sharedElementEnterTransitionEnable){
|
|
||||||
binding.rootView.transitionName = intent.getStringExtra("transitionName")
|
binding.rootView.transitionName = intent.getStringExtra("transitionName")
|
||||||
}
|
|
||||||
upScreenTimeOut()
|
upScreenTimeOut()
|
||||||
ReadBook.register(this)
|
ReadBook.register(this)
|
||||||
binding.readMenu.colorSurfaceContainer =
|
binding.readMenu.colorSurfaceContainer =
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
|||||||
import io.legado.app.utils.canvasrecorder.CanvasRecorderFactory
|
import io.legado.app.utils.canvasrecorder.CanvasRecorderFactory
|
||||||
import io.legado.app.utils.canvasrecorder.recordIfNeededThenDraw
|
import io.legado.app.utils.canvasrecorder.recordIfNeededThenDraw
|
||||||
import io.legado.app.utils.dpToPx
|
import io.legado.app.utils.dpToPx
|
||||||
import io.legado.app.utils.themeColor
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行信息
|
* 行信息
|
||||||
@@ -178,7 +177,7 @@ data class TextLine(
|
|||||||
ChapterProvider.contentPaint
|
ChapterProvider.contentPaint
|
||||||
}
|
}
|
||||||
val textColor = if (isReadAloud) {
|
val textColor = if (isReadAloud) {
|
||||||
view.context.themeColor(androidx.appcompat.R.attr.colorPrimary)
|
ReadBookConfig.menuColor
|
||||||
} else {
|
} else {
|
||||||
ReadBookConfig.textColor
|
ReadBookConfig.textColor
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ import io.legado.app.utils.bookshelfLayoutGrid
|
|||||||
import io.legado.app.utils.bookshelfLayoutMode
|
import io.legado.app.utils.bookshelfLayoutMode
|
||||||
import io.legado.app.utils.cnCompare
|
import io.legado.app.utils.cnCompare
|
||||||
import io.legado.app.utils.observeEvent
|
import io.legado.app.utils.observeEvent
|
||||||
|
import io.legado.app.utils.startActivity
|
||||||
|
import io.legado.app.utils.startActivityForBook
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@@ -290,6 +292,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun open(book: Book, sharedView: View) {
|
override fun open(book: Book, sharedView: View) {
|
||||||
|
if (AppConfig.sharedElementEnterTransitionEnable){
|
||||||
val transitionName = "book_${book.bookUrl}"
|
val transitionName = "book_${book.bookUrl}"
|
||||||
sharedView.transitionName = transitionName
|
sharedView.transitionName = transitionName
|
||||||
|
|
||||||
@@ -311,14 +314,18 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
)
|
)
|
||||||
|
|
||||||
startActivity(intent, options.toBundle())
|
startActivity(intent, options.toBundle())
|
||||||
|
} else {
|
||||||
|
startActivityForBook(book)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openBookInfo(book: Book, sharedView: View) {
|
override fun openBookInfo(book: Book, sharedView: View) {
|
||||||
|
if (AppConfig.sharedElementEnterTransitionEnable){
|
||||||
val intent = Intent(requireContext(), BookInfoActivity::class.java).apply {
|
val intent = Intent(requireContext(), BookInfoActivity::class.java).apply {
|
||||||
putExtra("name", book.name)
|
putExtra("name", book.name)
|
||||||
putExtra("author", book.author)
|
putExtra("author", book.author)
|
||||||
putExtra("bookUrl", book.bookUrl)
|
putExtra("bookUrl", book.bookUrl)
|
||||||
putExtra("transitionName", "book_${book.bookUrl}") // 给共享元素唯一标识
|
putExtra("transitionName", "book_${book.bookUrl}")
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedView.transitionName = "book_${book.bookUrl}"
|
sharedView.transitionName = "book_${book.bookUrl}"
|
||||||
@@ -330,6 +337,15 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
)
|
)
|
||||||
|
|
||||||
startActivity(intent, options.toBundle())
|
startActivity(intent, options.toBundle())
|
||||||
|
} else {
|
||||||
|
startActivity<BookInfoActivity> {
|
||||||
|
putExtra("name", book.name)
|
||||||
|
putExtra("author", book.author)
|
||||||
|
putExtra("bookUrl", book.bookUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ import io.legado.app.utils.cnCompare
|
|||||||
import io.legado.app.utils.flowWithLifecycleAndDatabaseChangeFirst
|
import io.legado.app.utils.flowWithLifecycleAndDatabaseChangeFirst
|
||||||
import io.legado.app.utils.observeEvent
|
import io.legado.app.utils.observeEvent
|
||||||
import io.legado.app.utils.showDialogFragment
|
import io.legado.app.utils.showDialogFragment
|
||||||
|
import io.legado.app.utils.startActivity
|
||||||
|
import io.legado.app.utils.startActivityForBook
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@@ -338,6 +340,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClick(item: Any, sharedView: View) {
|
override fun onItemClick(item: Any, sharedView: View) {
|
||||||
|
if (AppConfig.sharedElementEnterTransitionEnable){
|
||||||
when (item) {
|
when (item) {
|
||||||
is Book -> {
|
is Book -> {
|
||||||
val transitionName = "book_${item.bookUrl}"
|
val transitionName = "book_${item.bookUrl}"
|
||||||
@@ -370,9 +373,21 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
updateBackCallbackState()
|
updateBackCallbackState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
when (item) {
|
||||||
|
is Book -> startActivityForBook(item)
|
||||||
|
|
||||||
|
is BookGroup -> {
|
||||||
|
groupId = item.groupId
|
||||||
|
initBooksData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(item: Any, sharedView: View) {
|
override fun onItemLongClick(item: Any, sharedView: View) {
|
||||||
|
if (AppConfig.sharedElementEnterTransitionEnable){
|
||||||
when (item) {
|
when (item) {
|
||||||
is Book -> {
|
is Book -> {
|
||||||
val intent = Intent(requireContext(), BookInfoActivity::class.java).apply {
|
val intent = Intent(requireContext(), BookInfoActivity::class.java).apply {
|
||||||
@@ -395,6 +410,17 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
|
|
||||||
is BookGroup -> showDialogFragment(GroupEditDialog(item))
|
is BookGroup -> showDialogFragment(GroupEditDialog(item))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
when (item) {
|
||||||
|
is Book -> startActivity<BookInfoActivity> {
|
||||||
|
putExtra("name", item.name)
|
||||||
|
putExtra("author", item.author)
|
||||||
|
putExtra("bookUrl", item.bookUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
is BookGroup -> showDialogFragment(GroupEditDialog(item))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isUpdate(bookUrl: String): Boolean {
|
override fun isUpdate(bookUrl: String): Boolean {
|
||||||
|
|||||||
@@ -184,6 +184,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
|
android:layout_marginVertical="8dp"
|
||||||
app:singleLine="true"
|
app:singleLine="true"
|
||||||
app:singleSelection="true"
|
app:singleSelection="true"
|
||||||
app:selectionRequired="true">
|
app:selectionRequired="true">
|
||||||
@@ -301,6 +302,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="16dp"
|
android:layout_width="16dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
app:layout_constraintStart_toEndOf="@id/cb_share_layout"
|
app:layout_constraintStart_toEndOf="@id/cb_share_layout"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cv_content"
|
android:id="@+id/cv_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -102,5 +98,5 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="RtlHardcoded" />
|
tools:ignore="RtlHardcoded" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cv_content"
|
android:id="@+id/cv_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -152,5 +148,4 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="RtlHardcoded" />
|
tools:ignore="RtlHardcoded" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -19,33 +19,41 @@
|
|||||||
android:id="@+id/cd_cover"
|
android:id="@+id/cd_cover"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
app:cardCornerRadius="6dp"
|
||||||
app:strokeWidth="0dp"
|
app:strokeWidth="0dp"
|
||||||
app:cardCornerRadius="8dp"
|
android:layout_margin="8dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
android:transitionName="img_cover"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_cover"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="98dp">
|
||||||
|
|
||||||
<io.legado.app.ui.widget.image.CoverImageView
|
<io.legado.app.ui.widget.image.CoverImageView
|
||||||
android:id="@+id/iv_cover"
|
android:id="@+id/iv_cover"
|
||||||
android:layout_width="70dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="98dp"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/image_cover_default"
|
android:src="@drawable/image_cover_default"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:ignore="ImageContrastCheck" />
|
tools:ignore="ImageContrastCheck" />
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
android:id="@+id/rl_loading"
|
android:id="@+id/rl_loading"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginVertical="4dp"
|
android:layout_marginVertical="4dp"
|
||||||
android:layout_marginHorizontal="6dp"
|
android:layout_marginHorizontal="6dp"
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
app:layout_constraintTop_toTopOf="@id/cd_cover"
|
app:layout_constraintTop_toTopOf="@id/iv_cover"
|
||||||
app:layout_constraintStart_toStartOf="@id/cd_cover"
|
app:layout_constraintStart_toStartOf="@id/iv_cover"
|
||||||
app:layout_constraintEnd_toEndOf="@id/cd_cover" />
|
app:layout_constraintEnd_toEndOf="@id/iv_cover" />
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cd_unread"
|
android:id="@+id/cd_unread"
|
||||||
@@ -56,8 +64,8 @@
|
|||||||
app:cardCornerRadius="4dp"
|
app:cardCornerRadius="4dp"
|
||||||
app:strokeWidth="0dp"
|
app:strokeWidth="0dp"
|
||||||
app:cardBackgroundColor="?attr/colorSecondaryVariant"
|
app:cardBackgroundColor="?attr/colorSecondaryVariant"
|
||||||
app:layout_constraintTop_toTopOf="@id/cd_cover"
|
app:layout_constraintTop_toTopOf="@id/iv_cover"
|
||||||
app:layout_constraintEnd_toEndOf="@id/cd_cover">
|
app:layout_constraintEnd_toEndOf="@id/iv_cover">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_unread"
|
android:id="@+id/tv_unread"
|
||||||
@@ -73,6 +81,9 @@
|
|||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -1280,9 +1280,9 @@
|
|||||||
<string name="privacy">隐私</string>
|
<string name="privacy">隐私</string>
|
||||||
<string name="notification_permission">通知权限</string>
|
<string name="notification_permission">通知权限</string>
|
||||||
<string name="background_permission">后台权限</string>
|
<string name="background_permission">后台权限</string>
|
||||||
<string name="opt_animation">从书架进入阅读界面时,优化动画效果。</string>
|
<string name="opt_animation">从书架进入阅读界面时,优化动画效果。在某些设备上可能无法正常工作</string>
|
||||||
<string name="use_animation">使用共享元素动画</string>
|
<string name="use_animation">使用共享元素动画</string>
|
||||||
<string name="reduce_stutter">减少进入阅读界面时的卡顿,但加载书籍时间会延长。</string>
|
<string name="reduce_stutter">减少进入阅读界面时的卡顿,但加载书籍时间会延长。仅在开启共享元素动画时生效</string>
|
||||||
<string name="delay_book_load">延缓书籍加载</string>
|
<string name="delay_book_load">延缓书籍加载</string>
|
||||||
<string name="compact_list">紧凑列表</string>
|
<string name="compact_list">紧凑列表</string>
|
||||||
<string name="author_read">%s • %d章未读</string>
|
<string name="author_read">%s • %d章未读</string>
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
app:layout="@layout/view_preference_category">
|
app:layout="@layout/view_preference_category">
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.SwitchPreference
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="false"
|
||||||
android:key="sharedElementEnterTransitionEnable"
|
android:key="sharedElementEnterTransitionEnable"
|
||||||
android:summary="@string/opt_animation"
|
android:summary="@string/opt_animation"
|
||||||
android:title="@string/use_animation" />
|
android:title="@string/use_animation" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
VERSION_MAJOR=3
|
VERSION_MAJOR=3
|
||||||
VERSION_MINOR=26
|
VERSION_MINOR=26
|
||||||
VERSION_PATCH=3
|
VERSION_PATCH=3
|
||||||
VERSION_SUFFIX=-beta.6
|
VERSION_SUFFIX=
|
||||||
Reference in new issue
Block a user