Merge remote-tracking branch 'ldemianiuk/replace-fix'
This commit is contained in:
commit
ebce0bd69b
@ -553,7 +553,10 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
|
|||||||
// region OTHER THINGS
|
// region OTHER THINGS
|
||||||
void replaceText(boolean all) {
|
void replaceText(boolean all) {
|
||||||
if (all) {
|
if (all) {
|
||||||
|
if (searchResult.isRegex)
|
||||||
mEditor.setText(pageSystem.getAllText(mEditor.getText().toString()).replaceAll(searchResult.whatToSearch, searchResult.textToReplace));
|
mEditor.setText(pageSystem.getAllText(mEditor.getText().toString()).replaceAll(searchResult.whatToSearch, searchResult.textToReplace));
|
||||||
|
else
|
||||||
|
mEditor.setText(pageSystem.getAllText(mEditor.getText().toString()).replace(searchResult.whatToSearch, searchResult.textToReplace));
|
||||||
|
|
||||||
searchResult = null;
|
searchResult = null;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -193,7 +193,7 @@ public class FindTextDialog extends DialogFragment {
|
|||||||
return;
|
return;
|
||||||
// else we return positions and other things
|
// else we return positions and other things
|
||||||
else {
|
else {
|
||||||
SearchResult searchResult = new SearchResult(foundIndex, textToFind.length(), replaceCheck.isChecked(), textToFind.getText().toString(), textToReplace.getText().toString());
|
SearchResult searchResult = new SearchResult(foundIndex, textToFind.length(), replaceCheck.isChecked(), textToFind.getText().toString(), textToReplace.getText().toString(), regexCheck.isChecked());
|
||||||
searchDialogInterface.onSearchDone(searchResult);
|
searchDialogInterface.onSearchDone(searchResult);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,14 +29,16 @@ public class SearchResult {
|
|||||||
public String textToReplace;
|
public String textToReplace;
|
||||||
public int index;
|
public int index;
|
||||||
public String whatToSearch;
|
public String whatToSearch;
|
||||||
|
public boolean isRegex;
|
||||||
|
|
||||||
|
|
||||||
public SearchResult(LinkedList<Integer> foundIndex, int textLength, boolean isReplace, String whatToSearch, String textToReplace) {
|
public SearchResult(LinkedList<Integer> foundIndex, int textLength, boolean isReplace, String whatToSearch, String textToReplace, boolean isRegex) {
|
||||||
this.foundIndex = foundIndex;
|
this.foundIndex = foundIndex;
|
||||||
this.textLength = textLength;
|
this.textLength = textLength;
|
||||||
this.isReplace = isReplace;
|
this.isReplace = isReplace;
|
||||||
this.whatToSearch = whatToSearch;
|
this.whatToSearch = whatToSearch;
|
||||||
this.textToReplace = textToReplace;
|
this.textToReplace = textToReplace;
|
||||||
|
this.isRegex = isRegex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doneReplace() {
|
public void doneReplace() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user