Commit Graph

478 Commits

Author SHA1 Message Date
Fabrice Di Meglio
15c9c6141a Merge "Fix bug #6661824 Hebrew Text can be clipped" into jb-dev 2012-06-14 10:50:36 -07:00
Fabrice Di Meglio
8d44fff7e6 Fix bug #6661824 Hebrew Text can be clipped
- use the correct ellipsis char in both measurement and rendered string

Change-Id: Ia00285fc16da528f18702719026503b5d0610642
2012-06-13 15:54:55 -07:00
Gilles Debunne
a447eaca55 Merge "Prevent a crash when maxLines is set to 0" into jb-dev 2012-06-12 10:47:31 -07:00
Gilles Debunne
2fba3387c3 Prevent a crash when maxLines is set to 0
Bug 6642222

Using setMaxLines(0) and setMinHeight(30) causes a crash
because Layout#getLineRangeForDraw() returns a [0,0] interval
in that case.

Accessing the Direction in draw causes a NPE.

Change-Id: If50f9b554e3cdc598a721b623992e9196982838c
2012-06-11 17:46:26 -07:00
Victoria Lease
aa0980afab Revert "Fix fake bold for fallback fonts in frameworks."
This reverts commit b26fa0ce68
2012-06-11 14:46:04 -07:00
Victoria Lease
b26fa0ce68 Fix fake bold for fallback fonts in frameworks.
This change is analogous to Ic0e9f1bbd8cae9fdd3a6d1d015bb9224c8be545c
in WebView, and depends upon the same Skia change that that CL makes
use of.

This flips the "fake bold" flag on for bold fonts in
TextView.setTypeface(), with the expectation that Skia will ignore
the flag if the final typeface used to render the glyphs is already
bold. It also does the same for StyleSpans, TextAppearanceSpans,
TypefaceSpans, and the Switch widget.

With this, fake bold should work uniformly across all scripts - if
fake bold works for a primary typeface, it should also work for all
fallback typefaces.

Bug: 6629786
Change-Id: Id3b8639ab0df83052ffd82809cb12adaacc1d46b
2012-06-08 13:52:17 -07:00
Jean Chalard
405bc51c5d Add/refine comments to reflect key event policies
Make clearer how the platform is handling key events following some
unfortunate uses by third party applications. Also highlight the
changes in Jelly Bean default keyboard.

Bug: 6566711
Change-Id: Ibcdaf54c6d629fd0733529bfe2fffc82f555f084
2012-05-29 19:41:02 +09:00
Gilles Debunne
0ae107ff34 Merge "Cut long text into multiple DL at start" into jb-dev 2012-05-11 16:14:02 -07:00
Gilles Debunne
71afc39d68 Cut long text into multiple DL at start
Bug 5763685

To improve performance, preventively cut the the into display
list of 3-10 lines of text. Further updates to small parts of
the text (such as adding an underline on a word) will only
invalidate and redraw the affected sub display list.

DLs are aligned with paragraphs, just like they will be during
text edition.

Change-Id: I0d60debc7fdaea8b29080a6eacb2d60205e7d547
2012-05-11 15:32:43 -07:00
Raph Levien
d570e8987a Add fontFamily XML attribute to select font family by string
Change-Id: I0b649528d3d9888e3561a1a3907a6b6ee2e30238
2012-05-09 23:18:42 -07:00
Gilles Debunne
0caf421e3a Merge "Final fix in SpannableStringBuilder." into jb-dev 2012-05-07 11:17:38 -07:00
Gilles Debunne
e244868053 Final fix in SpannableStringBuilder.
Bug 6448052

The empty EXCLUSIVE removal condition was incorrect.
Also changed the unit test the didn't catch this problem.

Change-Id: I5576d830cdfa6cc3716c878fb698695a2978b296
2012-05-04 16:24:49 -07:00
Fabrice Di Meglio
66388dcb09 Hide RTL related APIs - DO NOT MERGE
- fix bug #6441155 API review: @hide RTL layout APIs

