mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 13:56:14 +03:00
#776 App crash when selected
This commit is contained in:
parent
847a6f5f9a
commit
e973295eaf
2 changed files with 10 additions and 5 deletions
|
@ -37,7 +37,7 @@ public class ContextBasedFormattingCallback implements ActionMode.Callback {
|
||||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||||
CharSequence text = editText.getText();
|
CharSequence text = editText.getText();
|
||||||
int originalCursorPosition = editText.getSelectionStart();
|
int originalCursorPosition = editText.getSelectionStart();
|
||||||
if(originalCursorPosition >= 0 && originalCursorPosition <= text.length()) {
|
if (originalCursorPosition >= 0 && originalCursorPosition <= text.length()) {
|
||||||
int startOfLine = getStartOfLine(text, originalCursorPosition);
|
int startOfLine = getStartOfLine(text, originalCursorPosition);
|
||||||
int endOfLine = originalCursorPosition;
|
int endOfLine = originalCursorPosition;
|
||||||
if (endOfLine != startOfLine) {
|
if (endOfLine != startOfLine) {
|
||||||
|
@ -45,10 +45,14 @@ public class ContextBasedFormattingCallback implements ActionMode.Callback {
|
||||||
endOfLine--;
|
endOfLine--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String line = text.subSequence(startOfLine, endOfLine).toString();
|
try {
|
||||||
if (MarkDownUtil.lineStartsWithCheckbox(line)) {
|
String line = text.subSequence(startOfLine, endOfLine).toString();
|
||||||
menu.findItem(R.id.checkbox).setVisible(false);
|
if (MarkDownUtil.lineStartsWithCheckbox(line)) {
|
||||||
Log.i(TAG, "Hide checkbox menu item because line starts already with checkbox");
|
menu.findItem(R.id.checkbox).setVisible(false);
|
||||||
|
Log.i(TAG, "Hide checkbox menu item because line starts already with checkbox");
|
||||||
|
}
|
||||||
|
} catch (StringIndexOutOfBoundsException e) {
|
||||||
|
Log.e(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "SelectionStart is " + originalCursorPosition + ". Expected to be between 0 and " + text.length());
|
Log.e(TAG, "SelectionStart is " + originalCursorPosition + ". Expected to be between 0 and " + text.length());
|
||||||
|
|
1
fastlane/metadata/android/en-US/changelogs/2011007.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/2011007.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
- App crash when selected (#776)
|
Loading…
Reference in a new issue