summaryrefslogtreecommitdiff
path: root/core/java/android/widget/SmartSelectSprite.java
Commit message (Collapse)AuthorAgeFilesLines
* Tweak smart selection animationTony Mak2020-11-031-31/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Result(with ag/12911059 as well): https://recall.googleplex.com/projects/ea8c4705-96bd-46f0-9f37-786708050727 1. Removed the corner animators. Before 3552167, we supported two modes - fit and overshoot. In fit mode, the highlight is expanded to a rounded rectangle. Then corner animator then fills the corner so that the highlight becomes a rectangle. In overshoot mode, the expansion animation ends up in a rectangular highlight, so the corner animator is just like doing no-op for 50ms. With ag/3552167, we deleted the fit mode and ended up using the overshoot mode. So, the corner animator is no longer necessary. Deleting it saves 50ms. I confirmed that it is a no-op by increasing the duration of it to be 5s. 2. Before this CL, the whole animation takes 350ms. As per the material design spec (https://material.io/design/motion/speed.html#duration) small animation(e.g. toggle) takes 100ms medium animation(bottom sheet) takes 250ms large animation(page transition) takes 300 ms. That means, our animation takes even longer than the large animation! I think smart selection animation is somewhere between small and medium, so adjusted the animation duration to be 200ms. Bug: 169043706 Test: Manual. Select the text and observe the animation. Change-Id: Ib32bb47851c1cfe95d6951998d6dc5c09a37e17b
* Replace com.android.internal.util.Preconditions.checkNotNull withDaulet Zhanguzin2020-01-031-4/+3
| | | | | | | | | | java.util.Objects.requireNonNull Bug: 126528330 Test: Treehugger Exempt-From-Owner-Approval: Global refactoring. Change-Id: Idf0949bd58a73bef2b5f3ecb6b99b2be2d1059c4
* Updating smart text selection animationJan Althaus2018-02-051-143/+25
| | | | | | | | Now animates the highlight itself as opposed to an outline. Bug: 70540865 Test: Manually tested it with single and multi-line - ltr and rtl Change-Id: I8afee259c9952fcff0b713bca62c82a1022f2b0d
* Improve starting offset calculationAbodunrinwa Toki2017-10-061-5/+27
| | | | | | | | | | | | The previous implementation did not take into account the various expansions that happen for OVERSHOOT and LEFT and RIGHT rectangles, thus causing the initial shape to be an oval instead of a circle. Test: manual - triggered smart select and verified that the intial shape is a circle under the touch point for both single line and multiline scenarios Change-Id: I75175bc3972db3f0608ef364109e0571268da4af
* Merge "Do not draw rectangles with the same left and right boundaries"TreeHugger Robot2017-09-291-2/+6
|\
| * Do not draw rectangles with the same left and right boundariesPetar Šegina2017-09-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | These should not be drawn at all, but the expansion logic for OVERSHOOT and LEFT and RIGHT rectangles will expand the rectangle into something that gets drawn. Test: manual - triggered smart selection and verified that rectangles on non-primary lines do not get prematurely shown Change-Id: I5235e4b214401e6ceee3f07bc5cc937907c261ba
* | Invert the animation over RTL selectionsPetar Šegina2017-09-281-40/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | When smart select is performed over right-to-left text (either standalone or mixed with left-to-right text), the animation should flow in from the opposite side than what it does over left-to-right text. Test: manual - verify smart select still works Test: manual - manually set the layout flags to RTL and verify the animation behaves as expected Test: bit FrameworksCoreTests:android.widget.SelectionActionModeHelperTest Change-Id: I2e7766e7dfe74e0861e91fc50b061da74432aee0
* | Merge "Replace stream operation with simple iteration"TreeHugger Robot2017-09-281-7/+7
|\ \
| * | Replace stream operation with simple iterationPetar Šegina2017-09-271-7/+7
| |/ | | | | | | | | | | | | | | | | | | Although the stream approach is elegant, we already have a simple loop iterating over the rectangles which we can reuse for finding the starting rectangle and save the overhead of the stream / additional iteration over the rectangles. Test: manual - verify smart select still works Change-Id: I4e4195ded4268a7c18ad1b0bc352a9c273396932
* | Merge "Fix clip expansion amount"Petar Šegina2017-09-281-1/+1
|\ \
| * | Fix clip expansion amountPetar Šegina2017-09-261-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The clipping rectangle needs to be expanded in order to cover the content drawn by the stroke. Since half the stroke is drawn on one side of the bounding rectangle and the other half on the other side, we need to expand the clip by half of the stroke width. The previous implementation expanded the clipping rectangle by the whole stroke width, this allowed for a part of the rounded rectangle to draw outside of the bounding box. Test: manual - verify smart select still works and that the rounded rectangle does not draw outside of the bounding box Change-Id: I8ca80b7b224d1ac2aa7638405b3cf516bd04b39f
* / Do not specify the unchecked exception in the method signaturePetar Šegina2017-09-271-1/+1
|/ | | | | Test: manual - compile the framework to verify everything still works Change-Id: Ifa69f824fcaa78c62f9be9bb9c281d2bf2716995
* Draw SmartSelectSprite in TextViewPetar Šegina2017-09-061-13/+19
| | | | | | | | | | | | | | Instead of the SmartSelectSprite drawing its contents into a View's ViewOverlay, the SmartSelectSprite can now be drawn on any Canvas. In order to perform the smart select animation, it is now the TextView that performs the actual drawing. Since the TextView can adjust the canvas for its padding and offset, there is no more need to manually transform the selection rectangles, so that part can be removed. Test: manual - verify smart select animation still works Change-Id: Ibaccf59fd44d5701e6f37d6b4fa97f2b05fd77cc
* Improve and simplify final polygon drawingPetar Šegina2017-09-011-140/+54
| | | | | | | | | | | | | | | | | | | | | | The final step of the smart select animation, drawing the outline of all the rectangles, was not working properly in cases where the rectangles would touch or intersect, which we cannot guarantee that they won't. Instead of the previous implementation, we now rely on Path to create the outline of the rectangles, making much of the code simpler. Now the polygon generation should work in the general case, which is one of the prerequisites in getting the smart select animation to work properly in multiline scenarios. Test: manual - test the smart select animation with various rectangle sets (100, 100, 500, 500), (300, 300, 700, 700) (100, 100, 500, 500), (500, 100, 900, 500) (100, 100, 500, 500), (500, 300, 900, 700) (100, 100, 500, 500), (300, 300, 700, 500), (200, 500, 400, 700) Change-Id: I51dd72e18c5efe36df734aa62ab47d57a5946399
* Merge "Improve rectangle direction generation"TreeHugger Robot2017-08-311-11/+19
|\
| * Improve rectangle direction generationPetar Šegina2017-08-311-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous solution didn't take into account that the source rectangle might be at either end of the selection, thus giving it the wrong direction of CENTER, while it should have been RIGHT or LEFT. Test: manual - verify that the rectangles expand properly in a smart select animation when there are multiple rectangles and the source is not in the center - e.g. a multiline case with the selection starting on the first line Change-Id: Id18ab8f9918e74a576503620dae2f7cdd593fb0e
* | Rename roundPercentage to roundRatioPetar Šegina2017-08-311-12/+11
|/ | | | | Test: manual - verify smart select animation still works Change-Id: Ic63236a47563b2daef57eeb52dd4fdbbb2cb1780
* Merge "Replace manual insetting with .inset()"TreeHugger Robot2017-08-311-4/+1
|\
| * Replace manual insetting with .inset()Petar Šegina2017-08-311-4/+1
| | | | | | | | | | Test: manual - verify smart selection animation still works Change-Id: Iea13ec8962777863121f49f47a13425bb0cc7d42
* | Merge "Do not round corners on tall selection rectangles"Petar Šegina2017-08-311-1/+11
|\ \ | |/ |/|
| * Do not round corners on tall selection rectanglesPetar Šegina2017-08-231-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | When performing the smart select animation, some of the selection rectangles may be taller than they are wide (e.g. due to a very large line-height). Since in these cases we cannot properly round the corners and the effect looks off, the agreed upon action is to not round the corners of these selection rectangles at all. Test: manual - run SmartSelectSprite on a manually constructed set of rectangles and verify that it behaves correctly Change-Id: Ifd02005e3d2709736c34f6d07671a4eb7a9557db
* | Expand the animation from the user's last touch pointPetar Šegina2017-08-231-20/+35
|/ | | | | | | | | | | | | | | | | | | | | | The Smart Select animation now expands from the spot the user last lifted their finger. In order to achieve this, the last up event coordinates need to be tracked in Editor. Since it's possible to trigger Smart Select by having the second of the two taps outside any of the rectangles, the touch point gets moved into the nearest rectangle and the animation starts from that point. Test: manual - try out Smart Select by touching different words at different points Test: manual - try to trigger Smart Select with a double tap where the second tap is outside of the word Test: bit FrameworksCoreTests:android.widget.SelectionActionModeHelperTest Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: bit CtsAccessibilityServiceTestCases:android.accessibilityservice.cts.AccessibilityTextTraversalTest Change-Id: I96844e8307554b010b476673820f98dae09c0cc3
* Load Smart Select stroke color from colorControlActivatedPetar Šegina2017-08-151-4/+21
| | | | | | | Test: manual - built an app that overrides colorControlActivated in it's theme and tested the Smart Select animation in it Change-Id: Ia6112e9e1f49b15a56f8f0455cd55bf3df598508
* Add animation for Semantic LiftPetar Šegina2017-08-111-0/+642
Test: manual - trigger smart select in a TextView Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Change-Id: I2b147a9cc4cbb79118bb78d948bac76a63cf4253