Skip to content

Commit

Permalink
Remove support for Android API < 23 in ReactEditText (#39671)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39671

Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactEditText

changelog: [Android][Breaking] Remove support for Android API < 23 in ReactEditText

Reviewed By: NickGerleman

Differential Revision: D48545507

fbshipit-source-id: 99e77ca7cf237dc35ac4b80928bed1f94363392f
  • Loading branch information
mdvacca committed Sep 29, 2023
1 parent 1347f92 commit 47d396f
Showing 1 changed file with 4 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import static com.facebook.react.uimanager.UIManagerHelper.getReactContext;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
Expand Down Expand Up @@ -210,9 +208,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
public void onDestroyActionMode(ActionMode mode) {}
};
setCustomSelectionActionModeCallback(customActionModeCallback);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
setCustomInsertionActionModeCallback(customActionModeCallback);
}
setCustomInsertionActionModeCallback(customActionModeCallback);
}

@Override
Expand Down Expand Up @@ -308,26 +304,7 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
@Override
public boolean onTextContextMenuItem(int id) {
if (id == android.R.id.paste) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
id = android.R.id.pasteAsPlainText;
} else {
ClipboardManager clipboard =
(ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData previousClipData = clipboard.getPrimaryClip();
if (previousClipData != null) {
for (int i = 0; i < previousClipData.getItemCount(); i++) {
final CharSequence text = previousClipData.getItemAt(i).coerceToText(getContext());
final CharSequence paste = (text instanceof Spanned) ? text.toString() : text;
if (paste != null) {
ClipData clipData = ClipData.newPlainText(null, text);
clipboard.setPrimaryClip(clipData);
}
}
boolean actionPerformed = super.onTextContextMenuItem(id);
clipboard.setPrimaryClip(previousClipData);
return actionPerformed;
}
}
id = android.R.id.pasteAsPlainText;
}
return super.onTextContextMenuItem(id);
}
Expand Down Expand Up @@ -702,10 +679,8 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) {
}
mDisableTextDiffing = false;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (getBreakStrategy() != reactTextUpdate.getTextBreakStrategy()) {
setBreakStrategy(reactTextUpdate.getTextBreakStrategy());
}
if (getBreakStrategy() != reactTextUpdate.getTextBreakStrategy()) {
setBreakStrategy(reactTextUpdate.getTextBreakStrategy());
}

// Update cached spans (in Fabric only).
Expand Down

0 comments on commit 47d396f

Please sign in to comment.