blob: 3dd1e70af7b0a87ac6ef01f2bb680496adc7b7b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
package de.timfreiheit.mathjax.android;
import android.content.res.TypedArray;
import android.os.Build;
import android.webkit.JavascriptInterface;
/**
* http://docs.mathjax.org/en/latest/options/
* for more information
* <p>
* Created by timfreiheit on 06.06.15.
*/
public class MathJaxConfig {
private String input = Input.TeX.value;
private String output = Output.SVG.value;
private int outputScale = 100;
private int minScaleAdjust = 100;
private boolean automaticLinebreaks = false;
private int blacker = 1;
private String textColor;
public MathJaxConfig() {
if (Build.VERSION.SDK_INT >= 14) {
output = Output.SVG.value;
} else {
output = Output.HTML_CSS.value;
}
}
public MathJaxConfig(TypedArray attrs) {
this();
int inputIndex = attrs.getInteger(R.styleable.MathJaxView_input, -1);
if (inputIndex > 0) {
setInput(Input.values()[inputIndex]);
}
int outputIndex = attrs.getInteger(R.styleable.MathJaxView_output, -1);
if (outputIndex > 0) {
setOutput(Output.values()[outputIndex]);
}
setAutomaticLinebreaks(attrs.getBoolean(R.styleable.MathJaxView_automaticLinebreaks, automaticLinebreaks));
setMinScaleAdjust(attrs.getInteger(R.styleable.MathJaxView_minScaleAdjust, minScaleAdjust));
setOutputScale(attrs.getInteger(R.styleable.MathJaxView_outputScale, outputScale));
setBlacker(attrs.getInteger(R.styleable.MathJaxView_blacker, blacker));
}
@JavascriptInterface
public String getInput() {
return input;
}
public void setInput(Input input) {
this.input = input.value;
}
public String getTextColor() {
return this.textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
@JavascriptInterface
public String getOutput() {
return output;
}
public void setOutput(Output output) {
this.output = output.value;
}
@JavascriptInterface
public int getOutputScale() {
return outputScale;
}
public void setOutputScale(int outputScale) {
this.outputScale = outputScale;
}
@JavascriptInterface
public int getMinScaleAdjust() {
return minScaleAdjust;
}
public void setMinScaleAdjust(int scale) {
this.minScaleAdjust = scale;
}
@JavascriptInterface
public boolean getAutomaticLinebreaks() {
return automaticLinebreaks;
}
public void setAutomaticLinebreaks(boolean b) {
this.automaticLinebreaks = b;
}
@JavascriptInterface
public int getBlacker() {
return blacker;
}
public void setBlacker(int blacker) {
this.blacker = blacker;
}
public enum Output {
SVG("output/SVG"),
HTML_CSS("output/HTML-CSS"),
CommonHTML("output/CommonHTML"),
NativeMML("output/NativeMML");
final String value;
Output(String s) {
value = s;
}
}
public enum Input {
TeX("input/TeX"),
MathML("input/MathML"),
AsciiMath("input/AsciiMath");
final String value;
Input(String s) {
value = s;
}
}
}
|