Commit Graph

786 Commits

Author SHA1 Message Date
Neil Fuller
4400f96d1f am a021e922: resolved conflicts for merge of 12260ad7 to lmp-mr1-dev-plus-aosp
* commit 'a021e922184ee16fc019e29c066719daa793dd2b':
  Deprecating FloatMath and Time
2014-10-24 10:41:46 +00:00
Neil Fuller
a021e92218 resolved conflicts for merge of 12260ad7 to lmp-mr1-dev-plus-aosp
Change-Id: Ie2222794208475216941289cf062e05ca9c75e0f
2014-10-24 11:36:46 +01:00
Elliott Hughes
85f60d3a03 Migrate off timeFormat12 and timeFormat24.
libcore now offers a wider variety of 12-/24-hour time formats,
so be more specific about which one we want here.

Bug: 10361358
Change-Id: I846ab7a6f84cd49e876ad21e9366aff1600e0530
2014-10-23 11:06:43 -07:00
Neil Fuller
bbf8871e1c Deprecating FloatMath and Time
Bug: https://code.google.com/p/android/issues/detail?id=36199
Bug: https://code.google.com/p/android/issues/detail?id=37653
Bug: https://code.google.com/p/android/issues/detail?id=42750
Bug: https://code.google.com/p/android/issues/detail?id=61137
Bug: https://code.google.com/p/android/issues/detail?id=74754
Bug: https://code.google.com/p/android/issues/detail?id=76386
Bug: https://code.google.com/p/android/issues/detail?id=76439
Bug: https://code.google.com/p/android/issues/detail?id=77836
Change-Id: Ic9b57d8a575f93b2258a5481df0ed6b3a952f636
2014-10-23 13:13:05 +01:00
Deepanshu Gupta
eea621810c Merge "Add Optimized Line breaking to LayoutLib" 2014-10-21 22:44:38 +00:00
Deepanshu Gupta
7053919a3a Add Optimized Line breaking to LayoutLib
Change-Id: I308a7d07d98ddd7747f16e06bcffcfd14d667534
2014-10-21 15:43:53 -07:00
Neil Fuller
f4d51632a6 am 8ee06212: am 1802567a: am e4625cc1: Merge "Fix Time docs to document various error cases"
* commit '8ee062122f75f5f9e4904ed95ca3778e670c5f88':
  Fix Time docs to document various error cases
2014-10-15 16:10:03 +00:00
Neil Fuller
8ee062122f am 1802567a: am e4625cc1: Merge "Fix Time docs to document various error cases"
* commit '1802567a79b2fc94aa1dff387cd55db8521cdca6':
  Fix Time docs to document various error cases
2014-10-15 16:05:55 +00:00
Neil Fuller
e4625cc1a8 Merge "Fix Time docs to document various error cases" 2014-10-15 15:56:06 +00:00
Neil Fuller
7079f2003c Fix Time docs to document various error cases
Bug: https://code.google.com/p/android/issues/detail?id=76386
Change-Id: Ibb71405b70453d5abaf45426ec4e36261b6695cf
2014-10-15 12:08:05 +01:00
Newton Allen
df2b8a1cb9 am 58f75627: am 94f5155d: am c68aad9f: am d84ce32b: Merge "Fix some documentation typos." into lmp-dev
* commit '58f75627d195082e263f6d6d8e3c46c6d0970e63':
  Fix some documentation typos.
2014-10-02 19:43:39 +00:00
Neil Fuller
ebf2e8b451 am c2a0b448: resolved conflicts for merge of ee665151 to lmp-mr1-dev-plus-aosp
* commit 'c2a0b4482d7144e8382346ea4c22c7b89368fec0':
  Switch from FloatMath -> Math and Math.hypot where possible
2014-10-02 13:39:55 +00:00
Neil Fuller
c2a0b4482d resolved conflicts for merge of ee665151 to lmp-mr1-dev-plus-aosp
Change-Id: I2588c65b7a9fa43f968151a206924a804f0595a7
2014-10-02 14:32:37 +01:00
Neil Fuller
33253a4baa Switch from FloatMath -> Math and Math.hypot where possible
The motivation is an API change: FloatMath is going to be
deprecated and/or removed. Performance is not the goal of
this change.

That said...

Math is faster than FloatMath with AOT compilation.

While making the change, occurances of:

{Float}Math.sqrt(x * x + y * y) and
{Float}Math.sqrt({Float}Math.pow(x, 2) + {Float}Math.pow(y, 2))

