Skip to content

Commit 2c91ab2

Browse files
committedDec 15, 2020
[Jetchat] Updates to 7033025
Change-Id: If9d947be516e81f6ccaa779fe57616887469f00e
1 parent 2cff653 commit 2c91ab2

File tree

7 files changed

+27
-28
lines changed

7 files changed

+27
-28
lines changed
 

‎Jetchat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import androidx.compose.ui.geometry.Offset
2323
import androidx.compose.ui.test.assertIsDisplayed
2424
import androidx.compose.ui.test.center
2525
import androidx.compose.ui.test.junit4.createAndroidComposeRule
26-
import androidx.compose.ui.test.onNodeWithLabel
26+
import androidx.compose.ui.test.onNodeWithContentDescription
2727
import androidx.compose.ui.test.onNodeWithTag
2828
import androidx.compose.ui.test.onNodeWithText
2929
import androidx.compose.ui.test.performClick
@@ -164,5 +164,5 @@ class ConversationTest {
164164
composeTestRule.onNodeWithText(activity.getString(R.string.jumpBottom))
165165

166166
private fun openEmojiSelector() =
167-
composeTestRule.onNodeWithLabel(activity.getString(R.string.emoji_selector_bt_desc)).performClick()
167+
composeTestRule.onNodeWithContentDescription(activity.getString(R.string.emoji_selector_bt_desc)).performClick()
168168
}

‎Jetchat/app/src/androidTest/java/com/example/compose/jetchat/UserInputTest.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import androidx.compose.ui.test.assertIsDisplayed
2424
import androidx.compose.ui.test.assertIsEnabled
2525
import androidx.compose.ui.test.assertIsNotEnabled
2626
import androidx.compose.ui.test.hasAnyAncestor
27-
import androidx.compose.ui.test.hasLabel
27+
import androidx.compose.ui.test.hasContentDescription
2828
import androidx.compose.ui.test.hasSetTextAction
2929
import androidx.compose.ui.test.junit4.createAndroidComposeRule
30-
import androidx.compose.ui.test.onNodeWithLabel
30+
import androidx.compose.ui.test.onNodeWithContentDescription
3131
import androidx.compose.ui.test.onNodeWithText
3232
import androidx.compose.ui.test.performClick
3333
import androidx.compose.ui.test.performTextInput
@@ -137,27 +137,27 @@ class UserInputTest {
137137
}
138138

139139
private fun clickOnTextField() =
140-
composeTestRule.onNodeWithLabel(activity.getString(R.string.textfield_desc))
140+
composeTestRule.onNodeWithContentDescription(activity.getString(R.string.textfield_desc))
141141
.performClick()
142142

143143
private fun openEmojiSelector() =
144-
composeTestRule.onNodeWithLabel(activity.getString(R.string.emoji_selector_bt_desc))
144+
composeTestRule.onNodeWithContentDescription(activity.getString(R.string.emoji_selector_bt_desc))
145145
.performClick()
146146

147147
private fun assertEmojiSelectorIsDisplayed() =
148-
composeTestRule.onNodeWithLabel(activity.getString(R.string.emoji_selector_desc))
148+
composeTestRule.onNodeWithContentDescription(activity.getString(R.string.emoji_selector_desc))
149149
.assertIsDisplayed()
150150

151151
private fun assertEmojiSelectorDoesNotExist() =
152-
composeTestRule.onNodeWithLabel(activity.getString(R.string.emoji_selector_desc))
152+
composeTestRule.onNodeWithContentDescription(activity.getString(R.string.emoji_selector_desc))
153153
.assertDoesNotExist()
154154

155155
private fun findSendButton() = composeTestRule.onNodeWithText(activity.getString(R.string.send))
156156

157157
private fun findTextInputField(): SemanticsNodeInteraction {
158158
return composeTestRule.onNode(
159159
hasSetTextAction() and
160-
hasAnyAncestor(hasLabel(activity.getString(R.string.textfield_desc)))
160+
hasAnyAncestor(hasContentDescription(activity.getString(R.string.textfield_desc)))
161161
)
162162
}
163163
}

