Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions Jetchat/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ android {
kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
}

packagingOptions {
exclude "META-INF/licenses/**"
exclude "META-INF/AL2.0"
exclude "META-INF/LGPL2.1"
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import androidx.activity.ComponentActivity
import androidx.compose.runtime.Providers
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.center
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithLabel
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.swipe
import androidx.compose.ui.unit.milliseconds
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.center
import androidx.ui.test.createAndroidComposeRule
import androidx.ui.test.onNodeWithLabel
import androidx.ui.test.onNodeWithTag
import androidx.ui.test.onNodeWithText
import androidx.ui.test.performClick
import androidx.ui.test.performGesture
import androidx.ui.test.swipe
import com.example.compose.jetchat.conversation.BackPressedDispatcherAmbient
import com.example.compose.jetchat.conversation.ConversationContent
import com.example.compose.jetchat.conversation.ConversationTestTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package com.example.compose.jetchat
import android.view.View
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Providers
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.test.espresso.Espresso
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.createAndroidComposeRule
import androidx.ui.test.onNodeWithText
import com.example.compose.jetchat.conversation.BackPressedDispatcherAmbient
import com.example.compose.jetchat.conversation.ConversationContent
import com.example.compose.jetchat.data.exampleUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ package com.example.compose.jetchat

import androidx.activity.ComponentActivity
import androidx.compose.runtime.Providers
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasInputMethodsSupport
import androidx.compose.ui.test.hasLabel
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithLabel
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.test.espresso.Espresso
import androidx.ui.test.SemanticsMatcher
import androidx.ui.test.SemanticsNodeInteraction
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.assertIsEnabled
import androidx.ui.test.assertIsNotEnabled
import androidx.ui.test.createAndroidComposeRule
import androidx.ui.test.hasAnyAncestor
import androidx.ui.test.hasInputMethodsSupport
import androidx.ui.test.hasLabel
import androidx.ui.test.onNodeWithLabel
import androidx.ui.test.onNodeWithText
import androidx.ui.test.performClick
import androidx.ui.test.performTextInput
import com.example.compose.jetchat.conversation.BackPressedDispatcherAmbient
import com.example.compose.jetchat.conversation.ConversationContent
import com.example.compose.jetchat.conversation.KeyboardShownKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

package com.example.compose.jetchat

import androidx.ui.test.ComposeTestRule
import androidx.ui.test.onRoot
import androidx.ui.test.printToLog
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.printToLog

/**
* Used to debug the semantic tree.
*
* TODO: Replace with aosp/1355659
*/
fun ComposeTestRule.dumpSemanticNodes() {
this.onRoot().printToLog(tag = "JetchatLog")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.example.compose.jetchat

import androidx.compose.foundation.Text
import androidx.compose.material.AlertDialog
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import androidx.compose.animation.transition
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawOpacity
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.util.lerp
import kotlin.math.roundToInt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package com.example.compose.jetchat.components

import androidx.compose.foundation.text.FirstBaseline
import androidx.compose.foundation.text.LastBaseline
import androidx.compose.ui.LayoutModifier
import androidx.compose.ui.Measurable
import androidx.compose.ui.MeasureScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.FirstBaseline
import androidx.compose.ui.layout.LastBaseline
import androidx.compose.ui.layout.LayoutModifier
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
import androidx.compose.ui.layout.MeasureScope
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp

Expand All @@ -45,7 +46,7 @@ data class BaselineHeightModifier(
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
): MeasureScope.MeasureResult {
): MeasureResult {

val textPlaceable = measurable.measure(constraints)
val firstBaseline = textPlaceable[FirstBaseline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package com.example.compose.jetchat.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.foundation.ClickableText
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.ScrollableColumn
import androidx.compose.foundation.Text
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand All @@ -32,29 +31,32 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.paddingFrom
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.relativePaddingFrom
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.LastBaseline
import androidx.compose.material.AmbientEmphasisLevels
import androidx.compose.material.AmbientContentAlpha
import androidx.compose.material.AmbientContentColor
import androidx.compose.material.ContentAlpha
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ProvideEmphasis
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Search
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.LastBaseline
import androidx.compose.ui.platform.DensityAmbient
import androidx.compose.ui.platform.UriHandlerAmbient
import androidx.compose.ui.platform.testTag
Expand Down Expand Up @@ -137,8 +139,7 @@ fun ChannelNameBar(
style = MaterialTheme.typography.subtitle1
)
// Number of members
// TODO: Multiple emphasis layers - https://issuetracker.google.com/159017896
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) {
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(R.string.members, channelMembers),
style = MaterialTheme.typography.caption,
Expand All @@ -148,7 +149,7 @@ fun ChannelNameBar(
}
},
actions = {
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) {
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
// Search icon
Icon(
asset = Icons.Outlined.Search,
Expand Down Expand Up @@ -311,17 +312,15 @@ fun AuthorAndTextMessage(
private fun AuthorNameTimestamp(msg: Message) {
// Combine author and timestamp for a11y.
Row(modifier = Modifier.semantics(mergeAllDescendants = true) {}) {
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.high) {
Text(
text = msg.author,
style = MaterialTheme.typography.subtitle1,
modifier = Modifier
.alignBy(LastBaseline)
.relativePaddingFrom(LastBaseline, after = 8.dp) // Space to 1st bubble
)
}
Text(
text = msg.author,
style = MaterialTheme.typography.subtitle1,
modifier = Modifier
.alignBy(LastBaseline)
.paddingFrom(LastBaseline, after = 8.dp) // Space to 1st bubble
)
Spacer(modifier = Modifier.preferredWidth(8.dp))
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) {
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Text(
text = msg.timestamp,
style = MaterialTheme.typography.caption,
Expand All @@ -338,7 +337,7 @@ private val LastChatBubbleShape = RoundedCornerShape(0.dp, 8.dp, 8.dp, 8.dp)
fun DayHeader(dayString: String) {
Row(modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp).preferredHeight(16.dp)) {
DayHeaderLine()
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) {
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Text(
text = dayString,
modifier = Modifier.padding(horizontal = 16.dp),
Expand Down Expand Up @@ -373,11 +372,9 @@ fun ChatItemBubble(
val bubbleShape = if (lastMessageByAuthor) LastChatBubbleShape else ChatBubbleShape
Column {
Surface(color = backgroundBubbleColor, shape = bubbleShape) {
ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.high) {
ClickableMessage(
message = message
)
}
ClickableMessage(
message = message
)
}

message.image?.let {
Expand All @@ -401,7 +398,7 @@ fun ClickableMessage(message: Message) {

ClickableText(
text = styledMessage,
style = MaterialTheme.typography.body1,
style = MaterialTheme.typography.body1.copy(color = AmbientContentColor.current),
modifier = Modifier.padding(8.dp),
onClick = {
styledMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package com.example.compose.jetchat.conversation
import androidx.compose.animation.DpPropKey
import androidx.compose.animation.core.transitionDefinition
import androidx.compose.animation.transition
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.material.ExtendedFloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.runtime.Composable
Expand Down
Loading