have been replaced with:

{(float)} Math.hypot(x, y)

Right now there is no runtime intrinsic for hypot so is not faster
in all cases for AOT compilation:

Math.sqrt(x * x + y * y) is faster than Math.hypot(x, y) with
AOT, but all other combinations of FloatMath, use of pow() etc.
are slower than hypot().

hypot() has the advantage of being self documenting and
could be optimized in future. None of the behavior differences
around NaN and rounding appear to be important for the cases
looked at: they all assume results and arguments are in range
and usually the results are cast to float.

Different implementations measured on hammerhead / L:

AOT compiled:

[FloatMath.hypot(x, y)]
benchmark=Hypot_FloatMathHypot} 633.85 ns; σ=0.32 ns @ 3 trials

[FloatMath.sqrt(x*x + y*y)]
benchmark=Hypot_FloatMathSqrtMult} 684.17 ns; σ=4.83 ns @ 3 trials

[FloatMath.sqrt(FloatMath.pow(x, 2) + FloatMath.pow(y, 2))]
benchmark=Hypot_FloatMathSqrtPow} 1270.65 ns; σ=12.20 ns @ 6 trials

[(float) Math.hypot(x, y)]
benchmark=Hypot_MathHypot} 96.80 ns; σ=0.05 ns @ 3 trials

[(float) Math.sqrt(x*x + y*y)]
benchmark=Hypot_MathSqrtMult} 23.97 ns; σ=0.01 ns @ 3 trials

[(float) Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))]
benchmark=Hypot_MathSqrtPow} 156.19 ns; σ=0.12 ns @ 3 trials

Interpreter:

benchmark=Hypot_FloatMathHypot} 1180.54 ns; σ=5.13 ns @ 3 trials
benchmark=Hypot_FloatMathSqrtMult} 1121.05 ns; σ=3.80 ns @ 3 trials
benchmark=Hypot_FloatMathSqrtPow} 3327.14 ns; σ=7.33 ns @ 3 trials
benchmark=Hypot_MathHypot} 856.57 ns; σ=1.41 ns @ 3 trials
benchmark=Hypot_MathSqrtMult} 1028.92 ns; σ=9.11 ns @ 3 trials
benchmark=Hypot_MathSqrtPow} 2539.47 ns; σ=24.44 ns @ 3 trials

Bug: https://code.google.com/p/android/issues/detail?id=36199
Change-Id: I06c91f682095e627cb547d60d936ef87941be692
2014-10-01 14:04:15 +01:00
Newton Allen
8f8a11b7fa Fix some documentation typos.
Change-Id: I747a0ade5c7b9c45d4465bf327952338bbc1cfaa
(cherry picked from commit 4465d1a03e)
2014-09-30 02:52:26 +00:00
Newton Allen
4465d1a03e Fix some documentation typos.
Change-Id: I747a0ade5c7b9c45d4465bf327952338bbc1cfaa
2014-09-30 02:49:00 +00:00
Elliott Hughes
51862b168f am 127ba8ff: am 4fec1b48: am 600ca140: Merge "Use constants instead of resources for ellipsis."
* commit '127ba8ff08fd8c317a11831ebf409d249fb5e646':
  Use constants instead of resources for ellipsis.
2014-09-19 23:41:01 +00:00
Elliott Hughes
69eb21074f am 4fec1b48: am 600ca140: Merge "Use constants instead of resources for ellipsis."
* commit '4fec1b488759a89732af151e21a89aa6693ba9bf':
  Use constants instead of resources for ellipsis.
2014-09-19 23:16:52 +00:00
Elliott Hughes
600ca140e2 Merge "Use constants instead of resources for ellipsis." 2014-09-19 22:02:45 +00:00
Igor Viarheichyk
ed0daa93e4 Use constants instead of resources for ellipsis.
All supported locales use only U+2025 and U+2026 to represent
ellipses, and it will unlikely change in future. Given translated
resources are inconsistent and often use three dots it is safer
to use constants instead of resources.

Change-Id: I51a6cb903f62f739fbadd6b78e5765c0028d641a
2014-09-19 22:02:08 +00:00
Elliott Hughes
a559a68c36 am d2f9559a: Merge "resolved conflicts for merge of 2008cff7 to lmp-dev-plus-aosp" into lmp-dev-plus-aosp
* commit 'd2f9559ad7cff93527a05cb85172a7bb29f4d9b2':
  Small documentation fixes across many files.
