Touch and input snippet migration - #1138
Draft
barbaralaw wants to merge 29 commits into
Draft
barbaralaw wants to merge 29 commits into
barbaralaw wants to merge 29 commits into
Conversation
Replaced Any? with a more reasonable List<String>. Added an example Log.e to avoid a comment. Signed-off-by: morgillo <morgillo@google.com>
…EXCLUDE section to keep up the unnecessary (on DAC) method implementation. Signed-off-by: morgillo <morgillo@google.com>
…re](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget#onCompositionError(android.content.Context,androidx.glance.GlanceId,kotlin.Int,kotlin.Throwable)). We shouldn't extract this. On the contrary, we should link out to the official reference page: ```` To use this feature, override the [onCompositionError()](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/GlanceAppWidget#onCompositionError(android.content.Context,androidx.glance.GlanceId,kotlin.Int,kotlin.Throwable)) function: ```` on the DAC page. Signed-off-by: morgillo <morgillo@google.com>
Signed-off-by: morgillo <morgillo@google.com>
Signed-off-by: morgillo <morgillo@google.com>
Signed-off-by: morgillo <morgillo@google.com>
…iew-based snippets. Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
Signed-off-by: morgillo <morgillo@google.com>
#1 (comment) Signed-off-by: morgillo <morgillo@google.com>
…snippets katherinekuan/migrate-dac-snippets
android#1031 (comment) Signed-off-by: Ivan Morgillo <imorgillo@gmail.com>
Aaron asked for one rule rather than a mix, and a period is the one he wants. Eight comments across the predictive back and edge-to-edge snippets. Two of them, the status bar icon lines, are copied from the setup-e2e page, which publishes them without a period, so the page picks up the change when it renders the include. The TODO in GlanceSnippets.kt keeps no period. "TODO: handle error." reads wrong.
* Add code snippets for parcelize * Use a declaration-level opt-in for the DataClass snippet The page's data class serializer block opens with a file-level @file:OptIn. A file annotation must precede the package declaration, so it cannot sit inside a region tag, and the published snippet lost the opt-in entirely -- a reader copying it would hit a compile error. Moving the annotation onto the class puts it inside the region, makes both @DataClass snippets use the same form, and lets the file-level annotation be dropped: nothing else in the file required it. This deviates from the page as published. The page's block needs the matching change. * Include the import line in the basic and parcelable_creator snippets * Code review updates --------- Co-authored-by: Katherine Kuan <843428+kkuan2011@users.noreply.github.com>
`./gradlew spotlessCheck` has been failing on main since these two files landed in #3, on nothing more than a missing newline at end of file. Two bytes, one per file, and `spotlessApply` writes both. It is not cosmetic while it sits on main. Every branch cut from main inherits a red format gate, so the check that is supposed to say "your change is clean" says "something is broken" to everyone regardless of what they changed. Three snippet pull requests this week each carried it as an unrelated failure, and `upstream-preflight check` runs spotlessApply and asserts a clean tree before anything goes to android/snippets, so it refuses every branch on principle. Upstream does not have these files. They are ours, from #3, so the sync with android:main was never going to fix them. Only the two files the formatter names, and nothing else in the tree.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates hardcoded Kotlin samples from three Compose touch-input guides into
:compose:snippetsas region-tagged source, so the guides can import them instead of hardcoding them.Two of those pages already had the samples in this repo (
commands.kt,KeyboardShortcutsHelper.kt). This PR only adds the page that did not: copy-and-paste.On that new page: 8 snippets. 5 publish exactly what the page shows. 3 differ, every one
listed below with a reason. Line wrapping is not counted as a difference:
spotlessApplyruns before submission and rewraps long calls without changing what a reader reads.
Region tags for the new file begin
android_compose_touchinput_copyandpaste_; the tables drop that prefix.How to read the "why" column
Per page
1. Copy and paste
https://developer.android.com/develop/ui/compose/touch-input/copy-and-paste
Not previously in the repo. 8 snippets, 5 match, 3 differ.
set_textsetText("Hello, clipboard")→setText(AnnotatedString("Hello, clipboard"))paste_textappend(text.toString())→append(annotatedString.text);var textFieldState→val textFieldStatepaste_rich_content)dropped onhasMediaType(MediaType.Image);by remember { mutableListOf<Uri>() }→remember { mutableStateListOf<Uri>() }Matching as published:
selection_container,clip_entry,copy_rich_content,has_media_type,sensitive_content.2. Handle keyboard actions
https://developer.android.com/develop/ui/compose/touch-input/keyboard-input/commands
Already region-tagged in
compose/snippets/.../touchinput/keyboardinput/commands.kt. This PR does not change that file.3. Keyboard Shortcuts Helper
https://developer.android.com/develop/ui/compose/touch-input/keyboard-input/keyboard-shortcuts-helper
Already region-tagged in
compose/snippets/.../touchinput/keyboardinput/KeyboardShortcutsHelper.kt. This PR does not change that file.Not extracted
Kotlin only. No Java twins on the copy-and-paste page.
Live snippet fixes this surfaced
clipboardManager.setText("Hello, clipboard")—ClipboardManager.setTexttakesAnnotatedString, notString.append(text.toString())—textis not in scope in theeditlambda; the pasted value isannotatedString.transferableContent.hasMediaType(MediaType.Image))— extra).val imageList by remember { mutableListOf<Uri>() }is not snapshot state, so laterimageList.addis not a correct Compose pattern.Verification
./gradlew :compose:snippets:compileDebugKotlin— passes./gradlew :compose:snippets:lintDebug— passes./gradlew spotlessApply— clean