{"id":13611426,"url":"https://github.com/santalu/textmatcher","last_synced_at":"2025-09-21T12:33:14.001Z","repository":{"id":144134450,"uuid":"208255530","full_name":"santalu/textmatcher","owner":"santalu","description":"A simple text watcher that matches specific targets like mention or hashtag in a string by defining rules","archived":false,"fork":false,"pushed_at":"2020-02-07T17:38:23.000Z","size":174,"stargazers_count":65,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T12:25:23.801Z","etag":null,"topics":["android","edittext","hashtag","mention","textinputfield","textview","textwatcher"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santalu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-09-13T11:57:56.000Z","updated_at":"2024-12-12T18:13:22.000Z","dependencies_parsed_at":"2024-01-16T23:31:12.138Z","dependency_job_id":"ef497768-28ab-425b-af44-025fce7f3ff9","html_url":"https://github.com/santalu/textmatcher","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santalu%2Ftextmatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santalu%2Ftextmatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santalu%2Ftextmatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santalu%2Ftextmatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santalu","download_url":"https://codeload.github.com/santalu/textmatcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233754572,"owners_count":18725032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","edittext","hashtag","mention","textinputfield","textview","textwatcher"],"created_at":"2024-08-01T19:01:55.163Z","updated_at":"2025-09-21T12:33:08.687Z","avatar_url":"https://github.com/santalu.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# TextMatcher\n\n[![](https://www.jitpack.io/v/santalu/textmatcher.svg)](https://www.jitpack.io/#santalu/textmatcher)\n[![Build Status](https://travis-ci.org/santalu/textmatcher.svg?branch=master)](https://travis-ci.org/santalu/textmatcher)\n\nA simple text watcher that matches specific targets like `mention` or `hashtag` in a string by defining `rules`\n\n## How It Works\n\n#### What is [`Style`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/style/Style.kt)\n\nStyle is basically a clickable span which lets you customize visual attributes of targets. \n\nIt's also used to differentiate between targets. So it's strongly recommended to have a different style for each single rule.\n\nBasic example: \n\n```\nclass CustomStyle : Style() {\n\n  override fun updateDrawState(ds: TextPaint) {\n    super.updateDrawState(ds)\n    ds.apply {\n      isUnderlineText = false\n      color = Color.DKGRAY\n      typeface = Typeface.create(Typeface.MONOSPACE, Typeface.BOLD)\n    }\n  }\n}\n```\n\nThere are 3 built-in styles for easy implementation. This can be changed in future according to needs.\n\n1. [`SimpleStyle`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/style/SimpleStyle.kt) is a open class which takes `textColor`, `isUnderline`, `isBold` and `typeface` as parameter to let you easily change these attributes without creating or overriding any method. For further customizations you can still override the `updateDrawState` method\n\n2. [`MentionStyle`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/style/MentionStyle.kt) extends from `SimpleStyle` and intended to use only for mentions\n\n3. [`HashtagStyle`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/style/HashtagStyle.kt) extends from `SimpleStyle` and intended to use only for hashtags\n\n#### What is [`Rule`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/rule/Rule.kt)\n\n`Rule` is simply definition of target boundaries and matching conditions. It's also used to apply styles for matching targets.\n\nThere are 3 built-in rules for easy implementation. This can be changed in future according to needs.\n\n1. [`SimpleRule`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/rule/SimpleRule.kt) is a open class which takes `prefixes`, `allowedCharacters` and `style` as parameter which matches targets starting with `prefixes` and ending with space or any word breaking character.\n\n2. [`MentionRule`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/rule/MentionRule.kt) extends from `SimpleRule` and matches targets which starts with `@`\n\n3. [`HashtagRule`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/rule/HashtagRule.kt) extends from `SimpleRule` and matches targets which starts with `#`\n\n#### Widgets\n\nThere are 3 built-in widgets for easy implementation. This can be changed in future according to needs.\n\n1. [`MatcherTextView`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/widget/MatcherTextView.kt)\n\n2. [`MatcherEditText`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/widget/MatcherEditText.kt)\n\n3. [`MatcherInputEditText`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/widget/MatcherInputEditText.kt)\n\n## Usage\n\n#### 1. Define [`Style`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/style/Style.kt)\n\n    val mentionStyle = MentionStyle(\n      textColor = ContextCompat.getColor(this, R.color.colorPrimary),\n      isBold = true\n    )\n\n#### 2. Define and Register [`Rule`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/rule/Rule.kt)\n\n    val mentionRule = MentionRule(\n      allowedCharacters = \"._-\",\n      style = mentionStyle\n    )\n    \n    editText.addRule(mentionRule)\n\n#### 3. Register [`Listeners`](https://github.com/santalu/textmatcher/blob/master/library/src/main/java/com/santalu/textmatcher/Commons.kt)\n\nTo receive matching results on typing:\n\n    editText.setOnMatchListener { rule, text -\u003e\n    }\n\nTo receive matching target's click event:\n\n    editText.setOnMatchClickListener { text-\u003e\n    }\n\n## Gradle\n```\nallprojects {\n  repositories {\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\n\n```\ndependencies {\n  implementation 'com.github.santalu:textmatcher:1.0.6'\n}\n```\n## License\n```\nCopyright 2019 Fatih Santalu\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantalu%2Ftextmatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantalu%2Ftextmatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantalu%2Ftextmatcher/lists"}