Commit Graph

1449 Commits

Author SHA1 Message Date
Seigo Nonaka
a75543820d Merge "Prepare NativeLineBreaker.LineBreaks to be public API" 2018-09-28 18:51:44 +00:00
Haoyu Zhang
88f0f6c9b1 Merge "Synchronize attributes in TextView with TextAppearanceSpan" 2018-09-27 19:15:31 +00:00
Haoyu Zhang
445326d93d Merge "Fix equals not working correctly in SpannableString and SpannableStringBuilder" 2018-09-27 19:14:53 +00:00
Seigo Nonaka
ab9b479d4f Prepare NativeLineBreaker.LineBreaks to be public API
This is a ground work of making NativeLineBreaker/MeasuredParagraph
public.

This CL rename NativeLineBreaker.LineBreaks to NativeLineBreaker.Result.
This CL also moving array re-allocation logic from native code to Java in
StaticLayout. Ideally, we can remove array but this CL keeps array since
that introduces additional complexity.

Here is a raw perf test result:
android.text.StaticLayoutPerfTest:
  create
    PrecomputedText Balanced Hyphenation  :    667 ->    810: (+143, +21.4%)
    PrecomputedText Balanced NoHyphenation:    510 ->    594: ( +84, +16.5%)
    PrecomputedText Greedy Hyphenation    :    446 ->    530: ( +84, +18.8%)
    PrecomputedText Greedy NoHyphenation  :    448 ->    533: ( +85, +19.0%)
    RandomText Balanced Hyphenation       : 17,982 -> 18,176: (+194, +1.1%)
    RandomText Balanced NoHyphenation     :  7,348 ->  7,461: (+113, +1.5%)
    RandomText Greedy Hyphenation         :  7,293 ->  7,330: ( +37, +0.5%)
    RandomText Greedy NoHyphenation       :  7,289 ->  7,352: ( +63, +0.9%)
  draw
    PrecomputedText NoStyle               :    645 ->    645: (  +0, +0.0%)
    PrecomputedText Style                 :    941 ->    947: (  +6, +0.6%)
    RandomText NoStyle                    :    541 ->    543: (  +2, +0.4%)
    RandomText Style                      :    751 ->    753: (  +2, +0.3%)
android.widget.TextViewPrecomputedTextPerfTest:
  newLayout
    PrecomputedText                       :    839 ->    983: (+144, +17.2%)
    PrecomputedText Selectable            :    883 ->  1,053: (+170, +19.3%)
    RandomText                            : 17,594 -> 17,761: (+167, +0.9%)
    RandomText Selectable                 : 18,331 -> 18,695: (+364, +2.0%)
  onDraw
    PrecomputedText                       :  1,233 ->  1,385: (+152, +12.3%)
    PrecomputedText Selectable            :  1,164 ->  1,207: ( +43, +3.7%)
    RandomText                            : 18,836 -> 19,042: (+206, +1.1%)
    RandomText Selectable                 : 19,025 -> 19,092: ( +67, +0.4%)
  onMeasure
    PrecomputedText                       :    853 ->    991: (+138, +16.2%)
    PrecomputedText Selectable            :  1,077 ->  1,234: (+157, +14.6%)
    RandomText                            : 17,613 -> 17,913: (+300, +1.7%)
    RandomText Selectable                 : 18,696 -> 18,922: (+226, +1.2%)
  setText
    PrecomputedText                       :    133 ->    136: (  +3, +2.3%)
    PrecomputedText Selectable            :    190 ->    192: (  +2, +1.1%)
    RandomText                            :     10 ->     11: (  +1, +10.0%)
    RandomText Selectable                 :     49 ->     50: (  +1, +2.0%)

Bug: 112327179
Test: atest FrameworksCoreTests CtsGraphicsTestCases CtsWidgetTestCases
    CtsTextTestCases

