From bd797476b3c0281f8fe50ccf4cd5775044bdf068 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 Apr 2022 20:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F=E6=8D=A2?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/arrange/ArrangeBookActivity.kt | 9 ++++- .../ui/book/arrange/ArrangeBookViewModel.kt | 3 ++ .../legado/app/ui/book/arrange/ComposeView.kt | 37 +++++++++++++++++++ .../app/ui/book/arrange/SourcePickerDialog.kt | 13 ++++--- .../legado/app/ui/book/audio/ComposeView.kt | 8 ---- .../java/io/legado/app/ui/theme/AppTheme.kt | 16 ++++---- .../main/res/layout/activity_arrange_book.xml | 19 +++++++--- .../res/layout/item_1line_text_and_del.xml | 1 + 8 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/arrange/ComposeView.kt diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 9b3930bec..56e7a7151 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -21,6 +21,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.book.group.GroupManageDialog import io.legado.app.ui.book.group.GroupSelectDialog +import io.legado.app.ui.theme.AppTheme import io.legado.app.ui.widget.SelectActionBar import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.ItemTouchCallback @@ -109,6 +110,11 @@ class ArrangeBookActivity : VMBaseActivity, canUpdate: Boolean) { execute { books.forEach { diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ComposeView.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ComposeView.kt new file mode 100644 index 000000000..a36dde904 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ComposeView.kt @@ -0,0 +1,37 @@ +package io.legado.app.ui.book.arrange + +import androidx.compose.material.AlertDialog +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import io.legado.app.R +import splitties.init.appCtx + + +@Composable +fun BatchChangeSourceDialog(state: MutableState) { + val value = remember { + mutableStateOf(0) + } + if (state.value) { + AlertDialog( + onDismissRequest = { }, + confirmButton = { + TextButton(onClick = { + state.value = false + }, content = { + Text(text = "取消") + }) + }, + title = { + Text(text = appCtx.getString(R.string.book_change_source)) + }, + text = { + + } + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/SourcePickerDialog.kt b/app/src/main/java/io/legado/app/ui/book/arrange/SourcePickerDialog.kt index df39d1f46..02c4c9897 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/SourcePickerDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/SourcePickerDialog.kt @@ -14,7 +14,7 @@ import io.legado.app.base.adapter.RecyclerAdapter import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.databinding.DialogSourcePickerBinding -import io.legado.app.databinding.ItemTextBinding +import io.legado.app.databinding.Item1lineTextAndDelBinding import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryTextColor import io.legado.app.utils.applyTint @@ -81,27 +81,28 @@ class SourcePickerDialog : BaseDialogFragment(R.layout.dialog_source_picker) { } inner class SourceAdapter(context: Context) : - RecyclerAdapter(context) { + RecyclerAdapter(context) { - override fun getViewBinding(parent: ViewGroup): ItemTextBinding { - return ItemTextBinding.inflate(inflater, parent, false).apply { + override fun getViewBinding(parent: ViewGroup): Item1lineTextAndDelBinding { + return Item1lineTextAndDelBinding.inflate(inflater, parent, false).apply { root.setPadding(16.dpToPx()) } } override fun convert( holder: ItemViewHolder, - binding: ItemTextBinding, + binding: Item1lineTextAndDelBinding, item: BookSource, payloads: MutableList ) { binding.textView.text = item.getDisPlayNameGroup() } - override fun registerListener(holder: ItemViewHolder, binding: ItemTextBinding) { + override fun registerListener(holder: ItemViewHolder, binding: Item1lineTextAndDelBinding) { binding.root.onClick { getItemByLayoutPosition(holder.layoutPosition)?.let { callback?.sourceOnClick(it) + dismissAllowingStateLoss() } } } diff --git a/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt b/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt index 798dee845..e1a262314 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/ComposeView.kt @@ -5,19 +5,15 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.Card import androidx.compose.material.Slider -import androidx.compose.material.SliderDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog -import io.legado.app.lib.theme.accentColor import io.legado.app.model.AudioPlay import io.legado.app.service.AudioPlayService -import splitties.init.appCtx @Composable @@ -37,10 +33,6 @@ fun TimerDialog(state: MutableState, parent: View) { AudioPlay.setTimer(it.toInt()) }, valueRange = 0f..180f, - colors = SliderDefaults.colors( - thumbColor = Color(appCtx.accentColor), - activeTrackColor = Color(appCtx.accentColor) - ) ) } } diff --git a/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt b/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt index f8b191e74..6f83d03aa 100644 --- a/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt +++ b/app/src/main/java/io/legado/app/ui/theme/AppTheme.kt @@ -16,17 +16,17 @@ object AppTheme { val colors get() = if (ThemeConfig.isDarkTheme()) { darkColors( - primary = Color(appCtx.primaryColor), - primaryVariant = Color(ColorUtils.darkenColor(appCtx.primaryColor)), - secondary = Color(appCtx.accentColor), - secondaryVariant = Color(appCtx.accentColor) + primary = Color(appCtx.accentColor), + primaryVariant = Color(ColorUtils.darkenColor(appCtx.accentColor)), + secondary = Color(appCtx.primaryColor), + secondaryVariant = Color(appCtx.primaryColor) ) } else { lightColors( - primary = Color(appCtx.primaryColor), - primaryVariant = Color(ColorUtils.darkenColor(appCtx.primaryColor)), - secondary = Color(appCtx.accentColor), - secondaryVariant = Color(appCtx.accentColor) + primary = Color(appCtx.accentColor), + primaryVariant = Color(ColorUtils.darkenColor(appCtx.accentColor)), + secondary = Color(appCtx.primaryColor), + secondaryVariant = Color(appCtx.primaryColor) ) } diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index 1be7bdb41..e85718977 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -1,5 +1,5 @@ - + app:title="@string/arrange_bookshelf" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@id/title_bar" + app:layout_constraintBottom_toTopOf="@id/select_action_bar" /> + android:layout_height="wrap_content" + app:layout_constraintBottom_toBottomOf="parent" /> + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_1line_text_and_del.xml b/app/src/main/res/layout/item_1line_text_and_del.xml index 2cc6daa2c..ae73faa7b 100644 --- a/app/src/main/res/layout/item_1line_text_and_del.xml +++ b/app/src/main/res/layout/item_1line_text_and_del.xml @@ -6,6 +6,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" + android:background="?attr/selectableItemBackground" android:padding="6dp" tools:ignore="UseCompoundDrawables">