diff --git a/examples/digit_classifier/android/app/src/main/ic_launcher-playstore.png b/examples/digit_classifier/android/app/src/main/ic_launcher-playstore.png
new file mode 100644
index 0000000..f48b7ad
Binary files /dev/null and b/examples/digit_classifier/android/app/src/main/ic_launcher-playstore.png differ
diff --git a/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/MainActivity.kt b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/MainActivity.kt
index 84f1447..168271a 100644
--- a/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/MainActivity.kt
+++ b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/MainActivity.kt
@@ -28,9 +28,7 @@ import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@@ -38,6 +36,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
@@ -58,13 +57,14 @@ import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.drawscope.Stroke
-import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
-import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.google.aiedge.examples.digit_classifier.ui.ApplicationTheme
class MainActivity : ComponentActivity() {
@@ -75,45 +75,47 @@ class MainActivity : ComponentActivity() {
setContent {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
- Scaffold(
- topBar = {
- Header()
- },
- ) { paddingValue ->
- Column(
- modifier = Modifier.padding(paddingValue),
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- // Board composable for drawing and interaction
- Board(
- modifier = Modifier.fillMaxWidth(),
- drawOffsets = uiState.drawOffsets,
- onDragStart = {
- viewModel.draw(it)
- },
- onDrag = {
- viewModel.draw(it)
- },
- onDragEnd = {},
- onDraw = {
- if (uiState.drawOffsets.isNotEmpty()) {
- viewModel.classify(it)
- }
- },
- )
-
- Spacer(modifier = Modifier.height(30.dp))
- Text("Prediction result: ${uiState.digit}")
- Spacer(modifier = Modifier.height(5.dp))
- Text("Confidence: ${uiState.score}")
- Spacer(Modifier.weight(1f))
- Button(onClick = {
- viewModel.cleanBoard()
- }) {
- Text("Clear")
+ ApplicationTheme {
+ Scaffold(
+ topBar = {
+ Header()
+ },
+ ) { paddingValue ->
+ Column(
+ modifier = Modifier.padding(paddingValue),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ // Board composable for drawing and interaction
+ Board(
+ modifier = Modifier.fillMaxWidth(),
+ drawOffsets = uiState.drawOffsets,
+ onDragStart = {
+ viewModel.draw(it)
+ },
+ onDrag = {
+ viewModel.draw(it)
+ },
+ onDragEnd = {},
+ onDraw = {
+ if (uiState.drawOffsets.isNotEmpty()) {
+ viewModel.classify(it)
+ }
+ },
+ )
+
+ Spacer(modifier = Modifier.height(30.dp))
+ Text(stringResource(id = R.string.result, uiState.digit))
+ Spacer(modifier = Modifier.height(5.dp))
+ Text(stringResource(id = R.string.confidence, uiState.score))
+ Spacer(Modifier.weight(1f))
+ Button(onClick = {
+ viewModel.cleanBoard()
+ }) {
+ Text(stringResource(id = R.string.clear))
+ }
}
- }
+ }
}
}
}
@@ -159,7 +161,7 @@ class MainActivity : ComponentActivity() {
modifier = modifier
.fillMaxWidth()
.height(screenWidth)
- .background(Color.Black)
+ .background(MaterialTheme.colorScheme.primary)
.detectDrag(
onDragStart = {
onDragStart(Start(it.x, it.y))
@@ -198,24 +200,18 @@ class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
- fun Header(modifier: Modifier = Modifier) {
+ fun Header() {
TopAppBar(
- modifier = modifier,
- colors = TopAppBarDefaults.topAppBarColors(containerColor = Color.LightGray),
+ colors = TopAppBarDefaults.topAppBarColors(
+ containerColor = MaterialTheme.colorScheme.secondary,
+ ),
title = {
- Row(
- modifier = Modifier.fillMaxSize(),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Image(
- modifier = Modifier.size(50.dp),
- painter = ColorPainter(color = Color.White),
- contentDescription = null,
- )
-
- Spacer(modifier = modifier.width(10.dp))
- Text(text = "LiteRT", color = Color.Blue, fontWeight = FontWeight.SemiBold)
- }
+ Image(
+ modifier = Modifier.size(120.dp),
+ alignment = Alignment.CenterStart,
+ painter = painterResource(id = R.drawable.logo),
+ contentDescription = null,
+ )
},
)
}
diff --git a/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Color.kt b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Color.kt
new file mode 100644
index 0000000..bc63f26
--- /dev/null
+++ b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Color.kt
@@ -0,0 +1,7 @@
+package com.google.aiedge.examples.digit_classifier.ui
+
+import androidx.compose.ui.graphics.Color
+
+val darkBlue = Color(0xFF020f59)
+val teal = Color(0xFF00c99e)
+val cyan = Color(0xFF5be3e3)
\ No newline at end of file
diff --git a/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Theme.kt b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Theme.kt
new file mode 100644
index 0000000..bda2cc2
--- /dev/null
+++ b/examples/digit_classifier/android/app/src/main/java/com/google/aiedge/examples/digit_classifier/ui/Theme.kt
@@ -0,0 +1,21 @@
+package com.google.aiedge.examples.digit_classifier.ui
+
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.Composable
+
+private val colorScheme = lightColorScheme(
+ primary = darkBlue,
+ secondary = teal,
+ onSurfaceVariant = teal,
+)
+
+@Composable
+fun ApplicationTheme(
+ content: @Composable () -> Unit
+) {
+ MaterialTheme(
+ colorScheme = colorScheme,
+ content = content
+ )
+}
\ No newline at end of file
diff --git a/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_background.xml b/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_background.xml
index 07d5da9..ca3826a 100644
--- a/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_background.xml
+++ b/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_background.xml
@@ -1,170 +1,74 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_foreground.xml
index 2b068d1..abfb156 100644
--- a/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ b/examples/digit_classifier/android/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -1,30 +1,26 @@
-
-
-
-
-
-
-
-
+ android:viewportWidth="1024"
+ android:viewportHeight="1024">
+
+
-
\ No newline at end of file
+ android:pathData="M-0.2,0.8l0,1024.2l1024.1,0l0,-1024.2l-1024.1,0l0,0z"
+ android:fillColor="#020f59"/>
+
+
+
+
+
+
+
+
diff --git a/examples/digit_classifier/android/app/src/main/res/drawable/logo.png b/examples/digit_classifier/android/app/src/main/res/drawable/logo.png
new file mode 100644
index 0000000..f7ab818
Binary files /dev/null and b/examples/digit_classifier/android/app/src/main/res/drawable/logo.png differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
index 6f3b755..bbd3e02 100644
--- a/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ b/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -1,6 +1,5 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
index 6f3b755..bbd3e02 100644
--- a/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ b/examples/digit_classifier/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -1,6 +1,5 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp
index c209e78..09b2292 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
index b2dfe3d..bd7d139 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp
index 4f0f1d6..cfba769 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
index 62b611d..08ce567 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
index 948a307..944e484 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
index 1b9a695..063c6c3 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
index 28d4b77..39e1f4d 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
index 9287f50..e040a50 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
index aa7d642..768bacc 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
index 9126ae3..5fed871 100644
Binary files a/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/examples/digit_classifier/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/examples/digit_classifier/android/app/src/main/res/values/strings.xml b/examples/digit_classifier/android/app/src/main/res/values/strings.xml
index 4c1174d..e0d7f0d 100644
--- a/examples/digit_classifier/android/app/src/main/res/values/strings.xml
+++ b/examples/digit_classifier/android/app/src/main/res/values/strings.xml
@@ -1,3 +1,6 @@
Digit Classifier
+ Prediction result: %s
+ Confidence: %.2f
+ Clear
\ No newline at end of file