summaryrefslogtreecommitdiff
path: root/core/java/android/text/SpannableStringInternal.java
Commit message (Collapse)AuthorAgeFilesLines
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-10/+11
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-11/+10
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-10/+11
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Add @Nullable annotation to the parameter of Object.equals() methods.Roman Kalukiewicz2020-10-151-1/+2
| | | | | | | | | | | | | | | | | | Those annotations could be inferred by some tools (like Kotlin), but the https://checkerframework.org/ doesn't check inherited annotations complaining about all equals() invocations that get nullable argument. The change was generated by running find . -name \*.java | xargs sed -i 's/public boolean equals(Object /public boolean equals(@Nullable Object /' in the frameworks/base directory and by automatically adding and formatting required imports if needed. No manual edits. Bug: 170883422 Test: Annotation change only. Should have not impact. Exempt-From-Owner-Approval: Mechanical change not specific to any component. Change-Id: I5eedb571c9d78862115dfdc5dae1cf2a35343580
* Merge "Avoid ambiguous overloads in SpannableStringInternal."Michael Wallstedt2020-01-101-6/+7
|\
| * Avoid ambiguous overloads in SpannableStringInternal.Mike Wallstedt2019-12-121-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As documented in Effective Java (http://go/ej3e#page=259), overloaded methods with the same number of parameters can be confusing when the parameters are in the same type hierarchy. Aside from readability concerns, this may be related to some crashes observed in Photos Android. For example in b/144849105 AutoCompleteViewBinder calls the SpannedString constructor, which delegates to SpannedStringInternal. The overload of copySpans that accepts a SpannedStringInternal has a call to isOutOfCopyRange that should make the failure in checkRange impossible. Bug: 144849105 Test: Simple refactor. Change-Id: I47d01cffe6f66c4d631a9ef1341bf118fb6e51e4
* | Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-071-1/+1
|/ | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I288969b0c22fa3a63bc2e71bb5009fe4a927e154
* Fix equals not working correctly in SpannableString and SpannableStringBuilderHaoyu Zhang2018-09-201-5/+7
| | | | | | Bug: 73359036 Test: atest SpannableStringTest SpannableStringBuilderTest Change-Id: Idfaf71cde914d5c5325a6c6a3bfcda20ebee62f2
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-151-0/+28
| | | | | | | | | | | | | | | | | | | | 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
* Fix crash when modifying SelectionClara Bayarri2018-04-061-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The root of this bug was in the fact that Selection.removeSelection removes two spans, the start index and end index of the selection. Each span removal triggers Editor#onSpanRemoved, which in turn tries to set a selection. This meant that if we started with selection (100, 120), then removeSpan(start) was called, so we had (-1, 120), then the onSpanRemoved code tried to set a selection so set it to (120, 120), then removeSpan(end) was called, ending up in (120, -1). There are two stages to this fix 1. A lot of our code assumes that when either start or end selection are larger than -1, both are valid. Therefore when we have one of them out of sync, we crash. Fixed this assumption in all the places I found 2. We didn't have a mechanism to use FLAG_INTERMEDIATE when removing spans, only when adding them, so this CL adds a remove with flags. This allows us to not trigger onSpanRemoved when only one of the selection indexes is removed. Because this is an added method to an interface, the default just calls the existing method. The new method is implemented in SpannableStringInternal and SpannableStringBuilder to read FLAG_INTERMEDIATE and avoid sending a spans changed event. Selection.removeSelection then uses FLAG_INTERMEDIATE when removing the first of the two selection spans. Note that 2. would be enough to fix the current bug, but we want to avoid other implementations of Spannable from crashing in the wild. In general, it seems like a good idea to verify both selection indexes are valid whenever they are used. Bug: 72101848 Test: atest FrameworksCoreTests:SpannableStringBuilderTest Test: atest FrameworksCoreTests:SpannableStringTest Test: atest CtsWidgetTestCases:TextViewTest Test: atest CtsWidgetTestCases:EditTextTest Test: atest android.text.cts.SelectionTest (note new test as well) Test: atest android.view.inputmethod.cts.BaseInputConnectionTest Test: atest android.text.DynamicLayoutTest Change-Id: I0d647fad152d0bef0f2115a46c3d17ebd8642281
* Introduce new constructor for not copying NoCopySpanSeigo Nonaka2018-03-201-20/+61
| | | | | | | | | | | | | | | | | | | To hold the original text in PrecomputedText, need to create SpannableString, but copying NoCopySpan causes some side effect. This CL introduces a way of copying SpannableString/SpannedString with all spans other than NoCopySpan. Bug: 72998298 Bug: 35638900 Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest Change-Id: I20dea2114ccaa54b16ff679c97682a5003f9a4c1
* Do not enforce paragraph constraint for copy ctrSiyamed Sinir2017-04-111-15/+23
| | | | | | | | | | | | Update SpannableStringBuilder, SpannedString and SpannableString classes so that they don’t enforce paragraph constraint for copy constructors. If a paragraph constraint is not satisfied for a span, that span is not copied. Before this change it would throw an exception. Test: New tests added for SpannableStringBuilder and SpannableString cts-tradefed run cts -m CtsTextTestCases Bug: 36511794 Change-Id: I62abf08a8d4fe7e342ed97b8e8c3a577a9397e39
* Revert "Don't copy NoCopySpans in SpannableStringInternal"Siyamed Sinir2017-02-221-30/+17
| | | | | | | | | This reverts commit 5de4fb641adbf4f139c08e3b2504fb0545342402. Bug: 34712634 Fixes: 35363881 Change-Id: I7311e1201152bde052511869c60a0d0c1c5b3242
* Don't copy NoCopySpans in SpannableStringInternalSiyamed Sinir2017-01-301-17/+30
| | | | | | | | | | | | Bug: 34712634 Test: Added new tests to cts.SpannableStringTest and cts.SpannedStringTest android.text.cts.SpannableStringTest android.text.cts.SpannedStringTest android.text.cts.SpannableStringBuilderTest android.text.SpannableStringTest android.text.SpannedTest Change-Id: I34e4ef4798b8d26fa8770c0021acb52b4047095e
* Enforce consistent sizes for arrays in SpannableStringInternalRaph Levien2016-07-251-1/+2
| | | | | | | | | | | | | The grow logic in SpannableStringInternal#setSpan assumes that the size of mSpanData is consistent with that of mSpans, in particular that if the latter doesn't need to grow, neither does the former. The copySpans() method didn't enforce this, creating an mSpanData array only big enough to hold the data. This patch documents the invariant in a comment and enforces it. Bug: 30359314 Change-Id: Ie25db70a76836e97af8476a7f5c10cb4b976c1cf
* Sort the result of SpannableStringBuilder.getSpansSiyamed Sinir2016-01-201-12/+87
| | | | | | | | | | | SpannableStringBuilder used to return the result of getSpans in the order of start indices because of the interval tree it uses. However, style spans has to be applied in the order of insertion to get predictable results. Sorted the results of getSpans ordered first by priority flag and then by insertion time. Moreover improved the performance of SpannableStringInternal copy constructor. Bug: 26240132 Change-Id: I0b0fa7bb30a3bd9ca37dedca66d8993718586027
* Reduce cost of span type checkingChris Craik2015-07-101-4/+5
| | | | | | bug:22378829 Change-Id: I1da5154b2fb4f5032eaed44586d5470d28ceb45b
* Uses VMRuntime.newUnpaddedArray for ideal array sizesAdam Lesinski2014-03-271-6/+8
| | | | | | Bug:13028925 Change-Id: I0a9301248b10a339afbdc5e4ffe3310ac4fa1fb7
* Fix infinite recursion in hashcode of SpannablesChet Haase2013-10-041-8/+16
| | | | | | | | | | | | | | | An app created a SpannableStringBuilder, one of which's spans was the instance of the string builder itself (that is, the builder contained a span that was the builder). This caused infinite recursion in the hashcode() method because it computes a hash from its fields, including all of its spans. The fix detects the case where a span equals the current instance and noops the computation on that span. A similar adjustment was made to equals() to avoid the same recursion problem. Issue #11051658 StackOverflowError in android.text.SpannableStringBuilder.hashCode Change-Id: I742687ab32d81ac51c4b9135f698cf5e96a1d295
* Add equals() and hashcode() to SpannableStringChet Haase2013-09-191-0/+41
| | | | | | | | | | | | | | | ActionBar uses a transition to animate text changes. This transition depends on testing the equality of start/end text values in CharSequence objects. Without equals(), SpannableString will return false for objects whose references are different, but whose text is exactly the same. This CL adds the equals() method, and the accompanying hashcode method, to ensure that two Spanned implementations will always be equal if their text and span data are equal. Issue #10760075 Wrong unread count in actionbar Change-Id: I5e77d40dd302eca035e8c56d40f3cd0aef8e6424
* Small optimization when getting the spansFabrice Di Meglio2011-02-151-4/+4
| | | | | | - loop earlier if the kind is not the one we want Change-Id: I5b020f20a144678ad2f7a4bca8fef64eb6ae491f
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+372
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-372/+0
|
* Initial ContributionThe Android Open Source Project2008-10-211-0/+372