This commit is contained in:
kunfei
2022-03-20 11:08:42 +08:00
parent 95873c02a5
commit 8397f55b55
2 changed files with 78 additions and 43 deletions
@@ -8,6 +8,7 @@ import android.view.MenuItem
import androidx.activity.viewModels import androidx.activity.viewModels
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.databinding.ActivityBookInfoEditBinding import io.legado.app.databinding.ActivityBookInfoEditBinding
import io.legado.app.ui.book.changecover.ChangeCoverDialog import io.legado.app.ui.book.changecover.ChangeCoverDialog
@@ -70,6 +71,13 @@ class BookInfoEditActivity :
private fun upView(book: Book) = binding.run { private fun upView(book: Book) = binding.run {
tieBookName.setText(book.name) tieBookName.setText(book.name)
tieBookAuthor.setText(book.author) tieBookAuthor.setText(book.author)
spType.setSelection(
when (book.type) {
BookType.image -> 2
BookType.audio -> 1
else -> 0
}
)
tieCoverUrl.setText(book.getDisplayCover()) tieCoverUrl.setText(book.getDisplayCover())
tieBookIntro.setText(book.getDisplayIntro()) tieBookIntro.setText(book.getDisplayIntro())
upCover() upCover()
@@ -85,6 +93,11 @@ class BookInfoEditActivity :
viewModel.book?.let { book -> viewModel.book?.let { book ->
book.name = tieBookName.text?.toString() ?: "" book.name = tieBookName.text?.toString() ?: ""
book.author = tieBookAuthor.text?.toString() ?: "" book.author = tieBookAuthor.text?.toString() ?: ""
book.type = when (spType.selectedItemPosition) {
2 -> BookType.image
1 -> BookType.audio
else -> BookType.default
}
val customCoverUrl = tieCoverUrl.text?.toString() val customCoverUrl = tieCoverUrl.text?.toString()
book.customCoverUrl = if (customCoverUrl == book.coverUrl) null else customCoverUrl book.customCoverUrl = if (customCoverUrl == book.coverUrl) null else customCoverUrl
book.customIntro = tieBookIntro.text?.toString() book.customIntro = tieBookIntro.text?.toString()
@@ -12,7 +12,56 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:title="@string/book_info_edit" /> app:title="@string/book_info_edit" />
<ScrollView <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<io.legado.app.ui.widget.image.CoverImageView
android:id="@+id/iv_cover"
android:layout_width="90dp"
android:layout_height="126dp"
android:contentDescription="@string/img_cover"
android:scaleType="centerCrop"
android:src="@drawable/image_cover_default" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_book_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/book_name">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/tie_book_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_book_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/author">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/tie_book_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout>
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@@ -21,54 +70,27 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="5dp"> android:layout_gravity="center_vertical">
<io.legado.app.ui.widget.image.CoverImageView <TextView
android:id="@+id/iv_cover" android:layout_width="wrap_content"
android:layout_width="90dp" android:layout_height="wrap_content"
android:layout_height="126dp" android:text="@string/book_type"
android:contentDescription="@string/img_cover" android:layout_marginLeft="12dp"
android:scaleType="centerCrop" android:layout_marginRight="3dp"
android:src="@drawable/image_cover_default" /> tools:ignore="RtlHardcoded" />
<LinearLayout <androidx.appcompat.widget.AppCompatSpinner
android:layout_width="match_parent" android:id="@+id/sp_type"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content"
android:padding="5dp"> android:entries="@array/book_type"
app:theme="@style/Spinner" />
<io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_book_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/book_name">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/tie_book_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_book_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/author">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/tie_book_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
<io.legado.app.ui.widget.text.TextInputLayout <io.legado.app.ui.widget.text.TextInputLayout
@@ -132,6 +154,6 @@
</io.legado.app.ui.widget.text.TextInputLayout> </io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>