From 2102f325a0e34f11733d83c10bc9d00f1fbcd30f Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Sat, 27 May 2017 16:09:08 +0300 Subject: [PATCH] Updated README.md for `library-view` module --- README.md | 4 +++- library-view/README.md | 41 ++++++++++++++++++++++++++++++++++ library-view/gradle.properties | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 library-view/README.md create mode 100644 library-view/gradle.properties diff --git a/README.md b/README.md index cda46461..81ef276f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ # Markwon [![maven|markwon](https://img.shields.io/maven-central/v/ru.noties/markwon.svg?label=maven%7Cmarkwon)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon%22) -[![maven|markwon-image-loader](https://img.shields.io/maven-central/v/ru.noties/markwon.svg?label=maven%7Cmarkwon-image-loader)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon%22) +[![maven|markwon-image-loader](https://img.shields.io/maven-central/v/ru.noties/markwon-image-loader.svg?label=maven%7Cmarkwon-image-loader)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon-image-loader%22) +[![maven|markwon-view](https://img.shields.io/maven-central/v/ru.noties/markwon-view.svg?label=maven%7Cmarkwon-view)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon-view%22) Android library for rendering markdown as system-native Spannables. Based on [commonmark-java][commonmark-java] @@ -11,6 +12,7 @@ Android library for rendering markdown as system-native Spannables. Based on [co ```groovy compile 'ru.noties:markwon:1.0.0' compile 'ru.noties:markwon-image-loader:1.0.0' // optional +compile 'ru.noties:markwon-view:1.0.0' // optional ``` --- diff --git a/library-view/README.md b/library-view/README.md new file mode 100644 index 00000000..71f032db --- /dev/null +++ b/library-view/README.md @@ -0,0 +1,41 @@ +# Markwon View + +[![maven|markwon-view](https://img.shields.io/maven-central/v/ru.noties/markwon-view.svg?label=maven%7Cmarkwon-view)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon-view%22) + +This is simple library containing 2 views that are able to display markdown: +* MarkwonView - extends `android.view.TextView` +* MarkwonViewCompat - extends `android.support.v7.widget.AppCompatTextView` + +Both of them implement common `IMarkwonView` interface: +```java +public interface IMarkwonView { + + interface ConfigurationProvider { + @NonNull + SpannableConfiguration provide(@NonNull Context context); + } + + void setConfigurationProvider(@NonNull ConfigurationProvider provider); + + void setMarkdown(@Nullable String markdown); + void setMarkdown(@Nullable SpannableConfiguration configuration, @Nullable String markdown); + + @Nullable + String getMarkdown(); +} +``` + +Both views support layout-preview in Android Studio (with some exceptions, for example, bold span is not rendered due to some limitations of layout preview). +These are XML attributes: +``` +app:mv_markdown="string" +app:mv_configurationProvider="string" +``` + +`mv_markdown` accepts a string and represents raw markdown + +`mv_configurationProvider` accepts a string and represents a full class name of a class of type `ConfigurationProvider`, +for example: `com.example.my.package.MyConfigurationProvider` (this class must have an empty constructor +in order to be instantiated via reflection). + +Please note that those views parse markdown in main thread, so their usage must be for relatively small markdown portions only diff --git a/library-view/gradle.properties b/library-view/gradle.properties new file mode 100644 index 00000000..a4413bba --- /dev/null +++ b/library-view/gradle.properties @@ -0,0 +1,3 @@ +POM_NAME=Markwon-View +POM_ARTIFACT_ID=markwon-view +POM_PACKAGING=aar \ No newline at end of file