Change-Id: I13c5ea5f579cecffed9d517f06180ab0576cd26a
2012-05-04 13:15:12 -07:00
Gilles Debunne
cefb4bc011 Hide TextDirectionHeuristics
Bug 6435363

Change-Id: I9ba0a3c057af67e2876e64fd8c18adbb8f4d0860
2012-05-02 18:20:25 -07:00
Gilles Debunne
2d589ffa1e Merge "SpannableStringBuilder correctly manages MARK and POINTS" into jb-dev 2012-04-30 15:44:02 -07:00
Gilles Debunne
26b62d4321 SpannableStringBuilder correctly manages MARK and POINTS
Bug 6343982

Finally deeply understood the meaning of the POINT and MARK flags.

Updated the Spanned documentation to reflect this.

Updated tests to come.

Change-Id: I400d56b7b4929bc1e7eb4f0497d8e081ee23682e
2012-04-26 19:04:03 -07:00
Gilles Debunne
eca5b7385a Basic renaming refactoring in Layout
Change-Id: I79f5444a097f1e2b2a81ececf1f0a14b6d7d5179
2012-04-25 18:48:42 -07:00
Gilles Debunne
97c03cac4d Merge "Do not notify text watchers when replace is a no-op" 2012-04-24 18:26:43 -07:00
Gilles Debunne
9177947741 Merge "Fixed SSB. Correct broadcast of removed spans' positions" 2012-04-23 18:17:30 -07:00
Gilles Debunne
157aafcbee TextView's sub display lists have tighten bounds
An editable TextView caches text rendering inside an adaptive
number of sub display lists. The bounds of these use to be those
of the entire View.

This CL creates block display lists with tighten bounds, so that
(a still-to-be-implemented) quick rejection can occur.

Also cleaned-up the contradictory translations that were used to
handle the TextView's internal scroll and removed the invalidation
of display lists in that case.

TODO: When internal scroll sets a tighter clipping rect, quick
reject the creation and display of the clipped display lists.

Also renamed blockEnds to a more explicit blockEndLines.

Change-Id: I7d79bea78d06d19b6935aef75ff7aa7df2594050
2012-04-19 18:06:46 -07:00
Gilles Debunne
d60da058c6 Do not notify text watchers when replace is a no-op
Bug 6344997

The early exit we used to do when both replaced and replacement
strings were empty has been added back.

Only this time it correctly also makes sure no spans from the
replacement string would get added with a 0-length.

Change-Id: Ifc38a7e3619c57aa7647c0a8e63d7627d86f1036
2012-04-18 15:12:22 -07:00
Gilles Debunne
9098528644 Fixed SSB. Correct broadcast of removed spans' positions
Found while tracking bug 6326750

A bug in the SpannableStringBuilderSpanTest JUnit CTS test was hiding
this problem.

Also removed the instanceof test on SpanWatcher. All spans, including
those implementing this interface should be copied.

Change-Id: I5233818fb0c08ab56477720db932a5be453e88ee
2012-04-18 13:39:07 -07:00
Dianne Hackborn
acb69bb909 Add direct support for HTML formatted text in ClipData etc.
When using the clipboard, ACTION_SEND, etc., you can now supply
HTML formatted text as one of the representations.  This is exposed
as a set of methods on ClipData for building items with HTML
formatted text, and retrieving and coercing to HTML (and styled)
text.  In addtion, there is a new EXTRA_HTML_TEXT for interoperating
with the old ACTION_SEND protocol.

Change-Id: I8846520a480c8a5f829ec1e693aeebd425ac170d
2012-04-13 15:36:06 -07:00
Gilles Debunne
174c44c6cf SpannableStringBuilder correctly broadcast span changes during replace
Bug 6331765

A call to replace was previously not sending any span modification to the
attached span watchers.

Change-Id: Ic9e4a8ac0210e422961adfb18e205d80531889fe
2012-04-12 14:50:31 -07:00
Gilles Debunne
34ec2b54da Removed exception from SpannableStringBuilder
Bug 6312196