Change-Id: I25f41dacf73e00a859f43331bc53f8d123116192
2018-09-26 16:25:32 -07:00
Seigo Nonaka
47e79a1626 Merge "Move hasEqualAttribute from Paint with adding some accessors" 2018-09-25 18:34:26 +00:00
Haoyu Zhang
6b4380ea5f Fix equals not working correctly in SpannableString and SpannableStringBuilder
Bug: 73359036
Test: atest SpannableStringTest SpannableStringBuilderTest
Change-Id: Idfaf71cde914d5c5325a6c6a3bfcda20ebee62f2
2018-09-20 16:21:52 -07:00
Haoyu Zhang
87682ba293 Synchronize attributes in TextView with TextAppearanceSpan
Bug: 78873447
Test: atest TextAppearanceSpanTest
Change-Id: I1c71e815389716ac9580f8f76690f6a423632015
2018-09-19 18:21:25 -07:00
Haoyu Zhang
6367c2e62e Merge "Fixed lineBackgroundSpan not called for first line" 2018-09-19 22:21:24 +00:00
Seigo Nonaka
16cd61459c Merge "Unhide getTextRunCursor APIs" 2018-09-19 20:18:32 +00:00
TreeHugger Robot
173222142f Merge "Always use Context.getSystemService() to get IMM" 2018-09-18 22:25:52 +00:00
Seigo Nonaka
fa95b83df7 Unhide getTextRunCursor APIs
This API is necessary for identifying the cursor locations.

Bug: 112327179
Test: atest android.graphics.cts.PaintTest
Change-Id: Ief6770bd622a296ae356094fe3ce58e9c4371088
2018-09-18 15:06:19 -07:00
Seigo Nonaka
32b87e01e0 Move hasEqualAttribute from Paint with adding some accessors
Paint#hasEqualAttributes is not a equal method in Paint.
TextLine depends on this method but making this public will make
developer confused. So, moving hasEqualAttributes to TextLine and
provide some accessors for shadow layer parameters.

For the TextPaint, unhide underlineColor and underlineThckness for
implementing equalAttributes in TextLine.

Bug: 112327179
Test: atest android.graphics.cts.PaintTest
Change-Id: I4565e18134856e31d26bd06bcddeb31ddbe7e093
2018-09-18 14:10:14 -07:00
kopriva
64c4523ed4 Merge "docs: fixed five typos" into pi-dev am: 82b413428e
am: d366837e05

Change-Id: I0cf5630bc936c872ca936f2d3de9e8aaa509f083
2018-09-18 12:10:35 -07:00
kopriva
d366837e05 Merge "docs: fixed five typos" into pi-dev
am: 82b413428e

Change-Id: I4af571d6bcfa151235223b51cb8135fbacb62c82
2018-09-18 12:00:24 -07:00
Haoyu Zhang
60b0983ae8 Fixed lineBackgroundSpan not called for first line
Bug: 1526775
Test: atest StaticLayoutTest LayoutTest

Change-Id: I71e4e5a14e385df6a79cca7cb7c5e2da15ac5cec
2018-09-18 10:46:29 -07:00
Yohei Yukawa
484d4afc92 Always use Context.getSystemService() to get IMM
This is a preparation to deprecate the following two methods.

 * InputMethodManager#getInstance()
 * InputMethodManager#peekInstance()

Since we soon need to stop relying on the current per-process
InputMethodManager singleton model to fully support multi-display,
those two methods really need to be deprecated.

With this CL, framework code no longer depends on
InputMethodManager#peekInstance(), which is also marked as deprecated
in this CL.

InputMethodManager#getInstance() is a bit tricky because it also works
as a constructor of such a per-process singleton instance.  Remaining
two call-sites of this method will be migrated in a subsequent CL.

This is a mechanical refactoring, which in theory should have no
observable logical behavior difference.

There could be a small performance regression, but it is basically not
avoidable to correctly support multi-display scenarios.

Bug: 115891476
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Test: atest CtsWidgetTestCases:android.widget.cts.EditTextTest
Test: atest CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: atest FrameworksCoreTests:com.android.internal.inputmethod
Test: atest FrameworksServicesTests:com.android.server.textservices
Change-Id: I5db31491f3d47d3ad4a621e956995135c72e007b
2018-09-17 16:47:08 -07:00
kopriva
7ecfe31427 docs: fixed five typos
Test: make ds-docs

Bug: 37095452
Bug: 37001217
Bug: 37004068
Bug: 37015340
Bug: 37044652

