diff --git a/app/build.gradle b/app/build.gradle index 1cf1e1e41..ba28c8557 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -133,8 +133,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.viewpager2:viewpager2:1.0.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'com.google.android:flexbox:1.1.0' + implementation 'com.google.android.material:material:1.4.0' + implementation 'com.google.android.flexbox:flexbox:3.0.0' implementation 'com.google.code.gson:gson:2.8.6' implementation 'androidx.webkit:webkit:1.4.0' diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 29373ae37..a0ea37e03 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -17,20 +17,23 @@ import androidx.annotation.RequiresApi import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.view.menu.MenuBuilder import androidx.appcompat.view.menu.MenuItemImpl -import androidx.core.view.isVisible import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter import io.legado.app.databinding.ItemTextBinding import io.legado.app.databinding.PopupActionMenuBinding import io.legado.app.service.BaseReadAloudService -import io.legado.app.utils.* +import io.legado.app.utils.isAbsUrl +import io.legado.app.utils.sendToClip +import io.legado.app.utils.share +import io.legado.app.utils.toastOnUi import java.util.* @SuppressLint("RestrictedApi") class TextActionMenu(private val context: Context, private val callBack: CallBack) : PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT), TextToSpeech.OnInitListener { + private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context)) private val adapter = Adapter(context) private val menu = MenuBuilder(context) @@ -48,38 +51,15 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac isFocusable = false initRecyclerView() - setOnDismissListener { - binding.ivMenuMore.setImageResource(R.drawable.ic_more_vert) - binding.recyclerViewMore.gone() - adapter.setItems(menu.visibleItems) - binding.recyclerView.visible() - } } private fun initRecyclerView() = with(binding) { recyclerView.adapter = adapter - recyclerViewMore.adapter = adapter SupportMenuInflater(context).inflate(R.menu.content_select_action, menu) - adapter.setItems(menu.visibleItems) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { onInitializeMenu(moreMenu) } - if (moreMenu.size() > 0) { - ivMenuMore.visible() - } - ivMenuMore.setOnClickListener { - if (recyclerView.isVisible) { - ivMenuMore.setImageResource(R.drawable.ic_arrow_back) - adapter.setItems(moreMenu.visibleItems) - recyclerView.gone() - recyclerViewMore.visible() - } else { - ivMenuMore.setImageResource(R.drawable.ic_more_vert) - recyclerViewMore.gone() - adapter.setItems(menu.visibleItems) - recyclerView.visible() - } - } + adapter.setItems(menu.visibleItems + moreMenu.visibleItems) } inner class Adapter(context: Context) : diff --git a/app/src/main/res/layout/dialog_dict.xml b/app/src/main/res/layout/dialog_dict.xml index e04adae59..acd6a42f3 100644 --- a/app/src/main/res/layout/dialog_dict.xml +++ b/app/src/main/res/layout/dialog_dict.xml @@ -1,7 +1,8 @@ + android:layout_height="wrap_content" + android:padding="16dp"> - - - - - - - - - - - + android:orientation="horizontal" + app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager"> - +