Fixes a crash in `getSystemEnvironment` on desktop when running in a
headless environment (such as most CI runners) by providing a default
density qualifier. In the future that might be something that's nice to
make configurable, but since both our use case and the linked issue
encountered it when calling `getString` I didn't worry about it too
hard.
Fixes [CMP-8068](https://youtrack.jetbrains.com/issue/CMP-8068)
## Testing
Made a local build and used it to run some tests in another project that
were failing on calls to `getString`
## Release Notes
### Fixes - Resources
- Fix crash in `getSystemEnvironment` on headless desktop
[CMP-9273](https://youtrack.jetbrains.com/issue/CMP-9273) Using Kotlin
2.2.20 in user project cause build error
## Release Notes
### Fixes - Resources
- _(prerelease fix)_ Fixed compatibility with Kotlin 2.2.20 on Web
Use Web Cache API for all resources
The Cache is reset on every app launch (page refresh).
The initial idea was to reset the Cache only when a new session starts,
but we risk to have an outdated resources state (it can be incompatible
with the app logic expectations and lead to crashes).
Fixes https://youtrack.jetbrains.com/issue/CMP-7996
## Testing
This should be tested by QA
## Release Notes
### Fixes - Resources
- Use Web Cache API for all resources to avoid repeated and redundant
HTTP requests
Partially addresses https://youtrack.jetbrains.com/issue/CMP-9075
But it doesn't ultimately fix the FOUC problem. In many cases font
preloading will be necessary to improve the UX.
Describe proposed changes and the issue being fixed
## Testing
- This should be tested by QA
## Release Notes
### Fixes - Resources
- Use the non-empty font as a default when awaiting for a asynchronous
request completion on web
The web demo stopped compiling after updating to 1.9.0 due to deprecated
API usages.
This PR uses ComposeViewport API and unifies the Js and Wasm main.kt
## Testing
N/A
## Release Notes
N/A
Handle a case when Int.Locale('...') is created without a region - then
use an empty string for region.
Fixes https://youtrack.jetbrains.com/issue/CMP-6930
## Testing
- Added a test
- This should be tested by QA
## Release Notes
### Fixes - Resources
- Fix a crash when calling `getString` and the Locale has no region
specified
It fixes Robolectric tests where a context is available through
InstrumentationRegistry
Fixes https://youtrack.jetbrains.com/issue/CMP-6612
## Release Notes
### Fixes - Resources
- Fix resource access in a Robolectric test environment.
Fixes https://youtrack.jetbrains.com/issue/CMP-6676
## Release Notes
### Features - Resources
- Add `setResourceReaderAndroidContext` to configure Android context in
cases when a provider initialization is not available.
Used by Compose Hot Reload to mark a related accessor as dirty if the
hash is changed after reloading of new accessors.
Fixes [CMP-8513](https://youtrack.jetbrains.com/issue/CMP-8513)
## Release Notes
N/A
Describe proposed changes and the issue being fixed
Fixes
[CMP-8134](https://youtrack.jetbrains.com/issue/CMP-8134/Switch-the-ClassLoader-used-by-ResourceReader)
## Testing
- [x] Add Test to **desktopTest** SourceSet
- (Optional) This should be tested by QA
## Release Notes
### Features - Resources
- Added `JvmResourceReader` API and made `LocalResourceReader` public to
allow providing a custom classloader for desktop target
Exposed the following Preview annotation parameters:
- name
- group
- widthDp
- heightDp
- locale
- showBackground
- backgroundColor
## Testing
Tested the local artifact in IJ: new parameters are exposed and picked
up. No additional changes on the IDE end are required.
But this should be tested by QA, of course.
## Release Notes
### Features - Multiple Platforms
- Extended the `@Preview` annotation with the following parameters:
- name
- group
- widthDp
- heightDp
- locale
- showBackground
- backgroundColor
IDE (IJ or AS) will pick up these parameters in the same way it works
for `androidx` Preview annotations.
This is required for the preview parameters to be correctly picked up by
the preview adapter in IDE, which expects the provider to be a subclass
of AndroidX's interface, and fails with the `ClassCastException`
otherwise.
## Release Notes
### Fixes - Multiple Platforms
- Support Preview parameters for Previews in common source sets in IJ
and AS. Note: IDEs also need to implement support on their end. Please
check the respective IDE release notes to confirm this is supported.
Example usage:
```
import androidx.compose.runtime.Composable
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.ui.tooling.preview.PreviewParameter
import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider
class MyPreviewParameterProvider : PreviewParameterProvider<String> {
override val values = sequenceOf("Hello, Compose!", "Hello, World!")
}
/**
* This function will generate two preview images with different texts.
*/
@Preview@Composable
fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) {
Text(text)
}
```
This PR fixes compose resources for native macOS app (see currently
broken chat app using runDebugExecutableMacosArm64).
This PR also adds support for embedding resources into native macOS
framework. Similar to how it works on iOS. This allows using the macOS
compose code in an Xcode project. Just like iOS, using kotlin code as
framwork. Then call the main function from the Xcode project to run the
compose app.
https://github.com/JetBrains/compose-multiplatform/pull/5219https://github.com/JetBrains/compose-multiplatform/pull/5169
## Testing
- For executable: run chat app using runDebugExecutableMacosArm64
- For framework: Tested by adding macOS support to the iOS Xcode project
in chat app (not in this PR). Can add the sample app if needed. There
were also tests added to verify this.
## Release Notes
N/A
This PR addresses typographical errors in the comments of the
`splitpane` package. The corrections are as follows:
1. **VerticalSplitPane function comment**:
- **Original**: "Pane that place it parts **vertically** from top to
bottom and allows to change items **heights**."
- **Correction**: "Pane that places its parts **vertically** from top to
bottom and allows changing items' **heights**."
2. **HorizontalSplitPane function comment**:
- **Original**: "Pane that place it parts **horizontally** from left to
right and allows to change items **width**."
- **Correction**: "Pane that places its parts **horizontally** from left
to right and allows changing items' **widths**."
3. **SplitPane function comment**:
- **Original**: "@param isHorizontal describes is it horizontal of
vertical split pane"
- **Correction**: "@param isHorizontal describes whether it is a
horizontal or vertical split pane"
These changes enhance the clarity and grammatical accuracy of the code
comments.
**Fixes**
N/A
**Testing**
As these changes are limited to comments and do not affect the
executable code, no additional testing is required.
**Release Notes**
N/A
Since the changes are non-functional and pertain only to code comments,
they do not necessitate an entry in the release notes.
Updated the regex to correctly match multi-digit placeholders in string
templates. Added a suite of tests to ensure `replaceWithArgs` handles
various edge cases like missing arguments, mismatched placeholders, and
invalid formats reliably.
Fixes https://youtrack.jetbrains.com/issue/CMP-7236
## Testing
- Unit tests
## Release Notes
### Fixes - Resources
- Fix string resource's regex for placeholders to correctly match
multi-digit placeholders.
First commit fixes compose resources for native macOS app (see currently
broken chat app using `runDebugExecutableMacosArm64`).
Second commit adds support for embedding resources into native macOS
framework. Similar to how it works on iOS. This allows using the macOS
compose code in an Xcode project. Just like iOS, using kotlin code as
framwork. Then call the main function from the Xcode project to run the
compose app.
## Testing
First commit: run chat app using `runDebugExecutableMacosArm64`
Second commit: Tested by adding macOS support to the iOS Xcode project
in chat app (not in this PR). Can add the sample app if needed.
## Release Notes
### Features - Resources
- Add new API to preload and cache font and image resources on web
targets: `preloadFont`, `preloadImageBitmap`, `preloadImageVector`
____
Add a new experimental web-specific API to preload fonts and images:
```kotlin
@Composable
fun preloadFont(
resource: FontResource,
weight: FontWeight = FontWeight.Normal,
style: FontStyle = FontStyle.Normal
): State<Font?>
@Composable
fun preloadImageBitmap(
resource: DrawableResource,
): State<ImageBitmap?>
@Composable
fun preloadImageVector(
resource: DrawableResource,
): State<ImageVector?>
```
Using this methods in advance, it's possible to avoid FOUT (flash of
unstyled text), or flickering of images/icons.
Usage example:
```kotlin
val font1 by preloadFont(Res.font.Workbench_Regular)
val font2 by preloadFont(Res.font.font_awesome, FontWeight.Normal, FontStyle.Normal)
UseResources() // Main App that uses the above fonts
if (font1 != null && font2 != null) {
println("Fonts are ready")
} else {
Box(modifier = Modifier.fillMaxSize().background(Color.White.copy(alpha = 0.8f)).clickable { }) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
println("Fonts are not ready yet")
}
```
Should fix
```
Dependency 'androidx.compose.foundation:foundation-android:1.8.0-alpha02' requires libraries and applications that depend on it to compile against version 35 or later of the Android APIs.
```
Fixes https://youtrack.jetbrains.com/issue/CMP-6688
## Testing
Added a unit test.
<!-- Optional -->
This should be tested by QA
## Release Notes
### Fixes - Resources
- Read `android:autoMirrored="true"` property and pass it to ImageVector
builder
1) The PR adds a support test resources in Compose multiplatform
projects.
2) The PR adds a support multi-module resources in JVM-only projects.
Fixes https://youtrack.jetbrains.com/issue/CMP-1470
Fixes https://youtrack.jetbrains.com/issue/CMP-5963
## Release Notes
### Features - Resources
- Added support of test resources in Compose Multiplatform projects
- Added support of multi-module resources in JVM-only projects
Use deprecated `seekToFileOffset` on iOS 12 to fix a crash on old Apple
devices
Fixes https://youtrack.jetbrains.com/issue/CMP-5967
## Release Notes
### Fixes - Resources
- _(prerelease fix)_ Fix a resource reading on iOS 12
The PR adds a method to convert a bitmap bytearray to the ImageBitma, a
vector XML content bytearray to the ImageVector in the common code. And
the same for an SVG files on non-android targets.
<!-- Optional -->
Fixes https://youtrack.jetbrains.com/issue/CMP-3869
Fixes https://youtrack.jetbrains.com/issue/CMP-4925
## Release Notes
### Features - Resources
- Added utility functions to decode `Bitmap ByteArray as ImageVector`
and `XML ByteArray as ImageVector` in the common code and `SVG ByteArray
as Painter` in the non-android code
Add a font cache on non-android targets.
Android targets already have own font caching.
Fixes https://youtrack.jetbrains.com/issue/CMP-1477
## Release Notes
### Features - Resources
- To avoid constant reading raw font bytes on each Font usage on
non-android targets, there was added the font cache. Android has own
font cache inside the platform implementation.