Skip to content

Commit 527f92f

Browse files
committed
InteractiveTextMaker.kt moved to a new module.
README.md has been updated.
1 parent b281201 commit 527f92f

14 files changed

Lines changed: 191 additions & 3 deletions

File tree

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

InteractiveTextMaker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

InteractiveTextMaker/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk 32
8+
9+
defaultConfig {
10+
minSdk 14
11+
targetSdk 32
12+
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14+
consumerProguardFiles "consumer-rules.pro"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
kotlinOptions {
28+
jvmTarget = '1.8'
29+
}
30+
}
31+
32+
dependencies {
33+
34+
implementation 'androidx.core:core-ktx:1.7.0'
35+
implementation 'androidx.appcompat:appcompat:1.4.2'
36+
implementation 'com.google.android.material:material:1.6.1'
37+
testImplementation 'junit:junit:4.13.2'
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
40+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.interactivetextmaker
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.interactivetextmaker.test", appContext.packageName)
23+
}
24+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.interactivetextmaker">
4+
5+
</manifest>

app/src/main/java/com/example/myapplication/InteractiveTextMaker.kt renamed to InteractiveTextMaker/src/main/java/com/example/interactivetextmaker/InteractiveTextMaker.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.myapplication
1+
package com.example.interactivetextmaker
22

33
import android.content.Context
44
import android.text.SpannableString
@@ -9,6 +9,7 @@ import android.util.Log
99
import android.view.View
1010
import android.widget.TextView
1111
import androidx.annotation.ColorRes
12+
import androidx.core.content.ContextCompat
1213
import androidx.core.graphics.ColorUtils
1314

1415
class InteractiveTextMaker private constructor(
@@ -33,14 +34,14 @@ class InteractiveTextMaker private constructor(
3334
}
3435

3536
fun setSpecialTextColor(@ColorRes colorId: Int): InteractiveTextMaker {
36-
val color = context.getColor(colorId)
37+
val color = ContextCompat.getColor(context,colorId)
3738
specialTextColor = color
3839
specialTextHighLightColor = ColorUtils.setAlphaComponent(color, 50)
3940
return this
4041
}
4142

4243
fun setSpecialTextHighlightColor(@ColorRes color: Int): InteractiveTextMaker {
43-
specialTextHighLightColor = context.getColor(color)
44+
specialTextHighLightColor = ContextCompat.getColor(context,color)
4445
return this
4546
}
4647

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.interactivetextmaker
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

0 commit comments

Comments
 (0)