-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Clipboard Adoption - CMP-7402 #1796
base: jb-main
Are you sure you want to change the base?
Conversation
import java.awt.datatransfer.Transferable | ||
import java.awt.datatransfer.UnsupportedFlavorException | ||
|
||
actual typealias NativeClipboard = java.awt.datatransfer.Clipboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing raw public typealias is a bad idea - it binds to AWT for desktop implementation without any options to compatibly change that.
Please consider changing that to extensions in platform sourcesets and removing this public API from common
PS sorry for late feedback, I had to do it in AOSP CL earlier. However, we still have an option to change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing raw public typealias is a bad idea - it binds to AWT for desktop implementation without any options to compatibly change that.
We can make it Any
, similar to nativeEvent in PointerEvent:
Line 108 in 085c24a
val nativeEvent: Any?, |
cc @m-sasha Wdyt?
Please consider changing that to extensions in platform sourcesets
I'll see how it would look like.
and removing this public API from common
It can be only deprecated, because Android uses this approach already, and it's not epxerimental. Given other prioroties, working on a new proposal for this API won't happen soon.
assertNotNull(nativeClipboard) | ||
|
||
runBlocking { | ||
// Can't do much more asserts in a unit test. For more checks use a UI (instrumental) test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Can't do much more asserts in a unit test. For more checks use a UI (instrumental) test | |
// Can't do much more asserts in a unit test. For more checks use an instrumented test |
@OptIn(ExperimentalTestApi::class) | ||
class UiKitPlatformClipboardTest { | ||
|
||
// TODO: consider writing instrumental tests for Clipboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: consider writing instrumental tests for Clipboard | |
// TODO: consider writing instrumented tests for Clipboard |
|
||
// TODO https://youtrack.jetbrains.com/issue/CMP-1260/ClipboardManager.-Implement-getClip-getClipMetadata-setClip | ||
actual val clipMetadata: ClipMetadata | ||
get() = TODO("ClipMetadata is not implemented. Consider using nativeClipboard") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It look list there is UTType
as a ClipMetadata representation on iOS. Do you want to use it in a separate MR?
I'll keep this sample here just in case:
val cString = CFStringGetCStringPtr(kUTTypeText, kCFStringEncodingUTF8)
val string = NSString.stringWithCString(cString) as String
println(string)
val type = UTType.typeWithIdentifier(string)
println(type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO was added before in skikoMain. But now one implementation in skikoMain won't work. So I copy/pasted the TODO too.
Yes, I believe it will be implemented in a separate MR.
Adopt new Clipboard interface on all targets.
New public api: It introduces some new public, platform-specific API: desktop, ios, web. See
ClipEntry
.For now each target implements it separately - there is no common API except the trivial class. This class wraps the platform type representing the Clipboard content.
Fixes https://youtrack.jetbrains.com/issue/CMP-7402
Testing
This should be tested by QA
Release Notes
Features - Multiple Platforms
Asking for 3 reviewers to review the new public API for every platform.