mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 12:56:02 +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.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -19,8 +18,6 @@ import java.io.InputStreamReader;
|
|||
import java.util.Calendar;
|
||||
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.R;
|
||||
import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener;
|
||||
|
@ -65,14 +62,7 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
|
|||
}
|
||||
|
||||
setSupportActionBar(binding.toolbar);
|
||||
binding.toolbar.setOnClickListener((v) -> {
|
||||
ClipboardUtil.INSTANCE.copyToClipboard(this,
|
||||
"```\n" +
|
||||
"Markdown Editor logs:\n\n" +
|
||||
TextUtils.join("\n", MarkwonMarkdownEditor.getLogs()) + "\n" +
|
||||
"```"
|
||||
);
|
||||
});
|
||||
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,8 +47,6 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
|||
|
||||
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 CombinedTextWatcher combinedWatcher;
|
||||
|
||||
|
@ -66,14 +64,12 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
|||
final Markwon markwon = createMarkwonBuilder(context).build();
|
||||
final MarkwonEditor editor = createMarkwonEditorBuilder(markwon).build();
|
||||
|
||||
MarkwonMarkdownEditor.log(MarkwonMarkdownEditor.class.getSimpleName() + " [constructor] attempt to add " + CombinedTextWatcher.class.getSimpleName());
|
||||
combinedWatcher = new CombinedTextWatcher(editor, this);
|
||||
addTextChangedListener(combinedWatcher);
|
||||
setCustomSelectionActionModeCallback(new ContextBasedRangeFormattingCallback(this));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
setCustomInsertionActionModeCallback(new ContextBasedFormattingCallback(this));
|
||||
}
|
||||
MarkwonMarkdownEditor.log(MarkwonMarkdownEditor.class.getSimpleName() + " [constructor] added " + CombinedTextWatcher.class.getSimpleName());
|
||||
}
|
||||
|
||||
private static Markwon.Builder createMarkwonBuilder(@NonNull Context context) {
|
||||
|
@ -97,15 +93,6 @@ public class MarkwonMarkdownEditor extends AppCompatEditText implements Markdown
|
|||
.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
|
||||
public void setSearchColor(@ColorInt int color) {
|
||||
final SearchHighlightTextWatcher searchHighlightTextWatcher = combinedWatcher.get(SearchHighlightTextWatcher.class);
|
||||
|
|
|
@ -30,35 +30,28 @@ public class AutoContinuationTextWatcher extends InterceptorTextWatcher {
|
|||
public AutoContinuationTextWatcher(@NonNull TextWatcher originalWatcher, @NonNull MarkwonMarkdownEditor editText) {
|
||||
super(originalWatcher);
|
||||
this.editText = editText;
|
||||
MarkwonMarkdownEditor.log("Initialize " + AutoContinuationTextWatcher.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
CharSequence inserted = getInsertedString(s, start, before, count);
|
||||
if (inserted.length() > 0 && inserted.charAt(inserted.length()-1)=='\n'){
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [onTextChanged] count == 1 && s.charAt(start == \\n");
|
||||
if (inserted.length() > 0 && inserted.charAt(inserted.length() - 1) == '\n') {
|
||||
handleNewlineInserted(s, start, count);
|
||||
}
|
||||
}
|
||||
oldText = s.toString();
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [onTextChanged] passing to originalWatcher");
|
||||
originalWatcher.onTextChanged(s, start, before, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged]");
|
||||
if (customText != null) {
|
||||
final CharSequence customText = this.customText;
|
||||
this.customText = null;
|
||||
if (isInsert) {
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged] - isInsert");
|
||||
insertCustomText(s, customText);
|
||||
} else {
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [afterTextChanged] - NOT isInsert");
|
||||
deleteCustomText(s, customText);
|
||||
}
|
||||
} else {
|
||||
|
@ -67,34 +60,30 @@ public class AutoContinuationTextWatcher extends InterceptorTextWatcher {
|
|||
editText.setMarkdownStringModel(s);
|
||||
}
|
||||
|
||||
private CharSequence getInsertedString(CharSequence newText, int start, int before, int count){
|
||||
if(newText != null && newText.length() > (oldText == null ? 0 : oldText.length())){
|
||||
private CharSequence getInsertedString(CharSequence newText, int start, int before, int count) {
|
||||
if (newText != null && newText.length() > (oldText == null ? 0 : oldText.length())) {
|
||||
// character added
|
||||
int position = start + before ;
|
||||
return newText.subSequence(position, position+count-before);
|
||||
int position = start + before;
|
||||
return newText.subSequence(position, position + count - before);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void deleteCustomText(Editable s, CharSequence customText) {
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [deleteCustomText] with customText = " + customText);
|
||||
s.replace(sequenceStart, sequenceStart + customText.length() + 1, "\n");
|
||||
editText.setSelection(sequenceStart + 1);
|
||||
}
|
||||
|
||||
private void insertCustomText(Editable s, CharSequence customText) {
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [insertCustomText] with customText = " + customText);
|
||||
s.insert(sequenceStart, customText);
|
||||
}
|
||||
|
||||
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 int startOfLine = getStartOfLine(s, start);
|
||||
final String line = s.subSequence(startOfLine, getEndOfLine(s, start)).toString();
|
||||
|
||||
final String emptyListString = getListItemIfIsEmpty(line);
|
||||
MarkwonMarkdownEditor.log(AutoContinuationTextWatcher.class.getSimpleName() + " [handleNewlineInserted] emptyListString = " + emptyListString);
|
||||
if (emptyListString != null) {
|
||||
customText = emptyListString;
|
||||
isInsert = false;
|
||||
|
|
|
@ -19,7 +19,6 @@ public class CombinedTextWatcher extends HashMap<Class<?>, TextWatcher> implemen
|
|||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public CombinedTextWatcher(@NonNull MarkwonEditor editor, @NonNull MarkwonMarkdownEditor editText) {
|
||||
MarkwonMarkdownEditor.log(CombinedTextWatcher.class.getSimpleName() + " [constructor]");
|
||||
put(MarkwonEditorTextWatcher.class, MarkwonEditorTextWatcher.withPreRender(editor, Executors.newSingleThreadExecutor(), editText));
|
||||
put(AutoContinuationTextWatcher.class, new AutoContinuationTextWatcher(get(MarkwonEditorTextWatcher.class), editText));
|
||||
put(SearchHighlightTextWatcher.class, new SearchHighlightTextWatcher(get(AutoContinuationTextWatcher.class), editText));
|
||||
|
|
Loading…
Reference in a new issue