All Projects → santalu → textmatcher

santalu / textmatcher

Licence: Apache-2.0 License
A simple text watcher that matches specific targets like mention or hashtag in a string by defining rules

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to textmatcher

Socially
Socially is a textView which is able to create separate clickable views according to your requirements.
Stars: ✭ 28 (-58.21%)
Mutual labels:  hashtag, textview, mention
Sharpview
安卓带有尖角气泡的控件(TextView,ImageView,EditText,Layout),支持渐变色,圆角等自定义属性
Stars: ✭ 137 (+104.48%)
Mutual labels:  textview, edittext
Xrichtext
一个Android富文本类库,支持图文混排,支持编辑和预览,支持插入和删除图片。
Stars: ✭ 1,639 (+2346.27%)
Mutual labels:  textview, edittext
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-77.61%)
Mutual labels:  edittext, textwatcher
Spedittool
An efficient and scalable library for inputing and displaying gif or @mention on graph-text mixed TextView/EditText
Stars: ✭ 292 (+335.82%)
Mutual labels:  textview, edittext
Gsyricktext
类似微博的emoji表情、@人、话题等的EdiText,优化了编辑框中的光标点击和删除处理。TextView支持emoji表情、话题、链接、电话和@某人特殊显示的文本。
Stars: ✭ 651 (+871.64%)
Mutual labels:  textview, edittext
ShapeView
打造万能shape,再也不用写很多xml了,可以当做TextView,Button,EditText等多种控件,方便实用
Stars: ✭ 34 (-49.25%)
Mutual labels:  textview, edittext
Toggleedittextview
Easily switch between EditText and TextView seamlessly.
Stars: ✭ 146 (+117.91%)
Mutual labels:  textview, edittext
OrangeLabel
OrangeLabel is extensions of UILabel linkable, available line background and placeholder text
Stars: ✭ 19 (-71.64%)
Mutual labels:  hashtag, mention
Mentions
An easy way to add mentions and hashtags
Stars: ✭ 24 (-64.18%)
Mutual labels:  hashtag, mention
Hyena
鬣狗快速开发库(2018年6月停止维护)
Stars: ✭ 21 (-68.66%)
Mutual labels:  textview, edittext
KodeEditor
A simple code editor with syntax highlighting and pinch to zoom
Stars: ✭ 60 (-10.45%)
Mutual labels:  textview, edittext
CustomFontView
Custom View classes for TextView, EditText & Buttons - to set custom fonts
Stars: ✭ 26 (-61.19%)
Mutual labels:  textview, edittext
Rxmarkdown
📠Markdown for Android, supports TextView && EditText (Live Preview), supports code high light.
Stars: ✭ 714 (+965.67%)
Mutual labels:  textview, edittext
SuperShapeView
A smart custom view support shapes for ImageView, TextView ,EditView ,instead of shape.xml.(自定义形状控件,支持TextView,EditText)
Stars: ✭ 60 (-10.45%)
Mutual labels:  textview, edittext
TextViewPlus
an android library for setting custom font in xml layout
Stars: ✭ 27 (-59.7%)
Mutual labels:  textview, edittext
EasyMoney-Widgets
The widgets (EditText and TextView) for support of money requirements like currency, number formatting, comma formatting etc.
Stars: ✭ 91 (+35.82%)
Mutual labels:  textview, edittext
android-prefix-suffix-edit-text
EditText with support for non editable prefix and suffix.
Stars: ✭ 36 (-46.27%)
Mutual labels:  edittext
OutlineTextView
Android TextView with outline
Stars: ✭ 59 (-11.94%)
Mutual labels:  textview
currency-edittext
A Custom EditText implementation that allows formatting of currency-based numeric inputs.
Stars: ✭ 86 (+28.36%)
Mutual labels:  edittext

TextMatcher

Build Status

A simple text watcher that matches specific targets like mention or hashtag in a string by defining rules

How It Works

What is Style

Style is basically a clickable span which lets you customize visual attributes of targets.

It's also used to differentiate between targets. So it's strongly recommended to have a different style for each single rule.

Basic example:

class CustomStyle : Style() {

  override fun updateDrawState(ds: TextPaint) {
    super.updateDrawState(ds)
    ds.apply {
      isUnderlineText = false
      color = Color.DKGRAY
      typeface = Typeface.create(Typeface.MONOSPACE, Typeface.BOLD)
    }
  }
}

There are 3 built-in styles for easy implementation. This can be changed in future according to needs.

  1. SimpleStyle 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

  2. MentionStyle extends from SimpleStyle and intended to use only for mentions

  3. HashtagStyle extends from SimpleStyle and intended to use only for hashtags

What is Rule

Rule is simply definition of target boundaries and matching conditions. It's also used to apply styles for matching targets.

There are 3 built-in rules for easy implementation. This can be changed in future according to needs.

  1. SimpleRule 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.

  2. MentionRule extends from SimpleRule and matches targets which starts with @

  3. HashtagRule extends from SimpleRule and matches targets which starts with #

Widgets

There are 3 built-in widgets for easy implementation. This can be changed in future according to needs.

  1. MatcherTextView

  2. MatcherEditText

  3. MatcherInputEditText

Usage

1. Define Style

val mentionStyle = MentionStyle(
  textColor = ContextCompat.getColor(this, R.color.colorPrimary),
  isBold = true
)

2. Define and Register Rule

val mentionRule = MentionRule(
  allowedCharacters = "._-",
  style = mentionStyle
)

editText.addRule(mentionRule)

3. Register Listeners

To receive matching results on typing:

editText.setOnMatchListener { rule, text ->
}

To receive matching target's click event:

editText.setOnMatchClickListener { text->
}

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.santalu:textmatcher:1.0.6'
}

License

Copyright 2019 Fatih Santalu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].