Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-12-21 15:05:34 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-12-21 15:18:17 +0300
commit6edd87537e06de2d8d296a31b510948830fd35fe (patch)
tree4e4c3e4fd4c18f29ddeeb93757331b02b4afdb6c /app/src/main/java/it/niedermann/owncloud/notes/widget
parentbc636f1e2b040f64c1c5498bcd8f1596f1a399de (diff)
Outsource markdown rendering for widgets
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/widget')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java26
1 files changed, 8 insertions, 18 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java
index 939c41ef..9305754f 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java
@@ -8,24 +8,18 @@ import android.util.Log;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
-import com.yydcdut.markdown.MarkdownProcessor;
-import com.yydcdut.markdown.syntax.text.TextFactory;
-
import java.util.NoSuchElementException;
+import it.niedermann.android.markdown.MarkdownUtil;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
-import it.niedermann.owncloud.notes.preferences.DarkModeSetting;
import it.niedermann.owncloud.notes.edit.EditNoteActivity;
-import it.niedermann.owncloud.notes.shared.model.DBNote;
import it.niedermann.owncloud.notes.persistence.NotesDatabase;
-import it.niedermann.owncloud.notes.shared.util.MarkDownUtil;
-import it.niedermann.owncloud.notes.NotesApplication;
-
-import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.parseCompat;
+import it.niedermann.owncloud.notes.preferences.DarkModeSetting;
+import it.niedermann.owncloud.notes.shared.model.DBNote;
public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFactory {
- private final MarkdownProcessor markdownProcessor;
private final Context context;
private final int appWidgetId;
@@ -37,18 +31,14 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
SingleNoteWidgetFactory(Context context, Intent intent) {
this.context = context;
- appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
+ this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
- db = NotesDatabase.getInstance(context);
- markdownProcessor = new MarkdownProcessor(this.context);
- markdownProcessor.factory(TextFactory.create());
+ this.db = NotesDatabase.getInstance(context);
try {
SingleNoteWidgetData data = db.getSingleNoteWidgetData(appWidgetId);
darkModeActive = NotesApplication.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode()));
} catch (NoSuchElementException e) {
Log.w(TAG, "Widget with ID " + appWidgetId + " seems to be not configured yet.");
- } finally {
- markdownProcessor.config(MarkDownUtil.getMarkDownConfiguration(this.context, darkModeActive).build());
}
}
@@ -111,12 +101,12 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
if (darkModeActive) {
note_content = new RemoteViews(context.getPackageName(), R.layout.widget_single_note_content_dark);
note_content.setOnClickFillInIntent(R.id.single_note_content_tv_dark, fillInIntent);
- note_content.setTextViewText(R.id.single_note_content_tv_dark, parseCompat(markdownProcessor, note.getContent()));
+ note_content.setTextViewText(R.id.single_note_content_tv_dark, MarkdownUtil.renderForWidget(context, note.getContent()));
} else {
note_content = new RemoteViews(context.getPackageName(), R.layout.widget_single_note_content);
note_content.setOnClickFillInIntent(R.id.single_note_content_tv, fillInIntent);
- note_content.setTextViewText(R.id.single_note_content_tv, parseCompat(markdownProcessor, note.getContent()));
+ note_content.setTextViewText(R.id.single_note_content_tv, MarkdownUtil.renderForWidget(context, note.getContent()));
}
return note_content;