• Stars
    star
    373
  • Rank 114,600 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android library designed for automatic formatting of text input by custom rules

Maven Central

Decoro

Android library designed for automatic formatting of text input by custom rules.

Installation

Add to the build.gradle of your app module:

dependencies {
    compile 'ru.tinkoff.decoro:decoro:$latestVersion'
}

Usage

String formatting

In examples below the content of the String text will be formatted according to a mask.

Example 1. Using predefined mask
Mask mask = new MaskImpl(PredefinedSlots.RUS_PHONE_NUMBER, true);
mask.insertFront("9995554433");
System.out.println(mask.toString()); // +7 (999) 555-44-33
Using custom mask

Example 2:

Slot[] slots = new UnderscoreDigitSlotsParser().parseSlots("___ ___");
Mask mask = MaskImpl.createTerminated(slots); // 'terminated' mask
mask.insertFront("9995554433");
System.out.println(mask.toString()); // 999 555

Example 3:

Slot[] slots = new UnderscoreDigitSlotsParser().parseSlots("___ ___");
Mask mask = MaskImpl.createNonTeminated(slots); // 'non-terminated' mask
mask.insertFront("9995554433");
System.out.println(mask.toString()); // 999 5554433

Formatting "on the fly"

In examples below all the user's text input to EditText will be formatted according to a mask.

Example 4. Using predefined mask
MaskImpl mask = MaskImpl.createTerminated(PredefinedSlots.CARD_NUMBER_USUAL);
FormatWatcher watcher = new MaskFormatWatcher(mask);
watcher.installOn(editText); // install on any TextView

sample static

Masks available out of the box:
PredefinedSlots.SINGLE_SLOT                   // Any character
PredefinedSlots.RUS_PHONE_NUMBER              // Russian phone number formatted as +7 (___) ___-__-__ (digits only)
PredefinedSlots.RUS_PASSPORT                  // Series and number of russian passport formatted as ____ ______  (digits only)
PredefinedSlots.CARD_NUMBER_STANDARD          // Credit card number formatted as ____ ____ ____ ____ (digits only)
PredefinedSlots.CARD_NUMBER_STANDARD_MASKABLE // Credit card number formatted as ____ ____ ____ ____ (digits and chars 'X', 'x', '*')
PredefinedSlots.CARD_NUMBER_MAESTRO           // Credit card number formatted as ________ ____ (digits only)
PredefinedSlots.CARD_NUMBER_MAESTRO_MASKABLE  // Credit card number formatted as ________ ____ (digits and chars 'X', 'x', '*')
Example 5. Using custom mask
Slot[] slots = new UnderscoreDigitSlotsParser().parseSlots("___ ___ ___");
FormatWatcher formatWatcher = new MaskFormatWatcher(MaskImpl.createTerminated(slots));
formatWatcher.installOn(editText); // install on any TextView

sample static

Migration

In version 1.1.0 class FormatWatcherImpl was renamed to DescriptorFormatWatcher. Also this version introduced MaskFormatWatcher that offers more clean API than DescriptorFormatWatcher.

References

More examples and details can be found in our wiki (in Russian yet).

More Repositories

1

ScrollingPagerIndicator

Pager indicator inspired by Instagram. Lightweight and easy to set up.
Java
561
star
2

EasyDi

Effective DI library for rapid development in 200 lines of code.
Swift
100
star
3

tinkoff-asdk-android

Kotlin
56
star
4

tinkoff-asdk-ios

Tinkoff Acquiring SDK
Swift
45
star
5

tinkoff-asdk-ios-old

Tinkoff Acquiring SDK for iOS
Objective-C
36
star
6

tinkoff-asdk-android-old

Tinkoff Acquiring SDK for Android
Java
33
star
7

TinkoffConcurrency

A toolset that makes Swift Concurrency a bit easier
Swift
33
star
8

droidherd

DroidHerd service - k8s android farm orchestration service
Kotlin
31
star
9

TiRecycler

Coolest way to work with Recycler and Adapter
Kotlin
24
star
10

TinkoffMockStrapping

Library for unifying the approach to network mocking in iOS unit- & UI-tests.
Swift
24
star
11

tcscustomrowactionfactory

TCSTableViewRowActionFactory allows you to setup the swipe actions for cells in a table view using UIView and some other convenient methods
Swift
24
star
12

TinkoffID-iOS

SDK авторизации iOS приложений через Тинькофф
Swift
19
star
13

EBA

EBA Architecture Sample
Kotlin
17
star
14

KoTEA

TEA architecture on coroutines
Kotlin
10
star
15

vkarmane-sdk-android

Kotlin
7
star
16

iosDynamicLibraryBuilder

Scripts to build dynamic versions of iOS libraries from static ones
Ruby
7
star
17

fastlane-plugin-compilation_time_report

Generate custom HTML report compilation time of each Swift func
Ruby
5
star
18

TinkoffID-Android

SDK авторизации Android приложений через Тинькофф
Kotlin
5
star
19

vkarmane-sdk-ios

Swift
5
star
20

tisdk-ios

Tinkoff Insurance SDK for iOS
Objective-C
4
star
21

InjectionsCheck

Small library to check injections into Swift objects
Swift
4
star
22

demo-tisdk

Kotlin
2
star