forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move getAllUncoveredSemanticsNodesToIntObjectMap to common
Move the semantic tree traversal function, including helper utils, to common code. Introduce SemanticRegion as a wrapper around the platform's Region class. Test: AndroidComposeViewAccessibilityDelegateCompatTest, ScrollCaptureTest Change-Id: Ibb25e7eac48ed0b61a9318b004669f0d7d0c8b97
- Loading branch information
Showing
9 changed files
with
284 additions
and
141 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
47 changes: 47 additions & 0 deletions
47
...ose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/semantics/SemanticsRegion.android.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package androidx.compose.ui.semantics | ||
|
||
import android.graphics.Region | ||
import androidx.compose.ui.graphics.toComposeIntRect | ||
import androidx.compose.ui.unit.IntRect | ||
|
||
/** Wrapper around platform-specific [android.graphics.Region] class */ | ||
private class SemanticRegionImpl : SemanticsRegion { | ||
val region = Region() | ||
|
||
override fun set(rect: IntRect) { | ||
region.set(rect.left, rect.top, rect.right, rect.bottom) | ||
} | ||
|
||
override val bounds: IntRect | ||
get() = region.bounds.toComposeIntRect() | ||
|
||
override val isEmpty: Boolean | ||
get() = region.isEmpty | ||
|
||
override fun intersect(region: SemanticsRegion): Boolean { | ||
return this.region.op((region as SemanticRegionImpl).region, Region.Op.INTERSECT) | ||
} | ||
|
||
override fun difference(rect: IntRect): Boolean { | ||
return region.op(rect.left, rect.top, rect.right, rect.bottom, Region.Op.DIFFERENCE) | ||
} | ||
} | ||
|
||
/** Builder that creates wrapper around platform-specific Region class */ | ||
internal actual fun SemanticsRegion(): SemanticsRegion = SemanticRegionImpl() |
Oops, something went wrong.