‎Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/MessageFormatter.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.ui.text.AnnotatedString
2424
import androidx.compose.ui.text.SpanStyle
2525
import androidx.compose.ui.text.StringAnnotation
2626
import androidx.compose.ui.text.annotatedString
27+
import androidx.compose.ui.text.buildAnnotatedString
2728
import androidx.compose.ui.text.font.FontFamily
2829
import androidx.compose.ui.text.font.FontStyle
2930
import androidx.compose.ui.text.font.FontWeight
@@ -62,7 +63,7 @@ fun messageFormatter(
6263
): AnnotatedString {
6364
val tokens = symbolPattern.findAll(text)
6465

65-
return annotatedString {
66+
return buildAnnotatedString {
6667

6768
var cursorPosition = 0
6869

‎Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/UserInput.kt

+9-13
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import androidx.compose.material.AmbientContentAlpha
4444
import androidx.compose.material.AmbientContentColor
4545
import androidx.compose.material.AmbientTextStyle
4646
import androidx.compose.material.Button
47-
import androidx.compose.material.ButtonConstants
47+
import androidx.compose.material.ButtonDefaults
4848
import androidx.compose.material.ContentAlpha
4949
import androidx.compose.material.Divider
5050
import androidx.compose.material.Icon
@@ -70,18 +70,17 @@ import androidx.compose.runtime.setValue
7070
import androidx.compose.ui.Alignment
7171
import androidx.compose.ui.Modifier
7272
import androidx.compose.ui.focus
73-
import androidx.compose.ui.focus.ExperimentalFocus
7473
import androidx.compose.ui.focus.FocusRequester
7574
import androidx.compose.ui.focus.FocusState
76-
import androidx.compose.ui.focusObserver
75+
import androidx.compose.ui.focus.onFocusChanged
7776
import androidx.compose.ui.focusRequester
7877
import androidx.compose.ui.graphics.Color
7978
import androidx.compose.ui.graphics.vector.ImageVector
8079
import androidx.compose.ui.layout.FirstBaseline
8180
import androidx.compose.ui.res.stringResource
8281
import androidx.compose.ui.semantics.SemanticsPropertyKey
8382
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
84-
import androidx.compose.ui.semantics.accessibilityLabel
83+
import androidx.compose.ui.semantics.contentDescription
8584
import androidx.compose.ui.semantics.semantics
8685
import androidx.compose.ui.text.SoftwareKeyboardController
8786
import androidx.compose.ui.text.TextRange
@@ -188,7 +187,6 @@ private fun TextFieldValue.addText(newString: String): TextFieldValue {
188187
return this.copy(text = newText, selection = newSelection)
189188
}
190189

191-
@OptIn(ExperimentalFocus::class)
192190
@Composable
193191
private fun SelectorExpanded(
194192
currentSelector: InputSelector,
@@ -311,7 +309,7 @@ private fun UserInputSelector(
311309
val disabledContentColor =
312310
MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
313311

314-
val buttonColors = ButtonConstants.defaultButtonColors(
312+
val buttonColors = ButtonDefaults.buttonColors(
315313
disabledBackgroundColor = MaterialTheme.colors.surface,
316314
disabledContentColor = disabledContentColor
317315
)
@@ -345,7 +343,7 @@ private fun InputSelectorButton(
345343
) {
346344
IconButton(
347345
onClick = onClick,
348-
modifier = Modifier.semantics { accessibilityLabel = description }
346+
modifier = Modifier.semantics { contentDescription = description }
349347
) {
350348
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
351349
val tint = if (selected) MaterialTheme.colors.primary else AmbientContentColor.current
@@ -366,7 +364,6 @@ private fun NotAvailablePopup(onDismissed: () -> Unit) {
366364
val KeyboardShownKey = SemanticsPropertyKey<Boolean>("KeyboardShownKey")
367365
var SemanticsPropertyReceiver.keyboardShownProperty by KeyboardShownKey
368366

369-
@OptIn(ExperimentalFocus::class)
370367
@ExperimentalFoundationApi
371368
@Composable
372369
private fun UserInputText(
@@ -393,7 +390,7 @@ private fun UserInputText(
393390
.fillMaxWidth()
394391
.preferredHeight(48.dp)
395392
.semantics {
396-
accessibilityLabel = a11ylabel
393+
contentDescription = a11ylabel
397394
keyboardShownProperty = keyboardShown
398395
},
399396
horizontalArrangement = Arrangement.End
@@ -410,7 +407,7 @@ private fun UserInputText(
410407
.fillMaxWidth()
411408
.padding(start = 16.dp)
412409
.align(Alignment.CenterStart)
413-
.focusObserver { state ->
410+
.onFocusChanged { state ->
414411
if (lastFocusState != state) {
415412
onTextFieldFocused(state == FocusState.Active)
416413
}
@@ -442,7 +439,6 @@ private fun UserInputText(
442439
}
443440
}
444441

445-
@OptIn(ExperimentalFocus::class)
446442
@Composable
447443
fun EmojiSelector(
448444
onTextAdded: (String) -> Unit,
@@ -455,7 +451,7 @@ fun EmojiSelector(
455451
modifier = Modifier
456452
.focusRequester(focusRequester) // Requests focus when the Emoji selector is displayed
457453
.focus() // Make the emoji selector focusable so it can steal focus from TextField
458-
.semantics { accessibilityLabel = a11yLabel }
454+
.semantics { contentDescription = a11yLabel }
459455
) {
460456
Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
461457
ExtendedSelectorInnerButton(
@@ -487,7 +483,7 @@ fun ExtendedSelectorInnerButton(
487483
selected: Boolean,
488484
modifier: Modifier = Modifier
489485
) {
490-
val colors = ButtonConstants.defaultButtonColors(
486+
val colors = ButtonDefaults.buttonColors(
491487
backgroundColor = MaterialTheme.colors.onSurface.copy(alpha = 0.08f),
492488
disabledBackgroundColor = getSelectorExpandedColor(), // Same as background
493489
contentColor = MaterialTheme.colors.onSurface,

‎Jetchat/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ subprojects {
4343

4444
if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
4545
maven { url Urls.composeSnapshotRepo }
46+
maven { url Urls.accompanistSnapshotRepo }
4647
}
4748
}
4849

‎Jetchat/buildSrc/src/main/java/com/example/compose/jetchat/buildsrc/dependencies.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object Libs {
2929
const val material = "com.google.android.material:material:1.1.0"
3030

3131
object Kotlin {
32-
private const val version = "1.4.20"
32+
private const val version = "1.4.21"
3333
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
3434
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
3535
const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version"
@@ -43,7 +43,7 @@ object Libs {
4343
}
4444

4545
object Accompanist {
46-
private const val version = "0.4.0"
46+
private const val version = "0.4.1.compose-7033025-SNAPSHOT"
4747
const val insets = "dev.chrisbanes.accompanist:accompanist-insets:$version"
4848
}
4949

@@ -52,8 +52,8 @@ object Libs {
5252
const val coreKtx = "androidx.core:core-ktx:1.5.0-alpha04"
5353

5454
object Compose {
55-
const val snapshot = ""
56-
const val version = "1.0.0-alpha08"
55+
const val snapshot = "7033025"
56+
const val version = "1.0.0-SNAPSHOT"
5757

5858
const val foundation = "androidx.compose.foundation:foundation:$version"
5959
const val layout = "androidx.compose.foundation:foundation-layout:$version"
@@ -99,4 +99,5 @@ object Libs {
9999
object Urls {
100100
const val composeSnapshotRepo = "https://androidx.dev/snapshots/builds/" +
101101
"${Libs.AndroidX.Compose.snapshot}/artifacts/repository/"
102+
const val accompanistSnapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots"
102103
}

‎Jetchat/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME
1919
distributionPath=wrapper/dists
2020
zipStoreBase=GRADLE_USER_HOME
2121
zipStorePath=wrapper/dists
22-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
22+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-rc-1-bin.zip

0 commit comments

Comments
 (0)
Please sign in to comment.