项目作者: tomvlk

项目描述 :
:twisted_rightwards_arrows: ManiaPlanet Color Style parser and formatter for Android
高级语言: Java
项目地址: git://github.com/tomvlk/MPFormatter_android.git
创建时间: 2015-03-04T11:48:30Z
项目社区:https://github.com/tomvlk/MPFormatter_android

开源协议:MIT License

下载


Build Status

MPFormatter_android

A ManiaPlanet Color Style parser and formatter for Android. Currently basicly only working with all the styles. But in future it can also strip styles, links and colors and have more options.
It will output a Spanned object that can be used in TextViews and more Android controls that support Spanned Strings.

Installation

You can use gradle to compile it, it’s in the jCentral repository and in the Maven Central.

  1. dependencies {
  2. compile 'net.tvalk.mpformatter:mpformatter:1.3.6'
  3. }

If you want to stay updated, replace the ‘1.3.6’ with ‘1.+’. But can break things when there is a new version.
Maybe you need to change your repositories for gradle:

  1. repositories {
  2. mavenCentral()
  3. jcenter()
  4. }

Usage

To get the Spanned from a styled nickname for example, use:

  1. String nickname = "$F80$i$o$SToffe$z$06FSmurf $z$n$l[http://goo.gl/y4M9VK][App]$l";
  2. Spanned styledNickname = new MPFormatter(nickname).parse().getSpannable();

This will result in:
Example result from above code

You can also strip the colors, links or styles with the functions stripColors(), stripLinks() and stripStyles() on the parse() return to strip it. You can also get a string without any styles, colors or links with getString() on the parse() return

For example, to strip the links in this nickname:

  1. String nickname = "$F80$i$o$SToffe$z$06FSmurf $z$n$l[http://goo.gl/y4M9VK][App]$l";
  2. Spanned styledNickname = new MPFormatter(nickname).parse().stripLinks().getSpannable();

Licence

See LICENCE file for MIT licence.