mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -104,7 +104,6 @@ android {
|
||||
}
|
||||
google {
|
||||
dimension "mode"
|
||||
minSdk 26
|
||||
applicationId "io.legado.play"
|
||||
manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
|
||||
}
|
||||
|
||||
@@ -60,8 +60,9 @@ class GroupEditDialog() : BaseDialogFragment(R.layout.dialog_book_group_edit) {
|
||||
bookGroup?.let {
|
||||
binding.btnDelete.visible(it.groupId > 0 || it.groupId == Long.MIN_VALUE)
|
||||
binding.tieGroupName.setText(it.groupName)
|
||||
binding.spSort.setSelection(it.bookSort + 1)
|
||||
binding.ivCover.load(it.cover)
|
||||
binding.spSort.setSelection(it.bookSort + 1)
|
||||
binding.cbEnableRefresh.isChecked = it.enableRefresh
|
||||
} ?: let {
|
||||
binding.toolBar.title = getString(R.string.add_group)
|
||||
binding.btnDelete.gone()
|
||||
@@ -79,15 +80,24 @@ class GroupEditDialog() : BaseDialogFragment(R.layout.dialog_book_group_edit) {
|
||||
if (groupName.isNullOrEmpty()) {
|
||||
toastOnUi("分组名称不能为空")
|
||||
} else {
|
||||
val bookSort = binding.spSort.selectedItemPosition - 1
|
||||
val coverPath = binding.ivCover.bitmapPath
|
||||
val enableRefresh = binding.cbEnableRefresh.isChecked
|
||||
bookGroup?.let {
|
||||
it.groupName = groupName
|
||||
it.cover = binding.ivCover.bitmapPath
|
||||
it.bookSort = binding.spSort.selectedItemPosition - 1
|
||||
it.cover = coverPath
|
||||
it.bookSort = bookSort
|
||||
it.enableRefresh = enableRefresh
|
||||
viewModel.upGroup(it) {
|
||||
dismiss()
|
||||
}
|
||||
} ?: let {
|
||||
viewModel.addGroup(groupName, binding.ivCover.bitmapPath) {
|
||||
viewModel.addGroup(
|
||||
groupName,
|
||||
bookSort,
|
||||
enableRefresh,
|
||||
coverPath
|
||||
) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,21 @@ class GroupViewModel(application: Application) : BaseViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
fun addGroup(groupName: String, cover: String?, finally: () -> Unit) {
|
||||
fun addGroup(
|
||||
groupName: String,
|
||||
bookSort: Int,
|
||||
enableRefresh: Boolean,
|
||||
cover: String?,
|
||||
finally: () -> Unit
|
||||
) {
|
||||
execute {
|
||||
val groupId = appDb.bookGroupDao.getUnusedId()
|
||||
val bookGroup = BookGroup(
|
||||
groupId = groupId,
|
||||
groupName = groupName,
|
||||
cover = cover,
|
||||
bookSort = bookSort,
|
||||
enableRefresh = enableRefresh,
|
||||
order = appDb.bookGroupDao.maxOrder.plus(1)
|
||||
)
|
||||
appDb.bookGroupDao.getByID(groupId) ?: appDb.bookDao.removeGroup(groupId)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background_menu">
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/tool_bar"
|
||||
@@ -15,99 +15,117 @@
|
||||
android:theme="?attr/actionBarStyle"
|
||||
app:displayHomeAsUp="false"
|
||||
app:fitStatusBar="false"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||
app:title="@string/group_edit"
|
||||
app:titleTextAppearance="@style/ToolbarTitle" />
|
||||
|
||||
<io.legado.app.ui.widget.image.CoverImageView
|
||||
android:id="@+id/iv_cover"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_margin="6dp"
|
||||
android:contentDescription="@string/img_cover"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/image_cover_default"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar"
|
||||
tools:ignore="ImageContrastCheck" />
|
||||
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/til_group_name"
|
||||
android:layout_width="0dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
android:hint="@string/group_name"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tv_sort"
|
||||
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar">
|
||||
android:background="@color/background_menu">
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeEditText
|
||||
android:id="@+id/tie_group_name"
|
||||
android:layout_width="match_parent"
|
||||
<io.legado.app.ui.widget.image.CoverImageView
|
||||
android:id="@+id/iv_cover"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_margin="6dp"
|
||||
android:contentDescription="@string/img_cover"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/image_cover_default"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ImageContrastCheck" />
|
||||
|
||||
|
||||
<io.legado.app.ui.widget.text.TextInputLayout
|
||||
android:id="@+id/til_group_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
android:layout_margin="6dp"
|
||||
android:hint="@string/group_name"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tv_sort"
|
||||
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/tv_sort"
|
||||
android:layout_width="wrap_content"
|
||||
<io.legado.app.lib.theme.view.ThemeEditText
|
||||
android:id="@+id/tie_group_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/tv_sort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="3dp"
|
||||
android:text="@string/sort"
|
||||
android:textColor="@color/primaryText"
|
||||
app:layout_constraintLeft_toLeftOf="@id/til_group_name"
|
||||
app:layout_constraintTop_toBottomOf="@id/til_group_name" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/sp_sort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:entries="@array/book_sort"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_sort"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_sort"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_sort"
|
||||
app:theme="@style/Spinner"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ThemeCheckBox
|
||||
android:id="@+id/cb_enable_refresh"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/allow_drop_down_refresh"
|
||||
android:checked="true"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_sort"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tv_sort" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sort"
|
||||
android:textColor="@color/primaryText"
|
||||
app:layout_constraintBottom_toTopOf="@id/btn_ok"
|
||||
app:layout_constraintLeft_toLeftOf="@id/til_group_name"
|
||||
app:layout_constraintTop_toBottomOf="@id/til_group_name" />
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/sp_sort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:entries="@array/book_sort"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_sort"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_sort"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_sort"
|
||||
app:theme="@style/Spinner"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="12dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/delete"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/delete"
|
||||
app:layout_constraintBottom_toBottomOf="@id/btn_ok"
|
||||
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_ok"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/ok"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_sort"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="12dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/cancel"
|
||||
app:layout_constraintBottom_toBottomOf="@id/btn_ok"
|
||||
app:layout_constraintRight_toLeftOf="@+id/btn_ok"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_ok" />
|
||||
<io.legado.app.ui.widget.text.AccentTextView
|
||||
android:id="@+id/btn_ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="12dp"
|
||||
android:padding="6dp"
|
||||
android:text="@string/ok"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1090,4 +1090,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1093,4 +1093,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1093,4 +1093,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1090,4 +1090,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1092,4 +1092,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1092,4 +1092,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
@@ -1093,4 +1093,5 @@
|
||||
<string name="file_manage">文件管理</string>
|
||||
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||
<string name="create_folder">创建文件夹</string>
|
||||
<string name="allow_drop_down_refresh">允许下拉刷新</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user