Skip to content

Commit 3b33b0d

Browse files
committed
Android Wear UI and text changes
1 parent 131de35 commit 3b33b0d

File tree

4 files changed

+65
-31
lines changed

4 files changed

+65
-31
lines changed

android/wear/src/main/java/com/codel1417/tail_App/json/WearData.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package com.codel1417.tail_App.json
33
data class WearActionData(val name: String, val uuid: String)
44
data class WearTriggerData(val name: String, val uuid: String, val enabled: Boolean)
55
data class WearLocalizationData(
6-
val triggersPage: String,
7-
val actionsPage: String,
8-
val favoriteActionsDescription: String
6+
val triggersPage: String = "",
7+
val actionsPage: String = "",
8+
val favoriteActionsDescription: String = "",
9+
val knownGear: String = "",
10+
val watchKnownGearNoGearPairedTip: String = ""
911
)
1012

1113
data class WearGearData(

android/wear/src/main/java/com/codel1417/tail_App/presentation/MainActivity.kt

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
3434
import androidx.wear.compose.material.Card
3535
import androidx.wear.compose.material.Chip
3636
import androidx.wear.compose.material.ChipDefaults
37+
import androidx.wear.compose.material.ListHeader
3738
import androidx.wear.compose.material.PositionIndicator
3839
import androidx.wear.compose.material.Scaffold
3940
import androidx.wear.compose.material.Text
4041
import androidx.wear.compose.material.Vignette
4142
import androidx.wear.compose.material.VignettePosition
42-
import androidx.wear.compose.material3.Card
4343
import androidx.wear.compose.material3.CircularProgressIndicator
4444
import androidx.wear.compose.material3.SwitchButton
4545
import androidx.wear.compose.material3.TimeText
@@ -239,7 +239,8 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
239239
}) {
240240

241241
if (state.value == null) {
242-
Box( modifier = Modifier.fillMaxSize(),
242+
Box(
243+
modifier = Modifier.fillMaxSize(),
243244
) {
244245
CircularProgressIndicator(
245246
modifier = Modifier
@@ -259,36 +260,54 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
259260
// DecayAnimationSpec.
260261
)
261262
) {
262-
item { Text(text = state.value!!.localization.actionsPage) }
263-
state.value!!.favoriteActions.map {
263+
item { ListHeader { Text(text = state.value!!.localization.actionsPage) } }
264+
if (state.value!!.favoriteActions.isEmpty()) {
264265
item {
265-
ActionButton(
266-
contentModifier,
267-
it.name,
268-
it.uuid,
269-
)
266+
Card(
267+
onClick = {}
268+
) { Text(text = state.value!!.localization.favoriteActionsDescription) }
269+
}
270+
} else {
271+
state.value!!.favoriteActions.map {
272+
item {
273+
ActionButton(
274+
contentModifier,
275+
it.name,
276+
it.uuid,
277+
)
278+
}
270279
}
271280
}
272-
item { Text(text = state.value!!.localization.triggersPage) }
273-
state.value!!.configuredTriggers.map {
274-
item {
275-
TriggerButton(
276-
contentModifier,
277-
it.name,
278-
it.uuid,
279-
it.enabled,
280-
)
281+
if (!state.value!!.configuredTriggers.isEmpty()) {
282+
item { ListHeader { Text(text = state.value!!.localization.triggersPage) } }
283+
state.value!!.configuredTriggers.map {
284+
item {
285+
TriggerButton(
286+
contentModifier,
287+
it.name,
288+
it.uuid,
289+
it.enabled,
290+
)
291+
}
281292
}
282293
}
283-
item { Text(text = state.value!!.localization.triggersPage) }
284-
state.value!!.knownGear.map {
294+
item { ListHeader { Text(text = state.value!!.localization.knownGear) } }
295+
if (state.value!!.knownGear.isEmpty()) {
285296
item {
286-
GearButton(
287-
contentModifier,
288-
it.name,
289-
it.batteryLevel.toInt(),
290-
it.color
291-
)
297+
Card(
298+
onClick = {}
299+
) { Text(text = state.value!!.localization.watchKnownGearNoGearPairedTip) }
300+
}
301+
} else {
302+
state.value!!.knownGear.map {
303+
item {
304+
GearButton(
305+
contentModifier,
306+
it.name,
307+
it.batteryLevel.toInt(),
308+
it.color
309+
)
310+
}
292311
}
293312
}
294313
}
@@ -351,6 +370,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
351370
},
352371
)
353372
}
373+
354374
@Composable
355375
fun GearButton(
356376
modifier: Modifier = Modifier,
@@ -366,6 +386,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
366386
secondaryLabel = { Text(text = "$battery%", textAlign = TextAlign.Center) },
367387
)
368388
}
389+
369390
override fun onMessageReceived(p0: MessageEvent) {
370391
println("onMessageReceived() ${p0.path} ${p0.data}")
371392
}

lib/Backend/wear_bridge.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ Future<void> updateWearData(Ref ref) async {
141141
// Listen for gear connect/disconnect events
142142
ref.watch(getAvailableGearProvider);
143143

144-
final WearLocalizationData localizationData = WearLocalizationData(triggersPage: triggersPage(), actionsPage: homePage(), favoriteActionsDescription: actionsFavoriteTip());
144+
final WearLocalizationData localizationData =
145+
WearLocalizationData(triggersPage: triggersPage(), actionsPage: watchFavoriteActionsTitle(), favoriteActionsDescription: watchFavoriteActionsNoFavoritesTip(), knownGear: watchKnownGearTitle(), watchKnownGearNoGearPairedTip: watchKnownGearNoGearPairedTip());
145146
final WearData wearData = WearData(
146147
favoriteActions: favoriteMap,
147148
configuredTriggers: triggersMap,
@@ -196,7 +197,9 @@ abstract class WearLocalizationData with _$WearLocalizationData {
196197
const factory WearLocalizationData({
197198
required String triggersPage,
198199
required String actionsPage,
200+
required String knownGear,
199201
required String favoriteActionsDescription,
202+
required String watchKnownGearNoGearPairedTip,
200203
}) = _WearLocalizationData;
201204

202205
factory WearLocalizationData.fromJson(Map<String, dynamic> json) => _$WearLocalizationDataFromJson(json);

lib/Frontend/translation_string_definitions.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ String noLongerSupported() => Intl.message("This gear is no longer supported. So
354354

355355
String mandatoryOtaRequired() => Intl.message("A firmware update is available to better support your gear", name: 'mandatoryOtaRequired', desc: 'Warning message which appears for gear which have old firmware on the manage gear page');
356356

357-
String actionsFavoriteTip() => Intl.message("Long press an action to favorite", name: 'actionsFavoriteTip', desc: 'tip message which appears when no actions are favorited on the actions page');
357+
String actionsFavoriteTip() => Intl.message("Long press an action to favorite", name: 'actionsFavoriteTip', desc: 'tip message which appears when no actions are added to favorite on the actions page');
358358

359359
String moreSourceCode() => Intl.message("Source Code", name: 'moreSourceCode', desc: 'Label for the github and dev mode button on the more tab');
360360

@@ -445,3 +445,11 @@ String morePageTranslateTitle() => Intl.message('Localization', name: 'morePageT
445445
String morePageTranslateDescription() => Intl.message('Help us Translate the app into your language', name: 'morePageTranslateDescription', desc: 'The description for the button on the More page to push users to assist in translating the app');
446446

447447
String appLanguageSelectorTitle() => Intl.message('App Language', name: 'appLanguageSelectorTitle', desc: 'The title for the button and dialog to select the app language');
448+
449+
String watchKnownGearTitle() => Intl.message('Your Gear', name: 'watchKnownGearTitle', desc: 'The title for the known gear section of the watch app');
450+
451+
String watchFavoriteActionsNoFavoritesTip() => Intl.message('On your phone, Long press an action to favorite', name: 'watchKnownGearTitle', desc: 'the tip for when no actions are favorited on the watch app');
452+
453+
String watchFavoriteActionsTitle() => Intl.message("Favorite Actions", name: 'watchFavoriteActionsTitle', desc: 'title for the favorite actions section of the watch app');
454+
455+
String watchKnownGearNoGearPairedTip() => Intl.message("On your phone, Use the `Scan For New Gear` button to pair your gear", name: 'watchKnownGearNoGearPairedTip', desc: 'the tip for when no actions are favorited on the watch app');

0 commit comments

Comments
 (0)