├── .gitignore
├── .travis.yml
├── LICENSE
├── LICENSE.velocity
├── README.md
├── app
└── manifest-merger-release-report.txt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── bluejamesbond
│ │ └── text
│ │ ├── ConcurrentModifiableLinkedList.java
│ │ ├── Console.java
│ │ ├── DocumentView.java
│ │ ├── IDocumentLayout.java
│ │ ├── SpannableDocumentLayout.java
│ │ ├── StringDocumentLayout.java
│ │ ├── Styled.java
│ │ ├── hyphen
│ │ ├── DefaultHyphenator.java
│ │ ├── IHyphenator.java
│ │ └── SqueezeHyphenator.java
│ │ └── style
│ │ ├── CenterSpan.java
│ │ ├── Direction.java
│ │ ├── DirectionSpan.java
│ │ ├── JustifiedSpan.java
│ │ ├── LeftSpan.java
│ │ ├── RightSpan.java
│ │ ├── TextAlignment.java
│ │ └── TextAlignmentSpan.java
│ └── res
│ └── values
│ └── attrs.xml
├── misc
├── comparisons.psd
├── logo.png
└── logo.psd
├── sample
├── .gitignore
├── build.gradle
├── manifest-merger-release-report.txt
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── fonts
│ │ ├── helvetica.ttf
│ │ └── notosans.ttf
│ ├── java
│ └── com
│ │ └── bluejamesbond
│ │ └── text
│ │ └── sample
│ │ ├── helper
│ │ ├── ArticleBuilder.java
│ │ ├── FontsOverride.java
│ │ ├── MyLeadingMarginSpan2.java
│ │ ├── MyQuoteSpan.java
│ │ ├── PressableDocumentView.java
│ │ ├── TestActivity.java
│ │ ├── TestList.java
│ │ └── Utils.java
│ │ └── test
│ │ ├── ChineseCharacterTest.java
│ │ ├── ClickableSpanTest.java
│ │ ├── ComplexLayoutTest.java
│ │ ├── CustomHyphenatorTest.java
│ │ ├── ForceNoCacheXMLTest.java
│ │ ├── HyphenatedTest.java
│ │ ├── ImageSpanTest.java
│ │ ├── LeadingMarginSpan2Test.java
│ │ ├── LineBreakTest.java
│ │ ├── ListViewTest.java
│ │ ├── LongFormattedTextTest.java
│ │ ├── LongPlainTextTest.java
│ │ ├── MixedRTLTest.java
│ │ ├── NewLineTest.java
│ │ ├── QuoteSpanTest.java
│ │ ├── RTLTest.java
│ │ ├── ShortFormattedTextTest.java
│ │ ├── TextUpdateTest.java
│ │ ├── TextViewTest.java
│ │ ├── WordSpacingTest.java
│ │ └── XMLTest.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable-xxxhdpi
│ └── ic_launcher.png
│ ├── drawable
│ ├── list__border_bottom.xml
│ ├── progress__background.xml
│ ├── simple_button__background.xml
│ ├── simple_button__background_default.xml
│ ├── simple_button__background_pressed.xml
│ └── test_listview_item_background.xml
│ ├── layout
│ ├── test_activity.xml
│ ├── test_complex_layout.xml
│ ├── test_listview.xml
│ ├── test_listview_item.xml
│ ├── test_textview_xml_activity.xml
│ ├── test_xml_activity.xml
│ ├── test_xml_activity_no_cache.xml
│ └── testlist_activity.xml
│ └── values
│ ├── dimens.xml
│ └── strings.xml
├── screenshots
├── chinese.png
├── leadMarginSpan2.png
├── quoteSpan.png
├── rtl-reverse.png
└── testlist.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
8 | # Created by https://www.gitignore.io
9 |
10 | ### Android ###
11 | # Built application files
12 | *.apk
13 | *.ap_
14 |
15 | # Files for the Dalvik VM
16 | *.dex
17 |
18 | # Java class files
19 | *.class
20 |
21 | # Generated files
22 | bin/
23 | gen/
24 |
25 | # Gradle files
26 | .gradle/
27 | build/
28 |
29 | # Local configuration file (sdk path, etc)
30 | local.properties
31 |
32 | # Proguard folder generated by Eclipse
33 | proguard/
34 |
35 | # Log Files
36 | *.log
37 |
38 |
39 | ### Intellij ###
40 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
41 |
42 | *.iml
43 |
44 | ## Directory-based project format:
45 | .idea/
46 | # if you remove the above rule, at least ignore the following:
47 |
48 | # User-specific stuff:
49 | # .idea/workspace.xml
50 | # .idea/tasks.xml
51 | # .idea/dictionaries
52 |
53 | # Sensitive or high-churn files:
54 | # .idea/dataSources.ids
55 | # .idea/dataSources.xml
56 | # .idea/sqlDataSources.xml
57 | # .idea/dynamic.xml
58 | # .idea/uiDesigner.xml
59 |
60 | # Gradle:
61 | # .idea/gradle.xml
62 | # .idea/libraries
63 |
64 | # Mongo Explorer plugin:
65 | # .idea/mongoSettings.xml
66 |
67 | ## File-based project format:
68 | *.ipr
69 | *.iws
70 |
71 | ## Plugin-specific files:
72 |
73 | # IntelliJ
74 | out/
75 |
76 | # mpeltonen/sbt-idea plugin
77 | .idea_modules/
78 |
79 | # JIRA plugin
80 | atlassian-ide-plugin.xml
81 |
82 | # Crashlytics plugin (for Android Studio and IntelliJ)
83 | com_crashlytics_export_strings.xml
84 | crashlytics.properties
85 | crashlytics-build.properties
86 |
87 |
88 | ### Gradle ###
89 | .gradle
90 | build/
91 |
92 | # Ignore Gradle GUI config
93 | gradle-app.setting
94 |
95 |
96 | ### Maven ###
97 | target/
98 | pom.xml.tag
99 | pom.xml.releaseBackup
100 | pom.xml.versionsBackup
101 | pom.xml.next
102 | release.properties
103 |
104 |
105 | ### Eclipse ###
106 | *.pydevproject
107 | .metadata
108 | .gradle
109 | bin/
110 | tmp/
111 | *.tmp
112 | *.bak
113 | *.swp
114 | *~.nib
115 | local.properties
116 | .settings/
117 | .loadpath
118 |
119 | # External tool builders
120 | .externalToolBuilders/
121 |
122 | # Locally stored "Eclipse launch configurations"
123 | *.launch
124 |
125 | # CDT-specific
126 | .cproject
127 |
128 | # PDT-specific
129 | .buildpath
130 |
131 | # sbteclipse plugin
132 | .target
133 |
134 | # TeXlipse plugin
135 | .texlipse
136 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | android:
3 | components:
4 | - platform-tools
5 | - android-16
6 | - build-tools-21.1.2
7 | - extra
8 |
9 | jdk: oraclejdk7
10 |
11 | notifications:
12 | email: false
13 |
14 | before_install:
15 | - sudo apt-get update -qq
16 | - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null; fi
17 |
18 | script:
19 | - ./gradlew clean build
20 |
--------------------------------------------------------------------------------
/LICENSE.velocity:
--------------------------------------------------------------------------------
1 | Copyright $today.year Mathew Kurian
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 |
17 | $file.fileName
18 | @author Mathew Kurian
19 |
20 | From TextJustify-Android Library v2.0
21 | https://github.com/bluejamesbond/TextJustify-Android
22 |
23 | Please report any issues
24 | https://github.com/bluejamesbond/TextJustify-Android/issues
25 |
26 | Date: $today
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://gratipay.com/bluejamesbond/) [](https://android-arsenal.com/details/1/1318) [](https://travis-ci.org/bluejamesbond/TextJustify-Android) [](https://maven-badges.herokuapp.com/maven-central/com.github.bluejamesbond/textjustify-android)
2 | 
3 | =======
4 |
5 | **Android Full Justification**
6 |
7 | #About
8 | This library will provide you a way to justify text. It supports both plain text and Spannables. Additionally, the library can auto-hyphentate your displayed content (thanks to [@muriloandrade](https://github.com/muriloandrade)).
9 |
10 | *Compatible for Android 2.2 to 5.X*
11 |
12 | #Screenshot
13 | 
14 |
15 | #Demo
16 | [](https://play.google.com/store/apps/details?id=com.bluejamesbond.text.sample)
17 |
18 | #Recent
19 | **01/11/2015** ► Added support for very long documents with fading and progress listener
20 | **01/10/2015** ► Refractored / renamed classes
21 | **01/04/2015** ► Improved caching support which allows for smooth scrolling
22 | **01/02/2015** ► Added XML attributes for `DocumentView`
23 |
24 | #Wiki
25 | For examples, tests, and API refer to the [Android-TextJustify Wiki](https://github.com/bluejamesbond/TextJustify-Android/wiki/1-%C2%B7-Home).
26 |
27 | #Install
28 | Just add to your `build.gradle`
29 | ```gradle
30 | dependencies {
31 | compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
32 | }
33 | ```
34 |
35 | #Known Issues
36 | | Status| Issues |
37 | | :------------: |:---------------|
38 | | **`CLOSED`** | Scroll caching for very large documents i.e. > 4000 paragaphs |
39 | | **`OPEN`** | Add letter-spacing feature like CSS |
40 | | **`OPEN`** | Improve text strike-through |
41 | | **`OPEN`** | Improve text underline |
42 | | **`CLOSED`** | Support more features like `TextView` in terms of `Paint` settings |
43 |
--------------------------------------------------------------------------------
/app/manifest-merger-release-report.txt:
--------------------------------------------------------------------------------
1 | -- Merging decision tree log ---
2 | manifest
3 | ADDED from AndroidManifest.xml:2:1
4 | xmlns:android
5 | ADDED from AndroidManifest.xml:2:11
6 | package
7 | ADDED from AndroidManifest.xml:3:5
8 | INJECTED from AndroidManifest.xml:0:0
9 | INJECTED from AndroidManifest.xml:0:0
10 | android:versionName
11 | INJECTED from AndroidManifest.xml:0:0
12 | INJECTED from AndroidManifest.xml:0:0
13 | android:versionCode
14 | INJECTED from AndroidManifest.xml:0:0
15 | INJECTED from AndroidManifest.xml:0:0
16 | application
17 | ADDED from AndroidManifest.xml:5:5
18 | MERGED from TextJustify-Android:library:unspecified:12:5
19 | android:label
20 | ADDED from AndroidManifest.xml:8:9
21 | android:allowBackup
22 | ADDED from AndroidManifest.xml:6:9
23 | android:icon
24 | ADDED from AndroidManifest.xml:7:9
25 | android:theme
26 | ADDED from AndroidManifest.xml:9:9
27 | activity#com.bluejamesbond.text.sample.helper.TestList
28 | ADDED from AndroidManifest.xml:10:9
29 | android:label
30 | ADDED from AndroidManifest.xml:12:13
31 | android:theme
32 | ADDED from AndroidManifest.xml:13:13
33 | android:name
34 | ADDED from AndroidManifest.xml:11:13
35 | intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
36 | ADDED from AndroidManifest.xml:14:13
37 | action#android.intent.action.MAIN
38 | ADDED from AndroidManifest.xml:15:17
39 | android:name
40 | ADDED from AndroidManifest.xml:15:25
41 | category#android.intent.category.LAUNCHER
42 | ADDED from AndroidManifest.xml:16:17
43 | android:name
44 | ADDED from AndroidManifest.xml:16:27
45 | activity#com.bluejamesbond.text.sample.test.FormattedTextTest
46 | ADDED from AndroidManifest.xml:19:9
47 | android:theme
48 | ADDED from AndroidManifest.xml:21:13
49 | android:name
50 | ADDED from AndroidManifest.xml:20:13
51 | activity#com.bluejamesbond.text.sample.test.LeadingMarginSpan2Test
52 | ADDED from AndroidManifest.xml:22:9
53 | android:theme
54 | ADDED from AndroidManifest.xml:24:13
55 | android:name
56 | ADDED from AndroidManifest.xml:23:13
57 | activity#com.bluejamesbond.text.sample.test.LineBreakTest
58 | ADDED from AndroidManifest.xml:25:9
59 | android:theme
60 | ADDED from AndroidManifest.xml:27:13
61 | android:name
62 | ADDED from AndroidManifest.xml:26:13
63 | activity#com.bluejamesbond.text.sample.test.PlainTextTest
64 | ADDED from AndroidManifest.xml:28:9
65 | android:theme
66 | ADDED from AndroidManifest.xml:30:13
67 | android:name
68 | ADDED from AndroidManifest.xml:29:13
69 | activity#com.bluejamesbond.text.sample.test.QuoteSpanTest
70 | ADDED from AndroidManifest.xml:31:9
71 | android:theme
72 | ADDED from AndroidManifest.xml:33:13
73 | android:name
74 | ADDED from AndroidManifest.xml:32:13
75 | activity#com.bluejamesbond.text.sample.test.ChineseCharacterTest
76 | ADDED from AndroidManifest.xml:34:9
77 | android:theme
78 | ADDED from AndroidManifest.xml:36:13
79 | android:name
80 | ADDED from AndroidManifest.xml:35:13
81 | activity#com.bluejamesbond.text.sample.test.RTLTest
82 | ADDED from AndroidManifest.xml:37:9
83 | android:theme
84 | ADDED from AndroidManifest.xml:39:13
85 | android:name
86 | ADDED from AndroidManifest.xml:38:13
87 | activity#com.bluejamesbond.text.sample.test.XMLTest
88 | ADDED from AndroidManifest.xml:40:9
89 | android:theme
90 | ADDED from AndroidManifest.xml:42:13
91 | android:name
92 | ADDED from AndroidManifest.xml:41:13
93 | activity#com.bluejamesbond.text.sample.test.HyphenatedTest
94 | ADDED from AndroidManifest.xml:43:9
95 | android:theme
96 | ADDED from AndroidManifest.xml:45:13
97 | android:name
98 | ADDED from AndroidManifest.xml:44:13
99 | activity#com.bluejamesbond.text.sample.test.WordSpacingTest
100 | ADDED from AndroidManifest.xml:46:9
101 | android:theme
102 | ADDED from AndroidManifest.xml:48:13
103 | android:name
104 | ADDED from AndroidManifest.xml:47:13
105 | uses-sdk
106 | INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
107 | MERGED from TextJustify-Android:library:unspecified:8:5
108 | android:targetSdkVersion
109 | INJECTED from AndroidManifest.xml:0:0
110 | INJECTED from AndroidManifest.xml:0:0
111 | android:minSdkVersion
112 | INJECTED from AndroidManifest.xml:0:0
113 | INJECTED from AndroidManifest.xml:0:0
114 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | VERSION_NAME=2.1.0
21 | VERSION_CODE=22
22 | GROUP=com.github.bluejamesbond
23 |
24 | POM_DESCRIPTION=Android Text Full Jusiftication
25 | POM_URL=https://github.com/bluejamesbond/TextJustify-Android
26 | POM_SCM_URL=https://github.com/bluejamesbond/TextJustify-Android
27 | POM_SCM_CONNECTION=scm:git@github.com:bluejamesbond/TextJustify-Android.git
28 | POM_SCM_DEV_CONNECTION=scm:git@github.com:bluejamesbond/TextJustify-Android.git
29 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
30 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
31 | POM_LICENCE_DIST=repo
32 | POM_DEVELOPER_ID=bluejamesbond
33 | POM_DEVELOPER_NAME=Mathew Kurian
34 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Nov 25 01:23:33 CST 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | onUpdate DEFAULT_JVM_OPTS=
13 |
14 | onUpdate DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" onUpdate DIRNAME=.
16 | onUpdate APP_BASE_NAME=%~n0
17 | onUpdate APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | onUpdate JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not onUpdate and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please onUpdate the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | onUpdate JAVA_HOME=%JAVA_HOME:"=%
36 | onUpdate JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is onUpdate to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please onUpdate the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | onUpdate CMD_LINE_ARGS=
57 | onUpdate _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | onUpdate CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | onUpdate CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | onUpdate CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Mathew Kurian
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 | *
18 | * build.gradle
19 | * @author Mathew Kurian
20 | *
21 | * From TextJustify-Android Library v2.0
22 | * https://github.com/bluejamesbond/TextJustify-Android
23 | *
24 | * Please report any issues
25 | * https://github.com/bluejamesbond/TextJustify-Android/issues
26 | *
27 | * Date: 1/27/15 3:35 AM
28 | */
29 |
30 | apply plugin: 'com.android.library'
31 | android {
32 | compileSdkVersion 21
33 | buildToolsVersion '21.1.2'
34 | defaultConfig {
35 | minSdkVersion 8
36 | targetSdkVersion 21
37 | versionCode 2
38 | versionName '2.0'
39 | }
40 | android {
41 | lintOptions {
42 | abortOnError false
43 | }
44 | }
45 | compileOptions {
46 | sourceCompatibility JavaVersion.VERSION_1_6
47 | sourceCompatibility JavaVersion.VERSION_1_7
48 | }
49 | }
50 |
51 | dependencies {
52 | }
53 |
54 | apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
55 |
56 |
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015 Mathew Kurian
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 | #
18 | # gradle.properties
19 | # @author Mathew Kurian
20 | #
21 | # From TextJustify-Android Library v2.0
22 | # https://github.com/bluejamesbond/TextJustify-Android
23 | #
24 | # Please report any issues
25 | # https://github.com/bluejamesbond/TextJustify-Android/issues
26 | #
27 | # Date: 1/27/15 3:35 AM
28 | #
29 |
30 | # Project-wide Gradle settings.
31 |
32 | # IDE (e.g. Android Studio) users:
33 | # Settings specified in this file will override any Gradle settings
34 | # configured through the IDE.
35 |
36 | # For more details on how to configure your build environment visit
37 | # http://www.gradle.org/docs/current/userguide/build_environment.html
38 |
39 | # Specifies the JVM arguments used for the daemon process.
40 | # The setting is particularly useful for tweaking memory settings.
41 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
42 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
43 |
44 | # When configured, Gradle will run in incubating parallel mode.
45 | # This option should only be used with decoupled projects. More details, visit
46 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
47 | # org.gradle.parallel=true
48 |
49 | POM_NAME=TextJustify-Android Library
50 | POM_ARTIFACT_ID=textjustify-android
51 | POM_PACKAGING=aar
52 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/Console.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * Console.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | @SuppressWarnings("unused")
33 | public class Console {
34 |
35 | public static void log(String tag, String s) {
36 | android.util.Log.d(tag, s);
37 | }
38 |
39 | public static void log(String tag, int s) {
40 | android.util.Log.d(tag, s + "");
41 | }
42 |
43 | public static void log(String tag, long s) {
44 | android.util.Log.d(tag, s + "");
45 | }
46 |
47 | public static void log(String tag, double s) {
48 | android.util.Log.d(tag, s + "");
49 | }
50 |
51 | public static void log(String tag, float s) {
52 | android.util.Log.d(tag, s + "");
53 | }
54 |
55 | public static void log(String tag, boolean s) {
56 | android.util.Log.d(tag, s + "");
57 | }
58 |
59 | public static void log(String s) {
60 | android.util.Log.d("", s);
61 | }
62 |
63 | public static void log(int s) {
64 | android.util.Log.d("", s + "");
65 | }
66 |
67 | public static void log(long s) {
68 | android.util.Log.d("", s + "");
69 | }
70 |
71 | public static void log(double s) {
72 | android.util.Log.d("", s + "");
73 | }
74 |
75 | public static void log(float s) {
76 | android.util.Log.d("", s + "");
77 | }
78 |
79 | public static void log(boolean s) {
80 | android.util.Log.d("", s + "");
81 | }
82 |
83 | public static void log(T s) {
84 | android.util.Log.d("", s == null ? "null" : s.toString());
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/hyphen/IHyphenator.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.hyphen;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * IHyphenator.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import java.util.ArrayList;
33 |
34 | public interface IHyphenator {
35 | public ArrayList hyphenate(String word);
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/hyphen/SqueezeHyphenator.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.hyphen;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * SqueezeHyphenator.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import java.util.ArrayList;
33 |
34 | public class SqueezeHyphenator implements IHyphenator {
35 |
36 | private static SqueezeHyphenator squeezeHyphenator;
37 |
38 | static {
39 | squeezeHyphenator = new SqueezeHyphenator();
40 | }
41 |
42 | private SqueezeHyphenator() {
43 | }
44 |
45 | public static SqueezeHyphenator getInstance() {
46 | return squeezeHyphenator;
47 | }
48 |
49 | @Override
50 | public ArrayList hyphenate(String word) {
51 |
52 | ArrayList broken = new ArrayList();
53 | int len = word.length() - 1, i;
54 |
55 | for (i = 0; i < len; i += 2) {
56 | broken.add(word.substring(i, i + 2));
57 | }
58 |
59 | if (i < len) {
60 | broken.add(word.substring(i, word.length()));
61 | }
62 |
63 | return broken;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/CenterSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * CenterSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | public class CenterSpan extends TextAlignmentSpan {
33 | @Override
34 | public TextAlignment getTextAlignment() {
35 | return TextAlignment.CENTER;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/Direction.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * Direction.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | @SuppressWarnings("unused")
33 | public enum Direction {
34 | LEFT_TO_RIGHT(false), RIGHT_TO_LEFT(true);
35 |
36 | private boolean flag;
37 |
38 | private Direction(boolean flag) {
39 | this.flag = flag;
40 | }
41 |
42 | public boolean isReverse() {
43 | return flag;
44 | }
45 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/DirectionSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | import android.text.TextPaint;
4 | import android.text.style.CharacterStyle;
5 |
6 | /*
7 | * Copyright 2015 Mathew Kurian
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | *
21 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 | *
23 | * DirectionSpan.java
24 | * @author Mathew Kurian
25 | *
26 | * From TextJustify-Android Library v2.0
27 | * https://github.com/bluejamesbond/TextJustify-Android
28 | *
29 | * Please report any issues
30 | * https://github.com/bluejamesbond/TextJustify-Android/issues
31 | *
32 | * Date: 1/27/15 3:35 AM
33 | */
34 |
35 | @SuppressWarnings("unused")
36 | public class DirectionSpan extends CharacterStyle {
37 | private final Direction direction;
38 |
39 | public DirectionSpan(Direction direction) {
40 | this.direction = direction;
41 | }
42 |
43 | public Direction getDirection() {
44 | return direction;
45 | }
46 |
47 | public boolean isReverse() {
48 | return direction.isReverse();
49 | }
50 |
51 | @Override
52 | public void updateDrawState(TextPaint tp) {
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/JustifiedSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * JustifiedSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | public class JustifiedSpan extends TextAlignmentSpan {
33 | @Override
34 | public TextAlignment getTextAlignment() {
35 | return TextAlignment.JUSTIFIED;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/LeftSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * LeftSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | public class LeftSpan extends TextAlignmentSpan {
33 | @Override
34 | public TextAlignment getTextAlignment() {
35 | return TextAlignment.LEFT;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/RightSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * RightSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | public class RightSpan extends TextAlignmentSpan {
33 |
34 | @Override
35 | public TextAlignment getTextAlignment() {
36 | return TextAlignment.RIGHT;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/TextAlignment.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TextAlignment.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | @SuppressWarnings("unused")
33 | public enum TextAlignment {
34 | LEFT(0), RIGHT(1), JUSTIFIED(2), CENTER(3);
35 |
36 | private final int mId;
37 |
38 | private TextAlignment(int id) {
39 | mId = id;
40 | }
41 |
42 | public static TextAlignment getById(int id) {
43 | switch (id) {
44 | default:
45 | case 0:
46 | return LEFT;
47 | case 1:
48 | return RIGHT;
49 | case 2:
50 | return JUSTIFIED;
51 | case 3:
52 | return CENTER;
53 | }
54 | }
55 |
56 | public int getId() {
57 | return mId;
58 | }
59 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/bluejamesbond/text/style/TextAlignmentSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.style;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TextAlignmentSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.text.Layout;
33 | import android.text.style.AlignmentSpan;
34 |
35 | public abstract class TextAlignmentSpan implements AlignmentSpan {
36 |
37 | @Override
38 | public Layout.Alignment getAlignment() {
39 | return Layout.Alignment.ALIGN_NORMAL;
40 | }
41 |
42 | public abstract TextAlignment getTextAlignment();
43 |
44 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
75 |
76 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/misc/comparisons.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/misc/comparisons.psd
--------------------------------------------------------------------------------
/misc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/misc/logo.png
--------------------------------------------------------------------------------
/misc/logo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/misc/logo.psd
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Mathew Kurian
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 | *
18 | * build.gradle
19 | * @author Mathew Kurian
20 | *
21 | * From TextJustify-Android Library v2.0
22 | * https://github.com/bluejamesbond/TextJustify-Android
23 | *
24 | * Please report any issues
25 | * https://github.com/bluejamesbond/TextJustify-Android/issues
26 | *
27 | * Date: 1/27/15 3:35 AM
28 | */
29 |
30 | apply plugin: 'com.android.application'
31 |
32 | android {
33 | // if keystore not available, don't build the release version
34 | try {
35 | File keystore = new File("C:/release.keystore.jks")
36 | if (keystore.exists()) {
37 | signingConfigs {
38 | release {
39 | keyAlias 'bluejamesbond'
40 | keyPassword ''
41 | storeFile file('C:/release.keystore.jks')
42 | storePassword ''
43 | }
44 | }
45 |
46 | buildTypes {
47 | release {
48 | minifyEnabled false
49 | debuggable true
50 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
51 | }
52 | }
53 | }
54 | } catch (Exception e) {
55 | }
56 | compileSdkVersion 21
57 | buildToolsVersion '21.1.2'
58 | defaultConfig {
59 | applicationId 'com.bluejamesbond.text.sample'
60 | minSdkVersion 8
61 | targetSdkVersion 21
62 | versionCode 9
63 | versionName '4.5'
64 | }
65 | android {
66 | lintOptions {
67 | abortOnError false
68 | }
69 | }
70 | productFlavors {
71 | }
72 | compileOptions {
73 | sourceCompatibility JavaVersion.VERSION_1_6
74 | sourceCompatibility JavaVersion.VERSION_1_7
75 | }
76 | }
77 |
78 | dependencies {
79 | compile project(':library')
80 | }
81 |
--------------------------------------------------------------------------------
/sample/manifest-merger-release-report.txt:
--------------------------------------------------------------------------------
1 | -- Merging decision tree log ---
2 | manifest
3 | ADDED from AndroidManifest.xml:2:1
4 | xmlns:android
5 | ADDED from AndroidManifest.xml:2:11
6 | package
7 | ADDED from AndroidManifest.xml:3:5
8 | INJECTED from AndroidManifest.xml:0:0
9 | INJECTED from AndroidManifest.xml:0:0
10 | android:versionName
11 | INJECTED from AndroidManifest.xml:0:0
12 | INJECTED from AndroidManifest.xml:0:0
13 | android:versionCode
14 | INJECTED from AndroidManifest.xml:0:0
15 | INJECTED from AndroidManifest.xml:0:0
16 | application
17 | ADDED from AndroidManifest.xml:5:5
18 | android:label
19 | ADDED from AndroidManifest.xml:8:9
20 | android:allowBackup
21 | ADDED from AndroidManifest.xml:6:9
22 | android:icon
23 | ADDED from AndroidManifest.xml:7:9
24 | android:theme
25 | ADDED from AndroidManifest.xml:9:9
26 | activity#com.bluejamesbond.text.demo.helper.TestList
27 | ADDED from AndroidManifest.xml:10:9
28 | android:label
29 | ADDED from AndroidManifest.xml:12:13
30 | android:theme
31 | ADDED from AndroidManifest.xml:13:13
32 | android:name
33 | ADDED from AndroidManifest.xml:11:13
34 | intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
35 | ADDED from AndroidManifest.xml:14:13
36 | action#android.intent.action.MAIN
37 | ADDED from AndroidManifest.xml:15:17
38 | android:name
39 | ADDED from AndroidManifest.xml:15:25
40 | category#android.intent.category.LAUNCHER
41 | ADDED from AndroidManifest.xml:16:17
42 | android:name
43 | ADDED from AndroidManifest.xml:16:27
44 | activity#com.bluejamesbond.text.demo.test.FormattedTextTest
45 | ADDED from AndroidManifest.xml:19:9
46 | android:theme
47 | ADDED from AndroidManifest.xml:20:13
48 | android:name
49 | ADDED from AndroidManifest.xml:19:19
50 | activity#com.bluejamesbond.text.demo.test.LeadingMarginSpan2Test
51 | ADDED from AndroidManifest.xml:21:9
52 | android:theme
53 | ADDED from AndroidManifest.xml:22:13
54 | android:name
55 | ADDED from AndroidManifest.xml:21:19
56 | activity#com.bluejamesbond.text.demo.test.LineBreakTest
57 | ADDED from AndroidManifest.xml:23:9
58 | android:theme
59 | ADDED from AndroidManifest.xml:24:13
60 | android:name
61 | ADDED from AndroidManifest.xml:23:19
62 | activity#com.bluejamesbond.text.demo.test.PlainTextTest
63 | ADDED from AndroidManifest.xml:25:9
64 | android:theme
65 | ADDED from AndroidManifest.xml:26:13
66 | android:name
67 | ADDED from AndroidManifest.xml:25:19
68 | activity#com.bluejamesbond.text.demo.test.QuoteSpanTest
69 | ADDED from AndroidManifest.xml:27:9
70 | android:theme
71 | ADDED from AndroidManifest.xml:28:13
72 | android:name
73 | ADDED from AndroidManifest.xml:27:19
74 | activity#com.bluejamesbond.text.demo.test.ChineseCharacterTest
75 | ADDED from AndroidManifest.xml:29:9
76 | android:theme
77 | ADDED from AndroidManifest.xml:30:13
78 | android:name
79 | ADDED from AndroidManifest.xml:29:19
80 | activity#com.bluejamesbond.text.demo.test.RTLTest
81 | ADDED from AndroidManifest.xml:31:9
82 | android:theme
83 | ADDED from AndroidManifest.xml:32:13
84 | android:name
85 | ADDED from AndroidManifest.xml:31:19
86 | uses-sdk
87 | INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
88 | android:targetSdkVersion
89 | INJECTED from AndroidManifest.xml:0:0
90 | INJECTED from AndroidManifest.xml:0:0
91 | android:minSdkVersion
92 | INJECTED from AndroidManifest.xml:0:0
93 | INJECTED from AndroidManifest.xml:0:0
94 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Mathew Kurian\AppData\Local\Android\android-studio\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
33 |
34 |
39 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
56 |
60 |
64 |
68 |
72 |
76 |
80 |
84 |
88 |
92 |
96 |
100 |
104 |
108 |
112 |
116 |
120 |
124 |
128 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/sample/src/main/assets/fonts/helvetica.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/assets/fonts/helvetica.ttf
--------------------------------------------------------------------------------
/sample/src/main/assets/fonts/notosans.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/assets/fonts/notosans.ttf
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/ArticleBuilder.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ArticleBuilder.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.text.Html;
33 | import android.text.SpannableStringBuilder;
34 | import android.text.Spanned;
35 |
36 | /**
37 | * Created by Mathew Kurian on 10/31/2014.
38 | */
39 | public class ArticleBuilder extends SpannableStringBuilder {
40 | public ArticleBuilder append(CharSequence text, boolean newline, Object... spans) {
41 | int start = this.length();
42 | this.append(Html.fromHtml(text + "
" + (newline ? "
" : "")));
43 | for (Object span : spans) {
44 | this.setSpan(span, start, this.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
45 | }
46 | return this;
47 | }
48 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/FontsOverride.java:
--------------------------------------------------------------------------------
1 | /*
2 | * http://stackoverflow.com/questions/2973270/using-a-custom-typeface-in-android/16275257#16275257
3 | */
4 |
5 | package com.bluejamesbond.text.sample.helper;
6 |
7 | /*
8 | * Copyright 2015 Mathew Kurian
9 | *
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | *
22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 | *
24 | * FontsOverride.java
25 | * @author Mathew Kurian
26 | *
27 | * From TextJustify-Android Library v2.0
28 | * https://github.com/bluejamesbond/TextJustify-Android
29 | *
30 | * Please report any issues
31 | * https://github.com/bluejamesbond/TextJustify-Android/issues
32 | *
33 | * Date: 1/27/15 3:35 AM
34 | */
35 |
36 | import android.content.Context;
37 | import android.graphics.Typeface;
38 |
39 | import java.lang.reflect.Field;
40 |
41 | public final class FontsOverride {
42 |
43 | public static void setDefaultFont(Context context,
44 | String staticTypefaceFieldName, String fontAssetName) {
45 | final Typeface regular = Typeface.createFromAsset(context.getAssets(),
46 | fontAssetName);
47 | replaceFont(staticTypefaceFieldName, regular);
48 | }
49 |
50 | protected static void replaceFont(String staticTypefaceFieldName,
51 | final Typeface newTypeface) {
52 | try {
53 | final Field staticField = Typeface.class
54 | .getDeclaredField(staticTypefaceFieldName);
55 | staticField.setAccessible(true);
56 | staticField.set(null, newTypeface);
57 | } catch (NoSuchFieldException e) {
58 | e.printStackTrace();
59 | } catch (IllegalAccessException e) {
60 | e.printStackTrace();
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/MyLeadingMarginSpan2.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * MyLeadingMarginSpan2.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | /*
33 | * Provided by @levifan
34 | * https://github.com/bluejamesbond/Sandbox/issues/2#issuecomment-60928630
35 | */
36 |
37 | import android.graphics.Canvas;
38 | import android.graphics.Paint;
39 | import android.text.Layout;
40 |
41 | public class MyLeadingMarginSpan2 implements
42 | android.text.style.LeadingMarginSpan.LeadingMarginSpan2 {
43 |
44 | private int margin;
45 | private int lines;
46 |
47 | public MyLeadingMarginSpan2(int lines, int margin) {
48 | this.lines = lines;
49 | this.margin = margin;
50 | }
51 |
52 | @Override
53 | public int getLeadingMargin(boolean first) {
54 | return margin;
55 | }
56 |
57 | @Override
58 | public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline,
59 | int bottom, CharSequence text, int start, int end, boolean first,
60 | Layout layout) {
61 | }
62 |
63 | @Override
64 | public int getLeadingMarginLineCount() {
65 | return lines;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/MyQuoteSpan.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * MyQuoteSpan.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Canvas;
33 | import android.graphics.Paint;
34 | import android.os.Parcel;
35 | import android.text.Layout;
36 | import android.text.ParcelableSpan;
37 | import android.text.style.LeadingMarginSpan;
38 |
39 | @SuppressWarnings("UnusedDeclaration")
40 | public class MyQuoteSpan implements LeadingMarginSpan, ParcelableSpan {
41 |
42 | private final static int QUOTE_SPAN = 9;
43 |
44 | private int mStripeWidth = 2;
45 | private int mGapWidth = 30;
46 | private int mColor;
47 |
48 | public MyQuoteSpan() {
49 | super();
50 | mColor = 0xff0000ff;
51 | }
52 |
53 | public MyQuoteSpan(int color) {
54 | super();
55 | mColor = color;
56 | }
57 |
58 | public MyQuoteSpan(int color, int stripeWidth) {
59 | super();
60 | mColor = color;
61 | mStripeWidth = stripeWidth;
62 | }
63 |
64 | public MyQuoteSpan(int color, int stripeWidth, int gapWidth) {
65 | super();
66 | mColor = color;
67 | mStripeWidth = stripeWidth;
68 | mGapWidth = gapWidth;
69 | }
70 |
71 | public MyQuoteSpan(Parcel src) {
72 | mColor = src.readInt();
73 | }
74 |
75 | public int getSpanTypeId() {
76 | return QUOTE_SPAN;
77 | }
78 |
79 | public int describeContents() {
80 | return 0;
81 | }
82 |
83 | public void writeToParcel(Parcel dest, int flags) {
84 | dest.writeInt(mColor);
85 | }
86 |
87 | public int getColor() {
88 | return mColor;
89 | }
90 |
91 | public int getLeadingMargin(boolean first) {
92 | return mStripeWidth + mGapWidth;
93 | }
94 |
95 | public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline,
96 | int bottom, CharSequence text, int start, int end, boolean first,
97 | Layout layout) {
98 |
99 | float strokeWidth = p.getStrokeWidth();
100 | int color = p.getColor();
101 |
102 | p.setStrokeWidth(mStripeWidth);
103 | p.setColor(mColor);
104 |
105 | c.drawLine(x, top, x, bottom, p);
106 |
107 | p.setStrokeWidth(strokeWidth);
108 | p.setColor(color);
109 | }
110 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/PressableDocumentView.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * PressableDocumentView.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.content.Context;
33 | import android.graphics.Color;
34 | import android.util.AttributeSet;
35 | import android.util.TypedValue;
36 | import android.view.MotionEvent;
37 | import android.view.View;
38 | import android.widget.LinearLayout;
39 |
40 | import com.bluejamesbond.text.DocumentView;
41 | import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
42 |
43 | @SuppressWarnings("unused")
44 | public class PressableDocumentView extends DocumentView {
45 |
46 | public PressableDocumentView(Context context, AttributeSet attrs, int defStyle) {
47 | super(context, attrs, defStyle);
48 | initPressableDocumentView();
49 | }
50 |
51 | public PressableDocumentView(Context context, AttributeSet attrs) {
52 | super(context, attrs);
53 | initPressableDocumentView();
54 | }
55 |
56 | public PressableDocumentView(Context context) {
57 | super(context);
58 | initPressableDocumentView();
59 | }
60 |
61 | public PressableDocumentView(Context context, int type) {
62 | super(context, type);
63 | initPressableDocumentView();
64 | }
65 |
66 | public PressableDocumentView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
67 | super(context, attrs, defStyleAttr, defStyleRes);
68 | initPressableDocumentView();
69 | }
70 |
71 | private void initPressableDocumentView() {
72 | getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
73 | getDocumentLayoutParams().setHyphenated(true);
74 | }
75 |
76 | @Override
77 | protected void dispatchSetPressed(boolean pressed) {
78 | super.dispatchSetPressed(pressed);
79 |
80 | if (pressed) {
81 | getDocumentLayoutParams().setTextColor(Color.BLACK);
82 | setDisallowInterceptTouch(true);
83 | } else {
84 | getDocumentLayoutParams().setTextColor(Color.WHITE);
85 | setDisallowInterceptTouch(false);
86 | }
87 |
88 | invalidate();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/TestActivity.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TestActivity.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.app.Activity;
33 | import android.graphics.Typeface;
34 | import android.os.Bundle;
35 | import android.util.TypedValue;
36 | import android.view.View;
37 | import android.widget.LinearLayout;
38 | import android.widget.ProgressBar;
39 | import android.widget.TextView;
40 | import android.widget.Toast;
41 |
42 | import com.bluejamesbond.text.DocumentView;
43 | import com.bluejamesbond.text.sample.R;
44 | import com.bluejamesbond.text.style.TextAlignment;
45 |
46 | public class TestActivity extends Activity {
47 |
48 | public String testName;
49 | private boolean debugging = false;
50 | private int cacheConfig = 0;
51 |
52 | protected int getContentView() {
53 | return R.layout.test_activity;
54 | }
55 |
56 | @Override
57 | protected void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 |
60 | setContentView(getContentView());
61 |
62 | testName = Utils.splitCamelCase(getClass().getSimpleName());
63 |
64 | TextView titleBar = ((TextView) findViewById(R.id.titlebar));
65 |
66 | if (titleBar != null) {
67 | titleBar.setText(testName);
68 | }
69 | }
70 |
71 | public DocumentView addDocumentView(CharSequence article, int type, boolean rtl) {
72 | final DocumentView documentView = new DocumentView(this, type);
73 | documentView.getDocumentLayoutParams().setTextColor(0xffffffff);
74 | documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
75 | documentView.getDocumentLayoutParams().setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
76 | documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
77 | documentView.getDocumentLayoutParams().setInsetPaddingLeft(30f);
78 | documentView.getDocumentLayoutParams().setInsetPaddingRight(30f);
79 | documentView.getDocumentLayoutParams().setInsetPaddingTop(30f);
80 | documentView.getDocumentLayoutParams().setInsetPaddingBottom(30f);
81 | documentView.getDocumentLayoutParams().setLineHeightMultiplier(1f);
82 | documentView.getDocumentLayoutParams().setReverse(rtl);
83 | documentView.getDocumentLayoutParams().setDebugging(debugging);
84 | documentView.setText(article);
85 | documentView.setProgressBar((ProgressBar) findViewById(R.id.progressBar));
86 | documentView.setFadeInDuration(800);
87 | documentView.setFadeInAnimationStepDelay(30);
88 | documentView.setFadeInTween(new DocumentView.ITween() {
89 | @Override
90 | public float get(float t, float b, float c, float d) {
91 | return c * (t /= d) * t * t + b;
92 | }
93 | });
94 |
95 | LinearLayout linearLayout = new LinearLayout(this);
96 | linearLayout.setOrientation(LinearLayout.VERTICAL);
97 | linearLayout.setLayoutParams(
98 | new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
99 | LinearLayout.LayoutParams.MATCH_PARENT));
100 | linearLayout.addView(documentView);
101 |
102 | LinearLayout articleList = (LinearLayout) findViewById(R.id.articleList);
103 | articleList.addView(linearLayout);
104 |
105 | debugging = documentView.getDocumentLayoutParams().isDebugging();
106 | cacheConfig = documentView.getCacheConfig().getId();
107 |
108 | final TextView debugButton = (TextView) findViewById(R.id.debugButton);
109 |
110 | if (debugButton != null) {
111 | debugButton.setText((debugging ? "DISABLE" : "ENABLE") + " DEBUG");
112 | debugButton.setOnClickListener(new View.OnClickListener() {
113 | @Override
114 | public void onClick(View view) {
115 | debugging = !debugging;
116 | debugButton.setText((debugging ? "DISABLE" : "ENABLE") + " DEBUG");
117 | documentView.getDocumentLayoutParams().setDebugging(debugging);
118 | }
119 | });
120 | }
121 |
122 | final TextView cacheButton = (TextView) findViewById(R.id.cacheButton);
123 | final Toast cacheConfigToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
124 |
125 | if (cacheButton != null) {
126 | cacheConfigToast.setText("Activated " + documentView.getCacheConfig().name());
127 | cacheConfigToast.show();
128 | cacheButton.setOnClickListener(new View.OnClickListener() {
129 | @Override
130 | public void onClick(View view) {
131 | cacheConfig = (cacheConfig + 1) % 5;
132 | DocumentView.CacheConfig newCacheConfig = DocumentView.CacheConfig.getById(cacheConfig);
133 | cacheConfigToast.setText("Activated " + newCacheConfig.name());
134 | cacheConfigToast.show();
135 | documentView.setCacheConfig(newCacheConfig);
136 | documentView.destroyCache();
137 | documentView.invalidate();
138 | }
139 | });
140 | }
141 | return documentView;
142 | }
143 |
144 | public DocumentView addDocumentView(CharSequence article, int type) {
145 | return addDocumentView(article, type, false);
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/TestList.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TestList.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.content.Intent;
33 | import android.graphics.Color;
34 | import android.graphics.Typeface;
35 | import android.os.Bundle;
36 | import android.util.TypedValue;
37 | import android.view.View;
38 | import android.view.ViewGroup;
39 | import android.widget.AdapterView;
40 | import android.widget.ArrayAdapter;
41 | import android.widget.ListView;
42 | import android.widget.TextView;
43 |
44 | import com.bluejamesbond.text.sample.R;
45 | import com.bluejamesbond.text.sample.test.ChineseCharacterTest;
46 | import com.bluejamesbond.text.sample.test.ClickableSpanTest;
47 | import com.bluejamesbond.text.sample.test.ComplexLayoutTest;
48 | import com.bluejamesbond.text.sample.test.CustomHyphenatorTest;
49 | import com.bluejamesbond.text.sample.test.ForceNoCacheXMLTest;
50 | import com.bluejamesbond.text.sample.test.HyphenatedTest;
51 | import com.bluejamesbond.text.sample.test.ImageSpanTest;
52 | import com.bluejamesbond.text.sample.test.LeadingMarginSpan2Test;
53 | import com.bluejamesbond.text.sample.test.LineBreakTest;
54 | import com.bluejamesbond.text.sample.test.ListViewTest;
55 | import com.bluejamesbond.text.sample.test.LongFormattedTextTest;
56 | import com.bluejamesbond.text.sample.test.LongPlainTextTest;
57 | import com.bluejamesbond.text.sample.test.MixedRTLTest;
58 | import com.bluejamesbond.text.sample.test.NewLineTest;
59 | import com.bluejamesbond.text.sample.test.QuoteSpanTest;
60 | import com.bluejamesbond.text.sample.test.RTLTest;
61 | import com.bluejamesbond.text.sample.test.ShortFormattedTextTest;
62 | import com.bluejamesbond.text.sample.test.TextUpdateTest;
63 | import com.bluejamesbond.text.sample.test.TextViewTest;
64 | import com.bluejamesbond.text.sample.test.WordSpacingTest;
65 | import com.bluejamesbond.text.sample.test.XMLTest;
66 |
67 | public class TestList extends TestActivity {
68 |
69 | private Class[] tests = new Class[]{
70 | ChineseCharacterTest.class,
71 | LongFormattedTextTest.class,
72 | NewLineTest.class,
73 | LeadingMarginSpan2Test.class,
74 | LineBreakTest.class,
75 | LongPlainTextTest.class,
76 | QuoteSpanTest.class,
77 | HyphenatedTest.class,
78 | WordSpacingTest.class,
79 | RTLTest.class,
80 | XMLTest.class,
81 | TextViewTest.class,
82 | CustomHyphenatorTest.class,
83 | ClickableSpanTest.class,
84 | MixedRTLTest.class,
85 | ListViewTest.class,
86 | ComplexLayoutTest.class,
87 | ShortFormattedTextTest.class,
88 | ImageSpanTest.class,
89 | TextUpdateTest.class,
90 | ForceNoCacheXMLTest.class
91 | };
92 |
93 | @Override
94 | protected void onCreate(Bundle savedInstanceState) {
95 | super.onCreate(savedInstanceState);
96 |
97 | // Set default app font
98 | // FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/notosans.ttf");
99 |
100 | // Set layout
101 | setContentView(R.layout.testlist_activity);
102 |
103 | // Create list of simple test names
104 | String[] testNames = new String[tests.length];
105 |
106 | for (int i = 0; i < testNames.length; i++) {
107 | testNames[i] = Utils.splitCamelCase(tests[i].getSimpleName()).toUpperCase();
108 | }
109 |
110 | // Get listView
111 | ListView lv = (ListView) findViewById(R.id.list);
112 |
113 | // Assign adapter to List
114 | lv.setAdapter(new ArrayAdapter(this,
115 | android.R.layout.simple_list_item_1, testNames) {
116 |
117 | @Override
118 | public View getView(int position, View convertView, ViewGroup parent) {
119 | View view = super.getView(position, convertView, parent);
120 | TextView textView = (TextView) view.findViewById(android.R.id.text1);
121 | textView.setTypeface(Typeface.DEFAULT_BOLD);
122 | textView.setBackgroundColor(Color.parseColor("#111111"));
123 | textView.setTextColor(Color.WHITE);
124 | textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
125 | return view;
126 | }
127 | });
128 |
129 | // For each click
130 | lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
131 | @Override
132 | public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
133 | startActivity(new Intent(TestList.this, tests[i]));
134 | }
135 | });
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/helper/Utils.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.helper;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * Utils.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | public class Utils {
33 |
34 | /*
35 | * Refer to http://stackoverflow.com/a/2560017/1100536
36 | */
37 | public static String splitCamelCase(String s) {
38 | return s.replaceAll(
39 | String.format("%s|%s|%s",
40 | "(?<=[A-Z])(?=[A-Z][a-z])",
41 | "(?<=[^A-Z])(?=[A-Z])",
42 | "(?<=[A-Za-z])(?=[^A-Za-z])"
43 | ),
44 | " "
45 | );
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ChineseCharacterTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ChineseCharacterTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.ForegroundColorSpan;
35 | import android.text.style.RelativeSizeSpan;
36 | import android.text.style.StyleSpan;
37 |
38 | import com.bluejamesbond.text.DocumentView;
39 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
40 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
41 | import com.bluejamesbond.text.sample.helper.TestActivity;
42 | import com.bluejamesbond.text.style.JustifiedSpan;
43 | import com.bluejamesbond.text.style.LeftSpan;
44 |
45 | public class ChineseCharacterTest extends TestActivity {
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 |
50 | ArticleBuilder amb = new ArticleBuilder();
51 |
52 | amb.append(testName, false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
53 | new LeftSpan());
54 | amb.append("@levifan Oct. 28, 2014",
55 | true, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD));
56 | amb.append(
57 | "事訖乃返己轉身,可曰:以測機意」樂而不淫誨去出.,可曰:」誨耳出意.第十一回後竊聽己轉身訖乃返建章曰:.父親回衙汗流如雨玉,不題.,可事關雎覽誨.汗流如雨覽吉安而來冒認收了」關雎出曰:矣玉,不題事父親回衙.父親回衙玉,不題吉安而來汗流如雨冒認收了.在一處己轉身訖乃返危德至.建章曰:訖乃返以測機白圭志不稱讚分得意.己轉身樂而不淫建章曰:白圭志.誨意曰:去覽」耳矣.第八回」,可招」不題耳德泉淹曰:矣誨出事.汗流如雨冒認收了吉安而來父親回衙玉,不題.矣出意曰:.己轉身事在一處出建章曰:樂而不淫,可後竊聽以測機去.,愈聽愈惱饒爾去罷」此是後話也懊悔不了.玉,不題,可出汗流如雨父親回衙冒認收了耳關雎事曰:吉安而來.了」第一回不題第二回第九回第五回.,愈聽愈惱此是後話饒爾去罷」.意,可此是後話,愈聽愈惱」也懊悔不了覽饒爾去罷」耳關雎.此是後話,愈聽愈惱也懊悔不了饒爾去罷」.意覽事出去.,愈聽愈惱饒爾去罷」也懊悔不了.第一回第三回德泉淹羨殺.了」第十回第八回.驚異第十回第五回第七回.,可驚異曰:德泉淹矣覽第二回出」相域去.意第十一回事訖乃返己轉身耳去白圭志曰:.事」耳,可意關雎誨.事,可父親回衙曰:意出冒認收了吉安而來」去.矣出意曰:.己轉身事在一處出建章曰:樂而不淫,可後竊聽以測機去.,愈聽愈惱饒爾去罷」此是後話也懊悔不了.玉,不題,可出汗流如雨父親回衙冒認收了耳關雎事曰:吉安而來.了」第一回不題第二回第九回第五回.,愈聽愈惱此是後話饒爾去罷」.意,可此是後話,愈聽愈惱」也懊悔不了覽饒爾去罷」耳關雎.此是後話,愈聽愈惱也懊悔不了饒爾去罷」.意覽事出去.,愈聽愈惱饒爾去罷」也懊悔不了.第一回第三回德泉淹羨殺.了」第十回第八回.驚異第十回第五回第七回.,可驚異曰:德泉淹矣覽第二回出」相域去.意第十一回事訖乃返己轉身耳去白圭志曰:.事」耳,可意關雎誨.事,可父親回衙曰:意出冒認收了吉安而來」去.矣出意曰:.己轉身事在一處出建章曰:樂而不淫,可後竊聽以測機去.,愈聽愈惱饒爾去罷」此是後話也懊悔不了.玉,不題,可出汗流如雨父親回衙冒認收了耳關雎事曰:吉安而來.了」第一回不題第二回第九回第五回.,愈聽愈惱此是後話饒爾去罷」.意,可此是後話,愈聽愈惱」也懊悔不了覽饒爾去罷」耳關雎.此是後話,愈聽愈惱也懊悔不了饒爾去罷」.意覽事出去.,愈聽愈惱饒爾去罷」也懊悔不了.第一回第三回德泉淹羨殺.了」第十回第八回.驚異第十回第五回第七回.,可驚異曰:德泉淹矣覽第二回出」相域去.意第十一回事訖乃返己轉身耳去白圭志曰:.事」耳,可意關雎誨.事,可父親回衙曰:意出冒認收了吉安而來」去.",
58 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801),
59 | new StyleSpan(Typeface.ITALIC), new ForegroundColorSpan(0xFF555555));
60 | amb.append(
61 | "矣意去出,可耳.,可意去矣不題招」德泉淹了」第二回.覽意誨事.吉安而來玉,不題父親回衙冒認收了汗流如雨.德泉淹出第六回第八回意第一回耳,可」第五回矣.樂而不淫建章曰:不稱讚第十一回訖乃返.吉安而來玉,不題父親回衙汗流如雨.曰:,可覽誨.不題德泉淹第二回第四回第十回第一回.去關雎出誨.饒爾去罷」也懊悔不了此是後話,愈聽愈惱.己轉身誨意第十一回事後竊聽去矣,可分得意」曰:.意,可出關雎覽」矣耳.出,可」事曰:耳.耳出事去.己轉身訖乃返分得意.矣吉安而來」耳冒認收了汗流如雨覽事出,可.第八回相域第三回第十回第九回.出意分得意耳覽誨第十一回關雎,可事白圭志.,愈聽愈惱饒爾去罷」也懊悔不了此是後話.矣意去出,可耳.,可意去矣不題招」德泉淹了」第二回.覽意誨事.吉安而來玉,不題父親回衙冒認收了汗流如雨.德泉淹出第六回第八回意第一回耳,可」第五回矣.樂而不淫建章曰:不稱讚第十一回訖乃返.吉安而來玉,不題父親回衙汗流如雨.曰:,可覽誨.不題德泉淹第二回第四回第十回第一回.去關雎出誨.饒爾去罷」也懊悔不了此是後話,愈聽愈惱.己轉身誨意第十一回事後竊聽去矣,可分得意」曰:.意,可出關雎覽」矣耳.出,可」事曰:耳.耳出事去.己轉身訖乃返分得意.矣吉安而來」耳冒認收了汗流如雨覽事出,可.第八回相域第三回第十回第九回.出意分得意耳覽誨第十一回關雎,可事白圭志.,愈聽愈惱饒爾去罷」也懊悔不了此是後話.矣意去出,可耳.,可意去矣不題招」德泉淹了」第二回.覽意誨事.吉安而來玉,不題父親回衙冒認收了汗流如雨.德泉淹出第六回第八回意第一回耳,可」第五回矣.樂而不淫建章曰:不稱讚第十一回訖乃返.吉安而來玉,不題父親回衙汗流如雨.曰:,可覽誨.不題德泉淹第二回第四回第十回第一回.去關雎出誨.饒爾去罷」也懊悔不了此是後話,愈聽愈惱.己轉身誨意第十一回事後竊聽去矣,可分得意」曰:.意,可出關雎覽」矣耳.出,可」事曰:耳.耳出事去.己轉身訖乃返分得意.矣吉安而來」耳冒認收了汗流如雨覽事出,可.第八回相域第三回第十回第九回.出意分得意耳覽誨第十一回關雎,可事白圭志.,愈聽愈惱饒爾去罷」也懊悔不了此是後話.",
62 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan());
63 | amb.append(
64 | "意關雎去覽矣曰:誨.去曰:覽關雎事意.意出關雎耳誨去覽.」事第八回不題曰:羨殺第三回誨第一回.去,可耳意關雎誨矣覽.曰:」出誨意事,可.父親回衙汗流如雨玉,不題冒認收了.第十一回樂而不淫以測機建章曰:危德至.訖乃返不稱讚第十一回建章曰:意己轉身關雎事後竊聽曰:去誨覽.去關雎耳,可」曰:矣.意矣」,可曰:.去意覽,可.父親回衙」出玉,不題誨事,可吉安而來冒認收了去曰:覽.耳此是後話,愈聽愈惱也懊悔不了曰:矣饒爾去罷」去出」.冒認收了汗流如雨吉安而來.誨」矣關雎事曰:覽,可.誨」曰:耳覽去關雎意.關雎事羨殺,可第十回耳了」招」矣德泉淹第七回覽去.饒爾去罷」也懊悔不了耳覽此是後話,愈聽愈惱,可矣」.第二回德泉淹第一回第七回不題第九回.在一處以測機分得意不稱讚.矣,可事曰:去意」.也懊悔不了此是後話,愈聽愈惱饒爾去罷」.意關雎去覽矣曰:誨.去曰:覽關雎事意.意出關雎耳誨去覽.」事第八回不題曰:羨殺第三回誨第一回.去,可耳意關雎誨矣覽.曰:」出誨意事,可.父親回衙汗流如雨玉,不題冒認收了.第十一回樂而不淫以測機建章曰:危德至.訖乃返不稱讚第十一回建章曰:意己轉身關雎事後竊聽曰:去誨覽.去關雎耳,可」曰:矣.意矣」,可曰:.去意覽,可.父親回衙」出玉,不題誨事,可吉安而來冒認收了去曰:覽.耳此是後話,愈聽愈惱也懊悔不了曰:矣饒爾去罷」去出」.冒認收了汗流如雨吉安而來.誨」矣關雎事曰:覽,可.誨」曰:耳覽去關雎意.關雎事羨殺,可第十回耳了」招」矣德泉淹第七回覽去.饒爾去罷」也懊悔不了耳覽此是後話,愈聽愈惱,可矣」.第二回德泉淹第一回第七回不題第九回.在一處以測機分得意不稱讚.矣,可事曰:去意」.也懊悔不了此是後話,愈聽愈惱饒爾去罷」.意關雎去覽矣曰:誨.去曰:覽關雎事意.意出關雎耳誨去覽.」事第八回不題曰:羨殺第三回誨第一回.去,可耳意關雎誨矣覽.曰:」出誨意事,可.父親回衙汗流如雨玉,不題冒認收了.第十一回樂而不淫以測機建章曰:危德至.訖乃返不稱讚第十一回建章曰:意己轉身關雎事後竊聽曰:去誨覽.去關雎耳,可」曰:矣.意矣」,可曰:.去意覽,可.父親回衙」出玉,不題誨事,可吉安而來冒認收了去曰:覽.耳此是後話,愈聽愈惱也懊悔不了曰:矣饒爾去罷」去出」.冒認收了汗流如雨吉安而來.誨」矣關雎事曰:覽,可.誨」曰:耳覽去關雎意.關雎事羨殺,可第十回耳了」招」矣德泉淹第七回覽去.饒爾去罷」也懊悔不了耳覽此是後話,愈聽愈惱,可矣」.第二回德泉淹第一回第七回不題第九回.在一處以測機分得意不稱讚.矣,可事曰:去意」.也懊悔不了此是後話,愈聽愈惱饒爾去罷」.意關雎去覽矣曰:誨.去曰:覽關雎事意.意出關雎耳誨去覽.」事第八回不題曰:羨殺第三回誨第一回.去,可耳意關雎誨矣覽.曰:」出誨意事,可.父親回衙汗流如雨玉,不題冒認收了.第十一回樂而不淫以測機建章曰:危德至.訖乃返不稱讚第十一回建章曰:意己轉身關雎事後竊聽曰:去誨覽.去關雎耳,可」曰:矣.意矣」,可曰:.去意覽,可.父親回衙」出玉,不題誨事,可吉安而來冒認收了去曰:覽.耳此是後話,愈聽愈惱也懊悔不了曰:矣饒爾去罷」去出」.冒認收了汗流如雨吉安而來.誨」矣關雎事曰:覽,可.誨」曰:耳覽去關雎意.關雎事羨殺,可第十回耳了」招」矣德泉淹第七回覽去.饒爾去罷」也懊悔不了耳覽此是後話,愈聽愈惱,可矣」.第二回德泉淹第一回第七回不題第九回.在一處以測機分得意不稱讚.矣,可事曰:去意」.也懊悔不了此是後話,愈聽愈惱饒爾去罷」.",
65 | true, new RelativeSizeSpan(1.3f), new JustifiedSpan());
66 | amb.append(
67 | "誨曰:覽出關雎.曰:,可矣誨事.意誨耳關雎出曰:去.覽吉安而來出父親回衙汗流如雨意誨」,可關雎玉,不題.關雎」出意覽去矣.以測機在一處訖乃返建章曰:.父親回衙汗流如雨吉安而來玉,不題.出曰:,可矣.曰:關雎誨覽耳.去父親回衙,可汗流如雨玉,不題意事誨曰:耳覽.關雎出,可意覽曰:」.事曰:,可矣去誨關雎.事覽誨關雎出矣.貢院第九回不題羨殺第八回第三回.第四回第一回第九回貢院.,可曰:吉安而來父親回衙汗流如雨玉,不題耳意.」曰:出關雎.第十回驚異德泉淹貢院.分得意己轉身建章曰:訖乃返.誨曰:覽出關雎.曰:,可矣誨事.意誨耳關雎出曰:去.覽吉安而來出父親回衙汗流如雨意誨」,可關雎玉,不題.關雎」出意覽去矣.以測機在一處訖乃返建章曰:.父親回衙汗流如雨吉安而來玉,不題.出曰:,可矣.曰:關雎誨覽耳.去父親回衙,可汗流如雨玉,不題意事誨曰:耳覽.關雎出,可意覽曰:」.事曰:,可矣去誨關雎.事覽誨關雎出矣.貢院第九回不題羨殺第八回第三回.第四回第一回第九回貢院.,可曰:吉安而來父親回衙汗流如雨玉,不題耳意.」曰:出關雎.第十回驚異德泉淹貢院.分得意己轉身建章曰:訖乃返.誨曰:覽出關雎.曰:,可矣誨事.意誨耳關雎出曰:去.覽吉安而來出父親回衙汗流如雨意誨」,可關雎玉,不題.關雎」出意覽去矣.以測機在一處訖乃返建章曰:.父親回衙汗流如雨吉安而來玉,不題.出曰:,可矣.曰:關雎誨覽耳.去父親回衙,可汗流如雨玉,不題意事誨曰:耳覽.關雎出,可意覽曰:」.事曰:,可矣去誨關雎.事覽誨關雎出矣.貢院第九回不題羨殺第八回第三回.第四回第一回第九回貢院.,可曰:吉安而來父親回衙汗流如雨玉,不題耳意.」曰:出關雎.第十回驚異德泉淹貢院.分得意己轉身建章曰:訖乃返.誨曰:覽出關雎.曰:,可矣誨事.意誨耳關雎出曰:去.覽吉安而來出父親回衙汗流如雨意誨」,可關雎玉,不題.關雎」出意覽去矣.以測機在一處訖乃返建章曰:.父親回衙汗流如雨吉安而來玉,不題.出曰:,可矣.曰:關雎誨覽耳.去父親回衙,可汗流如雨玉,不題意事誨曰:耳覽.關雎出,可意覽曰:」.事曰:,可矣去誨關雎.事覽誨關雎出矣.貢院第九回不題羨殺第八回第三回.第四回第一回第九回貢院.,可曰:吉安而來父親回衙汗流如雨玉,不題耳意.」曰:出關雎.第十回驚異德泉淹貢院.分得意己轉身建章曰:訖乃返.",
68 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan());
69 | amb.append(
70 | "意矣去出誨關雎耳.饒爾去罷」此是後話也懊悔不了,愈聽愈惱.曰:」耳去事矣關雎出.去意出,可.曰:耳」事.耳覽去曰:矣事」意.不稱讚樂而不淫在一處己轉身.第二回第九回第七回.第九回第二回第八回羨殺第六回.第四回第二回第五回羨殺.汗流如雨玉,不題吉安而來父親回衙.玉,不題汗流如雨吉安而來冒認收了父親回衙.關雎誨曰:去.父親回衙冒認收了吉安而來.饒爾去罷」也懊悔不了,愈聽愈惱此是後話.以測機不稱讚樂而不淫第十一回建章曰:.第三回」第二回第六回誨出了」第十回耳矣.出矣誨覽關雎」去事.也懊悔不了,愈聽愈惱饒爾去罷」.第二回覽矣第一回」第七回相域誨意第八回去出.驚異意招」出第二回德泉淹第十回關雎覽第四回誨曰:.也懊悔不了事饒爾去罷」誨」此是後話出矣去覽意.曰:出,可意意矣去出誨關雎耳.饒爾去罷」此是後話也懊悔不了,愈聽愈惱.曰:」耳去事矣關雎出.去意出,可.曰:耳」事.耳覽去曰:矣事」意.不稱讚樂而不淫在一處己轉身.第二回第九回第七回.第九回第二回第八回羨殺第六回.第四回第二回第五回羨殺.汗流如雨玉,不題吉安而來父親回衙.玉,不題汗流如雨吉安而來冒認收了父親回衙.關雎誨曰:去.父親回衙冒認收了吉安而來.饒爾去罷」也懊悔不了,愈聽愈惱此是後話.以測機不稱讚樂而不淫第十一回建章曰:.第三回」第二回第六回誨出了」第十回耳矣.出矣誨覽關雎」去事.也懊悔不了,愈聽愈惱饒爾去罷」.第二回覽矣第一回」第七回相域誨意第八回去出.驚異意招」出第二回德泉淹第十回關雎覽第四回誨曰:.也懊悔不了事饒爾去罷」誨」此是後話出矣去覽意.曰:出,可意意矣去出誨關雎耳.饒爾去罷」此是後話也懊悔不了,愈聽愈惱.曰:」耳去事矣關雎出.去意出,可.曰:耳」事.耳覽去曰:矣事」意.不稱讚樂而不淫在一處己轉身.第二回第九回第七回.第九回第二回第八回羨殺第六回.第四回第二回第五回羨殺.汗流如雨玉,不題吉安而來父親回衙.玉,不題汗流如雨吉安而來冒認收了父親回衙.關雎誨曰:去.父親回衙冒認收了吉安而來.饒爾去罷」也懊悔不了,愈聽愈惱此是後話.以測機不稱讚樂而不淫第十一回建章曰:.第三回」第二回第六回誨出了」第十回耳矣.出矣誨覽關雎」去事.也懊悔不了,愈聽愈惱饒爾去罷」.第二回覽矣第一回」第七回相域誨意第八回去出.驚異意招」出第二回德泉淹第十回關雎覽第四回誨曰:.也懊悔不了事饒爾去罷」誨」此是後話出矣去覽意.曰:出,可意意矣去出誨關雎耳.饒爾去罷」此是後話也懊悔不了,愈聽愈惱.曰:」耳去事矣關雎出.去意出,可.曰:耳」事.耳覽去曰:矣事」意.不稱讚樂而不淫在一處己轉身.第二回第九回第七回.第九回第二回第八回羨殺第六回.第四回第二回第五回羨殺.汗流如雨玉,不題吉安而來父親回衙.玉,不題汗流如雨吉安而來冒認收了父親回衙.關雎誨曰:去.父親回衙冒認收了吉安而來.饒爾去罷」也懊悔不了,愈聽愈惱此是後話.以測機不稱讚樂而不淫第十一回建章曰:.第三回」第二回第六回誨出了」第十回耳矣.出矣誨覽關雎」去事.也懊悔不了,愈聽愈惱饒爾去罷」.第二回覽矣第一回」第七回相域誨意第八回去出.驚異意招」出第二回德泉淹第十回關雎覽第四回誨曰:.也懊悔不了事饒爾去罷」誨」此是後話出矣去覽意.曰:出,可意意矣去出誨關雎耳.饒爾去罷」此是後話也懊悔不了,愈聽愈惱.曰:」耳去事矣關雎出.去意出,可.曰:耳」事.耳覽去曰:矣事」意.不稱讚樂而不淫在一處己轉身.第二回第九回第七回.第九回第二回第八回羨殺第六回.第四回第二回第五回羨殺.汗流如雨玉,不題吉安而來父親回衙.玉,不題汗流如雨吉安而來冒認收了父親回衙.關雎誨曰:去.父親回衙冒認收了吉安而來.饒爾去罷」也懊悔不了,愈聽愈惱此是後話.以測機不稱讚樂而不淫第十一回建章曰:.第三回」第二回第六回誨出了」第十回耳矣.出矣誨覽關雎」去事.也懊悔不了,愈聽愈惱饒爾去罷」.第二回覽矣第一回」第七回相域誨意第八回去出.驚異意招」出第二回德泉淹第十回關雎覽第四回誨曰:.也懊悔不了事饒爾去罷」誨」此是後話出矣去覽意.曰:出,可意",
71 | false, new RelativeSizeSpan(0.8f), new JustifiedSpan(),
72 | new StyleSpan(Typeface.ITALIC));
73 |
74 | addDocumentView(amb, DocumentView.FORMATTED_TEXT);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ClickableSpanTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ClickableSpanTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Color;
33 | import android.os.Bundle;
34 | import android.text.TextPaint;
35 | import android.text.style.ClickableSpan;
36 | import android.text.style.RelativeSizeSpan;
37 | import android.view.View;
38 | import android.widget.Toast;
39 |
40 | import com.bluejamesbond.text.DocumentView;
41 | import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
42 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
43 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
44 | import com.bluejamesbond.text.sample.helper.TestActivity;
45 | import com.bluejamesbond.text.style.JustifiedSpan;
46 |
47 | public class ClickableSpanTest extends TestActivity {
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 |
53 | final DocumentView documentView = addDocumentView(new ArticleBuilder().append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
54 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
55 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease. ",
56 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801))
57 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
58 | true, new RelativeSizeSpan(1f), new JustifiedSpan(), new ClickableSpan() {
59 | @Override
60 | public void onClick(View widget) {
61 | Toast.makeText(ClickableSpanTest.this, "Clicked", Toast.LENGTH_SHORT).show();
62 | }
63 |
64 | @Override
65 | public void updateDrawState(TextPaint ds) {
66 | ds.setColor(Color.parseColor("#ff05c5cf"));
67 | ds.setUnderlineText(true);
68 | }
69 | })
70 | .append("New York and New Jersey state health department staff will be present on the ground at John F. Kennedy International Airport in New York and Newark Liberty Airport in New Jersey. In addition to implementing the mandatory quarantine of health care workers and others who had direct contact with Ebola patients, health department officials in each state will determine whether others should travelers should be hospitalized or quarantined.",
71 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
72 | .append("“The announcements mark a dramatic escalation in measures designed to prevent the spread of Ebola in the United States. Previously, only individuals with symptoms of Ebola would be quarantined upon entry to the U.S. under a federal rule from the Centers for Diseases Control and the Department of Homeland Security.”",
73 | true, new RelativeSizeSpan(1f), new JustifiedSpan()), DocumentView.FORMATTED_TEXT);
74 |
75 | documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
76 | documentView.getDocumentLayoutParams().setHyphenated(true);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ComplexLayoutTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ComplexLayoutTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:36 AM
30 | */
31 |
32 | import com.bluejamesbond.text.sample.R;
33 | import com.bluejamesbond.text.sample.helper.TestActivity;
34 |
35 | public class ComplexLayoutTest extends TestActivity {
36 |
37 | @Override
38 | protected int getContentView() {
39 | return R.layout.test_complex_layout;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/CustomHyphenatorTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * CustomHyphenatorTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 |
34 | import com.bluejamesbond.text.DocumentView;
35 | import com.bluejamesbond.text.hyphen.DefaultHyphenator;
36 | import com.bluejamesbond.text.hyphen.IHyphenator;
37 | import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
38 | import com.bluejamesbond.text.sample.R;
39 | import com.bluejamesbond.text.sample.helper.TestActivity;
40 | import com.bluejamesbond.text.style.TextAlignment;
41 |
42 | import java.util.ArrayList;
43 |
44 | public class CustomHyphenatorTest extends TestActivity {
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 |
50 | DocumentView documentView = addDocumentView(new StringBuilder()
51 | .append(getResources().getString(R.string.plain_text))
52 | .toString(), DocumentView.PLAIN_TEXT);
53 |
54 | documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
55 | documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
56 | documentView.getDocumentLayoutParams().setHyphenated(true);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ForceNoCacheXMLTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ForeNoCacheXMLTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 2/4/15 11:31 AM
30 | */
31 |
32 | import com.bluejamesbond.text.sample.R;
33 | import com.bluejamesbond.text.sample.helper.TestActivity;
34 |
35 | public class ForceNoCacheXMLTest extends TestActivity {
36 |
37 | @Override
38 | protected int getContentView() {
39 | return R.layout.test_xml_activity_no_cache;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/HyphenatedTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * HyphenatedTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 |
34 | import com.bluejamesbond.text.DocumentView;
35 | import com.bluejamesbond.text.hyphen.DefaultHyphenator;
36 | import com.bluejamesbond.text.hyphen.DefaultHyphenator.HyphenPattern;
37 | import com.bluejamesbond.text.sample.helper.TestActivity;
38 | import com.bluejamesbond.text.style.TextAlignment;
39 |
40 | public class HyphenatedTest extends TestActivity {
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | DocumentView documentView = addDocumentView(new StringBuilder()
47 | .append("Vágner Mancini hoje é um sujeito tão angustiado quanto otimista, por mais que pareça uma contradição. O técnico do Botafogo tem a difícil missão de salvar " +
48 | "o time do rebaixamento no Campeonato Brasileiro, apesar de todas as dificuldades que o próprio clube impõe a seu trabalho - salários atrasados, afastamento " +
49 | "de jogadores importantes, dívidas que ameaçam até as poucas chances que ainda existem de permanência na Série A em 2015. Na manhã desta segunda-feira, Mancini " +
50 | "falou ao blog.")
51 | .toString(), DocumentView.PLAIN_TEXT);
52 |
53 | documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
54 | documentView.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.getInstance(HyphenPattern.PT));
55 | documentView.getDocumentLayoutParams().setHyphenated(true);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ImageSpanTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ImageSpanTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 2/3/15 11:00 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.ImageSpan;
35 | import android.text.style.RelativeSizeSpan;
36 | import android.text.style.StyleSpan;
37 |
38 | import com.bluejamesbond.text.DocumentView;
39 | import com.bluejamesbond.text.sample.R;
40 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
41 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
42 | import com.bluejamesbond.text.sample.helper.TestActivity;
43 | import com.bluejamesbond.text.style.CenterSpan;
44 | import com.bluejamesbond.text.style.JustifiedSpan;
45 | import com.bluejamesbond.text.style.LeftSpan;
46 |
47 | public class ImageSpanTest extends TestActivity {
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 |
53 | ArticleBuilder ab = new ArticleBuilder()
54 | .append(testName,
55 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
56 | new LeftSpan())
57 | .append("Justin Worland @justinworland Oct. 25, 2014",
58 | false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
59 | .append("Updated: Oct. 25, 2014 2:34 PM".toUpperCase(),
60 | true, new RelativeSizeSpan(0.6f), new StyleSpan(Typeface.BOLD))
61 | .append("State health department staff will be on the ground at state airports",
62 | true, new RelativeSizeSpan(1.2f), new StyleSpan(Typeface.BOLD),
63 | new StyleSpan(Typeface.ITALIC));
64 |
65 | for (int i = 0; i < 1; i++)
66 | ab.append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
67 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
68 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease.",
69 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801))
70 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
71 | true, new RelativeSizeSpan(1f), new CenterSpan(),
72 | new ImageSpan(getResources().getDrawable(R.drawable.ic_launcher), ImageSpan.ALIGN_BASELINE));
73 |
74 | addDocumentView(ab,
75 | DocumentView.FORMATTED_TEXT);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/LeadingMarginSpan2Test.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * LeadingMarginSpan2Test.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.RelativeSizeSpan;
35 | import android.text.style.StyleSpan;
36 |
37 | import com.bluejamesbond.text.DocumentView;
38 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
39 | import com.bluejamesbond.text.sample.helper.MyLeadingMarginSpan2;
40 | import com.bluejamesbond.text.sample.helper.TestActivity;
41 | import com.bluejamesbond.text.style.JustifiedSpan;
42 | import com.bluejamesbond.text.style.LeftSpan;
43 |
44 | public class LeadingMarginSpan2Test extends TestActivity {
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 |
49 | ArticleBuilder amb = new ArticleBuilder();
50 | amb.append(testName, false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
51 | new LeftSpan());
52 | amb.append(
53 | "@levifan Oct 9. 28, 2014",
54 | true, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD));
55 | amb.append(
56 | "现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始," +
57 | "但实际情况是在访问特定变量的时候经一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候" +
58 | "经一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。"
59 | , false, new RelativeSizeSpan(1f), new JustifiedSpan(),
60 | new MyLeadingMarginSpan2(2, 100));
61 |
62 | addDocumentView(amb
63 |
64 | , DocumentView.FORMATTED_TEXT);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/LineBreakTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * LineBreakTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 | import android.text.SpannableStringBuilder;
34 | import android.text.Spanned;
35 |
36 | import com.bluejamesbond.text.DocumentView;
37 | import com.bluejamesbond.text.sample.helper.MyLeadingMarginSpan2;
38 | import com.bluejamesbond.text.sample.helper.TestActivity;
39 | import com.bluejamesbond.text.style.JustifiedSpan;
40 |
41 | public class LineBreakTest extends TestActivity {
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | SpannableStringBuilder result = new SpannableStringBuilder();
47 | result.append(testName + "\n");
48 | result.append("SpaceBug\n");
49 | result.append(
50 | "现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始," +
51 | "但实际情况是在访问特定变量的时候经一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候" +
52 | "经一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。\n");
53 | result.append("现代计算机\n");
54 | result.setSpan(new JustifiedSpan(), 0, result.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
55 | result.setSpan(new MyLeadingMarginSpan2(2, 100), 0, result.length(),
56 | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
57 |
58 | addDocumentView(result, DocumentView.FORMATTED_TEXT);
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ListViewTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ListViewTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 | import android.view.MotionEvent;
34 | import android.view.View;
35 | import android.widget.ListView;
36 | import android.widget.SimpleAdapter;
37 |
38 | import com.bluejamesbond.text.sample.R;
39 | import com.bluejamesbond.text.sample.helper.TestActivity;
40 |
41 | import java.util.ArrayList;
42 | import java.util.HashMap;
43 |
44 | public class ListViewTest extends TestActivity {
45 |
46 | @Override
47 | protected int getContentView() {
48 | return R.layout.test_listview;
49 | }
50 |
51 | @Override
52 | public void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 |
55 | ArrayList> data = new ArrayList>();
56 | data.add(new HashMap() {{
57 | put("Title", "Item 1");
58 | }});
59 |
60 | data.add(new HashMap() {{
61 | put("Title", "Item 2");
62 | }});
63 |
64 | data.add(new HashMap() {{
65 | put("Title", "Item 3");
66 | }});
67 |
68 | final ListView listview = (ListView) findViewById(R.id.list);
69 | SimpleAdapter adapter = new SimpleAdapter(this,
70 | data,
71 | R.layout.test_listview_item,
72 | new String[]{"Title"},
73 | new int[]{R.id.title});
74 |
75 | listview.setAdapter(adapter);
76 |
77 | }
78 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/LongFormattedTextTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * LongFormattedTextTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.RelativeSizeSpan;
35 | import android.text.style.StyleSpan;
36 |
37 | import com.bluejamesbond.text.DocumentView;
38 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
39 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
40 | import com.bluejamesbond.text.sample.helper.TestActivity;
41 | import com.bluejamesbond.text.style.CenterSpan;
42 | import com.bluejamesbond.text.style.JustifiedSpan;
43 | import com.bluejamesbond.text.style.LeftSpan;
44 | import com.bluejamesbond.text.style.RightSpan;
45 |
46 | public class LongFormattedTextTest extends TestActivity {
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 |
52 | ArticleBuilder ab = new ArticleBuilder()
53 | .append(testName,
54 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
55 | new LeftSpan())
56 | .append("Justin Worland @justinworland Oct. 25, 2014",
57 | false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
58 | .append("Updated: Oct. 25, 2014 2:34 PM".toUpperCase(),
59 | true, new RelativeSizeSpan(0.6f), new StyleSpan(Typeface.BOLD))
60 | .append("State health department staff will be on the ground at state airports",
61 | true, new RelativeSizeSpan(1.2f), new StyleSpan(Typeface.BOLD),
62 | new StyleSpan(Typeface.ITALIC));
63 |
64 | for (int i = 0; i < 15; i++)
65 | ab.append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
66 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
67 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease.",
68 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801))
69 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
70 | true, new RelativeSizeSpan(1f), new CenterSpan())
71 | .append("New York and New Jersey state health department staff will be present on the ground at John F. Kennedy International Airport in New York and Newark Liberty Airport in New Jersey. In addition to implementing the mandatory quarantine of health care workers and others who had direct contact with Ebola patients, health department officials in each state will determine whether others should travelers should be hospitalized or quarantined.",
72 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
73 | .append("“The announcements mark a dramatic escalation in measures designed to prevent the spread of Ebola in the United States. Previously, only individuals with symptoms of Ebola would be quarantined upon entry to the U.S. under a federal rule from the Centers for Diseases Control and the Department of Homeland Security.”",
74 | true, new RelativeSizeSpan(1f), new RightSpan());
75 |
76 | addDocumentView(ab,
77 | DocumentView.FORMATTED_TEXT);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/LongPlainTextTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * LongPlainTextTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 |
34 | import com.bluejamesbond.text.DocumentView;
35 | import com.bluejamesbond.text.sample.R;
36 | import com.bluejamesbond.text.sample.helper.TestActivity;
37 |
38 | public class LongPlainTextTest extends TestActivity {
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 |
44 | addDocumentView("Short sentence.\n\n" +
45 | getResources().getString(R.string.plain_text), DocumentView.PLAIN_TEXT);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/MixedRTLTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * MixedRTLTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.RelativeSizeSpan;
35 | import android.text.style.StyleSpan;
36 |
37 | import com.bluejamesbond.text.DocumentView;
38 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
39 | import com.bluejamesbond.text.sample.helper.TestActivity;
40 | import com.bluejamesbond.text.style.Direction;
41 | import com.bluejamesbond.text.style.DirectionSpan;
42 | import com.bluejamesbond.text.style.JustifiedSpan;
43 | import com.bluejamesbond.text.style.LeftSpan;
44 | import com.bluejamesbond.text.style.RightSpan;
45 |
46 | public class MixedRTLTest extends TestActivity {
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 |
52 | addDocumentView(new ArticleBuilder()
53 | .append(testName,
54 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD), new LeftSpan())
55 | .append("Justin Worland @justinworland Oct. 25, 2014",
56 | false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD), new DirectionSpan(Direction.RIGHT_TO_LEFT))
57 | .append("Updated: Oct. 25, 2014 2:34 PM".toUpperCase(),
58 | true, new RelativeSizeSpan(0.6f), new StyleSpan(Typeface.BOLD))
59 | .append("State health department staff will be on the ground at state airports",
60 | true, new RelativeSizeSpan(1.2f), new StyleSpan(Typeface.BOLD),
61 | new StyleSpan(Typeface.ITALIC))
62 | .append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
63 | true, new RelativeSizeSpan(1f), new JustifiedSpan(), new DirectionSpan(Direction.RIGHT_TO_LEFT))
64 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease.",
65 | true, new RelativeSizeSpan(1f), new RightSpan(), new DirectionSpan(Direction.RIGHT_TO_LEFT))
66 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
67 | true, new RelativeSizeSpan(1f), new JustifiedSpan(),
68 | new StyleSpan(Typeface.ITALIC))
69 | .append("New York and New Jersey state health department staff will be present on the ground at John F. Kennedy International Airport in New York and Newark Liberty Airport in New Jersey. In addition to implementing the mandatory quarantine of health care workers and others who had direct contact with Ebola patients, health department officials in each state will determine whether others should travelers should be hospitalized or quarantined.",
70 | true, new RelativeSizeSpan(1f), new JustifiedSpan(),
71 | new StyleSpan(Typeface.ITALIC))
72 | .append("“The announcements mark a dramatic escalation in measures designed to prevent the spread of Ebola in the United States. Previously, only individuals with symptoms of Ebola would be quarantined upon entry to the U.S. under a federal rule from the Centers for Diseases Control and the Department of Homeland Security.”",
73 | false, new RelativeSizeSpan(1f), new JustifiedSpan()),
74 | DocumentView.FORMATTED_TEXT);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/NewLineTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * NewLineTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 |
34 | import com.bluejamesbond.text.DocumentView;
35 | import com.bluejamesbond.text.sample.helper.TestActivity;
36 |
37 | public class NewLineTest extends TestActivity {
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | addDocumentView("There will be 6 lines following this message.\n\n\n\n\n\n",
44 | DocumentView.PLAIN_TEXT);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/QuoteSpanTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * QuoteSpanTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.ForegroundColorSpan;
35 | import android.text.style.RelativeSizeSpan;
36 | import android.text.style.StyleSpan;
37 |
38 | import com.bluejamesbond.text.DocumentView;
39 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
40 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
41 | import com.bluejamesbond.text.sample.helper.TestActivity;
42 | import com.bluejamesbond.text.style.JustifiedSpan;
43 | import com.bluejamesbond.text.style.LeftSpan;
44 | import com.bluejamesbond.text.style.RightSpan;
45 |
46 | public class QuoteSpanTest extends TestActivity {
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 |
52 | addDocumentView(new ArticleBuilder()
53 | .append(testName,
54 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
55 | new LeftSpan())
56 | .append("Jon Brodkin Oct. 28, 2014",
57 | true, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
58 | .append("But now we have more numbers on the performance declines, thanks to a new report from the Measurement Lab Consortium (M-Lab). M-Lab hosts measuring equipment at Internet exchange points to analyze connections between network operators and has more than five years' worth of measurements. A report released today examines connections between consumer Internet service providers (\"Access ISPs\" in M-Lab parlance) and backbone operators (\"Transit ISPs\"), including the ones that sent traffic from Netflix to ISPs while the money fights were still going on."
59 | , true, new RelativeSizeSpan(0.8f), new JustifiedSpan(),
60 | new MyQuoteSpan(0xFFFFC801, 2, 50), new StyleSpan(Typeface.ITALIC),
61 | new ForegroundColorSpan(0xFF555555))
62 | .append("Using Measurement Lab (M-Lab) data, and constraining our research to the United States, we observed sustained performance degradation experienced by customers of Access ISPs AT&T, Comcast, CenturyLink, Time Warner Cable, and Verizon when their traffic passed over interconnections with Transit ISPs Cogent Communications (Cogent), Level 3 Communications (Level 3), and XO Communications (XO),\" researchers wrote. \"In a large number of cases we observed similar patterns of performance degradation whenever and wherever specific pairs of Access/Transit ISPs interconnected. From this we conclude that ISP interconnection has a substantial impact on consumer internet performance—sometimes a severely negative impact—and that business relationships between ISPs, and not major technical problems, are at the root of the problems we observed.",
63 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
64 | .append("Using Measurement Lab (M-Lab) data, and constraining our research to the United States, we observed sustained performance degradation experienced by customers of Access ISPs AT&T, Comcast, CenturyLink, Time Warner Cable, and Verizon when their traffic passed over interconnections with Transit ISPs Cogent Communications (Cogent), Level 3 Communications (Level 3), and XO Communications (XO),\" researchers wrote. \"In a large number of cases we observed similar patterns of performance degradation whenever and wherever specific pairs of Access/Transit ISPs interconnected. From this we conclude that ISP interconnection has a substantial impact on consumer internet performance—sometimes a severely negative impact—and that business relationships between ISPs, and not major technical problems, are at the root of the problems we observed."
65 | , false, new RelativeSizeSpan(0.8f), new RightSpan(),
66 | new MyQuoteSpan(0xFFFFC801, 2, 50), new StyleSpan(Typeface.ITALIC),
67 | new ForegroundColorSpan(0xFF555555)), DocumentView.FORMATTED_TEXT);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/RTLTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * RTLTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.RelativeSizeSpan;
35 | import android.text.style.StyleSpan;
36 |
37 | import com.bluejamesbond.text.DocumentView;
38 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
39 | import com.bluejamesbond.text.sample.helper.TestActivity;
40 | import com.bluejamesbond.text.style.JustifiedSpan;
41 | import com.bluejamesbond.text.style.RightSpan;
42 |
43 | public class RTLTest extends TestActivity {
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 |
49 | addDocumentView(new ArticleBuilder()
50 | .append(testName,
51 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
52 | new RightSpan())
53 | .append("Justin Worland @justinworland Oct. 25, 2014",
54 | false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
55 | .append("Updated: Oct. 25, 2014 2:34 PM".toUpperCase(),
56 | true, new RelativeSizeSpan(0.6f), new StyleSpan(Typeface.BOLD))
57 | .append("State health department staff will be on the ground at state airports",
58 | true, new RelativeSizeSpan(1.2f), new StyleSpan(Typeface.BOLD),
59 | new StyleSpan(Typeface.ITALIC))
60 | .append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
61 | true, new RelativeSizeSpan(1f), new RightSpan())
62 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease.",
63 | true, new RelativeSizeSpan(1f), new RightSpan())
64 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
65 | true, new RelativeSizeSpan(1f), new JustifiedSpan(),
66 | new StyleSpan(Typeface.ITALIC))
67 | .append("New York and New Jersey state health department staff will be present on the ground at John F. Kennedy International Airport in New York and Newark Liberty Airport in New Jersey. In addition to implementing the mandatory quarantine of health care workers and others who had direct contact with Ebola patients, health department officials in each state will determine whether others should travelers should be hospitalized or quarantined.",
68 | true, new RelativeSizeSpan(1f), new JustifiedSpan(),
69 | new StyleSpan(Typeface.ITALIC))
70 | .append("“The announcements mark a dramatic escalation in measures designed to prevent the spread of Ebola in the United States. Previously, only individuals with symptoms of Ebola would be quarantined upon entry to the U.S. under a federal rule from the Centers for Diseases Control and the Department of Homeland Security.”",
71 | false, new RelativeSizeSpan(1f), new RightSpan()),
72 | DocumentView.FORMATTED_TEXT, true);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/ShortFormattedTextTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * ShortFormattedTextTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 2/2/15 10:52 AM
30 | */
31 |
32 | import android.graphics.Typeface;
33 | import android.os.Bundle;
34 | import android.text.style.RelativeSizeSpan;
35 | import android.text.style.StyleSpan;
36 |
37 | import com.bluejamesbond.text.DocumentView;
38 | import com.bluejamesbond.text.sample.helper.ArticleBuilder;
39 | import com.bluejamesbond.text.sample.helper.MyQuoteSpan;
40 | import com.bluejamesbond.text.sample.helper.TestActivity;
41 | import com.bluejamesbond.text.style.CenterSpan;
42 | import com.bluejamesbond.text.style.JustifiedSpan;
43 | import com.bluejamesbond.text.style.LeftSpan;
44 | import com.bluejamesbond.text.style.RightSpan;
45 |
46 | public class ShortFormattedTextTest extends TestActivity {
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 |
52 | ArticleBuilder ab = new ArticleBuilder()
53 | .append(testName,
54 | false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD),
55 | new LeftSpan())
56 | .append("Justin Worland @justinworland Oct. 25, 2014",
57 | false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
58 | .append("Updated: Oct. 25, 2014 2:34 PM".toUpperCase(),
59 | true, new RelativeSizeSpan(0.6f), new StyleSpan(Typeface.BOLD))
60 | .append("State health department staff will be on the ground at state airports",
61 | true, new RelativeSizeSpan(1.2f), new StyleSpan(Typeface.BOLD),
62 | new StyleSpan(Typeface.ITALIC));
63 |
64 | for (int i = 0; i < 1; i++)
65 | ab.append("Healthcare workers returning to New York or New Jersey after treating Ebola patients in West Africa will be placed under a mandatory quarantine, officials announced Friday, one day after a Doctors Without Borders doctor was diagnosed with the virus in New York City. Illinois announced a similar policy Saturday, meaning it will be enforced in states with three of the five airports through which passengers traveling from the Ebola-stricken West African countries must enter the United States.",
66 | true, new RelativeSizeSpan(1f), new JustifiedSpan())
67 | .append("N.J. Gov. Chris Christie and N.Y. Gov. Andrew Cuomo made the announcement as part of a broader procedural plan to help protect the densely packed, highly populated area from any further spread of the disease.",
68 | true, new RelativeSizeSpan(0.8f), new JustifiedSpan(), new MyQuoteSpan(0xFFFFC801))
69 | .append("“Since taking office, I have erred on the side of caution when it comes to the safety and protection of New Yorkers, and the current situation regarding Ebola will be no different,” Gov. Cuomo said. “The steps New York and New Jersey are taking today will strengthen our safeguards to protect our residents against this disease and help ensure those that may be infected by Ebola are treated with the highest precautions.”",
70 | true, new RelativeSizeSpan(1f), new CenterSpan());
71 |
72 | addDocumentView(ab,
73 | DocumentView.FORMATTED_TEXT);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/TextUpdateTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TextUpdateTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 2/2/15 10:39 AM
30 | */
31 |
32 | import android.os.Bundle;
33 | import android.view.View;
34 |
35 | import com.bluejamesbond.text.Console;
36 | import com.bluejamesbond.text.DocumentView;
37 | import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
38 | import com.bluejamesbond.text.sample.helper.TestActivity;
39 |
40 | public class TextUpdateTest extends TestActivity {
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | final DocumentView documentView = addDocumentView("Click here!"
47 | , DocumentView.PLAIN_TEXT);
48 |
49 | documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
50 | documentView.getDocumentLayoutParams().setHyphenated(true);
51 | documentView.getViewportView().setClickable(true);
52 | documentView.getViewportView().setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | Console.log("Clicked");
56 | documentView.setText("Click[" + System.currentTimeMillis() + "], " + documentView.getText());
57 | }
58 | });
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/TextViewTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * TextViewTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import com.bluejamesbond.text.sample.R;
33 | import com.bluejamesbond.text.sample.helper.TestActivity;
34 |
35 | public class TextViewTest extends TestActivity {
36 |
37 | @Override
38 | protected int getContentView() {
39 | return R.layout.test_textview_xml_activity;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/WordSpacingTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * WordSpacingTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import android.os.Bundle;
33 |
34 | import com.bluejamesbond.text.DocumentView;
35 | import com.bluejamesbond.text.sample.helper.TestActivity;
36 |
37 | public class WordSpacingTest extends TestActivity {
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | DocumentView documentView = addDocumentView("Document view now supports both String and Spannables. To support this, there are two (2) types of layouts: (a) " +
44 | "DocumentLayout and (b) SpannedDocumentLayout. " +
45 | "DocumentLayout supports just plain Strings just like the text you are reading. However, Spannables require the " +
46 | "constructor to have SpannedDocumentLayout.class as a parameter. For now, DocumentLayout will offer significant speed improvements " +
47 | "compared to SpannedDocumentLayout, so use each class accordingly. DocumentLayout also supports hyphenation. To learn more about" +
48 | "these layouts and what they have to offer visit the link in the titlebar above. And please report all the issues on GitHub!"
49 | , DocumentView.PLAIN_TEXT);
50 |
51 | documentView.getDocumentLayoutParams().setWordSpacingMultiplier(5f);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/bluejamesbond/text/sample/test/XMLTest.java:
--------------------------------------------------------------------------------
1 | package com.bluejamesbond.text.sample.test;
2 |
3 | /*
4 | * Copyright 2015 Mathew Kurian
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 | *
20 | * XMLTest.java
21 | * @author Mathew Kurian
22 | *
23 | * From TextJustify-Android Library v2.0
24 | * https://github.com/bluejamesbond/TextJustify-Android
25 | *
26 | * Please report any issues
27 | * https://github.com/bluejamesbond/TextJustify-Android/issues
28 | *
29 | * Date: 1/27/15 3:35 AM
30 | */
31 |
32 | import com.bluejamesbond.text.sample.R;
33 | import com.bluejamesbond.text.sample.helper.TestActivity;
34 |
35 | public class XMLTest extends TestActivity {
36 |
37 | @Override
38 | protected int getContentView() {
39 | return R.layout.test_xml_activity;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/list__border_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 | -
33 |
34 |
35 |
36 |
37 | -
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/progress__background.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 | -
33 |
34 |
35 |
36 |
37 |
38 | -
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/simple_button__background.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
34 |
35 |
36 |
38 |
39 |
40 |
42 |
43 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/simple_button__background_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/simple_button__background_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/test_listview_item_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_activity.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
47 |
48 |
57 |
58 |
59 |
66 |
67 |
81 |
82 |
96 |
97 |
98 |
104 |
105 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_complex_layout.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
47 |
48 |
57 |
58 |
59 |
66 |
67 |
81 |
82 |
96 |
97 |
98 |
106 |
107 |
112 |
113 |
118 |
119 |
125 |
126 |
136 |
137 |
148 |
149 |
150 |
151 |
152 |
153 |
160 |
161 |
171 |
172 |
176 |
177 |
188 |
189 |
199 |
200 |
201 |
202 |
211 |
212 |
213 |
214 |
220 |
221 |
227 |
228 |
237 |
238 |
254 |
255 |
256 |
257 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_listview.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
47 |
48 |
57 |
58 |
59 |
66 |
67 |
81 |
82 |
96 |
97 |
98 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_listview_item.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
37 |
38 |
44 |
45 |
57 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_textview_xml_activity.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
49 |
50 |
51 |
58 |
59 |
73 |
74 |
88 |
89 |
90 |
95 |
96 |
102 |
103 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_xml_activity.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
47 |
48 |
57 |
58 |
59 |
66 |
67 |
81 |
82 |
96 |
97 |
98 |
124 |
125 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/test_xml_activity_no_cache.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
34 |
35 |
38 |
39 |
47 |
48 |
57 |
58 |
59 |
66 |
67 |
81 |
82 |
96 |
97 |
98 |
123 |
124 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/testlist_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
35 |
36 |
45 |
46 |
52 |
53 |
60 |
61 |
62 |
69 |
70 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 |
31 |
32 | 16dp
33 | 16dp
34 |
35 |
36 |
--------------------------------------------------------------------------------
/screenshots/chinese.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/screenshots/chinese.png
--------------------------------------------------------------------------------
/screenshots/leadMarginSpan2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/screenshots/leadMarginSpan2.png
--------------------------------------------------------------------------------
/screenshots/quoteSpan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/screenshots/quoteSpan.png
--------------------------------------------------------------------------------
/screenshots/rtl-reverse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/screenshots/rtl-reverse.png
--------------------------------------------------------------------------------
/screenshots/testlist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devilWwj/TextJustify-Android/1c957ac2b5fe2515deafa733086f2bafb5e6b457/screenshots/testlist.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':library'
--------------------------------------------------------------------------------