Change-Id: Ib305df88b63286810d7722e73321ddb238b45e8e
Exempt-From-Owner-Approval: Docs-only change
2018-09-17 15:17:50 -07:00
Mathew Inwood
8c854f86a4 Move some members to the "Q blacklist".
Based on some analysis, these fields/methods are likely false positives.
Set maxTargetSdk=P so that any apps using them are required to migrate off
them in future. See the bug for more details.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
2018-09-14 13:18:34 +01:00
Seigo Nonaka
9033e0c1a4 Unhide HyphenEdit related methods
These APIs are necessary to implement hyphenation by third party developers.

Bug: 112327179
Test: atest android.graphics.cts.PaintTest#testSetGetHyphenEdit
Change-Id: I692a56d3d1b15100503eb6d8e0f59d6c5c8af81b
2018-09-10 09:42:28 -07:00
Seigo Nonaka
c7b3e62f0d Introduce system font enumeration API
To be able to use font file in their apps, provides blob and path to the
font file and locale list as well.

Bug: 26116537
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    CtsGraphicsTestCases:android.graphics.font

Change-Id: I1ae1302c6906b808012e1e91b1e4ab393c887cb6
2018-09-05 14:54:12 -07:00
Haoyu Zhang
444be8bd41 Add new class LineHeightSpan.Standard
Add default implementation of interface LineHeightSpan

Bug: 112621694
Test: atest StaticLayoutTest LineHeightSpan_StandardTest
Change-Id: I21ec0d8f72b7234d87bf25e5e6fe6cb7c19953a7
2018-08-29 14:43:10 -07:00
Seigo Nonaka
41bb4fa748 Introduce NativeLineBreaker.Builder and ParagraphConstraint
To make NativeLineBreaker public API, introduce
NativeLineBreaker.Builder and ParagraphConstraint.

Here is a performance differences:

android.text.StaticLayoutPerfTest:
    PrecomputedText Balanced Hyphenation  :    635 ->    684: ( +49, +7.7%)
    PrecomputedText Balanced NoHyphenation:    477 ->    523: ( +46, +9.6%)
    PrecomputedText Greedy Hyphenation    :    413 ->    463: ( +50, +12.1%)
    PrecomputedText Greedy NoHyphenation  :    413 ->    463: ( +50, +12.1%)
    RandomText Balanced Hyphenation       : 18,030 -> 18,157: (+127, +0.7%)
    RandomText Balanced NoHyphenation     :  7,390 ->  7,388: (  -2, -0.0%)
    RandomText Greedy Hyphenation         :  7,319 ->  7,331: ( +12, +0.2%)
    RandomText Greedy NoHyphenation       :  7,316 ->  7,375: ( +59, +0.8%)
  draw
    PrecomputedText NoStyle               :    631 ->    627: (  -4, -0.6%)
    PrecomputedText Style                 :    842 ->    847: (  +5, +0.6%)
    RandomText NoStyle                    :    531 ->    547: ( +16, +3.0%)
    RandomText Style                      :    754 ->    758: (  +4, +0.5%)

Bug: 112327179
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    CtsGraphicsTestCases:android.graphics.fonts

Change-Id: I5b817bbc9f00e5806efa98f239ee20ff3d688c50
2018-08-17 14:16:26 -07:00
Mathew Inwood
e0f11e8ce6 Merge "Add @UnsupportedAppUsage annotations" am: 348a7e7315
am: 58b0d33e36

Change-Id: I47fd8beb33a06344cbacb1776d5cc3fb03089903
2018-08-16 03:25:16 -07:00
Mihai Popa
8caff9fd7a Merge "Fix crash during cursor moving on BiDi text" into pi-dev
am: f052c26a7d

Change-Id: I18123e7e08220b1483df6fd32ec0eecd68bb38de
2018-08-15 12:30:09 -07:00
Seigo Nonaka
a1076fdaa5 Fix crash during cursor moving on BiDi text
The crash was introduced by Ib66ef392c19c937718e7101f6d48fac3abe51ad0
The root cause of the crashing is requesting out-of-line access for the
horizontal width. This invalid access is silently ignored by
TextLine#measure() method but new implementation end up with out of
bounds access.

To makes behavior as old implementation, calling getHorizontal instead
of accessing measured result array.

