Merge remote-tracking branch 'ldemianiuk/replace-fix'

This commit is contained in:
Adrian Malacoda 2016-09-25 01:17:02 -05:00
commit ebce0bd69b
3 changed files with 8 additions and 3 deletions

View File

@ -553,7 +553,10 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
// region OTHER THINGS
void replaceText(boolean all) {
if (all) {
mEditor.setText(pageSystem.getAllText(mEditor.getText().toString()).replaceAll(searchResult.whatToSearch, searchResult.textToReplace));
if (searchResult.isRegex)
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;
invalidateOptionsMenu();

View File

@ -193,7 +193,7 @@ public class FindTextDialog extends DialogFragment {
return;
// else we return positions and other things
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);
}
} else {

View File

@ -29,14 +29,16 @@ public class SearchResult {
public String textToReplace;
public int index;
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.textLength = textLength;
this.isReplace = isReplace;
this.whatToSearch = whatToSearch;
this.textToReplace = textToReplace;
this.isRegex = isRegex;
}
public void doneReplace() {