-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fbshipit-source-id: 4799a0dd91a4b569e932c08ecc5849b2a8943dbb
- Loading branch information
0 parents
commit b060582
Showing
87 changed files
with
10,366 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gradle | ||
.DS_Store | ||
.idea | ||
build/ | ||
local.properties | ||
localhost/ | ||
obj/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Contributing to TextLayoutBuilder | ||
We want to make contributing to this project as easy and transparent as | ||
possible. | ||
|
||
|
||
## Issues | ||
We use GitHub issues to track public bugs. | ||
|
||
When you report an issue the more information the better. Here are some things that will help you get an answer faster: | ||
|
||
- A *title* as well as a body for the issue. | ||
- A screenshot or video of the problem. | ||
- Logcat output, if your app is crashing. | ||
- A snippet of the code in question | ||
- Place code in blocks so that it reads like code: | ||
|
||
``` | ||
```java (or xml) | ||
your code here | ||
```(terminating backticks) | ||
``` | ||
|
||
#### Security bugs | ||
|
||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe | ||
disclosure of security bugs. In those cases, please go through the process | ||
outlined on that page and do not file a public issue. | ||
|
||
## Pull Requests | ||
We actively welcome your pull requests. | ||
|
||
1. Fork the repo and create your branch from `master`. | ||
2. If you've added code that should be tested, add tests | ||
3. If you've changed APIs, update the documentation. | ||
4. Ensure the test suite passes. | ||
5. Make sure your code lints. | ||
6. If you haven't already, complete the Contributor License Agreement ("CLA"). | ||
|
||
## Contributor License Agreement ("CLA") | ||
In order to accept your pull request, we need you to submit a CLA. You only need | ||
to do this once to work on any of Facebook's open source projects. | ||
|
||
Complete your CLA here: <https://code.facebook.com/cla>. | ||
|
||
## Our Development Process | ||
Each pull request is first submitted into Facebook's internal repositories by a | ||
Facebook team member. Once the commit has successfully passed Facebook's internal | ||
test suite, it will be exported back out from Facebook's repository. We endeavour | ||
to do this as soon as possible for all commits. | ||
|
||
## Coding Style | ||
* 2 spaces for indentation rather than tabs | ||
* 100 character line length | ||
* Although officially archived, we still follow the practice of Oracle's | ||
[Coding Conventions for the Java Programming Language](http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html). | ||
|
||
## License | ||
By contributing to TextLayoutBuilder, you agree that your contributions will be licensed | ||
under its BSD license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BSD License | ||
|
||
For TextLayoutBuilder software | ||
|
||
Copyright (c) 2016-present, Facebook, Inc. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name Facebook nor the names of its contributors may be used to | ||
endorse or promote products derived from this software without specific | ||
prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Additional Grant of Patent Rights Version 2 | ||
|
||
"Software" means the TextLayoutBuilder software contributed by Facebook, Inc. | ||
|
||
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software | ||
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable | ||
(subject to the termination provision below) license under any Necessary | ||
Claims, to make, have made, use, sell, offer to sell, import, and otherwise | ||
transfer the Software. For avoidance of doubt, no license is granted under | ||
Facebook’s rights in any patent claims that are infringed by (i) modifications | ||
to the Software made by you or any third party or (ii) the Software in | ||
combination with any software or other technology. | ||
|
||
The license granted hereunder will terminate, automatically and without notice, | ||
if you (or any of your subsidiaries, corporate affiliates or agents) initiate | ||
directly or indirectly, or take a direct financial interest in, any Patent | ||
Assertion: (i) against Facebook or any of its subsidiaries or corporate | ||
affiliates, (ii) against any party if such Patent Assertion arises in whole or | ||
in part from any software, technology, product or service of Facebook or any of | ||
its subsidiaries or corporate affiliates, or (iii) against any party relating | ||
to the Software. Notwithstanding the foregoing, if Facebook or any of its | ||
subsidiaries or corporate affiliates files a lawsuit alleging patent | ||
infringement against you in the first instance, and you respond by filing a | ||
patent infringement counterclaim in that lawsuit against that party that is | ||
unrelated to the Software, the license granted hereunder will not terminate | ||
under section (i) of this paragraph due to such counterclaim. | ||
|
||
A "Necessary Claim" is a claim of a patent owned by Facebook that is | ||
necessarily infringed by the Software standing alone. | ||
|
||
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, | ||
or contributory infringement or inducement to infringe any patent, including a | ||
cross-claim or counterclaim. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
TextLayoutBuilder | ||
================= | ||
Build text [Layout](https://developer.android.com/reference/android/text/Layout.html)s easily on Android. | ||
|
||
![TextLayoutBuilder logo](./docs/logo.png) | ||
|
||
Features | ||
-------- | ||
- Create text `Layout`s easily. | ||
- Reuse builders to create similarly styled `Layout`s. | ||
- Cache `Layout`s of commonly used strings. | ||
- Improve performance using glyph warming. | ||
|
||
Download | ||
-------- | ||
If using Gradle, add this to your `build.gradle`: | ||
|
||
```groovy | ||
compile 'com.facebook.fbui.textlayoutbuilder:textlayoutbuilder:1.0.0' | ||
``` | ||
|
||
or, if using Maven: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.facebook.fbui.textlayoutbuilder</groupId> | ||
<artifactId>textlayoutbuilder</artifactId> | ||
<version>1.0.0</version> | ||
<type>aar</type> | ||
</dependency> | ||
``` | ||
|
||
Usage | ||
----- | ||
1. Set the properties on the `TextLayoutBuilder`: | ||
```java | ||
TextLayoutBuilder builder = new TextLayoutBuilder() | ||
.setTextAppearance(context, resId) | ||
.setText("TextLayoutBuilder makes life easy") | ||
.setWidth(400); | ||
``` | ||
|
||
2. Call `build()` on the builder to get a `Layout`: | ||
```java | ||
Layout layout = builder.build(); | ||
``` | ||
|
||
3. Use the `Layout` in your code: | ||
```java | ||
public class CustomView extends View { | ||
private Layout mLayout; | ||
|
||
public CustomView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public void setLayout(Layout layout) { | ||
mLayout = layout; | ||
} | ||
|
||
@Override | ||
protected void onDraw(Canvas canvas) { | ||
super.draw(canvas); | ||
|
||
// Draw the layout. | ||
mLayout.draw(canvas); | ||
} | ||
} | ||
``` | ||
|
||
Additional Usage | ||
---------------- | ||
1. Cache the layouts for commonly used strings by turning on caching in the `TextLayoutBuilder`. | ||
```java | ||
mTextLayoutBuilder.setShouldCacheLayout(true); | ||
``` | ||
|
||
2. Glyph warming provides significant performance boost for large blurbs of text. | ||
Turn this on and pass in a `GlyphWarmer` for the `TextLayoutBuilder`. | ||
```java | ||
mTextLayoutBuilder | ||
.setShouldWarmText(true) | ||
.setGlyphWarmer(new GlyphWarmerImpl()); | ||
``` | ||
|
||
3. Import a style defined in XML into a `TextLayoutBuilder` object. | ||
```java | ||
ResourceTextLayoutHelper.updateFromStyleResource( | ||
mTextLayoutBuilder, // builder object | ||
mContext, // Activity context | ||
resId); // style resource id | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.1.3' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
ext { | ||
minSdkVersion = 9 | ||
targetSdkVersion = 24 | ||
compileSdkVersion = 24 | ||
buildToolsVersion = '24.0.2' | ||
|
||
junitVersion = '4.12' | ||
mockitoCoreVersion = '1.10.19' | ||
robolectricVersion = '3.0' | ||
supportLibVersion = '24.2.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<meta property="og:url" content="http://facebookincubator.github.io/TextLayoutBuilder" /> | ||
<meta property="og:site_name" content="TextLayoutBuilder"/> | ||
<meta property="og:title" content="TextLayoutBuilder | Build text Layouts easily on Android." /> | ||
<meta property="og:image" content="http://facebookincubator.github.io/TextLayoutBuilder/logo.png" /> | ||
<meta property="og:description" content="TextLayoutBuilder is a utility to build text layouts easily on Android." /> | ||
|
||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> | ||
<link rel="stylesheet" href="./main.css" media="screen"> | ||
<link rel="icon" href="./favicon.png" type="image/x-icon"> | ||
|
||
<title>TextLayoutBuilder - API</title> | ||
<meta name="description" content="TextLayoutBuilder is a utility to build text layouts easily on Android."> | ||
|
||
<link rel="canonical" href="http://facebookincubator.github.io/TextLayoutBuilder"> | ||
<script> | ||
// Make #apiContainer use entire height of the window. | ||
window.onresize = window.onload = function() { | ||
// header and footer is 64px each. | ||
// apiContainer has a padding of 64px. | ||
document.getElementById('apiContainer').style.height = (window.outerHeight - 196) + 'px'; | ||
} | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<!-- Header --> | ||
<div class="headerContainer"> | ||
<header class="wrapper"> | ||
<a href="http://facebookincubator.github.io/TextLayoutBuilder"> | ||
<img src="./logo.png"> | ||
<h2>TextLayoutBuilder</h2> | ||
</a> | ||
|
||
<div class="spacer"></div> | ||
|
||
<nav> | ||
<ul> | ||
<li class="navItem"> | ||
<a href="./api.html">API</a> | ||
</li> | ||
<li class="navItem"> | ||
<a href="https://github.com/facebookincubator/TextLayoutBuilder">GitHub</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</header> | ||
</div> | ||
|
||
<!-- Contents --> | ||
<div id="apiContainer" class="apiContainer"> | ||
<iframe src="./javadoc/index.html" width="100%" height="100%"></iframe> | ||
</div> | ||
|
||
<!-- Footer --> | ||
<div class="footerContainer"> | ||
<footer class="wrapper"> | ||
<nav> | ||
<ul> | ||
<li> | ||
<div class="fboss"> | ||
<a href="https://code.facebook.com/projects/"> | ||
<svg class="facebookOSSLogoSvg" viewBox="0 0 1133.9 1133.9" x="0px" y="0px"> | ||
<g> | ||
<path class="logoRing outerRing" d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" /> | ||
<path class="logoRing middleRing" d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" /> | ||
<path class="logoRing innerRing" d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" /> | ||
</g> | ||
</svg> | ||
<h2>Facebook Open Source</h2> | ||
</a> | ||
</div> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="spacer"></div> | ||
<nav> | ||
<ul> | ||
<li> | ||
<a href="https://code.facebook.com/projects/" target="_blank">Open Source Projects</a> | ||
</li> | ||
<li> | ||
<a href="https://github.com/facebookincubator/" target="_blank">GitHub</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="spacer"></div> | ||
<nav> | ||
<ul> | ||
<li> | ||
<a href="https://github.com/facebookincubator/TextLayoutBuilder" target="_blank">Contribute to this project on GitHub</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</footer> | ||
</div> | ||
|
||
<!-- Google Analytics --> | ||
<script> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
|
||
ga('create', 'UA-44373548-22', 'auto'); | ||
ga('send', 'pageview'); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.