Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gsantner:master #222

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.gsantner.markor.format.markdown.MarkdownSyntaxHighlighter;
import net.gsantner.markor.model.AppSettings;
import net.gsantner.opoc.format.GsTextUtils;
import net.gsantner.opoc.util.GsContextUtils;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -25,7 +26,7 @@ public class CsvSyntaxHighlighter extends MarkdownSyntaxHighlighter {
// dkgray is not much different from black and not readable with black background
// blue is difficuilt to read on black background
private static final int[] COLUMN_COLORS = {
Color.RED, Color.rgb(150, 150, 255), Color.MAGENTA,
Color.RED, GsContextUtils.rgb(150, 150, 255), Color.MAGENTA,
0xff00b04c, // dark green,
0xffdaa500}; // brown
private static final String TAG = CsvSyntaxHighlighter.class.getSimpleName();
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/net/gsantner/opoc/util/GsContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,17 @@ public boolean shouldColorOnTopBeLight(@ColorInt final int colorOnBottomInt) {
+ (0.114 * Color.blue(colorOnBottomInt)))));
}

@ColorInt
public static int rgb(final int r, final int g, final int b) {
return argb(255, r, g, b);
}

@ColorInt
public static int argb(final int a, final int r, final int g, final int b) {
return (Math.max(0, Math.min(255, a)) << 24) | (Math.max(0, Math.min(255, r)) << 16) | (Math.max(0, Math.min(255, g)) << 8) | Math.max(0, Math.min(255, b));
}


/**
* Convert a html string to an android {@link Spanned} object
*/
Expand Down Expand Up @@ -853,7 +864,7 @@ public Bitmap drawTextOnDrawable(final Context context, @DrawableRes final int d
bitmap = bitmap.copy(bitmap.getConfig(), true);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.rgb(61, 61, 61));
paint.setColor(GsContextUtils.rgb(61, 61, 61));
paint.setTextSize((int) (textSize * scale));
paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

Expand Down