Skip to content

Commit eae7000

Browse files
Fix #1276 Checkboxes using an uppercase X can not be toggled
Signed-off-by: Stefan Niedermann <[email protected]>
1 parent 110d841 commit eae7000

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -184,33 +184,22 @@ protected void onCreate(Bundle savedInstanceState) {
184184
// Verbose log output for https://github.com/stefan-niedermann/nextcloud-notes/issues/1256
185185
runOnUiThread(() -> new AlertDialog.Builder(this)
186186
.setTitle(NextcloudFilesAppAccountNotFoundException.class.getSimpleName())
187-
.setMessage(R.string.backup_and_repair)
188-
.setPositiveButton(R.string.simple_repair, (a, b) -> {
189-
executor.submit(() -> {
190-
for (Account account : mainViewModel.getAccounts()) {
191-
SingleAccountHelper.setCurrentAccount(this, account.getAccountName());
192-
runOnUiThread(this::recreate);
193-
break;
194-
}
195-
});
196-
})
197-
.setNegativeButton(R.string.simple_backup, (a, b) -> {
198-
executor.submit(() -> {
199-
final List<Note> modifiedNotes = new LinkedList<>();
200-
for (Account account : mainViewModel.getAccounts()) {
201-
modifiedNotes.addAll(mainViewModel.getLocalModifiedNotes(account.getId()));
202-
}
203-
if (modifiedNotes.size() == 1) {
204-
final Note note = modifiedNotes.get(0);
205-
ShareUtil.openShareDialog(this, note.getTitle(), note.getContent());
206-
} else {
207-
ShareUtil.openShareDialog(this,
208-
getResources().getQuantityString(R.plurals.share_multiple, modifiedNotes.size(), modifiedNotes.size()),
209-
mainViewModel.collectNoteContents(modifiedNotes.stream().map(Note::getId).collect(Collectors.toList())));
210-
}
211-
});
212-
})
213-
.setNeutralButton(android.R.string.cancel, (a, b) -> {
187+
.setMessage(R.string.backup)
188+
.setPositiveButton(R.string.simple_backup, (a, b) -> executor.submit(() -> {
189+
final List<Note> modifiedNotes = new LinkedList<>();
190+
for (Account account : mainViewModel.getAccounts()) {
191+
modifiedNotes.addAll(mainViewModel.getLocalModifiedNotes(account.getId()));
192+
}
193+
if (modifiedNotes.size() == 1) {
194+
final Note note = modifiedNotes.get(0);
195+
ShareUtil.openShareDialog(this, note.getTitle(), note.getContent());
196+
} else {
197+
ShareUtil.openShareDialog(this,
198+
getResources().getQuantityString(R.plurals.share_multiple, modifiedNotes.size(), modifiedNotes.size()),
199+
mainViewModel.collectNoteContents(modifiedNotes.stream().map(Note::getId).collect(Collectors.toList())));
200+
}
201+
}))
202+
.setNegativeButton(R.string.simple_error, (a, b) -> {
214203
final SharedPreferences ssoPreferences = AccountImporter.getSharedPreferences(getApplicationContext());
215204
final StringBuilder ssoPreferencesString = new StringBuilder()
216205
.append("Current SSO account: ").append(ssoPreferences.getString("PREF_CURRENT_ACCOUNT_STRING", null)).append("\n")

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,5 +297,5 @@
297297
<string name="simple_prev">Previous</string>
298298
<string name="simple_backup">Backup</string>
299299
<string name="simple_repair">Repair</string>
300-
<string name="backup_and_repair">We recommend to backup all unsynchronized notes and then try to repair the setup.</string>
300+
<string name="backup">We detected an irrecoverably state of the app. Please backup your unsynchronized changes and clear the storage of the Notes app.</string>
301301
</resources>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- ✅ Checkboxes using an uppercase X can not be toggled (#1276)

markdown/src/main/java/it/niedermann/android/markdown/MarkdownUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public static String replaceCheckboxesWithEmojis(@NonNull String content) {
9292
for (EListType listType : EListType.values()) {
9393
if (checkboxCheckedEmoji != null) {
9494
line = line.replace(listType.checkboxChecked, checkboxCheckedEmoji);
95+
line = line.replace(listType.checkboxCheckedUpperCase, checkboxCheckedEmoji);
9596
}
9697
if (checkboxUncheckedEmoji != null) {
9798
line = line.replace(listType.checkboxUnchecked, checkboxUncheckedEmoji);
@@ -240,7 +241,7 @@ public static boolean lineStartsWithCheckbox(@NonNull String line) {
240241

241242
public static boolean lineStartsWithCheckbox(@NonNull String line, @NonNull EListType listType) {
242243
final String trimmedLine = line.trim();
243-
return (trimmedLine.startsWith(listType.checkboxUnchecked) || trimmedLine.startsWith(listType.checkboxChecked));
244+
return (trimmedLine.startsWith(listType.checkboxUnchecked) || trimmedLine.startsWith(listType.checkboxChecked) || trimmedLine.startsWith(listType.checkboxCheckedUpperCase));
244245
}
245246

246247
/**

markdown/src/main/java/it/niedermann/android/markdown/model/EListType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ public enum EListType {
88
public final String listSymbol;
99
public final String listSymbolWithTrailingSpace;
1010
public final String checkboxChecked;
11+
public final String checkboxCheckedUpperCase;
1112
public final String checkboxUnchecked;
1213
public final String checkboxUncheckedWithTrailingSpace;
1314

1415
EListType(char listSymbol) {
1516
this.listSymbol = String.valueOf(listSymbol);
1617
this.listSymbolWithTrailingSpace = listSymbol + " ";
1718
this.checkboxChecked = listSymbolWithTrailingSpace + "[x]";
19+
this.checkboxCheckedUpperCase = listSymbolWithTrailingSpace + "[X]";
1820
this.checkboxUnchecked = listSymbolWithTrailingSpace + "[ ]";
1921
this.checkboxUncheckedWithTrailingSpace = checkboxUnchecked + " ";
2022
}

markdown/src/test/java/it/niedermann/android/markdown/MarkdownUtilTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,14 @@ public void testSetCheckboxStatus() {
648648
listType.checkboxUnchecked + " \n" +
649649
listType.checkboxChecked + " Item";
650650
assertEquals(expected_9, MarkdownUtil.setCheckboxStatus(origin_9, 1, true));
651+
652+
final String origin_10 = "" +
653+
listType.checkboxChecked + " Item\n" +
654+
listType.checkboxCheckedUpperCase + " Item";
655+
final String expected_10 = "" +
656+
listType.checkboxChecked + " Item\n" +
657+
listType.checkboxUnchecked + " Item";
658+
assertEquals(expected_10, MarkdownUtil.setCheckboxStatus(origin_10, 1, false));
651659
}
652660
}
653661

0 commit comments

Comments
 (0)