Skip to content

Commit 5936bd7

Browse files
committed
xml app
1 parent df402b8 commit 5936bd7

17 files changed

Lines changed: 566 additions & 37 deletions

File tree

e2e/android/app/build.gradle.kts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ android {
5252
)
5353
}
5454
}
55+
flavorDimensions += "uiFramework"
56+
productFlavors {
57+
create("compose") {
58+
dimension = "uiFramework"
59+
}
60+
create("noCompose") {
61+
dimension = "uiFramework"
62+
applicationIdSuffix = ".nocompose"
63+
}
64+
}
5565
compileOptions {
5666
sourceCompatibility = JavaVersion.VERSION_11
5767
targetCompatibility = JavaVersion.VERSION_11
@@ -103,29 +113,34 @@ dependencies {
103113
implementation("androidx.recyclerview:recyclerview:1.3.2")
104114
implementation(libs.androidx.core.ktx)
105115
implementation(libs.androidx.lifecycle.runtime.ktx)
106-
implementation(libs.androidx.activity.compose)
116+
117+
// Compose runtime is needed by the Kotlin Compose compiler plugin (applied project-wide).
118+
// It does NOT contain any UI classes like AbstractComposeView, so the SDK's
119+
// isComposeAvailable runtime check still returns false in the noCompose variant.
107120
implementation(platform(libs.androidx.compose.bom))
108-
implementation(libs.androidx.ui)
109-
implementation(libs.androidx.ui.graphics)
110-
implementation(libs.androidx.ui.tooling.preview)
111-
implementation(libs.androidx.material3)
121+
implementation("androidx.compose.runtime:runtime")
122+
123+
// Compose UI dependencies -- only for the compose flavor
124+
"composeImplementation"(libs.androidx.activity.compose)
125+
"composeImplementation"(libs.androidx.ui)
126+
"composeImplementation"(libs.androidx.ui.graphics)
127+
"composeImplementation"(libs.androidx.ui.tooling.preview)
128+
"composeImplementation"(libs.androidx.material3)
129+
130+
// noCompose uses AppCompatActivity for proper Material Components theme resolution
131+
"noComposeImplementation"("androidx.appcompat:appcompat:1.7.0")
112132

113133
testImplementation(libs.junit)
114-
testImplementation(libs.androidx.ui.test.junit4)
115134
testImplementation(libs.core.ktx)
116135
testImplementation(libs.robolectric)
117136
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
118137
testImplementation("io.opentelemetry:opentelemetry-sdk-testing:1.51.0")
138+
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2")
119139
testImplementation(testFixtures(project(":observability-android")))
120140

121141
// Used for testing webviews masking
122142
implementation("org.mozilla.geckoview:geckoview:130.0.20240913135723")
123143

124144
androidTestImplementation(libs.androidx.junit)
125145
androidTestImplementation(libs.androidx.espresso.core)
126-
androidTestImplementation(platform(libs.androidx.compose.bom))
127-
androidTestImplementation(libs.androidx.ui.test.junit4)
128-
129-
debugImplementation(libs.androidx.ui.tooling)
130-
debugImplementation(libs.androidx.ui.test.manifest)
131146
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application>
5+
<activity
6+
android:name=".masking.ComposeUserFormActivity"
7+
android:exported="false"
8+
android:label="@string/title_activity_secondary"
9+
android:theme="@style/Theme.AndroidObservability" />
10+
<activity
11+
android:name=".masking.ComposeMaskingActivity"
12+
android:exported="false"
13+
android:label="Compose Masking"
14+
android:theme="@style/Theme.AndroidObservability" />
15+
<activity
16+
android:name=".masking.ComposeWebActivity"
17+
android:exported="false" />
18+
19+
<activity
20+
android:name=".MainActivity"
21+
android:exported="true"
22+
android:theme="@style/Theme.AndroidObservability" >
23+
<intent-filter>
24+
<action android:name="android.intent.action.MAIN" />
25+
<category android:name="android.intent.category.LAUNCHER" />
26+
</intent-filter>
27+
</activity>
28+
</application>
29+
30+
</manifest>

e2e/android/app/src/main/java/com/example/androidobservability/MainActivity.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/MainActivity.kt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ import androidx.compose.ui.unit.dp
3939
import androidx.compose.foundation.layout.PaddingValues
4040
import androidx.compose.foundation.layout.FlowRow
4141
import androidx.compose.foundation.layout.ExperimentalLayoutApi
42+
import androidx.compose.material3.ExperimentalMaterial3Api
4243
import androidx.compose.material3.HorizontalDivider
44+
import androidx.compose.material3.Icon
45+
import androidx.compose.material3.TopAppBar
46+
import androidx.compose.material3.TopAppBarDefaults
4347
import androidx.compose.ui.platform.LocalContext
4448
import androidx.compose.ui.graphics.Color
49+
import androidx.compose.ui.res.painterResource
4550
import com.example.androidobservability.masking.ComposeMaskingActivity
4651
import com.example.androidobservability.masking.ComposeUserFormActivity
4752
import com.example.androidobservability.masking.ComposeWebActivity
@@ -65,10 +70,33 @@ class MainActivity : ComponentActivity() {
6570
enableEdgeToEdge()
6671
setContent {
6772
AndroidObservabilityTheme {
73+
@OptIn(ExperimentalMaterial3Api::class)
6874
Scaffold(
6975
modifier = Modifier
7076
.fillMaxSize()
71-
.imePadding()
77+
.imePadding(),
78+
topBar = {
79+
TopAppBar(
80+
title = {
81+
Text(
82+
"Android Observability",
83+
modifier = Modifier.padding(start = 8.dp)
84+
)
85+
},
86+
navigationIcon = {
87+
Icon(
88+
painter = painterResource(id = R.drawable.ic_launchdarkly_logo),
89+
contentDescription = "LaunchDarkly",
90+
modifier = Modifier.padding(start = 12.dp),
91+
tint = Color.White
92+
)
93+
},
94+
colors = TopAppBarDefaults.topAppBarColors(
95+
containerColor = Color.Black,
96+
titleContentColor = Color.White
97+
)
98+
)
99+
}
72100
) { innerPadding ->
73101
MainScreen(viewModel, innerPadding)
74102
}

e2e/android/app/src/main/java/com/example/androidobservability/masking/ComposeMaskingActivity.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/masking/ComposeMaskingActivity.kt

File renamed without changes.

e2e/android/app/src/main/java/com/example/androidobservability/masking/ComposeUserForm.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/masking/ComposeUserForm.kt

File renamed without changes.

e2e/android/app/src/main/java/com/example/androidobservability/masking/ComposeWebActivity.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/masking/ComposeWebActivity.kt

File renamed without changes.

e2e/android/app/src/main/java/com/example/androidobservability/ui/theme/Color.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/ui/theme/Color.kt

File renamed without changes.

e2e/android/app/src/main/java/com/example/androidobservability/ui/theme/Theme.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/ui/theme/Theme.kt

File renamed without changes.

e2e/android/app/src/main/java/com/example/androidobservability/ui/theme/Type.kt renamed to e2e/android/app/src/compose/java/com/example/androidobservability/ui/theme/Type.kt

File renamed without changes.

e2e/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,10 @@
1616
android:theme="@style/Theme.AndroidObservability"
1717
android:usesCleartextTraffic="true"
1818
tools:targetApi="31" >
19-
<activity
20-
android:name=".masking.ComposeUserFormActivity"
21-
android:exported="false"
22-
android:label="@string/title_activity_secondary"
23-
android:theme="@style/Theme.AndroidObservability" />
2419
<activity
2520
android:name=".masking.XMLUserFormActivity"
2621
android:exported="false"
2722
android:theme="@style/Theme.AndroidObservability" />
28-
<activity
29-
android:name=".masking.ComposeMaskingActivity"
30-
android:exported="false"
31-
android:label="Compose Masking"
32-
android:theme="@style/Theme.AndroidObservability" />
3323
<activity
3424
android:name=".masking.XMLMaskingActivity"
3525
android:exported="false"
@@ -39,9 +29,6 @@
3929
android:name=".smoothie.SmoothieListActivity"
4030
android:exported="false"
4131
android:theme="@style/Theme.AndroidObservability" />
42-
<activity
43-
android:name=".masking.ComposeWebActivity"
44-
android:exported="false" />
4532
<activity
4633
android:name=".masking.XMLWebActivity"
4734
android:exported="false" />
@@ -52,16 +39,6 @@
5239
<service
5340
android:name=".ObservabilityBackgroundService"
5441
android:exported="false" />
55-
<activity
56-
android:name=".MainActivity"
57-
android:exported="true"
58-
android:theme="@style/Theme.AndroidObservability" >
59-
<intent-filter>
60-
<action android:name="android.intent.action.MAIN" />
61-
62-
<category android:name="android.intent.category.LAUNCHER" />
63-
</intent-filter>
64-
</activity>
6542
</application>
6643

6744
</manifest>

0 commit comments

Comments
 (0)