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

Restore commonMain to AOSP state (small fixes) #1756

Draft
wants to merge 1 commit into
base: jb-main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ public class KeyframesSpec<T>(public val config: KeyframesSpecConfig<T>) :
if (!config.keyframes.contains(config.durationMillis)) {
timestamps.add(config.durationMillis)
}

timestamps.sort()

return VectorizedKeyframesSpec(
Expand Down Expand Up @@ -772,7 +771,6 @@ public class KeyframesWithSplineSpec<T>(
if (!keyframes.contains(config.durationMillis)) {
timestamps.add(config.durationMillis)
}

timestamps.sort()
return VectorizedMonoSplineKeyframesSpec(
timestamps = timestamps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package androidx.compose.animation.core

import androidx.compose.animation.core.internal.binarySearch
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.IntervalTree
import androidx.compose.ui.graphics.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ internal constructor(
if (!keyframes.containsKey(durationMillis)) {
times.add(durationMillis)
}

times.sort()
return@run times
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Android Open Source Project
* Copyright 2024 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,6 @@
* limitations under the License.
*/

package androidx.compose.animation.core.internal;
package androidx.compose.animation.core.internal

internal expect annotation class JvmDefaultWithCompatibility()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ import androidx.compose.ui.platform.InspectorInfo
fun Modifier.dragAndDropTarget(
shouldStartDragAndDrop: (startEvent: DragAndDropEvent) -> Boolean,
target: DragAndDropTarget,
): Modifier {
return this then DropTargetElement(
target = target,
shouldStartDragAndDrop = shouldStartDragAndDrop,
)
}
): Modifier =
this then
DropTargetElement(
target = target,
shouldStartDragAndDrop = shouldStartDragAndDrop,
)

private class DropTargetElement(
val shouldStartDragAndDrop: (event: DragAndDropEvent) -> Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 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 Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2020 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 Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@
package androidx.compose.foundation.pager

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.snapping.calculateDistanceToDesiredSnapPosition
import androidx.compose.foundation.lazy.layout.LazyLayoutNearestRangeState
import androidx.compose.foundation.lazy.layout.findIndexByKey
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.setValue
import kotlin.math.roundToLong
import androidx.compose.ui.unit.Density
import androidx.compose.ui.util.fastMaxBy
import kotlin.math.absoluteValue
import kotlin.math.roundToInt

/**
* Contains the current scroll position represented by the first visible page and the first visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import androidx.compose.foundation.text.input.internal.TextFieldDecoratorModifie
import androidx.compose.foundation.text.input.internal.TextFieldTextLayoutModifier
import androidx.compose.foundation.text.input.internal.TextLayoutState
import androidx.compose.foundation.text.input.internal.TransformedTextFieldState
import androidx.compose.foundation.text.input.internal.selection.TextFieldHandleState
import androidx.compose.foundation.text.input.internal.selection.TextFieldSelectionState
import androidx.compose.foundation.text.input.internal.selection.TextFieldSelectionState.InputType
import androidx.compose.foundation.text.selection.SelectionHandle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,53 +66,55 @@ internal fun Modifier.textFieldScrollable(
interactionSource: MutableInteractionSource? = null,
enabled: Boolean = true,
overscrollEffect: OverscrollEffect? = null
) = composed(
inspectorInfo =
debugInspectorInfo {
name = "textFieldScrollable"
properties["scrollerPosition"] = scrollerPosition
properties["interactionSource"] = interactionSource
properties["enabled"] = enabled
}
) {
// do not reverse direction only in case of RTL in horizontal orientation
val rtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val reverseDirection = scrollerPosition.orientation == Orientation.Vertical || !rtl
val scrollableState = rememberScrollableState { delta ->
val newOffset = scrollerPosition.offset + delta
val consumedDelta =
when {
newOffset > scrollerPosition.maximum ->
scrollerPosition.maximum - scrollerPosition.offset
newOffset < 0f -> -scrollerPosition.offset
else -> delta
) =
composed(
inspectorInfo =
debugInspectorInfo {
name = "textFieldScrollable"
properties["scrollerPosition"] = scrollerPosition
properties["interactionSource"] = interactionSource
properties["enabled"] = enabled
}
scrollerPosition.offset += consumedDelta
consumedDelta
}
// TODO: b/255557085 remove when / if rememberScrollableState exposes lambda parameters for
// setting these
val wrappedScrollableState =
remember(scrollableState, scrollerPosition) {
object : ScrollableState by scrollableState {
override val canScrollForward by derivedStateOf {
scrollerPosition.offset < scrollerPosition.maximum
) {
// do not reverse direction only in case of RTL in horizontal orientation
val rtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val reverseDirection = scrollerPosition.orientation == Orientation.Vertical || !rtl
val scrollableState = rememberScrollableState { delta ->
val newOffset = scrollerPosition.offset + delta
val consumedDelta =
when {
newOffset > scrollerPosition.maximum ->
scrollerPosition.maximum - scrollerPosition.offset
newOffset < 0f -> -scrollerPosition.offset
else -> delta
}
override val canScrollBackward by derivedStateOf {
scrollerPosition.offset > 0f
scrollerPosition.offset += consumedDelta
consumedDelta
}
// TODO: b/255557085 remove when / if rememberScrollableState exposes lambda parameters for
// setting these
val wrappedScrollableState =
remember(scrollableState, scrollerPosition) {
object : ScrollableState by scrollableState {
override val canScrollForward by derivedStateOf {
scrollerPosition.offset < scrollerPosition.maximum
}
override val canScrollBackward by derivedStateOf {
scrollerPosition.offset > 0f
}
}
}
}
val scroll = Modifier.scrollable(
orientation = scrollerPosition.orientation,
reverseDirection = reverseDirection,
overscrollEffect = overscrollEffect,
state = wrappedScrollableState,
interactionSource = interactionSource,
enabled = enabled && scrollerPosition.maximum != 0f
)
scroll
}
val scroll =
Modifier.scrollable(
orientation = scrollerPosition.orientation,
reverseDirection = reverseDirection,
overscrollEffect = overscrollEffect,
state = wrappedScrollableState,
interactionSource = interactionSource,
enabled = enabled && scrollerPosition.maximum != 0f
)
scroll
}

// Layout
// Expect/actual is needed due to a different implementation in uikit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ package androidx.compose.foundation.text

import androidx.compose.ui.input.pointer.PointerIcon

// TODO Replace to PointerIcon.Text. No need for expect/actual
internal expect val textPointerIcon: PointerIcon

// TODO Add appropriate property to PointerIcon interface instead of bypassing abstraction layer.
// https://youtrack.jetbrains.com/issue/CMP-7145/Properly-adopt-stylus-handwriting-hover-icon
internal expect val handwritingPointerIcon: PointerIcon
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.text.substring
import androidx.compose.ui.text.toUpperCase
import kotlin.jvm.JvmName

/**
* A function that is ran after every change made to a [TextFieldState] by user input and can change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ internal expect fun CharSequence.codePointAt(index: Int): Int

internal expect fun charCount(codePoint: Int): Int

// TODO: It's not used from common, consider to remove
internal expect fun CharSequence.codePointBefore(index: Int): Int
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ internal class CursorAnimationState(val animate: Boolean) {
val job = animationJob.getAndSet(null)
job?.cancel()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2020 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 Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2020 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 Down Expand Up @@ -63,8 +63,8 @@ import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import kotlin.math.abs
import kotlin.jvm.JvmName
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlinx.coroutines.launch
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ internal value class Strings private constructor(@Suppress("unused") private val
val SliderRangeStart = Strings(5)
val SliderRangeEnd = Strings(6)
val SnackbarPaneTitle = Strings(7)
// When adding values here, make sure to also add them in material/build.gradle,
// updateTranslations task (stringByResourceName parameter), and re-run the task
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2021 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 Down

This file was deleted.

This file was deleted.

Loading
Loading