Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 4cd9d9d

Browse files
committed
Improve markdown activity.
1 parent f11b7e8 commit 4cd9d9d

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import android.content.pm.PackageManager;
55
import android.os.Bundle;
66
import android.util.Log;
7+
import android.view.View;
78
import android.view.ViewGroup;
9+
import android.view.WindowManager;
810
import android.widget.TextView;
911
import android.widget.Toast;
1012

@@ -40,7 +42,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4042
.getString(Constants.EXTRA_MARKDOWN_TITLE);
4143
String config = intent.getExtras()
4244
.getString(Constants.EXTRA_MARKDOWN_CONFIG);
43-
if (title != null && !title.isEmpty()) setTitle(title);
45+
if (title != null && !title.isEmpty()) {
46+
setTitle(title);
47+
}
48+
this.getWindow().setFlags(
49+
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
50+
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
4451
if (config != null && !config.isEmpty()) {
4552
String configPkg = IntentHelper.getPackageOfConfig(config);
4653
try {
@@ -75,6 +82,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7582
String markdown = new String(rawMarkdown, StandardCharsets.UTF_8);
7683
Log.d(TAG, "Done!");
7784
runOnUiThread(() -> {
85+
findViewById(R.id.markdownFooter)
86+
.setMinimumHeight(this.getNavigationBarHeight());
7887
MainApplication.getINSTANCE().getMarkwon().setMarkdown(
7988
textView, MarkdownUrlLinker.urlLinkify(markdown));
8089
if (markdownBackground != null) {
@@ -92,4 +101,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
92101
}
93102
}, "Markdown load thread").start();
94103
}
104+
105+
@Override
106+
protected void onResume() {
107+
super.onResume();
108+
View footer = findViewById(R.id.markdownFooter);
109+
if (footer != null) footer.setMinimumHeight(this.getNavigationBarHeight());
110+
}
95111
}

app/src/main/java/com/fox2code/mmm/markdown/MarkdownUrlLinker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public static String urlLinkify(String url) {
1515
ArrayList<LinkifyTask> linkifyTasks = new ArrayList<>();
1616
int extra = 0;
1717
while (index != -1) {
18-
int end = Math.min(url.indexOf('\n', index),
19-
url.indexOf(' ', index));
18+
int end = url.indexOf(' ', index);
19+
end = end == -1 ? url.indexOf('\n', index) :
20+
Math.min(url.indexOf('\n', index), end);
2021
if (end == -1) end = url.length();
2122
if (index == 0 ||
2223
'\n' == url.charAt(index - 1) ||
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
76
android:background="@color/black"
8-
android:id="@+id/markdownBackground">
7+
android:id="@+id/markdownBackground"
8+
app:fitsSystemWindowsInsets="top">
99
<androidx.cardview.widget.CardView
1010
android:layout_width="match_parent"
11-
android:layout_height="wrap_content"
12-
android:layout_margin="@dimen/markdown_border_content"
11+
android:layout_height="match_parent"
1312
android:gravity="center_vertical"
14-
app:cardCornerRadius="@dimen/card_corner_radius" >
13+
app:cardCornerRadius="@dimen/card_corner_radius">
1514
<ScrollView
1615
android:layout_width="match_parent"
1716
android:layout_height="wrap_content">
18-
<TextView
19-
android:id="@+id/markdownView"
20-
android:text="@string/loading"
17+
<LinearLayout
2118
android:layout_width="match_parent"
22-
android:layout_height="wrap_content" />
19+
android:layout_height="wrap_content"
20+
android:orientation="vertical">
21+
<TextView
22+
android:id="@+id/markdownView"
23+
android:text="@string/loading"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:layout_margin="@dimen/markdown_border_content" />
27+
28+
<TextView
29+
android:id="@+id/markdownFooter"
30+
android:text=""
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content" />
33+
</LinearLayout>
2334
</ScrollView>
2435
</androidx.cardview.widget.CardView>
2536
</LinearLayout>

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
<dimen name="card_corner_radius">8dp</dimen>
55
<dimen name="markdown_side_clearance">0dp</dimen>
66
<dimen name="markdown_topdown_clearance">32dp</dimen>
7-
<dimen name="markdown_border_content">0dp</dimen>
7+
<dimen name="markdown_border_content">8dp</dimen>
88
</resources>

0 commit comments

Comments
 (0)