2014-09-08 20:15:07 +00:00
Elliott Hughes
4656e69bf3 resolved conflicts for merge of 2008cff7 to lmp-dev-plus-aosp
Change-Id: I5148eda624e8504f12dbc1288cd4a7a5b7c10850
2014-09-08 13:08:43 -07:00
Elliott Hughes
ab94a1676e Merge "Small documentation fixes across many files." 2014-09-08 18:44:14 +00:00
Mark Doliner
d0646dca40 Small documentation fixes across many files.
Change-Id: I3e8787ce4bc6018ea1dc9aef2a2cd4e0a8dde663
2014-09-05 13:57:51 -07:00
Raph Levien
fa22262ed2 am a5c45276: am 188d9adb: am 43012fec: Merge "Up/down arrow moves to beginning/end of buffer" into lmp-dev
* commit 'a5c452769069bc21c9c8d29fb28dbfa371f6e81b':
  Up/down arrow moves to beginning/end of buffer
2014-09-04 23:42:11 +00:00
Raph Levien
fb0431b525 Up/down arrow moves to beginning/end of buffer
With a hardware keyboard, using up arrow within the top line should
move to the beginning of the buffer, to better match desktop text
editing expectations, and similarly for down arrow on the last line.
This patch implements that behavior.

Bug: 17385784
Change-Id: Ia23c23c9cc2462558bca9aaffec7d83e284d55e8
2014-09-04 15:03:14 -07:00
Raph Levien
9278b5f28e am c2a9bb67: am f7380a69: am 58e457cc: Merge "Fix Layout.isRtlCharAt" into lmp-dev
* commit 'c2a9bb67b8d76173e6220f852bcc4c78daa4bdd5':
  Fix Layout.isRtlCharAt
2014-09-04 21:28:29 +00:00
Kenny Guy
d946dfa6b0 am c9e9b3bf: am 68fc49ee: am 56e125ff: Merge "Revert "Ensure all RemoteViews use myUserId rather than context."" into lmp-dev
* commit 'c9e9b3bfc3569260d708270aee9c49380cfb7366':
  Revert "Ensure all RemoteViews use myUserId rather than context."
2014-09-04 19:51:13 +00:00
Raph Levien
875062059c Fix Layout.isRtlCharAt
We weren't getting correct results from Layout.isRtlCharAt, because it
was only testing half of the correct predicate for whether the argument
was inside the run. This patch restores the correct predicate.

Bug: 17381011
Change-Id: Ib0a77cc182f4ca4bfe824e85b7aff7268f465d73
2014-09-04 12:47:03 -07:00
Kenny Guy
692356b7c3 Revert "Ensure all RemoteViews use myUserId rather than context."
This reverts commit 5287e37687f117ac0b690100ad90842eff58d15a.
Reverting because only worked if settings cache had been populated
already.

Bug: 17302505
Change-Id: I4360606e9d9c6409951f0a02bd0b78c55085e0c6
2014-09-04 18:24:31 +01:00
Kenny Guy
3f9c59cea1 am aa0ffe26: am 0d548a70: am 5c32b77f: Merge "Ensure all RemoteViews use myUserId rather than context." into lmp-dev
* commit 'aa0ffe267c3bbdefb548cb5de6c7bda29f5365cb':
  Ensure all RemoteViews use myUserId rather than context.
2014-09-04 13:40:58 +00:00
Kenny Guy
879ebec4e2 Ensure all RemoteViews use myUserId rather than context.
Remote views may be inflated in another user so
explicitly use processes user id rather than the
user id of the context.

Bug: 17302505
Change-Id: I985c91745f03dd7e6b2ab6357600077664d8e6be
2014-09-04 12:40:24 +01:00
Neil Fuller
7e19fb0d69 Merge "Fixing android.text.format.Time for non-English locales" into lmp-dev 2014-08-29 13:36:02 +00:00
Neil Fuller
16566656cd Fixing android.text.format.Time for non-English locales
The test fixes for bug 17262063 showed up a real issue for
non-English locales with the Time.format() method:
If the Android string resources that contain the pattern use
non-ASCII characters then a '?' would be output instead of
those characters.

For example, in France the pattern for '%c' includes a 'à'
(a with a grave accent) and Japan includes 日.

The problem was due to converting the pattern to bytes using
the US_ASCII character set, which turns non-ASCII characters
into '?'. The code has been changed to use char throughout
and avoid bytes.