Change-Id: I9cece36b40d8948e0e85bd433954818991009ad5
2012-04-10 13:31:11 -07:00
Gilles Debunne
0249b43f6c Faster and simpler replace in SSB, take two
This is a new version of CL 179343 which had to be reverted.

This problem of the previous CL is that the ComposingSpan that
was part of the replacement text was correctly added during the
replace but was immediately removed because it had a zero-length
size.

Swapping the add and remove blocks solves the problem.

The new non-zero length enforcement also revealed a bug in the
spell checker where we were creating useless range spans.

Change-Id: I59cebd4708af3becc7ab625ae41bc36837f1a1cf
2012-04-09 16:08:37 -07:00
Gilles Debunne
425c726ae0 Merge "More minor refactoring in SpannableStringBuilder" 2012-04-09 13:27:11 -07:00
Gilles Debunne
bc6862300f Revert "Faster and simpler replace in SSB"
Bug 6300658

This change reveals a weird race condition where sometimes the
text is entered twice. Adding a debugger slows down everything,
and the problem is no longer reproducable. Reverting for now.

This reverts commit ebd9a23817.
2012-04-06 14:37:46 -07:00
Gilles Debunne
7c5f670bd6 More minor refactoring in SpannableStringBuilder
No change in the functionnalities.

Change-Id: I009acc75b4f70e65a810cdc67505bc0b13e627b2
2012-04-05 17:17:53 -07:00
Gilles Debunne
ebd9a23817 Faster and simpler replace in SSB
The original method was adding a suspicious space that was eventually
removed with a series of 3 calls to change.

This should not be necessary. I have tested this with various gap
positions and lengths, for all replace cases I could think of.

The test can not be added to the CTS as it would need to expose the
internal resizeFor and moveGapTo methods.

Change-Id: I194457fbcfd758fa69a7f380665cfd5ae4d3f1d4
2012-04-04 15:52:38 -07:00
Gilles Debunne
b51036f72a Refactoring SpannableStringBuilder
Made TextWatcher notification process clearer by moving it to
a single place, with methods renamed.

Also reverts CL 177544: we cannot broadcast span chages just yet,
the layout has not been reflown. A future CL will change this
behavior to make sure span changes are correctly broadcasted.

Change-Id: I9ef88dce91dff5f5f45e2845d5b3f18f1c853de3
2012-04-02 11:33:22 -07:00
Gilles Debunne
fc1190b8f1 Spans added during a text change are broadcasted
More consistent with the SpanWatcher design.

Change-Id: I3a1e4d92fb422f4cc689dabcdef1473d93fef5ad
2012-03-30 13:43:37 -07:00
Gilles Debunne
1e130b2abc Added a unit test for DynamicLayout#updateBlocks
Change-Id: I1824ebeae2bbb5c60a65de36fe1696bf003347c9
2012-03-26 16:39:25 -07:00
Romain Guy
cde6adf45c Fix the build
Change-Id: I6de62c7bfaecd85810178f58707157466291eca3
2012-03-15 17:04:47 -07:00
Gilles Debunne
33b7de85b6 Multiple display lists for editable text
Bug 5763685

Long text in a ScrollView (not when the View's internal
scroll is used) is cached as a unique display list when hardware
rendering is on.

As a result, each time the text is edited, the entire display
list has to be updated, which takes a significant amount of
time (up to 500ms for a few thousand lines), proportional to the
size of the text.

This CL splits the text into multiple display lists as the
text is edited. The boundaries of the display list are aligned
with paragraphs.

There is still an issue when the number of lines changes: onLayout()
is called which invalidates all the display list. When the source
of that change is line wrapping and not a change in the view's
dimensions, we should be able to simply shift down the previous DL
instead of re-creating everything.

