Skip to content

Commit

Permalink
Merge pull request #5 from judemanutd/bugfix/text-color
Browse files Browse the repository at this point in the history
Fixed text color issue
  • Loading branch information
judemanutd authored Feb 16, 2020
2 parents 4273d6c + c8bf6e9 commit 8edf21d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your module's build.gradle file:
dependencies {
// ... other dependencies
implementation 'com.github.judemanutd:katexview:1.0.1'
implementation 'com.github.judemanutd:katexview:1.0.2'
}
```
Expand All @@ -28,7 +28,7 @@ dependencies {
<dependency>
<groupId>com.github.judemanutd</groupId>
<artifactId>katexview</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<type>pom</type>
</dependency>

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ dependencies {
api project(':katexview')

/* Test tools */
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha03'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:' + versions.kotlin
implementation 'androidx.appcompat:appcompat:' + versions.androidxCore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.judemanutd.katexviewexample

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_katex_example.*
Expand All @@ -13,5 +14,8 @@ class KatexExampleActivity : AppCompatActivity() {
val text = "$$ c = \\pm\\sqrt{a^2 + b^2} $$"

katex_text.setText(text)

katex_text_2.setText(text)
katex_text_2.setTextColor(Color.BLUE)
}
}
9 changes: 8 additions & 1 deletion app/src/main/res/layout/activity_katex_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".KatexExampleActivity">

<com.judemanutd.katexview.KatexView
android:id="@+id/katex_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:textColor="@color/colorPrimary" />
app:textColor="@color/colorAccent" />

<com.judemanutd.katexview.KatexView
android:id="@+id/katex_text_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />

</LinearLayout>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apply plugin: "com.github.ben-manes.versions"
apply from: './dependencies.gradle'

buildscript {
apply from: './dependencies.gradle'
ext.kotlin_version = '1.3.21'
ext.kotlin_version = versions.kotlin
repositories {
google()
jcenter()
Expand All @@ -16,6 +17,7 @@ buildscript {

classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "com.github.ben-manes:gradle-versions-plugin:" + versions.gradleVersion
}
}

Expand Down
8 changes: 5 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ ext.versions = [
bintrayPlugin : '0.9',

// AndroidX
androidxCore : '1.1.0-alpha02',
androidxKotlinCore: '1.1.0-alpha05',
androidxCore : '1.2.0-alpha02',
androidxKotlinCore: '1.3.0-alpha01',

// Kotlin
kotlin : '1.3.21',
kotlin : '1.3.61',

gradleVersion : '0.27.0'
]
12 changes: 6 additions & 6 deletions katexview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

Expand All @@ -18,7 +18,7 @@ ext {
siteUrl = 'https://github.com/judemanutd/KatexView'
gitUrl = 'https://github.com/judemanutd/KatexView.git'

libraryVersion = '1.0.1'
libraryVersion = '1.0.2'

developerId = 'judemanutd'
developerName = 'Jude Fernandes'
Expand All @@ -36,7 +36,7 @@ android {
minSdkVersion 15
targetSdkVersion 28
versionCode 2
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -58,9 +58,9 @@ dependencies {

implementation 'com.x5dev:chunk-templates:3.5.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
Expand Down
2 changes: 1 addition & 1 deletion katexview/src/main/assets/katex/katex.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion katexview/src/main/assets/katex/katex.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion katexview/src/main/assets/themes/katex.chtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
body {
margin : 0;
padding : 0;
color : {$textColor}
color: {$textColor} !important;
-webkit-touch-callout: none!important;
-webkit-user-select: none!important;
user-select: none!important;
Expand Down
18 changes: 11 additions & 7 deletions katexview/src/main/java/com/judemanutd/katexview/KatexView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ import com.x5.template.providers.AndroidTemplates
import androidx.core.content.ContextCompat

@SuppressLint("SetJavaScriptEnabled")
class KatexView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
WebView(context, attrs, defStyleAttr) {
class KatexView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
WebView(context, attrs, defStyleAttr) {

private val TAG_FORMULA: String = "formula"
private val TAG_TEXT_COLOR: String = "textColor"

private var mText: String? = null
//TODO: pick theme set text color
private var mTextColor: Int = android.R.color.black
private var mTextColor: Int = android.R.color.holo_purple

init {
settings.allowFileAccess = true
Expand All @@ -37,10 +41,10 @@ class KatexView @JvmOverloads constructor(context: Context, attrs: AttributeSet?

try {
setTextColor(
mTypeArray.getColor(
R.styleable.KatexView_textColor,
ContextCompat.getColor(getContext(), android.R.color.black)
)
mTypeArray.getColor(
R.styleable.KatexView_textColor,
ContextCompat.getColor(getContext(), android.R.color.black)
)
)

val text: String? = mTypeArray.getString(R.styleable.KatexView_text)
Expand Down

0 comments on commit 8edf21d

Please sign in to comment.