Internal documentation has been improved.

Some calls to modifyAndAppend() have been replaced with a
direct call to outputBuilder.append() because the
modify step is guaranteed to a no-op for the literals given.

The formatter has been changed to use Locale.US because it
is only used for outputting numbers. It has been renamed
to make this more obvious and the locale field has been
removed.

Bug: 17262063

(cherry picked from commit 788cb18f65)

Change-Id: I96ee158fbeb01827f0bbf022631625416f872fdb
2014-08-29 14:10:35 +01:00
Neil Fuller
38e02cfc35 am 176c0ecd: am 23f6a4ab: am 8178edfc: Merge "Fixing android.text.format.Time for non-English locales"
* commit '176c0ecdb15683cdfb39c0fc9944213a65746b91':
  Fixing android.text.format.Time for non-English locales
2014-08-29 12:02:04 +00:00
Neil Fuller
a4bf544991 am 23f6a4ab: am 8178edfc: Merge "Fixing android.text.format.Time for non-English locales"
* commit '23f6a4ab5df4c7e156947f5324be8ae86f7c74fd':
  Fixing android.text.format.Time for non-English locales
2014-08-29 11:40:05 +00:00
Neil Fuller
788cb18f65 Fixing android.text.format.Time for non-English locales
The test fixes for bug 17262063 showed up a real issue for
non-English locales with the Time.format() method:
If the Android string resources that contain the pattern use
non-ASCII characters then a '?' would be output instead of
those characters.

For example, in France the pattern for '%c' includes a 'à'
(a with a grave accent) and Japan includes 日.

The problem was due to converting the pattern to bytes using
the US_ASCII character set, which turns non-ASCII characters
into '?'. The code has been changed to use char throughout
and avoid bytes.

Internal documentation has been improved.

Some calls to modifyAndAppend() have been replaced with a
direct call to outputBuilder.append() because the
modify step is guaranteed to a no-op for the literals given.

The formatter has been changed to use Locale.US because it
is only used for outputting numbers. It has been renamed
to make this more obvious and the locale field has been
removed.

Bug: 17262063
Change-Id: I32b92f7f7e3e6931d3514d87f1d9a38f136d4021
2014-08-29 09:08:47 +01:00
Raph Levien
26c87cfb58 Ignore width of trailing whitespace for computing ellipsis
We used the full width of a line, including trailing spaces, to compute
ellipsis, sometimes causing spurious ellipsization when the space pushed
it past the layout width. This patch uses only the width up to the last
graphing character.

Fix for bug 17186801 "First line of title text is getting truncated even
if there's space on second line"

Change-Id: I49d07c18c8dd1d3b279f591224d23e10645dc8c0
2014-08-28 12:56:51 -07:00
Niels Egberts
a1fc998924 am 190d2222: am 3709bca8: am 14e9dc50: Merge "Fixed spelling of android.nominative and updated some comments." into lmp-dev
* commit '190d22224884cad530b2f8a1a671e91fd3f80244':
  Fixed spelling of android.nominative and updated some comments.
2014-08-21 13:39:34 +00:00
Niels Egberts
b9f7692ce6 Fixed spelling of android.nominative and updated some comments.
Bug: 17000831
Change-Id: I3a87635a6a894ee8ad1386cde8b59dcd9533b23f
2014-08-21 11:28:29 +01:00
Anish Athalye
969e7b9496 Add optimizing line breaker
Change-Id: I1eabc863e7f027c4c19a9ab23e561c774c721993
2014-08-18 12:25:17 -07:00
Anish Athalye
c8f9e62186 Implement line breaking in native code
The main purpose for this change is to prepare for adding support for
alternative line breaking algorithms (such as optimal line breaking).

The existing implementation of line breaking was intertwined with
measurement, so it wasn't structured in a way such that other line
breaking algorithms could be easily added. In addition to this,
algorithms (such as optimal line breaking) are usually fairly complex
and computation-intensive, so it is advantageous to implement them in
native code.

This has several other advantages:

    * Unlike the Java code in the previous version of generate(), this
      implementation separates line breaking from measurement. This
      makes it easier to understand and modify the line breaking process
      without affecting measurement (and vice versa).

    * This native implementation of greedy line breaking is identical to
      the Java version in terms of functionality, and it is similar in
      terms of performance, depending on the use case. The performance
      gains from this change are not significant due to increased JNI
      overhead. However, this change is a step in the right direction in
      terms of increasing performance. Once more code moves to C++,
      there will be fewer JNI crossings per layout call and less data
      will be passed from Java to C++, resulting in better performance.

