Highlights various information (like credit cards, phone numbers, number values) in TextView and adds actions on it.
Definition of
omni-
: All, Universally
- Put Github username and token with
read:packages
scope intolocal.properties
file:
gpr.user=<github username>
gpr.key=<token>
- Add Github Maven repository to the root
build.gradle
script:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
allprojects {
repositories {
...
maven {
url "https://maven.pkg.github.com/StevenRudenko/OmniText"
credentials {
username properties.getProperty("gpr.user")
password properties.getProperty("gpr.key")
}
}
}
}
- Add dependency to app
build.gradle
implementation "com.github.stevenrudenko:omnitext:1.0.0"
Include the OmniTextView
into layout and use it as standard TextView
:
<com.github.stevenrudenko.omnitext.OmniTextView
android:id="@+id/omniText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
To subscribe for an omni-actions, add next tines into Activity
or Fragment
code:
val omniText = view.findViewById<OmniTextView>(R.id.omniText)
omniText.onOmniAction = { omni ->
// use omni data here
}
There are next omni
parsers available:
- Custom text wrapped with tag:
{omni}Text Here{/onmi}
- Numbers:
12.45
,0.23
,244532
- Phone numbers:
+1-234-567-89-00
- Credit cards (American Express, MasterCard, Visa, etc.):
371449635398431
,4012 8888 8888 1881
,6011-0009-9013-9424