TaggerString is very light library which allows to build dynamic string resource in much more readable way.

Related tags

Tools TaggerString
Overview

TaggerString

TaggerString is very light library which allows to build dynamic string resource in much more readable way.

License Android Arsenal

I guess that every Android developer has seen or added similar piece of code in string.xml file:

<string name="user_description_string">I am %s and I am %d years old</string>`

Some probably discovered that above code is a little bit not readable and extended such declarations to something like this:

<string name="user_description_string">I am $1%s and I am $2%d years old</string>

And in source code:

String userDesc = String.format(resources.getString(R.string.user_description_string), "John Kowalski", 27);

So far so good but maybe this could be a little bit more readable ? Yes, it can be (at least in my opinion) - TaggerString.

In source code above example will look like :

  TaggerString taggerString = TaggerString.from(getString(R.string.user_description_string));
  taggerString.with("user_name", "John Kowalski");
  taggerString.with("user_age", 27);
  tvExampleOne.setText(taggerString.format());

And our string resource looks

<string name="example_one">My name is {user_name} and I am a {developer_role}</string>

If you want to use bold (TaggerStyleType.BOLD), italic (TaggerStyleType.ITALIC) or underscore (TaggerStyleType.UNDERLINE), please go ahead:

TaggerString taggerString = TaggerString.from(getString(R.string.user_description_string));
taggerString.with("user_name", "John Kowalski", TaggerStyleType.BOLD);
taggerString.with("user_age", 27, TaggerStyleType.UNDERLINE);
tvExampleOne.setText(taggerString.formatCustom());

Please note that in this case method formatCustom() returns Spanned object.

Multiple formatting (since version 1.1.0)

If you want to apply few tags for one string go ahead and do it:

taggerString.with("developer_role", "Android Software Developer", TaggerStyleType.UNDERLINE, TaggerStyleType.BOLD, TaggerStyleType.ITALIC);

Usage

If you are using gradle please add below:

dependencies {
    compile 'com.github.polok.taggerstring:library:1.0.0'
}

Since version 1.1.0 the artefactId was changed from library to taggerstring:

dependencies {
    compile 'com.github.polok.taggerstring:taggerstring:1.1.0'
}

Developed By

Marcin Polak - mpolak87(at).gmail.com

License

Copyright 2015 Marcin Polak

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.
You might also like...
Remote script to create a maven compatible release of an android library (aar)

release-android-library 🚨 Deprecated 🚨 This script is deprecated in favour of: novoda/bintray-release Remote script to create a maven compatible rel

Simple library to generate and view PDF in Android
Simple library to generate and view PDF in Android

PDFCreatorAndroid Simple library to generate and view PDF in Android A simple library to create and view PDF with zero dependency Or native code. Add

:inbox_tray: [Android Library] Hunt down all package information
:inbox_tray: [Android Library] Hunt down all package information

Android library to hunt down package information. The library is built for simplicity and approachability. It not only eliminates most boilerplate cod

An android library that handles the closing of your app interactively.
An android library that handles the closing of your app interactively.

Shutdown A library that handles the closing of your app interactively. Overview of Shutdown library Shutdown library handles the closing of your app i

Android Material Design Theme UI and Tool Library. Support: 4.0.3~O
Android Material Design Theme UI and Tool Library. Support: 4.0.3~O

GitHub OSChina 中文 English Genius-Android Genius-Android: by Material Design style and some commonly used packages. Starting in 2015, The divided into

The Kotlin fake data generator library!
The Kotlin fake data generator library!

Fakeit This library is a port of the Ruby gem Faker. It generates realistic fake data — like names, emails, dates, countries — for a variety of scenar

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.

usb-serial-for-android This is a driver library for communication with Arduinos and other USB serial hardware on Android, using the Android USB Host M

🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.
🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.

SlidingUpMenu A library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet. Gradle Dependency

Phrase is an Android string resource templating library

Phrase - Android string formatting CharSequence formatted = Phrase.from("Hi {first_name}, you are {age} years old.") .put("first_name", firstName)

AndroidBriefActions - Android library for sending and observing non persistent actions such as showing a message; nice readable way to call navigation actions from ViewModel or Activity/Fragment.

implementation "com.vladmarkovic.briefactions:briefactions:$briefActionsVersion" Benefits Why use brief-actions library pattern: Prevent short-term ac

Dynamic-UI-From-JSON - A Sample Android app to show dynamic UI generation from Json
Dynamic-UI-From-JSON - A Sample Android app to show dynamic UI generation from Json

Dynamic UI from JSON Functionality The app's functionality includes: The app gen

 A light-weight Android client for Polyhoot! Written in Kotlin and made with Material 3 and Dynamic Colors support.
A light-weight Android client for Polyhoot! Written in Kotlin and made with Material 3 and Dynamic Colors support.

A light-weight Android client for Polyhoot! Written in Kotlin and made with Material 3 and Dynamic Colors support.

A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.
A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.

Measure App A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted o

Helps to find your surrounding's light value (for android only) using device light sensor

react-native-ambient-light-sensor Helps to find your surrounding's light value (in lux unit) (for android only) using device light sensor Installation

BlurView - A very fast and dynamic blur layout for Android
BlurView - A very fast and dynamic blur layout for Android

BlurView - A very fast and dynamic blur layout for Android

Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.

Stetho Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature nat

AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.
AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

AwesomeSwitch AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard swi

📭 Extension to Ktor’s routing system to add object oriented routing and much more. 💜

📭 Ktor Routing Extensions Extension to Ktor’s routing system to add object-oriented routing and much more. 💜 Why? This extension library was created

This custom snack bar will help you display much more personalized app toast
This custom snack bar will help you display much more personalized app toast

💥 Presentation Using the native android class of snack bar. This custom snack bar will help you display much more personalized app

Comments
  • java.lang.ArrayIndexOutOfBoundsException: length  index  at java.util.regex.Matcher.group

    java.lang.ArrayIndexOutOfBoundsException: length index at java.util.regex.Matcher.group

    Hi There,

    It will throw "java.lang.ArrayIndexOutOfBoundsException: length index at java.util.regex.Matcher.group" if there is "$" following with a number. I googled it and found out that this answer. http://stackoverflow.com/a/20533228/4068957. Just for you to know.

    Thanks for providing this useful library.

    Tony

    opened by TonyTangAndroid 3
  • Gradle link  broken

    Gradle link broken

    could you confirm this please? I've tried:

    compile 'com.github.polok.taggerstring:taggerstring:1.1.0'
    compile 'com.github.polok.taggerstring:taggerstring:1.0.0'
    compile 'com.github.polok.taggerstring:1.0.0'
    compile 'com.github.polok.taggerstring:library:1.1.0'
    
    opened by younes0 2
  • Adding multiple formatting

    Adding multiple formatting

    Hello Marcin!

    Nice library. I've added multiple style formatting, which can be useful when someone wants to apply a few styles at the same time. Here is a small code snippet presenting the idea.

    taggerString.with("developer_role", "Android Software Developer", TaggerStyleType.UNDERLINE, TaggerStyleType.BOLD, TaggerStyleType.ITALIC);
    

    In order to compile your project I needed to:

    • update com.android.tools.build:gradle:0.12.2 to com.android.tools.build:gradle:1.0.0 in build.gradle file
    • change distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip to distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip in gradle/wrapper/gradle-wrapper.properties
    • remove "applicationId" in library/build.gradle
    • replace "runProguard" to "minifyEnabled" in library/build.gradle and app/build.gradle file

    I didn't add these changes to the commit, because I don't know, which version of Android Studio you are using :-).

    I'm using Android Studio 1.0.2 from Canary Channel. If you are using the same version of Android Studio, mentioned changes have to be applied as well.

    opened by pwittchen 1
  • Missing bit in README

    Missing bit in README

    In the README you introduce this example:

      TaggerString taggerString = TaggerString.from(getString(R.string.user_description_string));
      taggerString.with("user_name", "John Kowalski");
      taggerString.with("user_age", 27);
    

    but you don't show how the string resource would look like in order to make this work. I assume it would be something like

    <string name="user_description_string">I am {user_name} and I am {user_age} years old</string>
    

    but you should probably be a bit more explicit.

    opened by ManuelPeinado 1
Owner
polok
polok
proguard resource for Android by wechat team

AndResGuard Read this in other languages: English, 简体中文. AndResGuard is a tooling for reducing your apk size, it works like the ProGuard for Java sour

shwenzhang 8.1k Jan 9, 2023
Android Resource Manager application to manage and analysis your app resources with many features like image resize, Color, Dimens and code Analysis

Android Resource Manager application to manage and analysis your app resources with many features like image resize, Color, Dimens and code Analysis

Amr Hesham 26 Nov 16, 2022
SVG to Android VectorDrawable XML resource file

svg2android [Deprecated - use official Vector Asset Studio directly from Android Studio] Convert SVG to Android VectorDrawable XML resource file. Extr

INLOOPX 1.7k Dec 29, 2022
This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically.

#Android Localizationer This is a Android Studio/ IntelliJ IDEA plugin to localize your Android app, translate your string resources automactically. T

Wesley Lin 822 Dec 8, 2022
Dynamic Delivery everywhere through a common API

A set of tools geared towards making Dynamic Delivery universally available, regardless of underlying App Store / distribution platform, while also providing a single unified Android client API and a streamlined developer experience.

Jesper Ã…man 272 Dec 9, 2022
A library which will save you a lot of time from writing the same intent creation code. it consist of many intent creation codes like Share, Contacts, Email and etc, which you can easily use.

Android-Intent-Library A library which will save you a lot of time from writing the same intent creation code. it consist of many intent creation code

Next 67 Aug 24, 2022
A super fast build tool for Android, an alternative to Instant Run

Freeline Freeline is a super fast build tool for Android and an alternative to Instant Run. Caching reusable class files and resource indices, it enab

Alibaba 5.5k Jan 2, 2023
Tool for create complex morphing animations using VectorDrawables (allows morphing between any pair of SVG images)

VectAlign VectAlign (a.k.a. VectorDrawableAlign) is a developer's tool which automagically aligns two VectorDrawable "pathData" strings (or SVG images

Stefano Bonetta 2k Dec 29, 2022
Library that makes it possible to read, edit and write CSV files

AdaptiveTableLayout Welcome the new CSV Library AdaptiveTableLayout for Android by Cleveroad Pay your attention to our new library that makes it possi

Cleveroad 1.9k Jan 6, 2023
Android Library Finder

alfi Android Library Finder Search through thousands of android libraries that can help you scale your projects elegantly Usage Search for something a

César Ferreira 509 Dec 8, 2022