parent
8662c66e11
commit
e29c9d8ad8
@ -0,0 +1,27 @@ |
||||
package io.legado.app.ui.book.read |
||||
|
||||
import android.annotation.SuppressLint |
||||
import android.content.Context |
||||
import android.view.LayoutInflater |
||||
import android.view.ViewGroup |
||||
import android.widget.PopupWindow |
||||
import io.legado.app.R |
||||
|
||||
|
||||
class TextActionMenu(context: Context, callBack: CallBack) : |
||||
PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) { |
||||
|
||||
init { |
||||
@SuppressLint("InflateParams") |
||||
contentView = LayoutInflater.from(context).inflate(R.layout.popup_action_menu, null) |
||||
|
||||
isTouchable = true |
||||
isOutsideTouchable = false |
||||
isFocusable = false |
||||
} |
||||
|
||||
|
||||
interface CallBack { |
||||
|
||||
} |
||||
} |
@ -1,39 +0,0 @@ |
||||
package io.legado.app.ui.book.read.page |
||||
|
||||
import android.view.ActionMode |
||||
import android.view.Menu |
||||
import android.view.MenuItem |
||||
import android.widget.TextView |
||||
|
||||
import io.legado.app.R |
||||
import io.legado.app.constant.EventBus |
||||
import io.legado.app.utils.postEvent |
||||
|
||||
class ContentSelectActionCallback(private val textView: TextView) : ActionMode.Callback { |
||||
|
||||
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean { |
||||
when (item?.itemId) { |
||||
R.id.menu_replace -> { |
||||
val text = textView.text.substring(textView.selectionStart, textView.selectionEnd) |
||||
postEvent(EventBus.REPLACE, text) |
||||
mode?.finish() |
||||
return true |
||||
} |
||||
} |
||||
return false |
||||
} |
||||
|
||||
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean { |
||||
mode?.menuInflater?.inflate(R.menu.content_select_action, menu) |
||||
return true |
||||
} |
||||
|
||||
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean { |
||||
return false |
||||
} |
||||
|
||||
override fun onDestroyActionMode(mode: ActionMode?) { |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,8 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/recycler_view" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:background="@color/background_card" |
||||
android:padding="5dp" /> |
Loading…
Reference in new issue