Skip to content

Commit

Permalink
resolve incorrect merging
Browse files Browse the repository at this point in the history
  • Loading branch information
guanglinn committed Dec 24, 2024
1 parent c4d42e0 commit 1c1a42f
Showing 1 changed file with 1 addition and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import android.text.Layout;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -344,60 +344,6 @@ public int getFirstVisibleLineNumber() {
return 1;
}

// Text-Casing
// ---------------------------------------------------------------------------------------------
public void toggleCase() {
String text = getSelectedText();
if (text.isEmpty()) {
text = Objects.requireNonNull(getText()).toString();
}
String newText = TextCasingUtils.toggleCase(text);
replaceSelection(newText);
}

public void switchCase() {
String text = getSelectedText();
if (text.isEmpty()) {
text = Objects.requireNonNull(getText()).toString();
}
String newText = TextCasingUtils.switchCase(text);
replaceSelection(newText);
}

public void capitalizeWords() {
String text = getSelectedText();
if (text.isEmpty()) {
text = Objects.requireNonNull(getText()).toString();
}
String newText = TextCasingUtils.capitalizeWords(text);
replaceSelection(newText);
}

public void capitalizeSentences() {
String text = getSelectedText();
if (text.isEmpty()) {
text = Objects.requireNonNull(getText()).toString();
}
String newText = TextCasingUtils.capitalizeSentences(text);
replaceSelection(newText);
}

private String getSelectedText() {
int start = Math.max(0, getSelectionStart());
int end = Math.max(0, getSelectionEnd());
return Objects.requireNonNull(getText()).toString().substring(start, end);
}

private void replaceSelection(String replacement) {
int start = Math.max(0, getSelectionStart());
int end = Math.max(0, getSelectionEnd());
if (start == end) { // If no selection is made, replace all the text in the document
setText(replacement);
} else { // Replace only the selected text
Objects.requireNonNull(getText()).replace(start, end, replacement);
}
}

// Various overrides
// ---------------------------------------------------------------------------------------------
public void setSaveInstanceState(final boolean save) {
Expand Down

0 comments on commit 1c1a42f

Please sign in to comment.