aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-12-30 14:46:45 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-12-30 14:46:45 +0000
commit286ab8ebca82a236a5ea40bdf111cda1e87927ec (patch)
treef3e311dcc6f96d54b8c09a11590e7cf1fa174fae /app/src/main/java
parenta60c249b168ed7ec628e1e0858e83689d66aa1ec (diff)
downloadinfinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar.gz
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar.bz2
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar.lz
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar.xz
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.tar.zst
infinity-for-reddit-286ab8ebca82a236a5ea40bdf111cda1e87927ec.zip
Change text color in TableLayout in markdown. Change markdown TextView style.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java7
2 files changed, 28 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
index 7470887a..936f4d48 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
@@ -7,17 +7,21 @@ import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.text.Spanned;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
+import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -110,6 +114,17 @@ public class ViewSidebarActivity extends BaseActivity {
params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId);
toolbar.setLayoutParams(params);
}
+
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ int dp = 16;
+ int px = (int) TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP,
+ dp,
+ resources.getDisplayMetrics()
+ );
+ markdownRecyclerView.setPadding(px, px, px, resources.getDimensionPixelSize(navBarResourceId));
+ }
}
String subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
@@ -123,9 +138,15 @@ public class ViewSidebarActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ int markdownColor = ContextCompat.getColor(this, R.color.defaultTextColor);
Markwon markwon = Markwon.builder(this)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
+ public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
+ textView.setTextColor(markdownColor);
+ }
+
+ @Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
Intent intent = new Intent(ViewSidebarActivity.this, LinkResolverActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index cd56c175..fb285316 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -8,6 +8,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.text.Spanned;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
import android.util.TypedValue;
@@ -136,9 +137,15 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mGlide = glide;
+ int markdownColor = ContextCompat.getColor(activity, R.color.defaultTextColor);
mMarkwon = Markwon.builder(mActivity)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
+ public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
+ textView.setTextColor(markdownColor);
+ }
+
+ @Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
Intent intent = new Intent(mActivity, LinkResolverActivity.class);