Skip to content

Commit

Permalink
Revert "Rename demo 1 and demo 2 to sample app and Playstore app. Mat…
Browse files Browse the repository at this point in the history
…ch description for counter sample"

This reverts commit b3a9126.
  • Loading branch information
kul3r4 committed Jan 18, 2024
1 parent 9b6d0c4 commit b9e7289
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.android.horologist.datalayer.sample.screens.counter

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -82,16 +81,8 @@ fun CounterScreen(
.padding(16.dp),
) {
Text(text = stringResource(R.string.app_helper_counter_increase_explanation))
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth(),
) {
Text(
text = "Counter: " + state.counter,
modifier = Modifier.padding(16.dp),
)
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = "Counter: " + state.counter)
Button(onClick = onPlusClick) {
Icon(imageVector = Icons.Default.Add, contentDescription = "Plus 1")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.android.horologist.datalayer.sample.R

@Composable
fun InstallSampleAppPromptDemoScreen(
fun InstallAppPromptDemo2Screen(
modifier: Modifier = Modifier,
viewModel: InstallSampleAppPromptDemoViewModel = hiltViewModel(),
viewModel: InstallAppPromptDemo2ViewModel = hiltViewModel(),
) {
val state by viewModel.uiState.collectAsStateWithLifecycle()

val context = LocalContext.current

InstallSampleAppPromptDemoScreen(
InstallAppPromptDemo2Screen(
state = state,
onRunDemoClick = viewModel::onRunDemoClick,
getInstallPromptIntent = { watchName ->
Expand All @@ -56,7 +56,7 @@ fun InstallSampleAppPromptDemoScreen(
appName = context.getString(R.string.app_name),
appPackageName = context.packageName,
watchName = watchName,
message = context.getString(R.string.install_sample_app_prompt_demo_prompt_message),
message = context.getString(R.string.install_app_prompt_demo2_prompt_message),
image = R.drawable.watch_app_screenshot,
)
},
Expand All @@ -68,8 +68,8 @@ fun InstallSampleAppPromptDemoScreen(
}

@Composable
fun InstallSampleAppPromptDemoScreen(
state: InstallSampleAppPromptDemoScreenState,
fun InstallAppPromptDemo2Screen(
state: InstallAppPromptDemo2ScreenState,
onRunDemoClick: () -> Unit,
getInstallPromptIntent: (watchName: String) -> Intent,
onInstallPromptLaunched: () -> Unit,
Expand All @@ -90,59 +90,56 @@ fun InstallSampleAppPromptDemoScreen(
Column(
modifier = modifier.padding(all = 10.dp),
) {
Text(text = stringResource(id = R.string.install_sample_app_prompt_api_call_demo_message))
Text(text = stringResource(id = R.string.install_app_prompt_api_call_demo2_message))

Button(
onClick = onRunDemoClick,
modifier = Modifier
.padding(top = 10.dp)
.align(Alignment.CenterHorizontally),
) {
Text(text = stringResource(id = R.string.install_sample_app_prompt_run_demo_button_label))
Text(text = stringResource(id = R.string.install_app_prompt_run_demo2_button_label))
}

when (state) {
InstallSampleAppPromptDemoScreenState.Idle -> {
InstallAppPromptDemo2ScreenState.Idle -> {
/* do nothing */
}

InstallSampleAppPromptDemoScreenState.Loading -> {
InstallAppPromptDemo2ScreenState.Loading -> {
CircularProgressIndicator()
}

is InstallSampleAppPromptDemoScreenState.WatchFound -> {
is InstallAppPromptDemo2ScreenState.WatchFound -> {
SideEffect { launcher.launch(getInstallPromptIntent(state.watchName)) }

onInstallPromptLaunched()
}

InstallSampleAppPromptDemoScreenState.WatchNotFound -> {
InstallAppPromptDemo2ScreenState.WatchNotFound -> {
Text(
stringResource(
id = R.string.install_sample_app_prompt_demo_result_label,
stringResource(id = R.string.install_sample_app_prompt_demo_no_watches_found_label),
id = R.string.install_app_prompt_demo2_result_label,
stringResource(id = R.string.install_app_prompt_demo2_no_watches_found_label),
),
modifier = Modifier.padding(16.dp),
)
}

InstallSampleAppPromptDemoScreenState.InstallPromptInstallClicked -> {
InstallAppPromptDemo2ScreenState.InstallPromptInstallClicked -> {
Text(
stringResource(
id = R.string.install_sample_app_prompt_demo_result_label,
stringResource(id = R.string.install_sample_app_prompt_demo_prompt_install_result_label),
id = R.string.install_app_prompt_demo2_result_label,
stringResource(id = R.string.install_app_prompt_demo2_prompt_install_result_label),
),
modifier = Modifier.padding(16.dp),
)
}

InstallSampleAppPromptDemoScreenState.InstallPromptInstallCancelled -> {
InstallAppPromptDemo2ScreenState.InstallPromptInstallCancelled -> {
Text(
stringResource(
id = R.string.install_sample_app_prompt_demo_result_label,
stringResource(id = R.string.install_sample_app_prompt_demo_prompt_cancel_result_label),
id = R.string.install_app_prompt_demo2_result_label,
stringResource(id = R.string.install_app_prompt_demo2_prompt_cancel_result_label),
),
modifier = Modifier.padding(16.dp),
)
}
}
Expand All @@ -152,8 +149,8 @@ fun InstallSampleAppPromptDemoScreen(
@Preview(showBackground = true)
@Composable
fun InstallAppPromptDemo2ScreenPreview() {
InstallSampleAppPromptDemoScreen(
state = InstallSampleAppPromptDemoScreenState.Idle,
InstallAppPromptDemo2Screen(
state = InstallAppPromptDemo2ScreenState.Idle,
onRunDemoClick = { },
getInstallPromptIntent = { Intent() },
onInstallPromptLaunched = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,49 @@ import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class InstallSampleAppPromptDemoViewModel
class InstallAppPromptDemo2ViewModel
@Inject
constructor(
private val phoneDataLayerAppHelper: PhoneDataLayerAppHelper,
val phoneUiDataLayerHelper: PhoneUiDataLayerHelper,
) : ViewModel() {

private val _uiState =
MutableStateFlow<InstallSampleAppPromptDemoScreenState>(InstallSampleAppPromptDemoScreenState.Idle)
public val uiState: StateFlow<InstallSampleAppPromptDemoScreenState> = _uiState
MutableStateFlow<InstallAppPromptDemo2ScreenState>(InstallAppPromptDemo2ScreenState.Idle)
public val uiState: StateFlow<InstallAppPromptDemo2ScreenState> = _uiState

fun onRunDemoClick() {
_uiState.value = InstallSampleAppPromptDemoScreenState.Loading
_uiState.value = InstallAppPromptDemo2ScreenState.Loading

viewModelScope.launch {
val node = phoneDataLayerAppHelper.connectedNodes().firstOrNull { !it.appInstalled }

_uiState.value = if (node != null) {
InstallSampleAppPromptDemoScreenState.WatchFound(watchName = node.displayName)
InstallAppPromptDemo2ScreenState.WatchFound(watchName = node.displayName)
} else {
InstallSampleAppPromptDemoScreenState.WatchNotFound
InstallAppPromptDemo2ScreenState.WatchNotFound
}
}
}

fun onInstallPromptLaunched() {
_uiState.value = InstallSampleAppPromptDemoScreenState.Idle
_uiState.value = InstallAppPromptDemo2ScreenState.Idle
}

fun onInstallPromptInstallClick() {
_uiState.value = InstallSampleAppPromptDemoScreenState.InstallPromptInstallClicked
_uiState.value = InstallAppPromptDemo2ScreenState.InstallPromptInstallClicked
}

fun onInstallPromptCancel() {
_uiState.value = InstallSampleAppPromptDemoScreenState.InstallPromptInstallCancelled
_uiState.value = InstallAppPromptDemo2ScreenState.InstallPromptInstallCancelled
}
}

sealed class InstallSampleAppPromptDemoScreenState {
data object Idle : InstallSampleAppPromptDemoScreenState()
data object Loading : InstallSampleAppPromptDemoScreenState()
data class WatchFound(val watchName: String) : InstallSampleAppPromptDemoScreenState()
data object WatchNotFound : InstallSampleAppPromptDemoScreenState()
data object InstallPromptInstallClicked : InstallSampleAppPromptDemoScreenState()
data object InstallPromptInstallCancelled : InstallSampleAppPromptDemoScreenState()
sealed class InstallAppPromptDemo2ScreenState {
data object Idle : InstallAppPromptDemo2ScreenState()
data object Loading : InstallAppPromptDemo2ScreenState()
data class WatchFound(val watchName: String) : InstallAppPromptDemo2ScreenState()
data object WatchNotFound : InstallAppPromptDemo2ScreenState()
data object InstallPromptInstallClicked : InstallAppPromptDemo2ScreenState()
data object InstallPromptInstallCancelled : InstallAppPromptDemo2ScreenState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,30 @@ import androidx.compose.ui.unit.dp
import com.google.android.horologist.datalayer.sample.R

@Composable
fun InstallPlaystoreAppPromptDemoScreen(
fun InstallAppPromptDemoScreen(
onShowInstallAppPrompt: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(all = 10.dp),
) {
Text(text = stringResource(id = R.string.install_playstore_app_prompt_api_call_demo_message))
Text(text = stringResource(id = R.string.install_app_prompt_api_call_demo_message))

Button(
onClick = onShowInstallAppPrompt,
modifier = Modifier
.padding(top = 10.dp)
.align(Alignment.CenterHorizontally),
) {
Text(text = stringResource(id = R.string.install_playstore_app_prompt_run_demo_button_label))
Text(text = stringResource(id = R.string.install_app_prompt_run_demo_button_label))
}
}
}

@Preview(showBackground = true)
@Composable
fun InstallAppPromptDemoScreenPreview() {
InstallPlaystoreAppPromptDemoScreen(
InstallAppPromptDemoScreen(
onShowInstallAppPrompt = { },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.google.android.horologist.datalayer.sample.screens.Screen
import com.google.android.horologist.datalayer.sample.screens.counter.CounterScreen
import com.google.android.horologist.datalayer.sample.screens.inappprompts.InstallPlaystoreAppPromptDemoScreen
import com.google.android.horologist.datalayer.sample.screens.inappprompts.InstallSampleAppPromptDemoScreen
import com.google.android.horologist.datalayer.sample.screens.inappprompts.InstallAppPromptDemo2Screen
import com.google.android.horologist.datalayer.sample.screens.inappprompts.InstallAppPromptDemoScreen
import com.google.android.horologist.datalayer.sample.screens.menu.MenuScreen
import com.google.android.horologist.datalayer.sample.screens.nodes.NodesScreen

Expand Down Expand Up @@ -63,10 +63,10 @@ fun MainScreen(
NodesScreen()
}
composable(route = Screen.InstallAppPromptDemoScreen.route) {
InstallPlaystoreAppPromptDemoScreen(onShowInstallAppPrompt = onShowInstallAppPrompt)
InstallAppPromptDemoScreen(onShowInstallAppPrompt = onShowInstallAppPrompt)
}
composable(route = Screen.InstallAppPromptDemo2Screen.route) {
InstallSampleAppPromptDemoScreen()
InstallAppPromptDemo2Screen()
}
composable(route = Screen.CounterScreen.route) {
CounterScreen()
Expand Down
26 changes: 13 additions & 13 deletions datalayer/sample/phone/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<string name="menu_screen_apphelper_header">App Helper</string>
<string name="menu_screen_nodes_item">Nodes</string>
<string name="menu_screen_inapp_prompts_header">In-App prompts</string>
<string name="menu_screen_install_app_demo1_item">Install Playstore app demo</string>
<string name="menu_screen_install_app_demo2_item">Install sample app demo</string>
<string name="menu_screen_install_app_demo1_item">Install app - demo 1</string>
<string name="menu_screen_install_app_demo2_item">Install app - demo 2</string>
<string name="menu_screen_datalayer_header">Data Layer</string>
<string name="menu_screen_counter_item">Counter sample</string>

Expand Down Expand Up @@ -56,18 +56,18 @@
<string name="node_status_start_own_app_button_label">Start remote own app</string>
<string name="node_status_start_remote_activity_button_label">Start remote activity</string>

<!-- In-app prompt - Install Playstore app Demo screen -->
<string name="install_playstore_app_prompt_api_call_demo_message">This demo calls the Horologist API to show the install app prompt and the invocation of the deeplink to the Google Play by using the Gmail app as an example. The developer has to gather all the information to display on the prompt, such as app name and watch name to use the prompt in their app.</string>
<string name="install_playstore_app_prompt_run_demo_button_label">Run demo</string>
<!-- In-app prompt - Install App Demo 1 screen -->
<string name="install_app_prompt_api_call_demo_message">This demo calls the Horologist API to show the install app prompt and the invocation of the deeplink to the Google Play by using the Gmail app as an example. The developer has to gather all the information to display on the prompt, such as app name and watch name to use the prompt in their app.</string>
<string name="install_app_prompt_run_demo_button_label">Run demo</string>

<!-- In-app prompt - Install Sample App Demo screen -->
<string name="install_sample_app_prompt_api_call_demo_message">This demo calls the Horologist API to show the install app prompt for the watch demo app. The API will only display the prompt if there is a watch connected and the watch does not have the app installed already.\n\nGoogle Play won\'t find this app as it is not published.</string>
<string name="install_sample_app_prompt_run_demo_button_label">Run demo</string>
<string name="install_sample_app_prompt_demo_prompt_message">Test the interactions between the phone and the watch with the demo app.</string>
<string name="install_sample_app_prompt_demo_result_label">Result: %1$s</string>
<string name="install_sample_app_prompt_demo_no_watches_found_label">No watches without the app installed were found.</string>
<string name="install_sample_app_prompt_demo_prompt_install_result_label">User tapped install on the prompt.</string>
<string name="install_sample_app_prompt_demo_prompt_cancel_result_label">User dismissed the prompt.</string>
<!-- In-app prompt - Install App Demo 2 screen -->
<string name="install_app_prompt_api_call_demo2_message">This demo calls the Horologist API to show the install app prompt for the watch demo app. The API will only display the prompt if there is a watch connected and the watch does not have the app installed already.\n\nGoogle Play won\'t find this app as it is not published.</string>
<string name="install_app_prompt_run_demo2_button_label">Run demo</string>
<string name="install_app_prompt_demo2_prompt_message">Test the interactions between the phone and the watch with the demo app.</string>
<string name="install_app_prompt_demo2_result_label">Result: %1$s</string>
<string name="install_app_prompt_demo2_no_watches_found_label">No watches without the app installed were found.</string>
<string name="install_app_prompt_demo2_prompt_install_result_label">User tapped install on the prompt.</string>
<string name="install_app_prompt_demo2_prompt_cancel_result_label">User dismissed the prompt.</string>

<!-- Counter screen -->
<string name="app_helper_counter_label">Counter: %1$s</string>
Expand Down
4 changes: 2 additions & 2 deletions datalayer/sample/wear/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
<string name="main_menu_apphelpers_nodes_actions_item">Nodes actions</string>

<!-- Counter screen -->
<string name="server_counter_message">Open the datalayer sample on your phone to observe how the counter number is incremented</string>
<string name="server_counter_message">Value of the counter from Phone</string>

<!-- Data Layer screen -->
<string name="data_layer_title">Data Layer</string>
<string name="data_layer_missing_message">Missing</string>
<string name="data_layer_error_message">Error: %1$s</string>
<string name="data_layer_value_message">Counter: %1$s</string>
<string name="data_layer_value_message">Value: %1$s</string>

<!-- App Helper Tracking screen -->
<string name="apphelper_tracking_title">AppHelper Tracking</string>
Expand Down

0 comments on commit b9e7289

Please sign in to comment.