Bug: 78464361, 111580019
Test: Manually done
Change-Id: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
(cherry picked from commit 960647d582)
Merged-In: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
2018-08-15 19:11:50 +00:00
TreeHugger Robot
3c159f6f1e Merge "Validate index for cursor on BiDi text" 2018-08-15 14:18:25 +00:00
Mathew Inwood
9cf99fd91f Add @UnsupportedAppUsage annotations
For packages:
  android.text.util
  android.text.style
  android.text.method
  android.text.format
  android.text

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I5be178ad05f2ff98bcf31e24cd4eb33961887c38
Merged-In: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
2018-08-15 12:49:00 +01:00
Siyamed Sinir
58df795cbe Validate index for cursor on BiDi text
Previously we have updated the code not to check mHorizontals if offset
is invalid (I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8) However we should
also check the final index to make sure no invalid index is accessed.

Test: None

Bug: 111580019
Change-Id: I5c32820cde5f91bfe8688e9394b8ba3254cbd731
2018-08-15 11:37:44 +00:00
Mathew Inwood
efeab847f9 Add @UnsupportedAppUsage annotations
For packages:
  android.text.util
  android.text.style
  android.text.method
  android.text.format
  android.text

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
2018-08-15 11:16:12 +01:00
Siyamed Sinir
042856b46a Merge "Disable hyphenation by in default theme" 2018-08-07 18:46:15 +00:00
Seigo Nonaka
6f11c6e7e2 Extract native methods into isolated classes
StaticLayout/MeasuredParagraph uses native methods which is a pain point
of porting TextView to JetPack.
To make minimize the dependency to the native methods, extract native
methods and put them into a thin wrapper class.

The performance impact is limited:

android.text.StaticLayoutPerfTest:
    PrecomputedText Balanced Hyphenation  :    602 ->    644: ( +42, +7.0%)
    PrecomputedText Balanced NoHyphenation:    457 ->    476: ( +19, +4.2%)
    PrecomputedText Greedy Hyphenation    :    397 ->    412: ( +15, +3.8%)
    PrecomputedText Greedy NoHyphenation  :    397 ->    411: ( +14, +3.5%)
    RandomText Balanced Hyphenation       : 17,594 -> 17,715: (+121, +0.7%)
    RandomText Balanced NoHyphenation     :  7,146 ->  7,236: ( +90, +1.3%)
    RandomText Greedy Hyphenation         :  7,125 ->  7,196: ( +71, +1.0%)
    RandomText Greedy NoHyphenation       :  7,099 ->  7,187: ( +88, +1.2%)
  draw
    PrecomputedText NoStyle               :    614 ->    628: ( +14, +2.3%)
    PrecomputedText Style                 :    778 ->    826: ( +48, +6.2%)
    RandomText NoStyle                    :    537 ->    540: (  +3, +0.6%)
    RandomText Style                      :    786 ->    759: ( -27, -3.4%)

Bug: N/A
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I976df4db63be241af395dd30dd94182f76bdae53
2018-07-27 11:08:43 -07:00
Siyamed Sinir
c0dab36d6b Disable hyphenation by in default theme
Test: Added cts tests for default values
Test: atest CtsWidgetTestCases:EditTextTest
Test: atest CtsWidgetTestCases:TextViewTest
Test: atest FrameworksCoreTests:TextViewTest

Bug: 111096709
Change-Id: Ia4d13574557970432fdcd27581ee3fff4ec36c64
2018-07-23 14:25:28 -07:00
TreeHugger Robot
014a89593a Merge "Fix crash during cursor moving on BiDi text" 2018-07-20 02:56:26 +00:00
Seigo Nonaka
960647d582 Fix crash during cursor moving on BiDi text
The crash was introduced by Ib66ef392c19c937718e7101f6d48fac3abe51ad0
The root cause of the crashing is requesting out-of-line access for the
horizontal width. This invalid access is silently ignored by
TextLine#measure() method but new implementation end up with out of
bounds access.

To makes behavior as old implementation, calling getHorizontal instead
of accessing measured result array.

Bug: 111580019
Test: Manually done
Change-Id: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
2018-07-19 16:22:02 -07:00
Chris Craik
59ff32c4c4 Remove Path codepath in BulletSpan
Test: none

Circles are historically actually easier to draw than Paths for HW
acceleration, though they're equivalent in Skia.

