Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add datalayer to README. Move Tile name to constant.Add exception if version format is not correct. #2130

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ the [Sign-In guidelines for Wear OS](https://developer.android.com/training/wear
- [sample wear](https://google.github.io/horologist/auth-sample-apps/#wear-sample): sample wear app to authenticate using different methods.
- [sample phone](https://google.github.io/horologist/auth-sample-apps/#phone-sample): sample phone app to authenticate using different methods.

## DataLayer

The Horologist DataLayer library, provide common abstractions on top of the
[Wearable DataLayer](https://developer.android.com/training/wearables/data/data-layer).
It includes libraries to build
[prompts on the phone](https://google.github.io/horologist/datalayer-phone-ui/) to improve
engagement with the correspondent Wear app and a
[sample](https://google.github.io/horologist/datalayer-sample/) to see the prompts in actions.
Find guidance in the project [documentation](https://google.github.io/horologist/datalayer/).

## ☰ Tiles

Kotlin coroutines flavoured TileService.
Expand Down
2 changes: 1 addition & 1 deletion datalayer/phone-ui/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ package com.google.android.horologist.datalayer.phone.ui.prompt.installtile {
@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class InstallTilePrompt {
ctor public InstallTilePrompt(com.google.android.horologist.datalayer.phone.PhoneDataLayerAppHelper phoneDataLayerAppHelper);
method public android.content.Intent getIntent(android.content.Context context, String appPackageName, @DrawableRes int image, String topMessage, String bottomMessage);
method public suspend Object? shouldDisplayPrompt(kotlin.coroutines.Continuation<? super com.google.android.horologist.data.apphelper.AppHelperNodeStatus>);
method public suspend Object? shouldDisplayPrompt(String tileName, kotlin.coroutines.Continuation<? super com.google.android.horologist.data.apphelper.AppHelperNodeStatus>);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class InstallTilePrompt(private val phoneDataLayerAppHelper: PhoneDataLay
* Returns a [AppHelperNodeStatus] that meets the criteria to show this prompt, otherwise
* returns null.
*/
private val tileName = "com.example.MediaPlayerTile"
public suspend fun shouldDisplayPrompt(): AppHelperNodeStatus? {
public suspend fun shouldDisplayPrompt(tileName: String): AppHelperNodeStatus? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, good catch.

if (phoneDataLayerAppHelper.checkCompanionVersionSupportTileEditing()
?.equals(AppHelperResultCode.APP_HELPER_RESULT_SUCCESS) == true
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ public class PhoneDataLayerAppHelper(
} else {
return AppHelperResultCode.APP_HELPER_RESULT_INVALID_COMPANION
}
} catch (e: PackageManager.NameNotFoundException) {
return AppHelperResultCode.APP_HELPER_RESULT_NO_COMPANION_FOUND
} catch (ex: Exception) {
when (ex) {
is PackageManager.NameNotFoundException, is IllegalArgumentException -> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about changing Version(version) to Version.parse(version) returning Version??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For follow up

return AppHelperResultCode.APP_HELPER_RESULT_NO_COMPANION_FOUND
}

else -> throw ex
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class InstallTilePromptDemoViewModel
_uiState.value = InstallTilePromptDemoScreenState.Loading

viewModelScope.launch {
val node = installTilePrompt.shouldDisplayPrompt()
val node = installTilePrompt.shouldDisplayPrompt(TILE_NAME)

_uiState.value = if (node != null) {
InstallTilePromptDemoScreenState.WatchFound(node.id)
Expand All @@ -82,6 +82,10 @@ class InstallTilePromptDemoViewModel
fun onPromptDismiss() {
_uiState.value = InstallTilePromptDemoScreenState.PromptDismissed
}

companion object {
private const val TILE_NAME = "com.example.MediaPlayerTile"
}
}

sealed class InstallTilePromptDemoScreenState {
Expand Down