Status Update
Comments
al...@google.com <al...@google.com>
ca...@google.com <ca...@google.com> #2
removed the dup; this is possibly about how android spans work on empty strings.
- the calculation in the composable level seemed correct but the layout was not
- it happens for a new line as well
- one problem with both includeFontPadding true/false is that the cursor height is possibly can be visually improved to match the text ascent/descent rather than line top/bottom (might be challenging)
ki...@smartpatient.eu <ki...@smartpatient.eu> #3
I do not fully understand your points, though I was wondering if a similar "trick" to measure "HHHHHHHHHHH" cannot be used here, because if I'm not mistaken the cursor gets drawn by text layout measuring on empty string.
ca...@google.com <ca...@google.com> #4
StaticLayout does not call LineHeightSpan's for empty sstring (or the empty final line at the end of the string - a string that ends with "\n")
ki...@smartpatient.eu <ki...@smartpatient.eu> #5
Branch: androidx-main
commit b7a67dc25a34b254adbaffd02495b5c6d26ee18c
Author: siyamed <siyamed@google.com>
Date: Thu Jul 28 08:06:35 2022
Fix TextField empty line lineHeight (2)
When a line is empty (including empty text) StaticLayout
does not apply the LineHeightSpans.
This causes the line height to be different for an empty
line compared to a non empty line. The issue becomes more
visible within TextField .
This CL stores adjustment values to report the height and the
last line metrics correctly.
For the other solution option please see aosp/2170504
Performance
There are no performance differences for cases where text
is not empty or does not end with "\n"
The below numbers are for the cases where text is empty or ends with "\n"
+--------+-----------+-----------+------+
| | Before | After | Diff |
+--------+-----------+-----------+------+
| length | ns | ns | ns |
| 0 | 115,835 | 180,161 | 56% |
| 16 | 395,679 | 484,748 | 23% |
| 32 | 513,235 | 590,783 | 15% |
| 64 | 807,133 | 901,896 | 12% |
| 128 | 1,330,733 | 1,421,371 | 7% |
| 256 | 2,338,534 | 2,464,810 | 5% |
+--------+-----------+-----------+------+
Test: Added test
Test: ./gradlew text:text:test
Test: ./gradlew text:text:cAT
Test: ./gradlew compose:ui:ui-text:test
Test: ./gradlew compose:ui:ui-text:cAT
Test: Treehugger
Bug: 236615813
Change-Id: I57f8b6632f569ad06e547cf6ec83df1bc42845c9
M compose/ui/ui-text/lint-baseline.xml
M compose/ui/ui-text/benchmark/src/androidTest/java/androidx/compose/ui/text/benchmark/input/EditProcessorBenchmark.kt
M compose/ui/ui-text/benchmark/src/androidTest/java/androidx/compose/ui/text/benchmark/ParagraphBenchmark.kt
M compose/ui/ui-text/benchmark/src/main/java/androidx/compose/ui/text/benchmark/TextBenchmarkHelper.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/ParagraphIntegrationLineHeightStyleTest.kt
M text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt
A compose/ui/ui-text/benchmark/src/androidTest/java/androidx/compose/ui/text/benchmark/ParagraphWithLineHeightBenchmark.kt
M text/text/src/main/java/androidx/compose/ui/text/android/TextLayout.kt
M compose/ui/ui-text/benchmark/src/androidTest/java/androidx/compose/ui/text/benchmark/TextMeasurerBenchmark.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
ca...@google.com <ca...@google.com> #6
Thank you for fixing this. Will be this cherry-picked to 1.2.x release?
ca...@google.com <ca...@google.com> #7
ki...@smartpatient.eu <ki...@smartpatient.eu> #8
I handled that, I used setSystemBarsAppearance
and it works but why do I need to do that?
ca...@google.com <ca...@google.com> #9
The splash screen is copied to your application when you use the listener, and then belongs to your application, using the same theme as the postSplashScreenTheme, so you need to ensure your app theme matches the starting theme for a seamless transition. We might add an helper method to be sure the right window attribute can be set when you use a listener.
If you have any other question or comment to make, I'll keep the bug open for the day, otherwise I'll close it as work as intended.
ki...@smartpatient.eu <ki...@smartpatient.eu> #10
I think the helper method will be useful. I don't have more questions.
ca...@google.com <ca...@google.com> #11
Thank you for your feedback
ca...@google.com <ca...@google.com> #12
After further investigation, I found a suitable fix. Hera is a demo with and without the fix
ki...@smartpatient.eu <ki...@smartpatient.eu> #13
Do you know when a fix will be available?
ca...@google.com <ca...@google.com> #14
I can't make any promises but I estimate within the 2 next weeks if no other bug arise.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit 5a75362dc96ccaebf9a431c8facd899e1bb5ae34
Author: Vadim Caen <caen@google.com>
Date: Fri Oct 15 21:33:58 2021
Fix systemBar flickering on API 31
On API 31, if an OnExitAnimationListener is set, the Window layout params are only
applied only when the [android.window.SplashScreenView] is removed. This lead to some
flickers.
To fix this, we apply these attributes to the window while the
[android.window.SplashScreenView] is still visible.
Bug: 196273921
Test: SplashscreenParametrizedTest#endStateStableWithAndWithoutListener
Change-Id: I7e0593caba49563ccf06892df7f294e43ead7a5d
M core/core-splashscreen/src/androidTest/AndroidManifest.xml
M core/core-splashscreen/samples/src/main/res/layout/main_activity.xml
M core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt
M core/core-splashscreen/src/androidTest/java/androidx/core/splashscreen/test/SplashscreenParametrizedTest.kt
M core/core-splashscreen/src/androidTest/res/layout/main_activity.xml
A core/core-splashscreen/src/main/java/androidx/core/splashscreen/ThemeUtils.kt
M core/core-splashscreen/src/androidTest/res/values/styles.xml
M core/core-splashscreen/src/androidTest/java/androidx/core/splashscreen/test/SplashScreenTestActivities.kt
A core/core-splashscreen/samples/src/main/res/drawable/vertical_line.xml
M core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreenViewProvider.kt
ca...@google.com <ca...@google.com>
sh...@gmail.com <sh...@gmail.com> #16
I don't think this issue has been fixed entirely. Yes it seems the style is applied, but it breaks the automatic colour change of the navigation bar and doesn't apply the scrim behind 3 button navigation.
Follow these steps to reproduce.
- Create a new project (I used a bottom tab project for my base)
- Implement basic instructions for SplashScreen (have some code snippits below)
- Implement edge-to-edge as in this document
https://developer.android.com/develop/ui/views/layout/edge-to-edge#java If your activity has a dark background, you'd think to setandroid:windowLightNavigationBar
to false, but setting this attribute will stop the automatic contrast feature for the bottom buttons.
Important to note, this is NOT an issue when using the gesture based navigation. Seems to only impact 2 & 3 button navigation.
Here is some code to kickstart.
themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MyApplication" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="android:navigationBarColor">
@android:color/transparent
</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/splashscreen_bg</item>
<item name="postSplashScreenTheme">@style/Theme.MyApplication</item>
</style>
</resources>
MainActivity
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
splashScreen.setOnExitAnimationListener(splashScreenViewProvider -> {
final View splashScreenView = splashScreenViewProvider.getView();
splashScreenView
.animate()
.setDuration(0)
// Hack to avoid automatic layout transitions
.setStartDelay(Math.min(0, 0))
.alpha(0.0f)
.setInterpolator(new AccelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
splashScreenViewProvider.remove();
}
}).start();
});
ad...@gmail.com <ad...@gmail.com> #17
I personally like to stay up to date but setKeepOnScreenCondition was introduced from 1.0.0-beta01, so I'm stuck with this bug.
ya...@gmail.com <ya...@gmail.com> #18
Can confirm. It only works in version 1.0.0-alpha02. All other version after are broken when using exit animation.
ht...@mega.co.nz <ht...@mega.co.nz> #19
to...@gmail.com <to...@gmail.com> #20
Yes. I reported it as
We can use `androidx.core:core-splashscreen:1.2.0-alpha01`
Description
Component used: core-splashscreen Version used: 1.0.0-alpha01 Devices/Android versions reproduced on: API 31
When
setOnExitAnimationListener
is used then wrong colors appear on NavigationBar and StatusBar.