Change-Id: I1a7e2ca6439b6a09fdac784237065668db8cadc6
2018-07-19 14:58:39 -07:00
Seigo Nonaka
73146e7ceb Remove unused line in PrecomputedText
Bug: N/A
Test: N/A
Change-Id: I2456116657d8be893a8c477df14a5de490fbaa37
2018-07-16 18:09:32 -07:00
Siyamed Sinir
4636cc848e Merge "Add UrlSpanFactory to Linkify" 2018-07-10 23:32:27 +00:00
Aaron Heuckroth
09d6bd8a66 Merge "Move channel logging to dump method and redact name." 2018-07-10 18:05:34 +00:00
Aaron Heuckroth
51d3288431 Move channel logging to dump method and redact name.
Test: Generate bug report and confirm that NotificationChannel logs contain redacted name strings.
Change-Id: Iebaf7b165de0276e69ead862aa7ec864ef912282
Fixes: 78326066
2018-07-09 13:26:48 -04:00
Siyamed Sinir
9c6c097604 Add UrlSpanFactory to Linkify
Enable API user to create their own URLSpan for Linkify operations.

Test: atest android.text.util.cts.LinkifyTest
Test: atest android.text.util.LinkifyTest

Bug: 28536972
Bug: 32613009
Bug: 29150779
Change-Id: I9a2f995656bd1510502e5517ac737b47ebd33130
2018-07-08 12:41:38 -07:00
Ian Pedowitz
0a35c20bc3 Revert "Add UrlSpanFactory to Linkify"
This reverts commit ad4883bb1b.

Reason for revert: b/111218263

Bug: 28536972
Bug: 32613009
Bug: 29150779
Change-Id: Idc1621d472d742929f56d10d72b077b774b9e56e
2018-07-07 22:02:29 +00:00
Siyamed Sinir
ad4883bb1b Add UrlSpanFactory to Linkify
Enable API user to create their own URLSpan for Linkify operations.

Test: atest android.text.util.cts.LinkifyTest
Test: atest android.text.util.LinkifyTest

Bug: 28536972
Bug: 32613009
Bug: 29150779

Change-Id: Ia4495dc7e656044b91a79804d3b50a30cae98225
2018-07-03 10:53:16 -07:00
Tobias Thierer
13b96fc1a1 Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28." am: b5f35aeaf3 am: 5442964205
am: e4449497ed

Change-Id: I3bbb854c61f476caaef20eeae2bbcc9473c49469
2018-06-27 08:40:26 -07:00
Tobias Thierer
5442964205 Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28."
am: b5f35aeaf3

Change-Id: I55ba23bfae8f578eb75a4cbfeb2ed4ad1492867d
2018-06-27 08:14:58 -07:00
Tobias Thierer
3e76c04c96 TextUtils: track behavior change of Pattern.split() when targeting > 28.
Another CL in this topic changes the behavior of String.split() and
Pattern.split() to omit a "" generated by a leading zero-width match.
TextUtils.split() is implemented on top of these methods and therefore
adopts the behavior change by default.

The behavior change only affects apps targeting API versions > 28.

Test: cts-tradefed run singleCommand cts-dev -m CtsTextTestCases \
      -t android.text.cts.TextUtilsTest
Test: cts-tradefed run singleCommand cts-dev -m CtsLibcoreTestCases
Bug: 109659282

Change-Id: I8abe251353f8eacf1429ac9a8e272d50a0944c29
2018-06-26 14:48:47 +01:00
TreeHugger Robot
4291ea0c3c Merge "Cleanup: Remove unused padding arguments" 2018-06-08 16:57:55 +00:00
Seigo Nonaka
9155fa6e41 Cleanup: Remove unused padding arguments
Bug: N/A
Test: N/A
Change-Id: I05f5a7d45fcbdc5aacee3e2e915b62017b9cd178
2018-06-05 18:22:03 -07:00
Aurimas Liutikas
7f6641b890 Merge "Fix broken links in @see tags in framework docs." 2018-06-04 19:51:34 +00:00
TreeHugger Robot
232e558006 Merge "Annotate Parcel param/return reference types." 2018-06-04 19:33:59 +00:00
Aurimas Liutikas
e701dc1799 Fix broken links in @see tags in framework docs.
doclava was accidentally suppressing all these broken links
in @see tags. This CL fixes issues so we can start enfocing
checks for broken @see links.

Test: make docs
Change-Id: If7830ece85f8d1f27c991eae282230814726e115
Exempt-From-Owner-Approval: Fixing @see javadoc link issues that are currently completely broken
2018-06-04 10:15:22 -07:00