kunfei 4 years ago
parent
commit
bd1a8102a3

+ 10 - 2
app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt

@@ -11,14 +11,16 @@ import io.legado.app.databinding.DialogBookmarkBinding
 import io.legado.app.lib.theme.primaryColor
 import io.legado.app.lib.theme.primaryColor
 import io.legado.app.utils.setLayout
 import io.legado.app.utils.setLayout
 import io.legado.app.utils.viewbindingdelegate.viewBinding
 import io.legado.app.utils.viewbindingdelegate.viewBinding
+import io.legado.app.utils.visible
 import kotlinx.coroutines.Dispatchers.IO
 import kotlinx.coroutines.Dispatchers.IO
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import kotlinx.coroutines.withContext
 
 
 class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) {
 class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) {
 
 
-    constructor(bookmark: Bookmark) : this() {
+    constructor(bookmark: Bookmark, editPos: Int = -1) : this() {
         arguments = Bundle().apply {
         arguments = Bundle().apply {
+            putInt("editPos", editPos)
             putParcelable("bookmark", bookmark)
             putParcelable("bookmark", bookmark)
         }
         }
     }
     }
@@ -32,11 +34,17 @@ class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) {
 
 
     override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
     override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
         binding.toolBar.setBackgroundColor(primaryColor)
         binding.toolBar.setBackgroundColor(primaryColor)
-        val bookmark = arguments?.getParcelable<Bookmark>("bookmark")
+        val arguments = arguments ?: let {
+            dismiss()
+            return
+        }
+        val bookmark = arguments.getParcelable<Bookmark>("bookmark")
         bookmark ?: let {
         bookmark ?: let {
             dismiss()
             dismiss()
             return
             return
         }
         }
+        val editPos = arguments.getInt("editPos", -1)
+        binding.tvFooterLeft.visible(editPos >= 0)
         binding.run {
         binding.run {
             tvChapterName.text = bookmark.chapterName
             tvChapterName.text = bookmark.chapterName
             editBookText.setText(bookmark.bookText)
             editBookText.setText(bookmark.bookText)

+ 3 - 2
app/src/main/res/layout/dialog_bookmark.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 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:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_height="wrap_content"
-    xmlns:tools="http://schemas.android.com/tools"
     android:orientation="vertical">
     android:orientation="vertical">
 
 
     <androidx.appcompat.widget.Toolbar
     <androidx.appcompat.widget.Toolbar
@@ -11,8 +11,8 @@
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
         android:theme="?attr/actionBarStyle"
         android:theme="?attr/actionBarStyle"
-        app:title="@string/bookmark"
         app:popupTheme="@style/AppTheme.PopupOverlay"
         app:popupTheme="@style/AppTheme.PopupOverlay"
+        app:title="@string/bookmark"
         app:titleTextAppearance="@style/ToolbarTitle" />
         app:titleTextAppearance="@style/ToolbarTitle" />
 
 
     <TextView
     <TextView
@@ -80,6 +80,7 @@
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:padding="12dp"
             android:padding="12dp"
             android:text="@string/delete"
             android:text="@string/delete"
+            android:visibility="invisible"
             tools:ignore="RtlHardcoded" />
             tools:ignore="RtlHardcoded" />
 
 
         <LinearLayout
         <LinearLayout