mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-29 20:09:09 +03:00
Remove debug logs
This commit is contained in:
parent
233f49dafe
commit
54dc388da4
4 changed files with 6 additions and 41 deletions
|
@ -3,7 +3,6 @@ package it.niedermann.owncloud.notes.edit;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -19,8 +18,6 @@ import java.io.InputStreamReader;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import it.niedermann.android.markdown.markwon.MarkwonMarkdownEditor;
|
|
||||||
import it.niedermann.android.util.ClipboardUtil;
|
|
||||||
import it.niedermann.owncloud.notes.LockedActivity;
|
import it.niedermann.owncloud.notes.LockedActivity;
|
||||||
import it.niedermann.owncloud.notes.R;
|
import it.niedermann.owncloud.notes.R;
|
||||||
import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener;
|
import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener;
|
||||||
|
@ -65,14 +62,7 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
binding.toolbar.setOnClickListener((v) -> {
|
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
|
||||||
ClipboardUtil.INSTANCE.copyToClipboard(this,
|
|
||||||
"```\n" +
|
|
||||||
"Markdown Editor logs:\n\n" +
|
|
||||||
TextUtils.join("\n", MarkwonMarkdownEditor.getLogs()) + "\n" +
|
|
||||||
"```"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,8 +47,6 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
||||||
|
|
||||||
private static final String TAG = MarkwonMarkdownEditor.class.getSimpleName();
|
private static final String TAG = MarkwonMarkdownEditor.class.getSimpleName();
|
||||||
|
|
||||||
private static final List<String> LOGS = new ArrayList<>();
|
|
||||||
|
|
||||||
private final MutableLiveData<CharSequence> unrenderedText$ = new MutableLiveData<>();
|
private final MutableLiveData<CharSequence> unrenderedText$ = new MutableLiveData<>();
|
||||||
private final CombinedTextWatcher combinedWatcher;
|
private final CombinedTextWatcher combinedWatcher;
|
||||||
|
|
||||||
|
@ -66,14 +64,12 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
||||||
final Markwon markwon = createMarkwonBuilder(context).build();
|
final Markwon markwon = createMarkwonBuilder(context).build();
|
||||||
final MarkwonEditor editor = createMarkwonEditorBuilder(markwon).build();
|
final MarkwonEditor editor = createMarkwonEditorBuilder(markwon).build();
|
||||||
|
|
||||||
MarkwonMarkdownEditor.log(MarkwonMarkdownEditor.class.getSimpleName() + " [constructor] attempt to add " + CombinedTextWatcher.class.getSimpleName());
|
|
||||||
combinedWatcher = new CombinedTextWatcher(editor, this);
|
combinedWatcher = new CombinedTextWatcher(editor, this);
|
||||||
addTextChangedListener(combinedWatcher);
|
addTextChangedListener(combinedWatcher);
|
||||||
setCustomSelectionActionModeCallback(new ContextBasedRangeFormattingCallback(this));
|
setCustomSelectionActionModeCallback(new ContextBasedRangeFormattingCallback(this));
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
setCustomInsertionActionModeCallback(new ContextBasedFormattingCallback(this));
|
setCustomInsertionActionModeCallback(new ContextBasedFormattingCallback(this));
|
||||||
}
|
}
|
||||||
MarkwonMarkdownEditor.log(MarkwonMarkdownEditor.class.getSimpleName() + " [constructor] added " + CombinedTextWatcher.class.getSimpleName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Markwon.Builder createMarkwonBuilder(@NonNull Context context) {
|
private static Markwon.Builder createMarkwonBuilder(@NonNull Context context) {
|
||||||
|
@ -97,15 +93,6 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
||||||
.useEditHandler(new HeadingEditHandler());
|
.useEditHandler(new HeadingEditHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String s) {
|
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(ZoneId.systemDefault());
|
|
||||||
LOGS.add(dtf.format(LocalDateTime.now().atZone(ZoneId.systemDefault())) + " → " + s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getLogs() {
|
|
||||||
return LOGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSearchColor(@ColorInt int color) {
|
public void setSearchColor(@ColorInt int color) {
|
||||||
final SearchHighlightTextWatcher searchHighlightTextWatcher = combinedWatcher.get(SearchHighlightTextWatcher.class);
|
final SearchHighlightTextWatcher searchHighlightTextWatcher = combinedWatcher.get(SearchHighlightTextWatcher.class);
|
||||||
|
|
|
@ -30,35 +30,28 @@ public class AutoContinuationTextWatcher extends InterceptorTextWatcher {
|
||||||
public AutoContinuationTextWatcher(@NonNull TextWatcher originalWatcher, @NonNull MarkwonMarkdownEditor editText) {
|
public AutoContinuationTextWatcher(@NonNull TextWatcher originalWatcher, @NonNull MarkwonMarkdownEditor editText) {
|
||||||
super(originalWatcher);
|
super(originalWatcher);
|
||||||
this.editText = editText;
|
this.editText = editText;
|
||||||
MarkwonMarkdownEditor.log("Initialize " + AutoContinuationTextWatcher.class.getSimpleName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [onTextChanged] with " + s + "|" + start + "|" + before + "|" + count);
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
CharSequence inserted = getInsertedString(s, start, before, count);
|
CharSequence inserted = getInsertedString(s, start, before, count);
|
||||||
if (inserted.length() > 0 && inserted.charAt(inserted.length() - 1) == '\n') {
|
if (inserted.length() > 0 && inserted.charAt(inserted.length() - 1) == '\n') {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [onTextChanged] count == 1 && s.charAt(start == \\n");
|
|
||||||
handleNewlineInserted(s, start, count);
|
handleNewlineInserted(s, start, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldText = s.toString();
|
oldText = s.toString();
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [onTextChanged] passing to originalWatcher");
|
|
||||||
originalWatcher.onTextChanged(s, start, before, count);
|
originalWatcher.onTextChanged(s, start, before, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged]");
|
|
||||||
if (customText != null) {
|
if (customText != null) {
|
||||||
final CharSequence customText = this.customText;
|
final CharSequence customText = this.customText;
|
||||||
this.customText = null;
|
this.customText = null;
|
||||||
if (isInsert) {
|
if (isInsert) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged] - isInsert");
|
|
||||||
insertCustomText(s, customText);
|
insertCustomText(s, customText);
|
||||||
} else {
|
} else {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged] - NOT isInsert");
|
|
||||||
deleteCustomText(s, customText);
|
deleteCustomText(s, customText);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,24 +70,20 @@ public class AutoContinuationTextWatcher extends InterceptorTextWatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteCustomText(Editable s, CharSequence customText) {
|
private void deleteCustomText(Editable s, CharSequence customText) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [deleteCustomText] with customText = " + customText);
|
|
||||||
s.replace(sequenceStart, sequenceStart + customText.length() + 1, "\n");
|
s.replace(sequenceStart, sequenceStart + customText.length() + 1, "\n");
|
||||||
editText.setSelection(sequenceStart + 1);
|
editText.setSelection(sequenceStart + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertCustomText(Editable s, CharSequence customText) {
|
private void insertCustomText(Editable s, CharSequence customText) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [insertCustomText] with customText = " + customText);
|
|
||||||
s.insert(sequenceStart, customText);
|
s.insert(sequenceStart, customText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNewlineInserted(CharSequence originalSequence, int start, int count) {
|
private void handleNewlineInserted(CharSequence originalSequence, int start, int count) {
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [handleNewlineInserted] with " + start + "|" + count);
|
|
||||||
final CharSequence s = originalSequence.subSequence(0, originalSequence.length());
|
final CharSequence s = originalSequence.subSequence(0, originalSequence.length());
|
||||||
final int startOfLine = getStartOfLine(s, start);
|
final int startOfLine = getStartOfLine(s, start);
|
||||||
final String line = s.subSequence(startOfLine, getEndOfLine(s, start)).toString();
|
final String line = s.subSequence(startOfLine, getEndOfLine(s, start)).toString();
|
||||||
|
|
||||||
final String emptyListString = getListItemIfIsEmpty(line);
|
final String emptyListString = getListItemIfIsEmpty(line);
|
||||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [handleNewlineInserted] emptyListString = " + emptyListString);
|
|
||||||
if (emptyListString != null) {
|
if (emptyListString != null) {
|
||||||
customText = emptyListString;
|
customText = emptyListString;
|
||||||
isInsert = false;
|
isInsert = false;
|
||||||
|
|
|
@ -19,7 +19,6 @@ public class CombinedTextWatcher extends HashMap<Class<?>, TextWatcher> implemen
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public CombinedTextWatcher(@NonNull MarkwonEditor editor, @NonNull MarkwonMarkdownEditor editText) {
|
public CombinedTextWatcher(@NonNull MarkwonEditor editor, @NonNull MarkwonMarkdownEditor editText) {
|
||||||
MarkwonMarkdownEditor.log(CombinedTextWatcher.class.getSimpleName() + " [constructor]");
|
|
||||||
put(MarkwonEditorTextWatcher.class, MarkwonEditorTextWatcher.withPreRender(editor, Executors.newSingleThreadExecutor(), editText));
|
put(MarkwonEditorTextWatcher.class, MarkwonEditorTextWatcher.withPreRender(editor, Executors.newSingleThreadExecutor(), editText));
|
||||||
put(AutoContinuationTextWatcher.class, new AutoContinuationTextWatcher(get(MarkwonEditorTextWatcher.class), editText));
|
put(AutoContinuationTextWatcher.class, new AutoContinuationTextWatcher(get(MarkwonEditorTextWatcher.class), editText));
|
||||||
put(SearchHighlightTextWatcher.class, new SearchHighlightTextWatcher(get(AutoContinuationTextWatcher.class), editText));
|
put(SearchHighlightTextWatcher.class, new SearchHighlightTextWatcher(get(AutoContinuationTextWatcher.class), editText));
|
||||||
|
|
Loading…
Reference in a new issue