This change moves line breaking from Java to native C++ code. Inspired
by the "Breaking Paragraphs into Lines" paper by Knuth and Plass (1981),
we express the line breaking problem in terms of 'box', 'glue', and
'penalty' primitives, along with a few others. Our implementation
differs in a couple ways:

    * We do not want to clip text when words are wider than the view, so
      we add a new primitive type to represent break opportunities
      between letters. These breaks are avoided whenever possible, but
      when single words do not fit on lines by themselves, they can be
      broken so the entire word is visible.

    * We have to support tab characters, along with user*specified tab
      stops, so we add a new primitive type for that purpose.

    * We are left*aligning text, and so we are not using shrinking /
      stretching glue.

    * We do not support hypenation, so we do not use penalties that have
      widths.

Change-Id: Ia22d1d1275ef26ff3d7b41ee2658e4db525a0305
2014-08-18 12:25:16 -07:00
Anish Athalye
c56c9ee718 am c255033f: am 675f13bf: am 2f2e3797: Merge "Make LeadingMarginSpan2 behavior more consistent" into lmp-dev
* commit 'c255033f0a4b55f8d4279a9a5b283ed742a5e642':
  Make LeadingMarginSpan2 behavior more consistent
2014-08-15 11:43:37 +00:00
Anish Athalye
ab08c6d38a Make LeadingMarginSpan2 behavior more consistent
This addresses b/16486549.

This change updates public documentation to specify the behavior of
LeadingMarginSpan2s. This change specifies what happens when a
LeadingMarginSpan2 is combined with other LeadingMarginSpans. This
behavior was not previously documented.

LeadingMarginSpan2s specify the number of lines used for the leading
margin. When laying out and rendering, for all LeadingMarginSpans, the
first line margin is applied for the number of lines specified by the
LeadingMarginSpan2.

Previously, this behavior was slightly buggy -- the LeadingMarginSpan2
affected all LeadingMarginSpans when laying out text, but not when
rendering.

This change is designed to cause the least amount of breakage in
existing code while achieving consistency with the way
LeadingMarginSpan2 is handled in layout and drawing.

For the most common use of LeadingMarginSpan2 -- getting a multi-line
first margin in the first paragraph of text in a layout -- this should
cause no change in behavior. For any other uses, the old (buggy)
implementation most likely did not exhibit correct behavior to begin
with, so developers were most likely not relying on that functionality.

Change-Id: I6f69df09c0130e703458e65bf3eaac4a905df56e
2014-08-14 11:58:37 -07:00
Alan Viverette
4466a68ed0 am 8a3b0af1: am ae1970d9: am 48286f82: Merge "Add API for obtaining max text length for accessibility" into lmp-dev
* commit '8a3b0af14cf9f6b844f4cd78bd69677e10aa99d1':
  Add API for obtaining max text length for accessibility
2014-08-13 00:43:53 +00:00
Alan Viverette
029942f77d Add API for obtaining max text length for accessibility
BUG: 16736956
Change-Id: I15ffb9bf68e074adf3e0dbcd230367e115c03e3c
2014-08-12 14:55:56 -07:00
Anish Athalye
46514a75e3 Fix performance bug in layout
When processing text ending with a newline character, calling
MeasuredText#setPara() on the whole buffer is inefficient because the
call results in a copy of the entire buffer.

Change-Id: I6fa038d950f6287665bad3dc0070234c98bc8a7a
2014-08-12 17:05:28 +00:00
Niels Egberts
2a236a6466 Simplify generics, and make Builder concrete.
Change-Id: I3e14966527c254d2c15dddefc2ef60cdde30421f
2014-08-01 11:46:16 +01:00
Narayan Kamath
08b3516984 Switch TextUtils over to new ICU API.
.. and use Locale.getScript() instead of ICU.getScript.

bug: 15876704
Change-Id: Idf9462d8ef568dbc88c95e65a971184952e97872
2014-07-31 11:29:44 +00:00
Narayan Kamath
31e6b1445f Switch TextUtils over to new ICU API.
.. and use Locale.getScript() instead of ICU.getScript.

bug: 15876704

(cherry picked from commit 08b3516984)

Change-Id: Ifac179e0577d66062f32c95372b631bf574dfdf9
2014-07-31 12:55:49 +01:00