Skip to content

Commit

Permalink
Don't keep the text selected after it's copied. (MozillaReality#2342)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and Alexandre Lissy committed Jan 21, 2020
1 parent 210aec4 commit 1b37d35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ public void onAction(String action) {
} else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_COPY) && selectionValid) {
String selectedText = mBinding.urlEditText.getText().toString().substring(startSelection, endSelection);
clipboard.setPrimaryClip(ClipData.newPlainText("text", selectedText));
mBinding.urlEditText.setSelection(endSelection);
} else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_PASTE) && clipboard.hasPrimaryClip()) {
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
if (selectionValid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,11 @@ public void onAction(String action) {
if (aSelection.isActionAvailable(action)) {
aSelection.execute(action);
}
if (GeckoSession.SelectionActionDelegate.ACTION_COPY.equals(action) &&
aSelection.isActionAvailable(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT)) {
// Don't keep the text selected after it's copied.
aSelection.execute(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT);
}
}

@Override
Expand Down

0 comments on commit 1b37d35

Please sign in to comment.