Pull from origin (linkify compat)
This commit is contained in:
		
							parent
							
								
									20d2bebd2b
								
							
						
					
					
						commit
						d31940a290
					
				| @ -19,11 +19,15 @@ | ||||
| * add `option` abstraction for `sample` module allowing switching of multiple cases in runtime via menu | ||||
| * non-empty bounds for `AsyncDrawable` when no dimensions are not yet available ([#189]) | ||||
| * `JLatexMathPlugin` add text color customization ([#207]) | ||||
| * `linkify` - option to use `LinkifyCompat` in `LinkifyPlugin` ([#201]) | ||||
| <br>Thanks to [@drakeet] | ||||
| 
 | ||||
| [#189]: https://github.com/noties/Markwon/issues/189 | ||||
| [#75]: https://github.com/noties/Markwon/issues/75 | ||||
| [#204]: https://github.com/noties/Markwon/issues/204  | ||||
| [#207]: https://github.com/noties/Markwon/issues/207 | ||||
| [#201]: https://github.com/noties/Markwon/issues/201 | ||||
| [@drakeet]: https://github.com/drakeet | ||||
| 
 | ||||
| 
 | ||||
| # 4.2.2 | ||||
|  | ||||
| @ -42,6 +42,7 @@ public class LinkifyPlugin extends AbstractMarkwonPlugin { | ||||
|      * @param useCompat If true, use {@link LinkifyCompat} to handle links. | ||||
|      *                  Note that the {@link LinkifyCompat} depends on androidx.core:core, | ||||
|      *                  the dependency must be added on a client side explicitly. | ||||
|      * @since 4.3.0-SNAPSHOT `useCompat` argument | ||||
|      */ | ||||
|     @NonNull | ||||
|     public static LinkifyPlugin create(boolean useCompat) { | ||||
| @ -57,6 +58,7 @@ public class LinkifyPlugin extends AbstractMarkwonPlugin { | ||||
|      * @param useCompat If true, use {@link LinkifyCompat} to handle links. | ||||
|      *                  Note that the {@link LinkifyCompat} depends on androidx.core:core, | ||||
|      *                  the dependency must be added on a client side explicitly. | ||||
|      * @since 4.3.0-SNAPSHOT `useCompat` argument | ||||
|      */ | ||||
|     @NonNull | ||||
|     public static LinkifyPlugin create(@LinkifyMask int mask, boolean useCompat) { | ||||
| @ -78,6 +80,7 @@ public class LinkifyPlugin extends AbstractMarkwonPlugin { | ||||
|             @Override | ||||
|             public void apply(@NonNull CorePlugin corePlugin) { | ||||
|                 final LinkifyTextAddedListener listener; | ||||
|                 // @since 4.3.0-SNAPSHOT | ||||
|                 if (useCompat) { | ||||
|                     listener = new LinkifyCompatTextAddedListener(mask); | ||||
|                 } else { | ||||
| @ -137,6 +140,7 @@ public class LinkifyPlugin extends AbstractMarkwonPlugin { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // @since 4.3.0-SNAPSHOT | ||||
|     private static class LinkifyCompatTextAddedListener extends LinkifyTextAddedListener { | ||||
| 
 | ||||
|         LinkifyCompatTextAddedListener(int mask) { | ||||
|  | ||||
| @ -3,6 +3,7 @@ package io.noties.markwon.sample.images; | ||||
| import android.content.Context; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Bundle; | ||||
| import android.text.method.LinkMovementMethod; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import androidx.annotation.NonNull; | ||||
| @ -14,6 +15,7 @@ import com.bumptech.glide.request.target.Target; | ||||
| 
 | ||||
| import io.noties.markwon.Markwon; | ||||
| import io.noties.markwon.image.AsyncDrawable; | ||||
| import io.noties.markwon.image.ImagesPlugin; | ||||
| import io.noties.markwon.image.glide.GlideImagesPlugin; | ||||
| import io.noties.markwon.sample.ActivityWithMenuOptions; | ||||
| import io.noties.markwon.sample.MenuOptions; | ||||
| @ -29,7 +31,8 @@ public class ImagesActivity extends ActivityWithMenuOptions { | ||||
|         // todo: same for other plugins | ||||
|         return MenuOptions.create() | ||||
|                 .add("glide-singleImage", this::glideSingleImage) | ||||
|                 .add("glide-singleImageWithPlaceholder", this::glideSingleImageWithPlaceholder); | ||||
|                 .add("glide-singleImageWithPlaceholder", this::glideSingleImageWithPlaceholder) | ||||
|                 .add("click", this::click); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| @ -82,4 +85,15 @@ public class ImagesActivity extends ActivityWithMenuOptions { | ||||
| 
 | ||||
|         markwon.setMarkdown(textView, md); | ||||
|     } | ||||
| 
 | ||||
|     private void click() { | ||||
| 
 | ||||
|         textView.setMovementMethod(LinkMovementMethod.getInstance()); | ||||
| 
 | ||||
|         final String md = "[](https://www.mdeditor.com/images/logos/markdown.png)"; | ||||
|         final Markwon markwon = Markwon.builder(this) | ||||
|                 .usePlugin(ImagesPlugin.create()) | ||||
|                 .build(); | ||||
|         markwon.setMarkdown(textView, md); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov