Commit Graph

1467 Commits

Author SHA1 Message Date
Haoyu Zhang
9b74c07517 Merge "Fix getLineRight()/getLineLeft() may compute leadingMargin twice" 2018-10-30 18:16:44 +00:00
Branden Archer
ea3bcb762d fix spelling typo in comment
Test: typo in comment, no test necessary

Change-Id: I5a56c289e1e29a8eca33d55a77c52e87efa446a2
2018-10-29 08:49:55 -07:00
Qingqing Deng
b3e9481f78 Merge "Disable double cursor for BiDi in Layout." 2018-10-22 20:24:52 +00:00
Haoyu Zhang
7425d982f1 Fix getLineRight()/getLineLeft() may compute leadingMargin twice
Bug: 74129926
Test: atest StaticLayoutGetLineLeftRightTest LayoutTest
Change-Id: I5f05d55eb4115d920ac8e5ecb52fbd16fdf60790
2018-10-19 20:53:28 -07:00
qqd
19799c44c4 Disable double cursor for BiDi in Layout.
-- Disabled double cursor for BiDi in Layout.getCursorPath.
-- Add tests in LayoutTest.

Bug: 112875662
Test: Manual (no more double cursors, bidi editing feels OK)
Test: bit FrameworksCoreTests:android.text.LayoutTest
Change-Id: I3d201734d12f59724fa627b06ba9ca8c307c27fb
2018-10-19 19:09:22 -07:00
Seigo Nonaka
9958c4ab21 Introduce FontStyle for future extensibility
This is a ground work for b/114479228
FontStyle is an argument of the font itemization. Currently Android
system uses weight and italic info for itemizing but maybe we will
use width and oblique style in future.
To be extensible in future, introduce FontStyle.

This CL includes:
- new class FontStyle which holds width and italic at this moment. In
  future, we may add width and oblique. (or grdual italic slant)
- Font class still returns weight/slant since they need to be immutable.
- Moved font weight constants from Font to FontStyle

Bug: 114479228
Test: atest CtsGraphicsTestCases
Change-Id: I0ba717fbf9f90ee6f760c1a0f6eda17b4bef6f43
2018-10-19 14:51:59 -07:00
Haoyu Zhang
0a04650e51 Merge "Add textLocale attributes to TextView and TextAppearanceSpan" 2018-10-19 20:30:02 +00:00
Haoyu Zhang
1137512f7c Add textLocale attributes to TextView and TextAppearanceSpan
Bug: 112390716
Test: atest TextAppearanceSpanTest TextViewTest
Change-Id: I812f76cc3acec14b9839436cc7c5cc1ef827998e
2018-10-18 15:38:30 -07:00
Seigo Nonaka
7b86fe573c Change add{StyleRun, ReplacementRun} to append{StyleRun, ReplacementRun}
Giving any range to the Builder is too much freedum and hard to tell
errors. Changes to accept length instead of ranges. By this change, we
can prevent and tell errors about
- The gap in the text that no Paint is assigned.
- The given range is overlapped.
- The given range exceeds the text length.

Bug: 112327179
Test: TreeHugger

Change-Id: Iefc078b1f7be2d006a65b46e0b4ea1018ecb29e7
2018-10-18 14:58:18 -07:00
TreeHugger Robot
e9944aa1dc Merge "Make loadSafeLabel a generic facility as makeSafeForPresentation" 2018-10-16 16:21:10 +00:00
TreeHugger Robot
13635f0ec0 Merge "Fix invalid character access" 2018-10-16 09:08:01 +00:00
Seigo Nonaka
5783c13806 Fix invalid character access
The invalid access has introduced by
I976df4db63be241af395dd30dd94182f76bdae53

Bug: 114454225
Test: atest StaticLayoutLineBreakingTest
Change-Id: I8ad3d7761c98eb8ace97af3a4794d4bfe04c05e0
2018-10-15 18:03:44 -07:00
Haoyu Zhang
36252bf2bf Merge "Add default implementation for LineBackgroundSpan" 2018-10-16 00:31:40 +00:00
Seigo Nonaka
aa35899430 Merge "Make LineBreaker public" 2018-10-15 21:56:12 +00:00
Philip P. Moltmann
c1fda744f0 Make loadSafeLabel a generic facility as makeSafeForPresentation
Any app loading untrusted strings should make the strings face. Hence make
the method publicly available.

Test: atest CtsTextTestCases:MakeSafeForPresentationTest GtsContentTestCases:PackageItemInfoTests
Change-Id: Ib0679fe892181535339dac77583c427e0d64dd05
Fixes: 113856697
2018-10-15 09:11:52 -07:00
Haoyu Zhang
3ad5850818 Update docs for TextAppearanceSpan
Bug: 78873447
Test: atest TextAppearanceSpanTest
Change-Id: If9e4f00a7b023d952f0e091f96765d6234523628
2018-10-12 21:32:00 +00:00
Seigo Nonaka
70200b0f56 Make LineBreaker public
This CL includes:
- Move NativeLineBreaker/NativeMeasuredParagraph to android.graphics.text
package since these two uses the shaping result of the text which is a
part of graphics responsibility. At the same time, by this moving,
minikin is only used by android.graphics package.
- Rename NativeLineBreaker/NativeMeasuredParagraph to
LineBreaker/MeasuredText.
- Updated comments of the break strategy and hyphenation frequency.

Bug: 112327179
Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases
Change-Id: Id69c328e7c9097b9fc11b5c0bd04d1c2e0939c6a
2018-10-09 12:16:52 -07:00
Haoyu Zhang
003f737163 Add default implementation for LineBackgroundSpan
Bug: 1526775
Test: atest LineBackgroundSpan_StandardTest
Change-Id: Id97981857a90804387d93e89a1b93c1a74498f47
2018-10-04 12:24:34 -07:00
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