Skip to content

Commit

Permalink
Add App Helper Nodes screen on the datalayer phone sample app (#1916)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizgrp authored Jan 2, 2024
1 parent 4682ee1 commit be18b9c
Show file tree
Hide file tree
Showing 17 changed files with 763 additions and 344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ abstract class DataLayerAppHelper(
* apps are not being launched as a result of a background process on the calling device.
*/
protected fun checkIsForegroundOrThrow() {
val isForeground = activityManager.runningAppProcesses.find {
val runningAppProcesses = activityManager.runningAppProcesses ?: emptyList()
val isForeground = runningAppProcesses.find {
it.pid == Process.myPid()
}?.importance == IMPORTANCE_FOREGROUND
if (!isForeground) {
Expand Down
3 changes: 1 addition & 2 deletions datalayer/sample/phone/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
android:name=".screens.startremote.StartRemoteSampleActivity"
android:exported="false"
android:taskAffinity=".main"
android:theme="@style/Theme.Horologist">
</activity>
android:theme="@style/Theme.Horologist" />

<service android:name=".grpc.WearCounterDataService" android:exported="true"
tools:ignore="ExportedService">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,11 @@ package com.google.android.horologist.datalayer.sample
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
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.listnodes.ListNodesScreen
import com.google.android.horologist.datalayer.sample.screens.menu.MenuScreen
import com.google.android.horologist.datalayer.sample.screens.main.MainScreen
import com.google.android.horologist.datalayer.sample.ui.theme.HorologistTheme
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -47,7 +34,6 @@ class MainActivity : ComponentActivity() {

setContent {
HorologistTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
Expand All @@ -58,39 +44,3 @@ class MainActivity : ComponentActivity() {
}
}
}

@Composable
fun MainScreen(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
) {
Scaffold(
modifier = modifier,
) { padding ->
Column(
modifier = modifier
.fillMaxSize()
.padding(padding),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
NavHost(
navController = navController,
startDestination = Screen.MenuScreen.route,
modifier = modifier,
) {
composable(route = Screen.MenuScreen.route) {
MenuScreen(navController = navController)
}

composable(route = Screen.ListNodesScreen.route) {
ListNodesScreen()
}

composable(route = Screen.CounterScreen.route) {
CounterScreen()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ sealed class Screen(
val route: String,
) {
data object MenuScreen : Screen("menu")
data object ListNodesScreen : Screen("listNodes")
data object CounterScreen : Screen("counter")
data object AppHelperNodesScreen : Screen("appHelperNodesScreen")
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit be18b9c

Please sign in to comment.