Status Update
Comments
il...@google.com <il...@google.com> #2
but the fontStyle and fontFamily parameters are not. I expected "World" to display as bold, italic and monospace.
+1, it sounds like a bug and agree that fontStyle
and fontFamily
should be carried as long as they are note overridden
Note also how textDecoration = TextDecoration.LineThrough from the annotated string and TextDecoration.Underline on the Text combine
This also sounds like a bug (especially for a case where Text has LineThrough, AnnotatedString has TextDecoration.None, where the intention is "this part of the text should not have a text decoration)
co...@google.com <co...@google.com> #3
Branch: androidx-main
commit 28810a41432e2fc8713e0a4b59ac311d9db77eb3
Author: Haoyu Zhang <haoyuchang@google.com>
Date: Fri Apr 09 16:04:52 2021
Read global font attributes when resolve font attributes on AnnotatedString
Also introduced screenshot test for styled text.
Bug: 184760917
Test: ./gradlew test
Change-Id: I8f21298ffd551f0963e11b059412f0c582dc9dd6
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/BasicTextScreenshotTest.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/SpannableExtensionsTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraphHelper.android.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraphIntrinsics.android.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
il...@google.com <il...@google.com> #4
Branch: androidx-main
commit eeff527b7ec6ca2accb0163696098d2765076262
Author: Haoyu Zhang <haoyuchang@google.com>
Date: Thu Apr 29 11:13:41 2021
Make SpanStyle merge logic on AnnotatedString consistent
Bug: 184760917
Test: ./gradlew test
Test: ./gradlew compose:ui:ui-text:connectedAndroidTest
RelNote: "TextGeomerticTransform and TextDecoration on AnnotatedString
will be applied as given."
Change-Id: I61900b749deafc1570dc329a64d1050fd52b20a2
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidParagraphTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidAccessibilitySpannableString.android.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
A text/text/src/main/java/androidx/compose/ui/text/android/style/TextDecorationSpan.kt
ke...@gmail.com <ke...@gmail.com> #5
I tried this on beta06 (assuming that's where the fix went) and fontStyle
and fontFamily
now apply as expected. However, I still get underlining AND linethrough on "World". I wanted to confirm that it is your intention to combine them, based on the comments above.
Playing with the example further:
- Changing the
Text
toTextDecoration.None
results in no decoration on "Hello" but a linethrough on "World" (seems reasonable -- annotated overrides Text) - Changing the annotated "World" to
TextDecoration.None
and theText
toTextDecoration.LineThrough
(as suggested in the comments above) results in a linethrough on "Hello World" (seems inconsistent -- shouldn't "World" have no decoration?)
(And sometimes, oddly, I have to uninstall the test app manually in the emulator before the new code will take effect.)
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #6
Hi, thanks for your report! The fixing CL for TextDeocration and LineThrough was just merged recently. And it's probably not included in the beta-06, can you please check it again in next release?
Description
Version used: 1.1.0-alplha01
Devices/Android versions reproduced on: Essential PH-1, Android 9.0 (PPR1.181005.034)
Attached a sample project to reproduce the issue. Essentially, given the component structure:
Activity:
supportFragmentManager -> HeadlessFragment
HeadlessFragment:
childFragmentManager -> HeadlessChildFragment
When the Activity is recreated, the state provided to the HeadlessChildFragment when recreating is null. However, logging the calls to onSaveInstanceState() it's clear that the Fragment's state is being saved, it's just failing to be restored. Running with FragmentManager.enableDebugLogging(true) gives the following output:
2018-11-20 12:59:46.293 17352-17352/ D/MainActivity: 218206560: onCreate(): savedInstanceState == null
2018-11-20 12:59:46.315 17352-17352/ V/FragmentManager: Commit: BackStackEntry{bc270bf}
2018-11-20 12:59:46.316 17352-17352/ D/FragmentManager: mName=null mIndex=-1 mCommitted=false
2018-11-20 12:59:46.316 17352-17352/ D/FragmentManager: Operations:
2018-11-20 12:59:46.316 17352-17352/ D/FragmentManager: Op #0: ADD ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.340 17352-17352/ V/FragmentManager: Run: BackStackEntry{bc270bf}
2018-11-20 12:59:46.343 17352-17352/ V/FragmentManager: add: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.343 17352-17352/ V/FragmentManager: Added fragment to active set ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.343 17352-17352/ V/FragmentManager: moveto CREATED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.343 17352-17352/ D/ParentHeadlessFragment: 48128908: onCreate() with savedInstanceState = null
2018-11-20 12:59:46.345 17352-17352/ V/FragmentManager: Commit: BackStackEntry{85b9824}
2018-11-20 12:59:46.345 17352-17352/ D/FragmentManager: mName=null mIndex=-1 mCommitted=false
2018-11-20 12:59:46.345 17352-17352/ D/FragmentManager: Operations:
2018-11-20 12:59:46.345 17352-17352/ D/FragmentManager: Op #0: ADD ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.345 17352-17352/ V/FragmentManager: moveto ACTIVITY_CREATED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.345 17352-17352/ V/FragmentManager: Run: BackStackEntry{85b9824}
2018-11-20 12:59:46.346 17352-17352/ V/FragmentManager: add: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.346 17352-17352/ V/FragmentManager: Added fragment to active set ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.346 17352-17352/ V/FragmentManager: moveto CREATED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.346 17352-17352/ D/ChildHeadlessFragment: 120778637: onCreate() with savedInstanceState = null
2018-11-20 12:59:46.346 17352-17352/ V/FragmentManager: moveto ACTIVITY_CREATED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.347 17352-17352/ V/FragmentManager: moveto STARTED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.347 17352-17352/ V/FragmentManager: moveto STARTED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:46.383 17352-17352/ W/ildfragmenttes: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2018-11-20 12:59:46.384 17352-17352/ W/ildfragmenttes: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2018-11-20 12:59:46.394 17352-17352/ V/FragmentManager: moveto RESUMED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:46.394 17352-17352/ V/FragmentManager: moveto RESUMED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
// Configuration changed:
2018-11-20 12:59:58.045 17352-17352/ V/FragmentManager: movefrom RESUMED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.045 17352-17352/ V/FragmentManager: movefrom RESUMED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.048 17352-17352/ V/FragmentManager: movefrom STARTED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.048 17352-17352/ V/FragmentManager: movefrom STARTED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.048 17352-17352/ D/MainActivity: 218206560: onSaveInstanceState()
2018-11-20 12:59:58.050 17352-17352/ D/ParentHeadlessFragment: 48128908: onSaveInstanceState()
2018-11-20 12:59:58.050 17352-17352/ D/ChildHeadlessFragment: 120778637: onSaveInstanceState()
// I suspect the issue is here, where the Bundle listed in the log is null:
2018-11-20 12:59:58.051 17352-17352/ V/FragmentManager: Saved state of ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}: null
2018-11-20 12:59:58.051 17352-17352/ V/FragmentManager: saveAllState: adding fragment (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e): ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.051 17352-17352/ V/FragmentManager: Saved state of ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}: Bundle[{android:support:fragments=androidx.fragment.app.FragmentManagerState@beee1bb}]
2018-11-20 12:59:58.051 17352-17352/ V/FragmentManager: saveAllState: adding fragment (c94b7470-c453-471f-9231-254d296d2ab1): ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.052 17352-17352/ V/FragmentManager: movefrom ACTIVITY_CREATED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.052 17352-17352/ V/FragmentManager: movefrom ACTIVITY_CREATED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.054 17352-17352/ V/FragmentManager: movefrom CREATED: ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.054 17352-17352/ V/FragmentManager: movefrom CREATED: ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.054 17352-17352/ V/FragmentManager: Removed fragment from active set ChildHeadlessFragment{732ef8d (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.055 17352-17352/ V/FragmentManager: Removed fragment from active set ParentHeadlessFragment{2de638c (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.088 17352-17352/ D/MainActivity: 178784293: onCreate(): savedInstanceState == Bundle[{android:viewHierarchyState=Bundle[{android:views={16908290=android.view.AbsSavedState$1@7ee69, 2131165191=androidx.appcompat.widget.Toolbar$SavedState@c3ab0ee, 2131165193=android.view.AbsSavedState$1@7ee69, 2131165199=android.view.AbsSavedState$1@7ee69, 2131165231=android.view.AbsSavedState$1@7ee69}}], android:support:fragments=androidx.fragment.app.FragmentManagerState@cfa098f, android:lastAutofillId=1073741823, android:fragments=android.app.FragmentManagerState@8f9d41c}]
2018-11-20 12:59:58.091 17352-17352/ V/FragmentManager: Instantiated fragment ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.092 17352-17352/ V/FragmentManager: restoreAllState: active (c94b7470-c453-471f-9231-254d296d2ab1): ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.092 17352-17352/ V/FragmentManager: restoreAllState: added (c94b7470-c453-471f-9231-254d296d2ab1): ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.092 17352-17352/ V/FragmentManager: moveto CREATED: ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.092 17352-17352/ D/ParentHeadlessFragment: 152547243: onCreate() with savedInstanceState = Bundle[{android:support:fragments=androidx.fragment.app.FragmentManagerState@beee1bb}]
2018-11-20 12:59:58.093 17352-17352/ V/FragmentManager: Instantiated fragment ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.093 17352-17352/ V/FragmentManager: restoreAllState: active (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e): ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.093 17352-17352/ V/FragmentManager: restoreAllState: added (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e): ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.093 17352-17352/ V/FragmentManager: moveto CREATED: ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.093 17352-17352/ D/ChildHeadlessFragment: 242614689: onCreate() with savedInstanceState = null
2018-11-20 12:59:58.107 17352-17352/ V/FragmentManager: moveto ACTIVITY_CREATED: ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.107 17352-17352/ V/FragmentManager: moveto ACTIVITY_CREATED: ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.108 17352-17352/ V/FragmentManager: moveto STARTED: ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.108 17352-17352/ V/FragmentManager: moveto STARTED: ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}
2018-11-20 12:59:58.127 17352-17352/ V/FragmentManager: moveto RESUMED: ParentHeadlessFragment{917afab (c94b7470-c453-471f-9231-254d296d2ab1) parent}
2018-11-20 12:59:58.127 17352-17352/ V/FragmentManager: moveto RESUMED: ChildHeadlessFragment{e7601a1 (e67b23a6-fe18-484d-b8d0-db2da9ee2a7e) child}