Skip to content

Commit

Permalink
fix: android do not call onPaste if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum committed Jan 19, 2023
1 parent 69f65de commit 753852d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import java.lang.Exception

class PasteInputEditText(context: ThemedReactContext) : ReactEditText(context) {
private lateinit var mOnPasteListener: IPasteInputListener
private var mDisabledCopyPaste: Boolean = false

fun setDisableCopyPaste(disabled: Boolean) {
this.mDisabledCopyPaste = disabled
}

fun setOnPasteListener(listener: IPasteInputListener) {
mOnPasteListener = listener
Expand All @@ -36,7 +41,9 @@ class PasteInputEditText(context: ThemedReactContext) : ReactEditText(context) {
}
}

getOnPasteListener().onPaste(inputContentInfo.contentUri)
if (!mDisabledCopyPaste) {
getOnPasteListener().onPaste(inputContentInfo.contentUri)
}

true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PasteInputManager(reactContext: ReactContext) : ReactTextInputManager() {
disableCopyPaste = disabled
editText.customInsertionActionModeCallback = PasteInputActionCallback(editText, disabled)
editText.customSelectionActionModeCallback = PasteInputActionCallback(editText, disabled)
editText.setDisableCopyPaste(disabled)
}

@RequiresApi(Build.VERSION_CODES.M)
Expand All @@ -53,7 +54,6 @@ class PasteInputManager(reactContext: ReactContext) : ReactTextInputManager() {
pasteInputEditText.setOnPasteListener(PasteInputListener(pasteInputEditText))
}

@Nullable
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
val map = super.getExportedCustomBubblingEventTypeConstants()!!
map.put(
Expand Down

0 comments on commit 753852d

Please sign in to comment.