Skip to content

Commit

Permalink
courses: auto image size (fixes #2793) (#2794)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Dec 5, 2023
1 parent 69c83db commit 65ae47b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1181
versionName "0.11.81"
versionCode 1182
versionName "0.11.82"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -132,6 +132,8 @@ dependencies {
implementation 'com.github.kizitonwose:CalendarView:1.1.0'
implementation "io.noties.markwon:editor:4.6.2"
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:html:4.6.2"
implementation 'com.caverock:androidsvg-aar:1.4'
implementation "androidx.core:core-ktx:1.12.0"
implementation "com.github.VaibhavLakhera:Circular-Progress-View:0.1.2"
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.ImagesPlugin;
import io.noties.markwon.image.file.FileSchemeHandler;
import io.noties.markwon.image.network.NetworkSchemeHandler;
import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.realm.Realm;
import io.realm.RealmResults;
Expand All @@ -58,13 +61,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
id = getArguments().getString("courseId");
}
markwon = Markwon.builder(context)
.usePlugin(HtmlPlugin.create())
.usePlugin(ImagesPlugin.create())
.usePlugin(MovementMethodPlugin.none())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configure(@NonNull MarkwonPlugin.Registry registry) {
registry.require(ImagesPlugin.class, imagesPlugin ->
imagesPlugin.addSchemeHandler(FileSchemeHandler.create())
registry.require(ImagesPlugin.class, imagesPlugin -> {
imagesPlugin.addSchemeHandler(FileSchemeHandler.create());
imagesPlugin.addSchemeHandler(NetworkSchemeHandler.create());
imagesPlugin.addSchemeHandler(OkHttpNetworkSchemeHandler.create());
}
);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.ImagesPlugin;
import io.noties.markwon.image.file.FileSchemeHandler;
import io.noties.markwon.image.network.NetworkSchemeHandler;
import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.realm.Case;
import io.realm.Realm;
Expand Down Expand Up @@ -73,13 +76,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
setUserVisibleHint(false);
markwon = Markwon.builder(context)
.usePlugin(HtmlPlugin.create())
.usePlugin(ImagesPlugin.create())
.usePlugin(MovementMethodPlugin.none())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configure(@NonNull MarkwonPlugin.Registry registry) {
registry.require(ImagesPlugin.class, imagesPlugin ->
imagesPlugin.addSchemeHandler(FileSchemeHandler.create())
registry.require(ImagesPlugin.class, imagesPlugin -> {
imagesPlugin.addSchemeHandler(FileSchemeHandler.create());
imagesPlugin.addSchemeHandler(NetworkSchemeHandler.create());
imagesPlugin.addSchemeHandler(OkHttpNetworkSchemeHandler.create());
}
);
}
})
Expand Down Expand Up @@ -230,7 +237,7 @@ public static String prependBaseUrlToImages(String markdownContent, String baseU
String relativePath = matcher.group(1);
String modifiedPath = relativePath.replaceFirst("resources/", "");
String fullUrl = baseUrl + modifiedPath;
matcher.appendReplacement(result, "![](" + fullUrl + ")");
matcher.appendReplacement(result, "<img src=" + fullUrl + " width=600 height=350/>");
}
matcher.appendTail(result);

Expand Down

0 comments on commit 65ae47b

Please sign in to comment.