Change-Id: I7de49a1e5637cdfc9ef06b64b1ec4b61d9ea2415
2012-03-15 11:32:50 -07:00
Gilles Debunne
60e3b3fa60 Use SpanSet to accelerate Layout.drawBackground
The main performance improvement should come from the fact
that we entirely skip the loop (which calls getLineStart, getLineTop
and getLineDescent on each line) in the frequent case where there
are no LineBackgroundSpans.

Change-Id: Ie2d3168521e88d43f1a4236da2b3e8447606df1e
2012-03-13 15:58:33 -07:00
Gilles Debunne
4ffb879f48 New SpanSet class extracted from TextLine.
Change-Id: I424dbd7ff0693fd465b6c83ebabba221b2eca6fe
2012-03-13 14:58:37 -07:00
Ken Wakasa
f76a50ce8f Fix obvious typos under frameworks/base/core
Change-Id: Ia5fc3db1bb51824e7523885553be926bcc42d736
2012-03-09 22:48:43 +09:00
Gilles Debunne
957c800ac0 Merge "Ellipsize avoids spaces and starts right after text" 2012-03-06 13:57:16 -08:00
Gilles Debunne
6c488de023 EditText caches only text in its internal display list.
Decorelate background and text in layout display. This allows
to only store the text in the editable TextView's display list.

Selection and cursor changes no longer need to invalidate the
display list, leading to faster rendering.

Change-Id: I3af3a98846e1bfe2d9ec6c42590e71bf3704595e
2012-03-05 14:22:20 -08:00
Fabrice Di Meglio
81c4350a89 Merge "Fix bug #3389545 android:ellipsize="end" doesn't work without using android:singleLine="true" which is deprecated" 2012-02-29 18:45:54 -08:00
Fabrice Di Meglio
34a126e51a Fix bug #3389545 android:ellipsize="end" doesn't work without using android:singleLine="true" which is deprecated
- take care of single line case too

Change-Id: I73c3dcb96f22241b35d7cbaf43cd9bd46a4abcaa
2012-02-29 18:43:14 -08:00
Fabrice Di Meglio
c97f9c14a5 Merge "Fix bug #5217606 LocaleUtils constants TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE and TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE should be renamed" 2012-02-29 12:37:13 -08:00
Fabrice Di Meglio
cd4161b134 Fix bug #5371909 Hebrew & Arabic mails are sent as LTR intead of RTL
- make paragraphs aware of text direction

Change-Id: I0b0cf5a47c7da870dea836cb6150aa83e9de0e90
2012-02-29 11:15:07 -08:00
Fabrice Di Meglio
3fb824bae3 Fix bug #5217606 LocaleUtils constants TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE and TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE should be renamed
- replace them by the View constants

Change-Id: I7c2bf0213319247d3db369b6f7c36771fdf3e509
2012-02-28 18:08:11 -08:00
Gilles Debunne
c70e7a0b8a Ellipsize avoids spaces and starts right after text
Bug 5509226

Change ellipsize bounds to take spaces into account

The hardcoded ' ' character may be problematic with other langages.

Note that a different ellipsize logic also exists in StaticLayout.
Created 6062415 to track this.

Change-Id: I3406ec23a592f952bf3e0ca68f0838ee807baba0
2012-02-23 18:05:59 -08:00
Fabrice Di Meglio
d7c845c39a Merge "Make textDirection API public" 2012-02-14 14:45:51 -08:00
Gilles Debunne
07ba2a2131 Minor typo fixes
Change-Id: I8cd9500cc50b7a484bf387e6a6a0c9b4ffb175a4
2012-02-13 18:13:44 -08:00
Fabrice Di Meglio
e7beae3f4c Make textDirection API public
Change-Id: I2d5a0e3a990b9a5b78a3bbc8df7f655702743e4b
2012-02-13 17:21:05 -08:00
Marc Blank
f4832da16a Use ' for apostrophe in HTML encoding
* We were using ' which is not correct

Change-Id: I4872da7d5e19f18ecd570dbcaac295020d66681c
2012-02-13 10:11:50 -08:00