Skip to content
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

[Insets] Deprecate IME nested scroll connection #1141

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/insets.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you are using insets for IME support, you also still need to ensure that the
1. Replace padding modifiers with `androidx.compose.foundation` equivalents. If using `additionalPadding` or only applying the insets to certain sides, use the corresponding [`WindowInsets.add`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets).add(androidx.compose.foundation.layout.WindowInsets)) and [`WindowInsets.only`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets).only(androidx.compose.foundation.layout.WindowInsetsSides)) extensions.
1. Replace `rememberInsetsPaddingValues` with the equivalent `WindowInsets.asPaddingValues`.
1. Replace direct calculations from `LocalWindowInsets.current` with calculations on `WindowInsets`.
1. Continue using the non-deprecated [`insets-ui`](#inset-aware-layouts-insets-ui) and experimental [`rememberImeNestedScrollConnection()`](#controlling-the-ime-on-screen-keyboard) for now.
1. Continue using the non-deprecated [`insets-ui`](#inset-aware-layouts-insets-ui) for now.

For reference, consult the [Migration table](#migration-table) below.

Expand Down Expand Up @@ -87,12 +87,12 @@ As a result, the equivalent of `Modifier.navigationBarsWithImePadding()` is simp
| `LocalWindowInsets.current.systemBars` | [`WindowInsets.systemBars`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).systemBars()) |
| `LocalWindowInsets.current.displayCutout` | [`WindowInsets.displayCutout`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).displayCutout()) |
| `LocalWindowInsets.current.ime.bottom` | [`WindowInsets.ime.getBottom(LocalDensity.current)`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets#getBottom(androidx.compose.ui.unit.Density)) |
| `WindowInsets.Type.isVisible` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.animationInProgress` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.animationFraction` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.layoutInsets` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.animatedInsets` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `rememberImeNestedScrollConnection()` | [Bug: 217770710](https://issuetracker.google.com/issues/217770710) |
| `WindowInsets.Type.isVisible` | [`WindowInsets.isImeVisible`](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).isImeVisible()), etc. |
| `WindowInsets.Type.animationInProgress` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.animationFraction` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.layoutInsets` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `WindowInsets.Type.animatedInsets` | [Bug: 217770337](https://issuetracker.google.com/issues/217770337) |
| `rememberImeNestedScrollConnection()` | [`Modifier.imeNestedScroll()`](https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier#(androidx.compose.ui.Modifier).imeNestedScroll()) |

## Original docs

Expand Down
12 changes: 6 additions & 6 deletions insets/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ package com.google.accompanist.insets {
enum_constant @Deprecated public static final com.google.accompanist.insets.HorizontalSide Right;
}

@com.google.accompanist.insets.ExperimentalAnimatedInsets public final class ImeNestedScrollConnection implements androidx.compose.ui.input.nestedscroll.NestedScrollConnection {
ctor public ImeNestedScrollConnection(android.view.View view, boolean scrollImeOffScreenWhenVisible, boolean scrollImeOnScreenWhenNotVisible);
method public suspend Object? onPostFling(long consumed, long available, kotlin.coroutines.Continuation<? super androidx.compose.ui.unit.Velocity> p);
method public long onPostScroll(long consumed, long available, int source);
method public long onPreScroll(long available, int source);
@Deprecated @com.google.accompanist.insets.ExperimentalAnimatedInsets public final class ImeNestedScrollConnection implements androidx.compose.ui.input.nestedscroll.NestedScrollConnection {
ctor @Deprecated public ImeNestedScrollConnection(android.view.View view, boolean scrollImeOffScreenWhenVisible, boolean scrollImeOnScreenWhenNotVisible);
method @Deprecated public suspend Object? onPostFling(long consumed, long available, kotlin.coroutines.Continuation<? super androidx.compose.ui.unit.Velocity> p);
method @Deprecated public long onPostScroll(long consumed, long available, int source);
method @Deprecated public long onPreScroll(long available, int source);
}

public final class ImeNestedScrollConnectionKt {
method @androidx.compose.runtime.Composable @com.google.accompanist.insets.ExperimentalAnimatedInsets public static androidx.compose.ui.input.nestedscroll.NestedScrollConnection rememberImeNestedScrollConnection(optional boolean scrollImeOffScreenWhenVisible, optional boolean scrollImeOnScreenWhenNotVisible);
method @Deprecated @androidx.compose.runtime.Composable @com.google.accompanist.insets.ExperimentalAnimatedInsets public static androidx.compose.ui.input.nestedscroll.NestedScrollConnection rememberImeNestedScrollConnection(optional boolean scrollImeOffScreenWhenVisible, optional boolean scrollImeOnScreenWhenNotVisible);
}

@Deprecated @androidx.compose.runtime.Stable public interface Insets {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 The Android Open Source Project
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

package com.google.accompanist.insets

import android.os.Build
Expand Down Expand Up @@ -44,6 +46,17 @@ import kotlin.math.roundToInt
*/
@ExperimentalAnimatedInsets
@Composable
@Deprecated(
"""
accompanist/insets is deprecated.
For more migration information, please visit https://google.github.io/accompanist/insets/#migration
""",
replaceWith = ReplaceWith(
"Modifier.imeNestedScroll()",
"androidx.compose.foundation.layout.imeNestedScroll",
"androidx.compose.ui.Modifier"
)
)
fun rememberImeNestedScrollConnection(
scrollImeOffScreenWhenVisible: Boolean = true,
scrollImeOnScreenWhenNotVisible: Boolean = true,
Expand Down Expand Up @@ -73,6 +86,17 @@ fun rememberImeNestedScrollConnection(
* (from not being visible), by an upwards scroll. Defaults to `true`.
*/
@ExperimentalAnimatedInsets
@Deprecated(
"""
accompanist/insets is deprecated.
For more migration information, please visit https://google.github.io/accompanist/insets/#migration
""",
replaceWith = ReplaceWith(
"Modifier.imeNestedScroll()",
"androidx.compose.foundation.layout.imeNestedScroll",
"androidx.compose.ui.Modifier"
)
)
class ImeNestedScrollConnection(
private val view: View,
private val scrollImeOffScreenWhenVisible: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import com.google.accompanist.sample.R
import com.google.accompanist.sample.randomSampleImageUrl
import com.google.accompanist.systemuicontroller.rememberSystemUiController

@OptIn(ExperimentalAnimatedInsets::class)
class ImeAnimationSample : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down