Added since annotation to newly added method/classes
This commit is contained in:
parent
bf5a8142f5
commit
3eaaf9b72c
@ -6,7 +6,7 @@ org.gradle.configureondemand=true
|
|||||||
android.enableBuildCache=true
|
android.enableBuildCache=true
|
||||||
android.buildCacheDir=build/pre-dex-cache
|
android.buildCacheDir=build/pre-dex-cache
|
||||||
|
|
||||||
VERSION_NAME=1.0.0
|
VERSION_NAME=1.0.1
|
||||||
|
|
||||||
GROUP=ru.noties
|
GROUP=ru.noties
|
||||||
POM_DESCRIPTION=Markwon
|
POM_DESCRIPTION=Markwon
|
||||||
|
@ -22,13 +22,19 @@ public abstract class Markwon {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to obtain a Parser with registered strike-through & table extensions
|
* Helper method to obtain a Parser with registered strike-through & table extensions
|
||||||
|
* & task lists (added in 1.0.1)
|
||||||
*
|
*
|
||||||
* @return a Parser instance that is supported by this library
|
* @return a Parser instance that is supported by this library
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public static Parser createParser() {
|
public static Parser createParser() {
|
||||||
return new Parser.Builder()
|
return new Parser.Builder()
|
||||||
.extensions(Arrays.asList(StrikethroughExtension.create(), TablesExtension.create(), TaskListExtension.create()))
|
.extensions(Arrays.asList(
|
||||||
|
StrikethroughExtension.create(),
|
||||||
|
TablesExtension.create(),
|
||||||
|
TaskListExtension.create()
|
||||||
|
))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +98,7 @@ public abstract class Markwon {
|
|||||||
* @return parsed markdown
|
* @return parsed markdown
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static CharSequence markdown(@NonNull Context context, @Nullable String markdown) {
|
public static CharSequence markdown(@NonNull Context context, @Nullable String markdown) {
|
||||||
final CharSequence out;
|
final CharSequence out;
|
||||||
if (TextUtils.isEmpty(markdown)) {
|
if (TextUtils.isEmpty(markdown)) {
|
||||||
@ -112,6 +119,7 @@ public abstract class Markwon {
|
|||||||
* @see SpannableConfiguration
|
* @see SpannableConfiguration
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static CharSequence markdown(@NonNull SpannableConfiguration configuration, @Nullable String markdown) {
|
public static CharSequence markdown(@NonNull SpannableConfiguration configuration, @Nullable String markdown) {
|
||||||
final CharSequence out;
|
final CharSequence out;
|
||||||
if (TextUtils.isEmpty(markdown)) {
|
if (TextUtils.isEmpty(markdown)) {
|
||||||
|
@ -273,6 +273,9 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
newLine();
|
newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void visit(CustomBlock customBlock) {
|
public void visit(CustomBlock customBlock) {
|
||||||
if (customBlock instanceof TaskListBlock) {
|
if (customBlock instanceof TaskListBlock) {
|
||||||
@ -295,9 +298,9 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
visitChildren(customNode);
|
visitChildren(customNode);
|
||||||
setSpan(length, new StrikethroughSpan());
|
setSpan(length, new StrikethroughSpan());
|
||||||
|
|
||||||
} else if (!handleTableNodes(customNode)) {
|
} else if (customNode instanceof TaskListItem) {
|
||||||
|
|
||||||
if (customNode instanceof TaskListItem) {
|
// new in 1.0.1
|
||||||
|
|
||||||
final TaskListItem listItem = (TaskListItem) customNode;
|
final TaskListItem listItem = (TaskListItem) customNode;
|
||||||
|
|
||||||
@ -318,11 +321,10 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
|
|
||||||
blockQuoteIndent -= listItem.indent();
|
blockQuoteIndent -= listItem.indent();
|
||||||
|
|
||||||
} else {
|
} else if (!handleTableNodes(customNode)) {
|
||||||
super.visit(customNode);
|
super.visit(customNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleTableNodes(CustomNode node) {
|
private boolean handleTableNodes(CustomNode node) {
|
||||||
|
|
||||||
|
@ -18,18 +18,57 @@ import android.util.TypedValue;
|
|||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class SpannableTheme {
|
public class SpannableTheme {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to obtain an instance of {@link SpannableTheme} with all values as defaults
|
||||||
|
*
|
||||||
|
* @param context Context in order to resolve defaults
|
||||||
|
* @return {@link SpannableTheme} instance
|
||||||
|
* @see #builderWithDefaults(Context)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
public static SpannableTheme create(@NonNull Context context) {
|
public static SpannableTheme create(@NonNull Context context) {
|
||||||
return builderWithDefaults(context).build();
|
return builderWithDefaults(context).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to obtain an instance of {@link Builder}. Please note, that no default
|
||||||
|
* values are set. This might be useful if you require a lot of special styling that differs
|
||||||
|
* a lot with default one
|
||||||
|
*
|
||||||
|
* @return {@link Builder instance}
|
||||||
|
* @see #builderWithDefaults(Context)
|
||||||
|
* @see #builder(SpannableTheme)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to create a {@link Builder} instance and initialize it with values
|
||||||
|
* from supplied {@link SpannableTheme}
|
||||||
|
*
|
||||||
|
* @param copyFrom {@link SpannableTheme} to copy values from
|
||||||
|
* @return {@link Builder} instance
|
||||||
|
* @see #builderWithDefaults(Context)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
public static Builder builder(@NonNull SpannableTheme copyFrom) {
|
public static Builder builder(@NonNull SpannableTheme copyFrom) {
|
||||||
return new Builder(copyFrom);
|
return new Builder(copyFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to obtain a {@link Builder} instance initialized with default values taken
|
||||||
|
* from current application theme.
|
||||||
|
*
|
||||||
|
* @param context Context to obtain default styling values (colors, etc)
|
||||||
|
* @return {@link Builder} instance
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
public static Builder builderWithDefaults(@NonNull Context context) {
|
public static Builder builderWithDefaults(@NonNull Context context) {
|
||||||
|
|
||||||
// by default we will be using link color for the checkbox color
|
// by default we will be using link color for the checkbox color
|
||||||
@ -373,6 +412,10 @@ public class SpannableTheme {
|
|||||||
paint.setStyle(Paint.Style.FILL);
|
paint.setStyle(Paint.Style.FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a Drawable to be used as a checkbox indication in task lists
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Drawable getTaskListDrawable() {
|
public Drawable getTaskListDrawable() {
|
||||||
return taskListDrawable;
|
return taskListDrawable;
|
||||||
@ -431,116 +474,149 @@ public class SpannableTheme {
|
|||||||
this.taskListDrawable = theme.taskListDrawable;
|
this.taskListDrawable = theme.taskListDrawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder linkColor(@ColorInt int linkColor) {
|
public Builder linkColor(@ColorInt int linkColor) {
|
||||||
this.linkColor = linkColor;
|
this.linkColor = linkColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder blockMargin(@Dimension int blockMargin) {
|
public Builder blockMargin(@Dimension int blockMargin) {
|
||||||
this.blockMargin = blockMargin;
|
this.blockMargin = blockMargin;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder blockQuoteWidth(@Dimension int blockQuoteWidth) {
|
public Builder blockQuoteWidth(@Dimension int blockQuoteWidth) {
|
||||||
this.blockQuoteWidth = blockQuoteWidth;
|
this.blockQuoteWidth = blockQuoteWidth;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder blockQuoteColor(@ColorInt int blockQuoteColor) {
|
public Builder blockQuoteColor(@ColorInt int blockQuoteColor) {
|
||||||
this.blockQuoteColor = blockQuoteColor;
|
this.blockQuoteColor = blockQuoteColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder listItemColor(@ColorInt int listItemColor) {
|
public Builder listItemColor(@ColorInt int listItemColor) {
|
||||||
this.listItemColor = listItemColor;
|
this.listItemColor = listItemColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder bulletListItemStrokeWidth(@Dimension int bulletListItemStrokeWidth) {
|
public Builder bulletListItemStrokeWidth(@Dimension int bulletListItemStrokeWidth) {
|
||||||
this.bulletListItemStrokeWidth = bulletListItemStrokeWidth;
|
this.bulletListItemStrokeWidth = bulletListItemStrokeWidth;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder bulletWidth(@Dimension int bulletWidth) {
|
public Builder bulletWidth(@Dimension int bulletWidth) {
|
||||||
this.bulletWidth = bulletWidth;
|
this.bulletWidth = bulletWidth;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder codeTextColor(@ColorInt int codeTextColor) {
|
public Builder codeTextColor(@ColorInt int codeTextColor) {
|
||||||
this.codeTextColor = codeTextColor;
|
this.codeTextColor = codeTextColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder codeBackgroundColor(@ColorInt int codeBackgroundColor) {
|
public Builder codeBackgroundColor(@ColorInt int codeBackgroundColor) {
|
||||||
this.codeBackgroundColor = codeBackgroundColor;
|
this.codeBackgroundColor = codeBackgroundColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder codeMultilineMargin(@Dimension int codeMultilineMargin) {
|
public Builder codeMultilineMargin(@Dimension int codeMultilineMargin) {
|
||||||
this.codeMultilineMargin = codeMultilineMargin;
|
this.codeMultilineMargin = codeMultilineMargin;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder codeTypeface(@NonNull Typeface codeTypeface) {
|
public Builder codeTypeface(@NonNull Typeface codeTypeface) {
|
||||||
this.codeTypeface = codeTypeface;
|
this.codeTypeface = codeTypeface;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder codeTextSize(@Dimension int codeTextSize) {
|
public Builder codeTextSize(@Dimension int codeTextSize) {
|
||||||
this.codeTextSize = codeTextSize;
|
this.codeTextSize = codeTextSize;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder headingBreakHeight(@Dimension int headingBreakHeight) {
|
public Builder headingBreakHeight(@Dimension int headingBreakHeight) {
|
||||||
this.headingBreakHeight = headingBreakHeight;
|
this.headingBreakHeight = headingBreakHeight;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder headingBreakColor(@ColorInt int headingBreakColor) {
|
public Builder headingBreakColor(@ColorInt int headingBreakColor) {
|
||||||
this.headingBreakColor = headingBreakColor;
|
this.headingBreakColor = headingBreakColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder scriptTextSizeRatio(@FloatRange(from = .0F, to = Float.MAX_VALUE) float scriptTextSizeRatio) {
|
public Builder scriptTextSizeRatio(@FloatRange(from = .0F, to = Float.MAX_VALUE) float scriptTextSizeRatio) {
|
||||||
this.scriptTextSizeRatio = scriptTextSizeRatio;
|
this.scriptTextSizeRatio = scriptTextSizeRatio;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder thematicBreakColor(@ColorInt int thematicBreakColor) {
|
public Builder thematicBreakColor(@ColorInt int thematicBreakColor) {
|
||||||
this.thematicBreakColor = thematicBreakColor;
|
this.thematicBreakColor = thematicBreakColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder thematicBreakHeight(@Dimension int thematicBreakHeight) {
|
public Builder thematicBreakHeight(@Dimension int thematicBreakHeight) {
|
||||||
this.thematicBreakHeight = thematicBreakHeight;
|
this.thematicBreakHeight = thematicBreakHeight;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder tableCellPadding(@Dimension int tableCellPadding) {
|
public Builder tableCellPadding(@Dimension int tableCellPadding) {
|
||||||
this.tableCellPadding = tableCellPadding;
|
this.tableCellPadding = tableCellPadding;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder tableBorderColor(@ColorInt int tableBorderColor) {
|
public Builder tableBorderColor(@ColorInt int tableBorderColor) {
|
||||||
this.tableBorderColor = tableBorderColor;
|
this.tableBorderColor = tableBorderColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder tableBorderWidth(@Dimension int tableBorderWidth) {
|
public Builder tableBorderWidth(@Dimension int tableBorderWidth) {
|
||||||
this.tableBorderWidth = tableBorderWidth;
|
this.tableBorderWidth = tableBorderWidth;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Builder tableOddRowBackgroundColor(@ColorInt int tableOddRowBackgroundColor) {
|
public Builder tableOddRowBackgroundColor(@ColorInt int tableOddRowBackgroundColor) {
|
||||||
this.tableOddRowBackgroundColor = tableOddRowBackgroundColor;
|
this.tableOddRowBackgroundColor = tableOddRowBackgroundColor;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supplied Drawable must be stateful ({@link Drawable#isStateful()} -> true). If a task
|
||||||
|
* is marked as done, then this drawable will be updated with an {@code int[] { android.R.attr.state_checked }}
|
||||||
|
* as the state, otherwise an empty array will be used. This library provides a ready to be
|
||||||
|
* used Drawable: {@link TaskListDrawable}
|
||||||
|
*
|
||||||
|
* @param taskListDrawable Drawable to be used as the task list indication (checkbox)
|
||||||
|
* @see TaskListDrawable
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
public Builder taskListDrawable(@NonNull Drawable taskListDrawable) {
|
public Builder taskListDrawable(@NonNull Drawable taskListDrawable) {
|
||||||
this.taskListDrawable = taskListDrawable;
|
this.taskListDrawable = taskListDrawable;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public SpannableTheme build() {
|
public SpannableTheme build() {
|
||||||
return new SpannableTheme(this);
|
return new SpannableTheme(this);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ import android.support.annotation.IntRange;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class TaskListDrawable extends Drawable {
|
public class TaskListDrawable extends Drawable {
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ import android.support.annotation.NonNull;
|
|||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.style.LeadingMarginSpan;
|
import android.text.style.LeadingMarginSpan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
public class TaskListSpan implements LeadingMarginSpan {
|
public class TaskListSpan implements LeadingMarginSpan {
|
||||||
|
|
||||||
private final SpannableTheme theme;
|
private final SpannableTheme theme;
|
||||||
|
@ -2,5 +2,8 @@ package ru.noties.markwon.tasklist;
|
|||||||
|
|
||||||
import org.commonmark.node.CustomBlock;
|
import org.commonmark.node.CustomBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
public class TaskListBlock extends CustomBlock {
|
public class TaskListBlock extends CustomBlock {
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,9 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
class TaskListBlockParser extends AbstractBlockParser {
|
class TaskListBlockParser extends AbstractBlockParser {
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import android.support.annotation.NonNull;
|
|||||||
|
|
||||||
import org.commonmark.parser.Parser;
|
import org.commonmark.parser.Parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
public class TaskListExtension implements Parser.ParserExtension {
|
public class TaskListExtension implements Parser.ParserExtension {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -2,6 +2,9 @@ package ru.noties.markwon.tasklist;
|
|||||||
|
|
||||||
import org.commonmark.node.CustomNode;
|
import org.commonmark.node.CustomNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.1
|
||||||
|
*/
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class TaskListItem extends CustomNode {
|
public class TaskListItem extends CustomNode {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user