Commit Graph

1437 Commits

Author SHA1 Message Date
TreeHugger Robot
173222142f Merge "Always use Context.getSystemService() to get IMM" 2018-09-18 22:25:52 +00: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
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
Jake Wharton
b1f474c066 Annotate Parcel param/return reference types.
Bug: 78245676
Test: atest ParcelNullabilityTest
Change-Id: I7bb844164d4b417445ff2d6f2f99c8a88d7f7f48
2018-06-04 12:47:45 -04:00
Mihai Popa
138b106402 Optimise the hit test algorithm
Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the
length of the current line. The method is used when a touch event
happens on a text line, to compute the cursor offset (and the character)
where it happened. Although this is not an issue in common usecases,
where the number of characters on a line is relatively small, this can
be very inefficient as a consequence of Unicode containing 0-width
(invisible) characters. Specifically, there are characters defining the
text direction (LTR or RTL), which cause our algorithm to touch the
worst case quadratic runtime. For example, a person is able to send a
message containing a few visible characters, and also a lot of these
direction changing invisible ones. When the receiver touches the message
(causing the Layout#getOffsetForHorizontal method to be called), the
receiver's application would become not responsive.

This CL optimizes the method to run in O(n) worst case. This is achieved
by computing the measurements of all line prefixes at first, which can
be done in a single pass. Then, all the prefix measurement queries will
be answered in O(1), rather than O(n) as it was happening before.

Bug: 79215201
Test: manual testing
Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
Merged-In: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-05-31 19:14:17 +01:00
Mihai Popa
ce642dc2ff Supress text replacement spans for ellipsis
When a sequence of characters belonging to a text is ellipsized, we
usually replace the first characters with ... and then all the others
with a 0 width character, knowing that they will be drawn, but will be
invisible. However, these positions could have had ReplacementSpans
attached to them, such as EmojiTypefaceSpan when the EmojiCompat library
is used. When this happened, all the ellipsized out characters were
invisible, apart from emojis, which were still drawn as usual (as they
were replacing sequences of 0 width characters).
This CL fixes this behaviour, by skipping those ReplacementSpans that
were completely included in ellipsis. Please check the bug for a more
detailed explanation.

Bug: 69802699
Test: manual testing
Test: atest FrameworksCoreTests:android.text.TextLineTest
Change-Id: If9758537948abaa0226fe6b551a703110c5457b9
2018-05-30 12:52:50 +01:00
Mihai Popa
7626c86ad7 Optimise the hit test algorithm
Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the
length of the current line. The method is used when a touch event
happens on a text line, to compute the cursor offset (and the character)
where it happened. Although this is not an issue in common usecases,
where the number of characters on a line is relatively small, this can
be very inefficient as a consequence of Unicode containing 0-width
(invisible) characters. Specifically, there are characters defining the
text direction (LTR or RTL), which cause our algorithm to touch the
worst case quadratic runtime. For example, a person is able to send a
message containing a few visible characters, and also a lot of these
direction changing invisible ones. When the receiver touches the message
(causing the Layout#getOffsetForHorizontal method to be called), the
receiver's application would become not responsive.

This CL optimizes the method to run in O(n) worst case. This is achieved
by computing the measurements of all line prefixes at first, which can
be done in a single pass. Then, all the prefix measurement queries will
be answered in O(1), rather than O(n) as it was happening before.

Bug: 79215201
Test: manual testing
Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-05-22 23:44:00 +00:00
Seigo Nonaka
50fe78805d Reorder the drawing of underline/stroke and text
The underline and stroke should be top of the text.
This regression happens on O-MR1 and the root cause is still unknown,
but the drawning underline/stroke should do before drawing text.

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

Change-Id: Idc2f99b9c0fa125af331e496da8daa326d14bfac
2018-05-21 14:56:40 -07:00
TreeHugger Robot
ff63291986 Merge "Add test cases for Layout.primaryIsTrailingPrevious" 2018-05-17 17:30:21 +00:00
Seigo Nonaka
32afe26a00 Add TextLayout.measure test cases
Bug: 78464361
Test: atest android.text.TextLineTest
Change-Id: I62e05d4fe18c115060da918a2c9105f0e94fe4b0
2018-05-16 22:20:57 -07:00
Seigo Nonaka
19e75a6a42 Add test cases for Layout.primaryIsTrailingPrevious
Bug: 78464361
Test: atest FrameworksCoreTests:android.text.LayoutTest
Change-Id: Id2735e993849bced47f9b361c99e13f91fe88070
2018-05-16 17:00:02 -07:00
Mihai Popa
a875271fcc Check against null text in TextView constructor
It is common for TextView subclasses to override the #setText method,
and there is nothing preventing the new implementations from leaving
mText and mTransformed unchanged. On the other hand, TextView assumes
mText and mTransformed will be non null at all times after the first
overridden implementations, these can remain null, causing null pointer
exceptions later.

Bug: 74411872
Test: atest FrameworksCoreTests:android.widget.TextViewTest
Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest
Test: atest CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: Ifaddb46d156c495a371789c6f32cfd67ffaaaef2
2018-05-14 16:54:00 +01:00
Jake Wharton
fe16dfe76d Avoid internal method call and its branching.
This is a simple check that can be done locally.

Test: TextUtilsTest.java
Change-Id: I00f2a4fd087aa98ece2c3aa032e106496663b13f
2018-04-23 15:34:57 -04:00
Siyamed Sinir
5ee0f5c1d7 Merge "Update Emoji.java for emoji 11" into pi-dev 2018-04-23 18:19:22 +00:00
Abodunrinwa Toki
85767df8cf Merge "SmartLinkify - handle keyboard clicks" into pi-dev am: 686fab1464
am: f8a770a515

Change-Id: I534794c28c13fc44829427a1d4dd567fe683c6b9
2018-04-20 12:25:43 -07:00