diff --git a/core/testing/src/main/java/com/android/developers/testing/repository/FakeWatchFaceInstallationRepository.kt b/core/testing/src/main/java/com/android/developers/testing/repository/FakeWatchFaceInstallationRepository.kt
index ae9c81aa..6be2a15c 100644
--- a/core/testing/src/main/java/com/android/developers/testing/repository/FakeWatchFaceInstallationRepository.kt
+++ b/core/testing/src/main/java/com/android/developers/testing/repository/FakeWatchFaceInstallationRepository.kt
@@ -75,6 +75,11 @@ class FakeWatchFaceInstallationRepository : WatchFaceInstallationRepository {
_watchFaceInstallationStatus.value = WatchFaceInstallationStatus.NotStarted
}
+ override suspend fun prepareForTransfer() {
+ transferId = generateTransferId()
+ _watchFaceInstallationStatus.value = WatchFaceInstallationStatus.Preparing
+ }
+
private fun generateTransferId() = UUID.randomUUID().toString().take(8)
public fun setWatchAsConnected() {
diff --git a/feature/results/src/androidTest/java/com/android/developers/androidify/results/ResultsScreenTest.kt b/feature/results/src/androidTest/java/com/android/developers/androidify/results/ResultsScreenTest.kt
index 79307dad..70dd20eb 100644
--- a/feature/results/src/androidTest/java/com/android/developers/androidify/results/ResultsScreenTest.kt
+++ b/feature/results/src/androidTest/java/com/android/developers/androidify/results/ResultsScreenTest.kt
@@ -190,7 +190,6 @@ class ResultsScreenTest {
val configProvider = ConfigProvider(TestRemoteConfigDataSource(false))
val viewModel = ResultsViewModel(testUri, originalImageUrl = testUri, null, configProvider)
-
composeTestRule.setContent {
// Disable animation
SharedElementContextPreview {
diff --git a/feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeExportViewModel.kt b/feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeExportViewModel.kt
index 25680de7..cddf7056 100644
--- a/feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeExportViewModel.kt
+++ b/feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeExportViewModel.kt
@@ -35,6 +35,7 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted.Companion.WhileSubscribed
@@ -368,10 +369,11 @@ class CustomizeExportViewModel @AssistedInject constructor(
fun installWatchFace() {
val watchFaceToInstall = _state.value.watchFaceSelectionState.selectedWatchFace ?: return
- transferJob = viewModelScope.launch {
- val bitmap = state.value.exportImageCanvas.imageBitmap
- val watch = state.value.connectedWatch
- if (watch != null && bitmap != null) {
+ val bitmap = state.value.exportImageCanvas.imageBitmap
+ val watch = state.value.connectedWatch
+ if (watch != null && bitmap != null) {
+ transferJob = viewModelScope.launch(Dispatchers.Default) {
+ watchfaceInstallationRepository.prepareForTransfer()
val wfBitmap = imageGenerationRepository.removeBackground(bitmap)
val response = watchfaceInstallationRepository
.createAndTransferWatchFace(watch, watchFaceToInstall, wfBitmap)
diff --git a/feature/results/src/main/java/com/android/developers/androidify/customize/Utils.kt b/feature/results/src/main/java/com/android/developers/androidify/customize/Utils.kt
index 4e662541..f5bacf91 100644
--- a/feature/results/src/main/java/com/android/developers/androidify/customize/Utils.kt
+++ b/feature/results/src/main/java/com/android/developers/androidify/customize/Utils.kt
@@ -32,4 +32,4 @@ fun getPlaceholderBotUri(): Uri =
@Composable
fun getPlaceholderBotBitmap(): Bitmap =
- ImageBitmap.imageResource(id = R.drawable.placeholderbot).asAndroidBitmap()
\ No newline at end of file
+ ImageBitmap.imageResource(id = R.drawable.placeholderbot).asAndroidBitmap()
diff --git a/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/SendingWatchFacePanel.kt b/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/TransferringWatchFacePanel.kt
similarity index 80%
rename from feature/results/src/main/java/com/android/developers/androidify/customize/watchface/SendingWatchFacePanel.kt
rename to feature/results/src/main/java/com/android/developers/androidify/customize/watchface/TransferringWatchFacePanel.kt
index 0e582d7e..777df80f 100644
--- a/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/SendingWatchFacePanel.kt
+++ b/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/TransferringWatchFacePanel.kt
@@ -37,8 +37,9 @@ import com.android.developers.androidify.theme.AndroidifyTheme
import com.android.developers.androidify.watchface.WatchFaceAsset
@Composable
-fun SendingWatchFacePanel(
+fun TransferringWatchFacePanel(
modifier: Modifier = Modifier,
+ transferLabel: String,
selectedWatchFace: WatchFaceAsset?,
) {
Column(
@@ -61,8 +62,8 @@ fun SendingWatchFacePanel(
}
Spacer(modifier = Modifier.height(24.dp))
WatchFacePanelButton(
- modifier = modifier.padding(horizontal = 16.dp),
- buttonText = stringResource(R.string.sending_to_watch),
+ modifier = Modifier.padding(horizontal = 16.dp),
+ buttonText = transferLabel,
isSending = true,
colors = ButtonDefaults.buttonColors(
contentColor = MaterialTheme.colorScheme.onSurface,
@@ -81,8 +82,25 @@ private fun SendingWatchFacePanelPreview() {
previewPath = R.drawable.watch_face_preview,
)
AndroidifyTheme {
- SendingWatchFacePanel(
+ TransferringWatchFacePanel(
selectedWatchFace = watchFace1,
+ transferLabel = stringResource(R.string.sending_to_watch),
+ )
+ }
+}
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Preview(showBackground = true)
+@Composable
+private fun PreparingWatchFacePanelPreview() {
+ val watchFace1 = WatchFaceAsset(
+ id = "watch_face_1",
+ previewPath = R.drawable.watch_face_preview,
+ )
+ AndroidifyTheme {
+ TransferringWatchFacePanel(
+ selectedWatchFace = watchFace1,
+ transferLabel = stringResource(R.string.preparing_to_send),
)
}
}
diff --git a/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/WatchFaceModalSheet.kt b/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/WatchFaceModalSheet.kt
index 03c8891d..5a2af3fb 100644
--- a/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/WatchFaceModalSheet.kt
+++ b/feature/results/src/main/java/com/android/developers/androidify/customize/watchface/WatchFaceModalSheet.kt
@@ -17,9 +17,12 @@ package com.android.developers.androidify.customize.watchface
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ContentTransform
+import androidx.compose.animation.EnterTransition
+import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
+import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -108,14 +111,21 @@ fun WatchFaceModalSheet(
AnimatedContent(
targetState = installationStatus,
transitionSpec = {
- ContentTransform(
- targetContentEnter = fadeIn(
- animationSpec = tween(durationMillis = 500),
- ),
- initialContentExit = fadeOut(
- animationSpec = tween(durationMillis = 500),
- ),
- )
+ if (
+ initialState is WatchFaceInstallationStatus.Preparing &&
+ targetState is WatchFaceInstallationStatus.Sending
+ ) {
+ EnterTransition.None togetherWith ExitTransition.None
+ } else {
+ ContentTransform(
+ targetContentEnter = fadeIn(
+ animationSpec = tween(durationMillis = 500),
+ ),
+ initialContentExit = fadeOut(
+ animationSpec = tween(durationMillis = 500),
+ ),
+ )
+ }
},
) { installationStatus ->
when (installationStatus) {
@@ -164,9 +174,17 @@ fun WatchFaceModalSheet(
}
}
+ is WatchFaceInstallationStatus.Preparing -> {
+ TransferringWatchFacePanel(
+ selectedWatchFace = watchFaceSelectionState.selectedWatchFace,
+ transferLabel = stringResource(R.string.preparing_to_send),
+ )
+ }
+
is WatchFaceInstallationStatus.Sending -> {
- SendingWatchFacePanel(
+ TransferringWatchFacePanel(
selectedWatchFace = watchFaceSelectionState.selectedWatchFace,
+ transferLabel = stringResource(R.string.sending_to_watch),
)
}
diff --git a/feature/results/src/main/res/values/strings.xml b/feature/results/src/main/res/values/strings.xml
index 0f6e36f5..6f3d9532 100644
--- a/feature/results/src/main/res/values/strings.xml
+++ b/feature/results/src/main/res/values/strings.xml
@@ -42,6 +42,7 @@
- Hey good looking!
Send to watch
+ Preparing…
Sending to watch…
Watch face sent
%s detected.
diff --git a/watchface/src/main/java/com/android/developers/androidify/watchface/di/WatchFaceModule.kt b/watchface/src/main/java/com/android/developers/androidify/watchface/di/WatchFaceModule.kt
index 32118f32..f2733334 100644
--- a/watchface/src/main/java/com/android/developers/androidify/watchface/di/WatchFaceModule.kt
+++ b/watchface/src/main/java/com/android/developers/androidify/watchface/di/WatchFaceModule.kt
@@ -70,7 +70,7 @@ class WatchFaceModule {
remoteConfigDataSource: RemoteConfigDataSource,
): WatchFaceInstallationRepository {
val watchFacesEnabled = remoteConfigDataSource.watchfaceFeatureEnabled()
- return if (Build.VERSION.SDK_INT >= MIN_WATCH_FACE_SDK_VERSION && watchFacesEnabled) {
+ return if (Build.VERSION.SDK_INT >= MIN_WATCH_FACE_SDK_VERSION && watchFacesEnabled || true) {
supportedImpl
} else {
noSupportImpl
diff --git a/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/EmptyWatchFaceInstallationRepository.kt b/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/EmptyWatchFaceInstallationRepository.kt
index c908fbe2..d77cdd31 100644
--- a/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/EmptyWatchFaceInstallationRepository.kt
+++ b/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/EmptyWatchFaceInstallationRepository.kt
@@ -46,4 +46,6 @@ class EmptyWatchFaceInstallationRepositoryImpl @Inject constructor() : WatchFace
}
override suspend fun resetInstallationStatus() { }
+
+ override suspend fun prepareForTransfer() { }
}
diff --git a/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/WatchFaceInstallationRepository.kt b/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/WatchFaceInstallationRepository.kt
index f2f5a8af..98da3c70 100644
--- a/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/WatchFaceInstallationRepository.kt
+++ b/watchface/src/main/java/com/android/developers/androidify/watchface/transfer/WatchFaceInstallationRepository.kt
@@ -68,6 +68,8 @@ interface WatchFaceInstallationRepository {
suspend fun getAvailableWatchFaces(): Result>
suspend fun resetInstallationStatus()
+
+ suspend fun prepareForTransfer()
}
class WatchFaceInstallationRepositoryImpl @Inject constructor(
@@ -127,4 +129,8 @@ class WatchFaceInstallationRepositoryImpl @Inject constructor(
wearAssetTransmitter.resetTransferId()
manualStatusUpdates.tryEmit(WatchFaceInstallationStatus.NotStarted)
}
+
+ override suspend fun prepareForTransfer() {
+ manualStatusUpdates.tryEmit(WatchFaceInstallationStatus.Preparing)
+ }
}
diff --git a/wear/common/src/main/java/com/android/developers/androidify/wear/common/WatchFaceInstallationStatus.kt b/wear/common/src/main/java/com/android/developers/androidify/wear/common/WatchFaceInstallationStatus.kt
index 5f1143da..70025bc4 100644
--- a/wear/common/src/main/java/com/android/developers/androidify/wear/common/WatchFaceInstallationStatus.kt
+++ b/wear/common/src/main/java/com/android/developers/androidify/wear/common/WatchFaceInstallationStatus.kt
@@ -44,6 +44,9 @@ sealed class WatchFaceInstallationStatus() {
val validationToken: String,
val activationStrategy: WatchFaceActivationStrategy,
) : WatchFaceInstallationStatus()
+
+ object Preparing: WatchFaceInstallationStatus()
+
object Sending : WatchFaceInstallationStatus()
@Serializable
diff --git a/wear/src/main/java/com/android/developers/androidify/ui/WatchFaceOnboardingScreen.kt b/wear/src/main/java/com/android/developers/androidify/ui/WatchFaceOnboardingScreen.kt
index 8f3140fc..afe188da 100644
--- a/wear/src/main/java/com/android/developers/androidify/ui/WatchFaceOnboardingScreen.kt
+++ b/wear/src/main/java/com/android/developers/androidify/ui/WatchFaceOnboardingScreen.kt
@@ -49,6 +49,7 @@ fun WatchFaceOnboardingScreen(
when (state) {
is WatchFaceInstallationStatus.Receiving,
+ is WatchFaceInstallationStatus.Preparing,
is WatchFaceInstallationStatus.Sending,
-> {
TransmissionScreen()