├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── chattymin
│ │ │ │ └── textgrapheme
│ │ │ │ ├── ui
│ │ │ │ └── theme
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── chattymin
│ │ │ └── textgrapheme
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── chattymin
│ │ └── textgrapheme
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle.kts
├── pebble
├── .gitignore
├── consumer-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── chattymin
│ │ └── pebble
│ │ ├── CharExt.kt
│ │ ├── CharArrayExt.kt
│ │ ├── AnyExt.kt
│ │ ├── ArrayExt.kt
│ │ ├── IterableExt.kt
│ │ ├── LocalBreakIterator.kt
│ │ ├── PebbleExt.kt
│ │ ├── MapExt.kt
│ │ ├── CharSequenceExt.kt
│ │ └── StringExt.kt
├── proguard-rules.pro
└── build.gradle.kts
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── settings.gradle.kts
├── .github
└── workflows
│ └── dokka.yml
├── gradle.properties
├── CONTRIBUTING.md
├── gradlew.bat
├── README.md
├── .gitignore
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/pebble/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/pebble/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TextGrapheme
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chattymin/Pebble/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/pebble/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/CharExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | /**
4 | * Returns `true` if this Char is an Emoji.
5 | */
6 | fun Char.isEmoji(): Boolean {
7 | return isEmoji(this.code)
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 30 17:56:39 KST 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/CharArrayExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | /**
4 | * Returns `true` if this CharArray contains any Emoji characters.
5 | */
6 | fun CharArray.containsEmoji(): Boolean {
7 | for (input in this) {
8 | if (input.isEmoji()) return true
9 | }
10 | return false
11 | }
12 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/AnyExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | internal fun Any?.containsEmoji(): Boolean {
4 | return when (this) {
5 | is Char -> this.isEmoji()
6 | is String -> this.containsEmoji()
7 | is CharSequence -> this.containsEmoji()
8 | else -> false
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/ArrayExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | /**
4 | * Returns `true` if this Array contains any Emoji characters.
5 | */
6 | fun Array .containsEmoji(): Boolean {
7 | for (input in this) {
8 | if (input.containsEmoji()) return true
9 | }
10 | return false
11 | }
12 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/IterableExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | /**
4 | * Returns `true` if this Iterable contains any Emoji characters.
5 | */
6 | fun Iterable.containsEmoji(): Boolean {
7 | for (input in this) {
8 | if (input.containsEmoji()) return true
9 | }
10 | return false
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chattymin/textgrapheme/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/chattymin/textgrapheme/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme
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 | }
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/LocalBreakIterator.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | import java.text.BreakIterator
4 | import java.util.Locale
5 |
6 | private val LocalBreakIterator = ThreadLocal().apply {
7 | set(BreakIterator.getCharacterInstance(Locale.ROOT))
8 | }
9 |
10 | internal val localBreakIterator: BreakIterator = LocalBreakIterator.get() ?: initBreakIterator()
11 |
12 | private fun initBreakIterator() = BreakIterator.getCharacterInstance(Locale.ROOT).also {
13 | LocalBreakIterator.set(it)
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "TextGrapheme"
23 | include(":app")
24 | include(":pebble")
25 |
--------------------------------------------------------------------------------
/.github/workflows/dokka.yml:
--------------------------------------------------------------------------------
1 | name: Pebble Dokka
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 |
7 | jobs:
8 | docs:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - name: Checkout Code
13 | uses: actions/checkout@v4
14 |
15 | - name: Set up JDK 17
16 | uses: actions/setup-java@v4
17 | with:
18 | java-version: 17
19 | distribution: "temurin"
20 |
21 | - name: permissions
22 | run: chmod +x gradlew
23 |
24 | - name: Build Documentation
25 | run: ./gradlew dokkaHtml
26 |
27 | - name: Deploy Documentation to GitHub Pages
28 | uses: JamesIves/github-pages-deploy-action@v4
29 | with:
30 | BRANCH: gh-pages
31 | FOLDER: pebble/build/dokka/html
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/chattymin/textgrapheme/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme
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.chattymin.textgrapheme", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/pebble/proguard-rules.pro:
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/PebbleExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | internal const val ASCII_MAX = 0x7F
4 |
5 | internal fun isEmoji(codePoint: Int): Boolean {
6 | return (codePoint in 0x1F600..0x1F64F) || // Emoticons (smileys, emotions)
7 | (codePoint in 0x1F300..0x1F5FF) || // Symbols & pictographs (weather, places, objects)
8 | (codePoint in 0x1F680..0x1F6FF) || // Transport & map symbols
9 | (codePoint in 0x1F700..0x1F77F) || // Alchemical symbols
10 | (codePoint in 0x1F900..0x1F9FF) || // Supplemental symbols & pictographs
11 | (codePoint in 0x1FA70..0x1FAFF) || // Symbols & pictographs extended-A
12 | (codePoint in 0x2600..0x26FF) || // Miscellaneous symbols
13 | (codePoint in 0x2700..0x27BF) || // Dingbats
14 | (codePoint in 0xFE00..0xFE0F) || // Variation selectors
15 | (codePoint == 0x200D) // Zero Width Joiner (ZWJ)
16 | }
17 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/MapExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | /**
4 | * Returns `true` if this Map contains any Emoji characters.
5 | */
6 | fun Map.containsEmoji(): Boolean {
7 | for (entry in this) {
8 | val key = entry.key
9 | val value = entry.value
10 |
11 | if (key.containsEmoji()) return true
12 | if (value.containsEmoji()) return true
13 | }
14 | return false
15 | }
16 |
17 | /**
18 | * Returns `true` if this Map contains any Emoji characters in the keys.
19 | */
20 | fun Map.containsEmojiKey(): Boolean {
21 | for (entry in this) {
22 | val key = entry.key
23 |
24 | if (key.containsEmoji()) return true
25 | }
26 | return false
27 | }
28 |
29 | /**
30 | * Returns `true` if this Map contains any Emoji characters in the values.
31 | */
32 | fun Map.containsEmojiValue(): Boolean {
33 | for (entry in this) {
34 | val value = entry.value
35 |
36 | if (value.containsEmoji()) return true
37 | }
38 | return false
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chattymin/textgrapheme/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/CharSequenceExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | import java.text.BreakIterator
4 |
5 | /**
6 | * Returns the number of graphemes (user-perceived characters) in the character sequence.
7 | */
8 | val CharSequence.graphemeLength: Int
9 | get() {
10 | if (this.isEmpty()) return 0
11 | if (this.length == 1) return 1
12 | if (this.isAscii()) return this.length
13 |
14 | val iterator = localBreakIterator
15 | iterator.setText(this.toString())
16 |
17 | var count = 0
18 | while (iterator.next() != BreakIterator.DONE) {
19 | count++
20 | }
21 | return count
22 | }
23 |
24 | /**
25 | * Returns `true` if the char sequence consists only of ASCII characters (0x00 - 0x7F).
26 | */
27 | private fun CharSequence.isAscii(): Boolean {
28 | for (input in this) {
29 | if (input.code > ASCII_MAX) return false
30 | }
31 | return true
32 | }
33 |
34 | /**
35 | * Returns `true` if this CharSequence is a single Emoji character.
36 | */
37 | fun CharSequence.isEmoji(): Boolean {
38 | return this.graphemeLength == 1 && isEmoji(this.toString().codePointAt(0))
39 | }
40 |
41 | /**
42 | * Returns `true` if this CharSequence contains any Emoji characters.
43 | */
44 | fun CharSequence.containsEmoji(): Boolean {
45 | var i = 0
46 | while (i < this.length) {
47 | val codePoint = Character.codePointAt(this, i)
48 | if (isEmoji(codePoint)) return true
49 | i += Character.charCount(codePoint)
50 | }
51 | return false
52 | }
53 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## How to contribute
2 | We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.
3 |
4 |
5 |
6 | ## Issues
7 |
8 | ### 1. Check for Duplicates
9 |
10 | Before creating a new issue, please check existing issues.
11 |
12 | ### 2. Have a Question?
13 |
14 | GitHub issues are for bugs and enhancement suggestions. For questions about the project, please use our contact methods.
15 |
16 | ### 3. Found a Bug?
17 |
18 | If you want to report a bug, please use the bug issue template. It contains questions to help us track and diagnose the issue accurately.
19 |
20 | ### 4. Feature Requests
21 |
22 | When requesting a new feature, please describe the necessity and expected benefits in as much detail as possible.
23 |
24 |
25 |
26 | ## Check Before Pull Request(PR)
27 |
28 | ### 1. Is it work with out edgecase
29 | Please correct any failures before requesting a review.
30 | Check many types of [Emoji](https://www.emojiall.com/ko). ex) 🚀 🧑🧑🧒🧒 😀 🤚🏿...
31 |
32 | ### 2. Apply it to the SampleApp in the app module
33 | This is to be used for verifying that it works as intended and to showcase the currently implemented functions clearly.
34 |
35 | ### 3. Please check if the comments are well written
36 | The comments should be concise yet friendly, helping users of the function understand it easily.
37 |
38 |
39 |
40 | ## Code reviews
41 | All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) for more information on using pull requests.
42 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chattymin/textgrapheme/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.platform.LocalContext
13 |
14 | private val DarkColorScheme = darkColorScheme(
15 | primary = Purple80,
16 | secondary = PurpleGrey80,
17 | tertiary = Pink80
18 | )
19 |
20 | private val LightColorScheme = lightColorScheme(
21 | primary = Purple40,
22 | secondary = PurpleGrey40,
23 | tertiary = Pink40
24 |
25 | /* Other default colors to override
26 | background = Color(0xFFFFFBFE),
27 | surface = Color(0xFFFFFBFE),
28 | onPrimary = Color.White,
29 | onSecondary = Color.White,
30 | onTertiary = Color.White,
31 | onBackground = Color(0xFF1C1B1F),
32 | onSurface = Color(0xFF1C1B1F),
33 | */
34 | )
35 |
36 | @Composable
37 | fun TextGraphemeTheme(
38 | darkTheme: Boolean = isSystemInDarkTheme(),
39 | // Dynamic color is available on Android 12+
40 | dynamicColor: Boolean = true,
41 | content: @Composable () -> Unit
42 | ) {
43 | val colorScheme = when {
44 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
45 | val context = LocalContext.current
46 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
47 | }
48 | darkTheme -> DarkColorScheme
49 | else -> LightColorScheme
50 | }
51 |
52 | MaterialTheme(
53 | colorScheme = colorScheme,
54 | typography = Typography,
55 | content = content
56 | )
57 | }
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.kotlin.android)
4 | alias(libs.plugins.kotlin.compose)
5 | }
6 |
7 | android {
8 | namespace = "com.chattymin.textgrapheme"
9 | compileSdk = 36
10 |
11 | defaultConfig {
12 | applicationId = "com.chattymin.textgrapheme"
13 | minSdk = 21
14 | targetSdk = 36
15 | versionCode = 1
16 | versionName = "1.0"
17 |
18 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | buildTypes {
22 | release {
23 | isMinifyEnabled = false
24 | proguardFiles(
25 | getDefaultProguardFile("proguard-android-optimize.txt"),
26 | "proguard-rules.pro"
27 | )
28 | }
29 | }
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_11
32 | targetCompatibility = JavaVersion.VERSION_11
33 | }
34 | kotlinOptions {
35 | jvmTarget = "11"
36 | }
37 | buildFeatures {
38 | compose = true
39 | }
40 | }
41 |
42 | dependencies {
43 | implementation(project(":pebble"))
44 |
45 | implementation(libs.androidx.core.ktx)
46 | implementation(libs.androidx.lifecycle.runtime.ktx)
47 | implementation(libs.androidx.activity.compose)
48 | implementation(platform(libs.androidx.compose.bom))
49 | implementation(libs.androidx.ui)
50 | implementation(libs.androidx.ui.graphics)
51 | implementation(libs.androidx.ui.tooling.preview)
52 | implementation(libs.androidx.material3)
53 | testImplementation(libs.junit)
54 | androidTestImplementation(libs.androidx.junit)
55 | androidTestImplementation(libs.androidx.espresso.core)
56 | androidTestImplementation(platform(libs.androidx.compose.bom))
57 | androidTestImplementation(libs.androidx.ui.test.junit4)
58 | debugImplementation(libs.androidx.ui.tooling)
59 | debugImplementation(libs.androidx.ui.test.manifest)
60 | }
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.9.0"
3 | kotlin = "2.0.21"
4 | coreKtx = "1.15.0"
5 | junit = "4.13.2"
6 | junitVersion = "1.2.1"
7 | espressoCore = "3.6.1"
8 | lifecycleRuntimeKtx = "2.8.7"
9 | activityCompose = "1.10.1"
10 | composeBom = "2024.09.00"
11 | appcompat = "1.7.0"
12 | material = "1.12.0"
13 | vanniktech = "0.31.0"
14 | dokka = "2.0.0"
15 |
16 | [libraries]
17 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
18 | junit = { group = "junit", name = "junit", version.ref = "junit" }
19 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
20 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
21 | androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
22 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
23 | androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
24 | androidx-ui = { group = "androidx.compose.ui", name = "ui" }
25 | androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
26 | androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
27 | androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
28 | androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
29 | androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
30 | androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
31 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
32 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
33 |
34 | [plugins]
35 | android-application = { id = "com.android.application", version.ref = "agp" }
36 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
37 | kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
38 | android-library = { id = "com.android.library", version.ref = "agp" }
39 | vanniktech = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }
40 | dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
41 |
--------------------------------------------------------------------------------
/pebble/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import com.vanniktech.maven.publish.SonatypeHost
2 |
3 | plugins {
4 | alias(libs.plugins.android.library)
5 | alias(libs.plugins.kotlin.android)
6 | alias(libs.plugins.vanniktech)
7 | alias(libs.plugins.dokka)
8 | }
9 |
10 | android {
11 | namespace = "com.chattymin.pebble"
12 | compileSdk = 36
13 |
14 | defaultConfig {
15 | minSdk = 21
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | consumerProguardFiles("consumer-rules.pro")
19 | }
20 |
21 | buildTypes {
22 | release {
23 | isMinifyEnabled = false
24 | proguardFiles(
25 | getDefaultProguardFile("proguard-android-optimize.txt"),
26 | "proguard-rules.pro"
27 | )
28 | }
29 | }
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_11
32 | targetCompatibility = JavaVersion.VERSION_11
33 | }
34 | kotlinOptions {
35 | jvmTarget = "11"
36 | }
37 | }
38 |
39 | tasks.dokkaHtml.configure {
40 | dokkaSourceSets {
41 | named("main") {
42 | noAndroidSdkLink.set(false)
43 | }
44 | }
45 | }
46 |
47 | val pebbleVersion = "0.1.1"
48 |
49 | mavenPublishing {
50 | publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
51 |
52 | signAllPublications()
53 |
54 | coordinates("io.github.chattymin", "pebble", pebbleVersion)
55 |
56 | pom {
57 | name = "Pebble"
58 | description = "Android Grapheme String Extensions"
59 | url = "https://github.com/chattymin/Pebble"
60 | inceptionYear = "2025"
61 |
62 | licenses {
63 | license {
64 | name = "The Apache License, Version 2.0"
65 | url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
66 | }
67 | }
68 | developers {
69 | developer {
70 | id = "chattymin"
71 | name = "chattymin"
72 | email = "parkdongmin123@gmail.com"
73 | url = "https://github.com/chattymin"
74 | }
75 | }
76 |
77 | scm {
78 | connection = "scm:git:github.com/chattymin/pebble.git"
79 | developerConnection.set("scm:git:ssh://github.com:chattymin/pebble.git")
80 | url = "https://github.com/chattymin/pebble"
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Pebble [](https://opensource.org/licenses/Apache-2.0) []([https://opensource.org/licenses/Apache-2.0](https://android-arsenal.com/api?level=21))
2 |
3 | Treat String Like A Pebble With Grapheme At Kotlin 🫧
4 | The Easy Way To Use Emoji 🚀
5 |
6 |
7 |
8 | ## Why Pebble?
9 | In Android, String is encoded in UTF-8, which means characters like emojis may not count as a single character.
10 | ```kotlin
11 | "🚀".length == 2
12 | "🧑🧑🧒🧒".length == 11
13 | ```
14 |
15 |
16 | Many applications display the character count when users enter text, such as nicknames or posts.
17 | However, due to certain issues, emojis are not counted correctly.
18 | AS-IS | TO-BE
19 | :--: | :--:
20 |
|
21 |
22 |
23 |
24 | To address this inconvenience, Pebble Is Coming!
25 |
26 |
27 |
28 | ## Gradle Settings
29 | Add the codes below to your **root** `build.gradle` file (not your module-level build.gradle file):
30 | ```gradle
31 | allprojects {
32 | repositories {
33 | mavenCentral()
34 | }
35 | }
36 | ```
37 |
38 | And, Add the dependency below to your **module** `build.gradle` file:
39 | ```kotlin
40 | dependencies {
41 | implementation("io.github.chattymin:pebble:0.1.0")
42 | }
43 | ```
44 |
45 |
46 |
47 | ## How To Use?
48 | ```kotlin
49 | "🚀".graphemeLength == 1
50 | "🚀".isEmoji() == true
51 | "Hello Pebble 🚀 Welcome!".containsEmoji() == true
52 | "Hello🚀 This is Pebble!🫧 Welc🧑🧑🧒🧒ome :)".extractEmojis() == ["🚀", "🫧", "🧑🧑🧒🧒"]
53 | "Hello🚀 This is Pebble!🫧 Welc🧑🧑🧒🧒ome :)".filterEmojis() == "Hello This is Pebble! Welcome :)"
54 | ```
55 | In addition to this, various types of extension functions are also available.
56 | The goal is to cover all ranges officially provided by Kotlin.
57 |
58 |
59 | You can explore and use various extension functions within the `Pebble` module :)
60 |
61 |
62 |
63 | ## Want To Contriubte
64 | Contributions are always welcome!
65 | Feel free to make an issue everything that you want to contribute!
66 | Welcome **New Extensions**, **Performance Improvements**, and all ways of working with strings—**just like Pebble**!
67 |
68 | [CONTRIBUTING.md](https://github.com/chattymin/Pebble/blob/main/CONTRIBUTING.md)
69 |
70 |
71 |
72 | ## Contributors
73 |
74 | [](https://github.com/chattymin/pebble/contributors)
75 |
76 |
77 |
78 | # License
79 | ```xml
80 | Copyright 2025 chattymin (Dongmin Park)
81 |
82 | Licensed under the Apache License, Version 2.0 (the "License");
83 | you may not use this file except in compliance with the License.
84 | You may obtain a copy of the License at
85 |
86 | http://www.apache.org/licenses/LICENSE-2.0
87 |
88 | Unless required by applicable law or agreed to in writing, software
89 | distributed under the License is distributed on an "AS IS" BASIS,
90 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 | See the License for the specific language governing permissions and
92 | limitations under the License.
93 | ```
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chattymin/textgrapheme/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.textgrapheme
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.activity.enableEdgeToEdge
7 | import androidx.compose.foundation.layout.Arrangement
8 | import androidx.compose.foundation.layout.Column
9 | import androidx.compose.foundation.layout.fillMaxSize
10 | import androidx.compose.foundation.layout.fillMaxWidth
11 | import androidx.compose.foundation.layout.padding
12 | import androidx.compose.foundation.rememberScrollState
13 | import androidx.compose.foundation.verticalScroll
14 | import androidx.compose.material3.Scaffold
15 | import androidx.compose.material3.Text
16 | import androidx.compose.material3.TextField
17 | import androidx.compose.runtime.getValue
18 | import androidx.compose.runtime.mutableStateOf
19 | import androidx.compose.runtime.remember
20 | import androidx.compose.runtime.setValue
21 | import androidx.compose.ui.Modifier
22 | import androidx.compose.ui.unit.dp
23 | import com.chattymin.pebble.containsEmoji
24 | import com.chattymin.pebble.extractEmojis
25 | import com.chattymin.pebble.filterEmojis
26 | import com.chattymin.pebble.graphemeLength
27 | import com.chattymin.pebble.isEmoji
28 | import com.chattymin.textgrapheme.ui.theme.TextGraphemeTheme
29 |
30 | class MainActivity : ComponentActivity() {
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | enableEdgeToEdge()
34 | setContent {
35 | TextGraphemeTheme {
36 | Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
37 | val scrollState = rememberScrollState()
38 |
39 | Column(
40 | modifier = Modifier
41 | .padding(innerPadding)
42 | .padding(16.dp)
43 | .verticalScroll(scrollState)
44 | .fillMaxSize(),
45 | verticalArrangement = Arrangement.spacedBy(12.dp)
46 | ) {
47 | var text by remember { mutableStateOf("") }
48 |
49 | TextField(
50 | value = text,
51 | onValueChange = { newText ->
52 | text = newText
53 | },
54 | label = {
55 | Text("Input Anything Here!")
56 | },
57 | modifier = Modifier.fillMaxWidth()
58 | )
59 |
60 | Text(
61 | text = "graphemeLength: ${text.graphemeLength}"
62 | )
63 |
64 | Text(
65 | text = "isEmoji: ${text.isEmoji()}",
66 | )
67 |
68 | Text(
69 | text = "containsEmoji: ${text.containsEmoji()}",
70 | )
71 |
72 | Text(
73 | text = "extractEmojis: ${text.extractEmojis()}",
74 | )
75 |
76 | Text(
77 | text = "filterEmojis: ${text.filterEmojis()}",
78 | )
79 | }
80 | }
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/pebble/src/main/java/com/chattymin/pebble/StringExt.kt:
--------------------------------------------------------------------------------
1 | package com.chattymin.pebble
2 |
3 | import java.text.BreakIterator
4 |
5 | /**
6 | * Returns the number of graphemes (user-perceived characters) in the string.
7 | */
8 | val String.graphemeLength: Int
9 | get() {
10 | if (this.isEmpty()) return 0
11 | if (this.length == 1) return 1
12 | if (this.isAscii()) return this.length
13 |
14 | val iterator = localBreakIterator
15 | iterator.setText(this)
16 |
17 | var count = 0
18 | while (iterator.next() != BreakIterator.DONE) {
19 | count++
20 | }
21 | return count
22 | }
23 |
24 | /**
25 | * Returns `true` if the string consists only of ASCII characters (0x00 - 0x7F).
26 | */
27 | private fun String.isAscii(): Boolean {
28 | for (input in this) {
29 | if (input.code > ASCII_MAX) return false
30 | }
31 | return true
32 | }
33 |
34 | /**
35 | * Returns `true` if this String is a single Emoji character.
36 | */
37 | fun String.isEmoji(): Boolean {
38 | return this.graphemeLength == 1 && isEmoji(this.codePointAt(0))
39 | }
40 |
41 | /**
42 | * Returns `true` if this String contains any Emoji characters.
43 | */
44 | fun String.containsEmoji(): Boolean {
45 | var i = 0
46 |
47 | while (i < this.length) {
48 | val codePoint = this.codePointAt(i)
49 | if (isEmoji(codePoint)) return true
50 | i += Character.charCount(codePoint)
51 | }
52 |
53 | return false
54 | }
55 |
56 | /**
57 | * Similar to [String.codePoints] which is available from API 24.
58 | * This internal implementation is provided for compatibility with API 21+.
59 | */
60 | private fun String.codePointsArray(): IntArray {
61 | val codePoints = mutableListOf()
62 |
63 | var i = 0
64 | while (i < this.length) {
65 | val codePoint = this.codePointAt(i)
66 | codePoints.add(codePoint)
67 | i += Character.charCount(codePoint)
68 | }
69 |
70 | return codePoints.toIntArray()
71 | }
72 |
73 | /**
74 | * Returns string list of emojis from the given text.
75 | */
76 | fun String.extractEmojis(): List {
77 | if (this.isBlank()) return emptyList()
78 |
79 | val iterator = localBreakIterator
80 | iterator.setText(this)
81 |
82 | val emojis = mutableListOf()
83 |
84 | var start = iterator.first()
85 | var end = iterator.next()
86 |
87 | while (end != BreakIterator.DONE) {
88 | val grapheme = this.substring(start, end)
89 |
90 | val codePoints = grapheme.codePointsArray()
91 |
92 | if (codePoints.any { isEmoji(it) }) {
93 | emojis.add(grapheme)
94 | }
95 |
96 | start = end
97 | end = iterator.next()
98 | }
99 |
100 | return emojis
101 | }
102 |
103 | /**
104 | * Return a new string with all emojis removed.
105 | */
106 | fun String.filterEmojis(): String {
107 | if (this.isBlank()) return this
108 |
109 | val iterator = localBreakIterator
110 | iterator.setText(this)
111 |
112 | val filtered = StringBuilder()
113 |
114 | var start = iterator.first()
115 | var end = iterator.next()
116 |
117 | while (end != BreakIterator.DONE) {
118 | val grapheme = this.substring(start, end)
119 |
120 | val codePoints = grapheme.codePointsArray()
121 |
122 | if (!codePoints.any { isEmoji(it) }) {
123 | filtered.append(grapheme)
124 | }
125 |
126 | start = end
127 | end = iterator.next()
128 | }
129 |
130 | return filtered.toString()
131 | }
132 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/kotlin,android,androidstudio,macos,windows
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=kotlin,android,androidstudio,macos,windows
3 |
4 | ### Android ###
5 | # Gradle files
6 | .gradle/
7 | build/
8 |
9 | # Local configuration file (sdk path, etc)
10 | local.properties
11 |
12 | # Log/OS Files
13 | *.log
14 |
15 | # Android Studio generated files and folders
16 | captures/
17 | .externalNativeBuild/
18 | .cxx/
19 | *.apk
20 | output.json
21 |
22 | # IntelliJ
23 | *.iml
24 | .idea/
25 | misc.xml
26 | deploymentTargetDropDown.xml
27 | render.experimental.xml
28 |
29 | # Keystore files
30 | *.jks
31 | *.keystore
32 |
33 | # Google Services (e.g. APIs or Firebase)
34 | google-services.json
35 |
36 | # Android Profiling
37 | *.hprof
38 |
39 | ### Android Patch ###
40 | gen-external-apklibs
41 |
42 | # Replacement of .externalNativeBuild directories introduced
43 | # with Android Studio 3.5.
44 |
45 | ### Kotlin ###
46 | # Compiled class file
47 | *.class
48 |
49 | # Log file
50 |
51 | # BlueJ files
52 | *.ctxt
53 |
54 | # Mobile Tools for Java (J2ME)
55 | .mtj.tmp/
56 |
57 | # Package Files #
58 | *.jar
59 | *.war
60 | *.nar
61 | *.ear
62 | *.zip
63 | *.tar.gz
64 | *.rar
65 |
66 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
67 | hs_err_pid*
68 | replay_pid*
69 |
70 | ### macOS ###
71 | # General
72 | .DS_Store
73 | .AppleDouble
74 | .LSOverride
75 |
76 | # Icon must end with two \r
77 | Icon
78 |
79 |
80 | # Thumbnails
81 | ._*
82 |
83 | # Files that might appear in the root of a volume
84 | .DocumentRevisions-V100
85 | .fseventsd
86 | .Spotlight-V100
87 | .TemporaryItems
88 | .Trashes
89 | .VolumeIcon.icns
90 | .com.apple.timemachine.donotpresent
91 |
92 | # Directories potentially created on remote AFP share
93 | .AppleDB
94 | .AppleDesktop
95 | Network Trash Folder
96 | Temporary Items
97 | .apdisk
98 |
99 | ### macOS Patch ###
100 | # iCloud generated files
101 | *.icloud
102 |
103 | ### Windows ###
104 | # Windows thumbnail cache files
105 | Thumbs.db
106 | Thumbs.db:encryptable
107 | ehthumbs.db
108 | ehthumbs_vista.db
109 |
110 | # Dump file
111 | *.stackdump
112 |
113 | # Folder config file
114 | [Dd]esktop.ini
115 |
116 | # Recycle Bin used on file shares
117 | $RECYCLE.BIN/
118 |
119 | # Windows Installer files
120 | *.cab
121 | *.msi
122 | *.msix
123 | *.msm
124 | *.msp
125 |
126 | # Windows shortcuts
127 | *.lnk
128 |
129 | ### AndroidStudio ###
130 | # Covers files to be ignored for android development using Android Studio.
131 |
132 | # Built application files
133 | *.ap_
134 | *.aab
135 |
136 | # Files for the ART/Dalvik VM
137 | *.dex
138 |
139 | # Java class files
140 |
141 | # Generated files
142 | bin/
143 | gen/
144 | out/
145 |
146 | # Gradle files
147 | .gradle
148 |
149 | # Signing files
150 | .signing/
151 |
152 | # Local configuration file (sdk path, etc)
153 |
154 | # Proguard folder generated by Eclipse
155 | proguard/
156 |
157 | # Log Files
158 |
159 | # Android Studio
160 | /*/build/
161 | /*/local.properties
162 | /*/out
163 | /*/*/build
164 | /*/*/production
165 | .navigation/
166 | *.ipr
167 | *~
168 | *.swp
169 |
170 | # Keystore files
171 |
172 | # Google Services (e.g. APIs or Firebase)
173 | # google-services.json
174 |
175 | # Android Patch
176 |
177 | # External native build folder generated in Android Studio 2.2 and later
178 | .externalNativeBuild
179 |
180 | # NDK
181 | obj/
182 |
183 | # IntelliJ IDEA
184 | *.iws
185 | /out/
186 |
187 | # User-specific configurations
188 | .idea/caches/
189 | .idea/libraries/
190 | .idea/shelf/
191 | .idea/workspace.xml
192 | .idea/tasks.xml
193 | .idea/.name
194 | .idea/compiler.xml
195 | .idea/copyright/profiles_settings.xml
196 | .idea/encodings.xml
197 | .idea/misc.xml
198 | .idea/modules.xml
199 | .idea/scopes/scope_settings.xml
200 | .idea/dictionaries
201 | .idea/vcs.xml
202 | .idea/jsLibraryMappings.xml
203 | .idea/datasources.xml
204 | .idea/dataSources.ids
205 | .idea/sqlDataSources.xml
206 | .idea/dynamic.xml
207 | .idea/uiDesigner.xml
208 | .idea/assetWizardSettings.xml
209 | .idea/gradle.xml
210 | .idea/jarRepositories.xml
211 | .idea/navEditor.xml
212 |
213 | # Legacy Eclipse project files
214 | .classpath
215 | .project
216 | .cproject
217 | .settings/
218 |
219 | # Mobile Tools for Java (J2ME)
220 |
221 | # Package Files #
222 |
223 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
224 |
225 | ## Plugin-specific files:
226 |
227 | # mpeltonen/sbt-idea plugin
228 | .idea_modules/
229 |
230 | # JIRA plugin
231 | atlassian-ide-plugin.xml
232 |
233 | # Mongo Explorer plugin
234 | .idea/mongoSettings.xml
235 |
236 | # Crashlytics plugin (for Android Studio and IntelliJ)
237 | com_crashlytics_export_strings.xml
238 | crashlytics.properties
239 | crashlytics-build.properties
240 | fabric.properties
241 |
242 | ### AndroidStudio Patch ###
243 |
244 | !/gradle/wrapper/gradle-wrapper.jar
245 |
246 | # End of https://www.toptal.com/developers/gitignore/api/kotlin,android,androidstudio,macos,windows
247 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------