Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
java-version: "17"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Test, lint and build debug APK
- name: Test, lint and build debug APKs
working-directory: android
run: ./gradlew testDebugUnitTest lintDebug assembleDebug --stacktrace
run: ./gradlew testDebugUnitTest lintDebug assembleDebug assembleDebugAndroidTest --stacktrace
- name: Upload debug APK
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Test, lint and build signed artifacts
working-directory: android
run: >-
./gradlew testDebugUnitTest lintRelease assembleRelease bundleRelease
./gradlew testDebugUnitTest assembleDebugAndroidTest lintRelease assembleRelease bundleRelease
-PedgechatVersionName=${{ steps.version.outputs.version }}
-PedgechatVersionCode=${{ github.run_number }}
--stacktrace
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ frontend/demo-dist/

# Android local/build outputs
android/.gradle/
android/.kotlin/
android/**/build/
android/local.properties
android/signing.properties
Expand Down
22 changes: 22 additions & 0 deletions android/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Third-party notice

The Android conversation UI incorporates interaction and layout patterns adapted from
[Jetchat](https://github.com/android/compose-samples/tree/main/Jetchat), part of the
Android Compose Samples project.

Copyright 2020 The Android Open Source Project.

Jetchat is licensed under the Apache License, Version 2.0. EdgeChat's implementation
has been substantially modified for its own data model, navigation, offline queue,
attachments, localization and adaptive layouts.

Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0

## Design reference

The 2026 Android interface refresh studied the public user interface and design
language of [Element X Android](https://github.com/element-hq/element-x-android).
EdgeChat's Compose implementation is original and does not incorporate Element X
source code, icons, trademarks or other brand assets. Element X Android is offered
under AGPL-3.0-only or Element's commercial license; those licenses do not apply to
the independently implemented EdgeChat interface.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ package com.aozorae.edgechat.feature.auth

import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.junit4.StateRestorationTester
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performTextInput
import org.junit.Rule
import org.junit.Test

Expand All @@ -18,4 +22,17 @@ class ServerSetupScreenTest {
compose.onNodeWithText("Server address").assertIsDisplayed()
compose.onNodeWithText("Verify and continue").assertIsNotEnabled()
}

@Test
fun serverAddressSurvivesStateRestoration() {
val restoration = StateRestorationTester(compose)
restoration.setContent {
ServerSetupScreen(false, null, "en-US", {})
}

compose.onNode(hasSetTextAction()).performTextInput("https://chat.example.com")
restoration.emulateSavedInstanceStateRestore()

compose.onNode(hasSetTextAction()).assertTextContains("https://chat.example.com")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.aozorae.edgechat.feature.auth

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test

class WelcomeScreenTest {
@get:Rule val compose = createComposeRule()

@Test
fun connectServerOpensSetupFlow() {
var continued = false
compose.setContent {
WelcomeScreen(language = "en-US", onContinue = { continued = true })
}

compose.onNodeWithText("EdgeChat").assertIsDisplayed()
compose.onNodeWithText("Connect server").assertIsDisplayed().performClick()
assertTrue(continued)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.aozorae.edgechat.feature.chat

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.dp
import com.aozorae.edgechat.core.database.MessageEntity
import com.aozorae.edgechat.core.database.OutboxEntity
import com.aozorae.edgechat.core.network.dto.SessionDto
import com.aozorae.edgechat.ui.theme.EdgeChatTheme
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test

class ChatMessagesLayoutTest {
@get:Rule val compose = createComposeRule()

@Test
fun ownAndIncomingMessagesUseOppositeSides() {
compose.setContent {
EdgeChatTheme {
Box(Modifier.width(360.dp).height(640.dp)) {
ChatMessages(
messages = listOf(
message(id = 1, senderId = "2", content = "Incoming"),
message(id = 2, senderId = "1", content = "Mine"),
),
outbox = listOf(pendingMessage()),
currentUser = currentUser(),
serverBaseUrl = "https://example.com",
language = "en-US",
scrollState = rememberLazyListState(),
onLoadOlder = {},
onRetry = {},
onCancel = {},
onDeleteMessage = {},
onOpenAttachment = { _, _, _ -> },
)
}
}
}

val listCenter = compose.onNodeWithTag("message_list").fetchSemanticsNode().boundsInRoot.center.x
val incomingCenter = compose.onNodeWithTag("message_bubble:1").fetchSemanticsNode().boundsInRoot.center.x
val ownCenter = compose.onNodeWithTag("message_bubble:2").fetchSemanticsNode().boundsInRoot.center.x
val pendingCenter = compose
.onNodeWithTag("pending_message_bubble:pending-1")
.fetchSemanticsNode()
.boundsInRoot
.center
.x

assertTrue(incomingCenter < listCenter)
assertTrue(ownCenter > listCenter)
assertTrue(pendingCenter > listCenter)
}

private fun currentUser() = SessionDto(
userId = 1,
username = "me",
displayName = "Me",
)

private fun message(id: Long, senderId: String, content: String) = MessageEntity(
id = id,
roomKind = "public",
roomId = 1,
clientMessageId = null,
content = content,
createdAt = "2026-08-30T10:0${id}:00Z",
source = "edgechat",
senderKind = "local",
senderId = senderId,
senderUsername = "user$senderId",
senderDisplayName = "User $senderId",
senderAvatarUrl = "",
attachmentKey = null,
attachmentName = null,
attachmentType = null,
attachmentSize = null,
attachmentUrl = null,
)

private fun pendingMessage() = OutboxEntity(
clientMessageId = "pending-1",
roomKind = "public",
roomId = 1,
content = "Pending",
localAttachmentPath = null,
attachmentName = null,
attachmentType = null,
attachmentSize = null,
clientUploadId = null,
uploadedKey = null,
uploadedUrl = null,
state = "SENDING",
failure = null,
attempts = 0,
createdAt = 0,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.aozorae.edgechat.feature.chat

import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.semantics.SemanticsProperties
import com.aozorae.edgechat.ui.theme.EdgeChatTheme
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test

class MessageComposerTest {
@get:Rule val compose = createComposeRule()

@Test
fun sendEnablesForTextAndClearsAfterSending() {
var sent = ""
compose.setContent {
EdgeChatTheme {
MessageComposer(
roomKey = "public:1",
roomTitle = "general",
attachment = null,
language = "en-US",
onChooseAttachment = {},
onClearAttachment = {},
onSend = { sent = it },
)
}
}

compose.onNodeWithTag("send_message").assertIsNotEnabled()
compose.onNodeWithTag("message_input").performTextInput("Hello")
compose.onNodeWithTag("send_message").assertIsEnabled().performClick()
val editableText = compose
.onNodeWithTag("message_input")
.fetchSemanticsNode()
.config[SemanticsProperties.EditableText]
.text
assertEquals("", editableText)
assertEquals("Hello", sent)
}

@Test
fun inputGrowsForMultipleLines() {
compose.setContent {
EdgeChatTheme {
MessageComposer(
roomKey = "public:1",
roomTitle = "general",
attachment = null,
language = "en-US",
onChooseAttachment = {},
onClearAttachment = {},
onSend = {},
)
}
}

val input = compose.onNodeWithTag("message_input")
val initialHeight = input.fetchSemanticsNode().boundsInRoot.height
input.performTextInput("One\nTwo\nThree\nFour")
compose.waitForIdle()

assertTrue(input.fetchSemanticsNode().boundsInRoot.height > initialHeight)
}
}
8 changes: 7 additions & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
xmlns:tools="http://schemas.android.com/tools">
<application
android:usesCleartextTraffic="true"
tools:replace="android:usesCleartextTraffic" />
tools:replace="android:usesCleartextTraffic">
<!-- Compose instrumentation 使用该通用 Activity;允许它越过锁屏,避免测试语义树随宿主暂停而消失。 -->
<activity
android:name="androidx.activity.ComponentActivity"
android:showWhenLocked="true"
android:turnScreenOn="true" />
</application>
</manifest>
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Loading
Loading