Added since annotation to newly added method/classes

This commit is contained in:
Dimitry Ivanov 2017-10-23 15:56:18 +03:00
parent bf5a8142f5
commit 3eaaf9b72c
10 changed files with 131 additions and 27 deletions

View File

@ -6,7 +6,7 @@ org.gradle.configureondemand=true
android.enableBuildCache=true
android.buildCacheDir=build/pre-dex-cache
VERSION_NAME=1.0.0
VERSION_NAME=1.0.1
GROUP=ru.noties
POM_DESCRIPTION=Markwon

View File

@ -22,13 +22,19 @@ public abstract class Markwon {
/**
* 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
* @since 1.0.0
*/
@NonNull
public static Parser createParser() {
return new Parser.Builder()
.extensions(Arrays.asList(StrikethroughExtension.create(), TablesExtension.create(), TaskListExtension.create()))
.extensions(Arrays.asList(
StrikethroughExtension.create(),
TablesExtension.create(),
TaskListExtension.create()
))
.build();
}
@ -92,6 +98,7 @@ public abstract class Markwon {
* @return parsed markdown
* @since 1.0.0
*/
@Nullable
public static CharSequence markdown(@NonNull Context context, @Nullable String markdown) {
final CharSequence out;
if (TextUtils.isEmpty(markdown)) {
@ -112,6 +119,7 @@ public abstract class Markwon {
* @see SpannableConfiguration
* @since 1.0.0
*/
@Nullable
public static CharSequence markdown(@NonNull SpannableConfiguration configuration, @Nullable String markdown) {
final CharSequence out;
if (TextUtils.isEmpty(markdown)) {

View File

@ -273,6 +273,9 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
newLine();
}
/**
* @since 1.0.1
*/
@Override
public void visit(CustomBlock customBlock) {
if (customBlock instanceof TaskListBlock) {
@ -295,9 +298,9 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
visitChildren(customNode);
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;
@ -318,11 +321,10 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
blockQuoteIndent -= listItem.indent();
} else {
} else if (!handleTableNodes(customNode)) {
super.visit(customNode);
}
}
}
private boolean handleTableNodes(CustomNode node) {

View File

@ -18,18 +18,57 @@ import android.util.TypedValue;
@SuppressWarnings("WeakerAccess")
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) {
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() {
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) {
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) {
// by default we will be using link color for the checkbox color
@ -373,6 +412,10 @@ public class SpannableTheme {
paint.setStyle(Paint.Style.FILL);
}
/**
* @return a Drawable to be used as a checkbox indication in task lists
* @since 1.0.1
*/
@Nullable
public Drawable getTaskListDrawable() {
return taskListDrawable;
@ -431,116 +474,149 @@ public class SpannableTheme {
this.taskListDrawable = theme.taskListDrawable;
}
@NonNull
public Builder linkColor(@ColorInt int linkColor) {
this.linkColor = linkColor;
return this;
}
@NonNull
public Builder blockMargin(@Dimension int blockMargin) {
this.blockMargin = blockMargin;
return this;
}
@NonNull
public Builder blockQuoteWidth(@Dimension int blockQuoteWidth) {
this.blockQuoteWidth = blockQuoteWidth;
return this;
}
@NonNull
public Builder blockQuoteColor(@ColorInt int blockQuoteColor) {
this.blockQuoteColor = blockQuoteColor;
return this;
}
@NonNull
public Builder listItemColor(@ColorInt int listItemColor) {
this.listItemColor = listItemColor;
return this;
}
@NonNull
public Builder bulletListItemStrokeWidth(@Dimension int bulletListItemStrokeWidth) {
this.bulletListItemStrokeWidth = bulletListItemStrokeWidth;
return this;
}
@NonNull
public Builder bulletWidth(@Dimension int bulletWidth) {
this.bulletWidth = bulletWidth;
return this;
}
@NonNull
public Builder codeTextColor(@ColorInt int codeTextColor) {
this.codeTextColor = codeTextColor;
return this;
}
@NonNull
public Builder codeBackgroundColor(@ColorInt int codeBackgroundColor) {
this.codeBackgroundColor = codeBackgroundColor;
return this;
}
@NonNull
public Builder codeMultilineMargin(@Dimension int codeMultilineMargin) {
this.codeMultilineMargin = codeMultilineMargin;
return this;
}
@NonNull
public Builder codeTypeface(@NonNull Typeface codeTypeface) {
this.codeTypeface = codeTypeface;
return this;
}
@NonNull
public Builder codeTextSize(@Dimension int codeTextSize) {
this.codeTextSize = codeTextSize;
return this;
}
@NonNull
public Builder headingBreakHeight(@Dimension int headingBreakHeight) {
this.headingBreakHeight = headingBreakHeight;
return this;
}
@NonNull
public Builder headingBreakColor(@ColorInt int headingBreakColor) {
this.headingBreakColor = headingBreakColor;
return this;
}
@NonNull
public Builder scriptTextSizeRatio(@FloatRange(from = .0F, to = Float.MAX_VALUE) float scriptTextSizeRatio) {
this.scriptTextSizeRatio = scriptTextSizeRatio;
return this;
}
@NonNull
public Builder thematicBreakColor(@ColorInt int thematicBreakColor) {
this.thematicBreakColor = thematicBreakColor;
return this;
}
@NonNull
public Builder thematicBreakHeight(@Dimension int thematicBreakHeight) {
this.thematicBreakHeight = thematicBreakHeight;
return this;
}
@NonNull
public Builder tableCellPadding(@Dimension int tableCellPadding) {
this.tableCellPadding = tableCellPadding;
return this;
}
@NonNull
public Builder tableBorderColor(@ColorInt int tableBorderColor) {
this.tableBorderColor = tableBorderColor;
return this;
}
@NonNull
public Builder tableBorderWidth(@Dimension int tableBorderWidth) {
this.tableBorderWidth = tableBorderWidth;
return this;
}
@NonNull
public Builder tableOddRowBackgroundColor(@ColorInt int tableOddRowBackgroundColor) {
this.tableOddRowBackgroundColor = tableOddRowBackgroundColor;
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) {
this.taskListDrawable = taskListDrawable;
return this;
}
@NonNull
public SpannableTheme build() {
return new SpannableTheme(this);
}

View File

@ -13,6 +13,9 @@ import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
/**
* @since 1.0.1
*/
@SuppressWarnings("WeakerAccess")
public class TaskListDrawable extends Drawable {

View File

@ -7,6 +7,9 @@ import android.support.annotation.NonNull;
import android.text.Layout;
import android.text.style.LeadingMarginSpan;
/**
* @since 1.0.1
*/
public class TaskListSpan implements LeadingMarginSpan {
private final SpannableTheme theme;

View File

@ -2,5 +2,8 @@ package ru.noties.markwon.tasklist;
import org.commonmark.node.CustomBlock;
/**
* @since 1.0.1
*/
public class TaskListBlock extends CustomBlock {
}

View File

@ -17,6 +17,9 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @since 1.0.1
*/
@SuppressWarnings("WeakerAccess")
class TaskListBlockParser extends AbstractBlockParser {

View File

@ -4,6 +4,9 @@ import android.support.annotation.NonNull;
import org.commonmark.parser.Parser;
/**
* @since 1.0.1
*/
public class TaskListExtension implements Parser.ParserExtension {
@NonNull

View File

@ -2,6 +2,9 @@ package ru.noties.markwon.tasklist;
import org.commonmark.node.CustomNode;
/**
* @since 1.0.1
*/
@SuppressWarnings("WeakerAccess")
public class TaskListItem extends CustomNode {