.
This commit is contained in:
parent
0405629106
commit
964655af7f
@ -14,6 +14,9 @@ import androidx.activity.compose.setContent
|
|||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -22,6 +25,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.wear.compose.material.Button
|
||||||
import androidx.wear.compose.material.MaterialTheme
|
import androidx.wear.compose.material.MaterialTheme
|
||||||
import androidx.wear.compose.material.Text
|
import androidx.wear.compose.material.Text
|
||||||
import androidx.wear.compose.material.TimeText
|
import androidx.wear.compose.material.TimeText
|
||||||
@ -40,7 +44,9 @@ class MainActivity : ComponentActivity() , SensorEventListener {
|
|||||||
setTheme(android.R.style.Theme_DeviceDefault)
|
setTheme(android.R.style.Theme_DeviceDefault)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
WearApp("Android")
|
WearApp("Android",sendGestureToLauncher = { text ->
|
||||||
|
sendGestureToLauncher(text)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +59,6 @@ class MainActivity : ComponentActivity() , SensorEventListener {
|
|||||||
event?.let {
|
event?.let {
|
||||||
if (it.sensor.type == Sensor.TYPE_ACCELEROMETER) {
|
if (it.sensor.type == Sensor.TYPE_ACCELEROMETER) {
|
||||||
val x = it.values[0]
|
val x = it.values[0]
|
||||||
|
|
||||||
// 임계값(Threshold)을 약간 높여 오작동 방지
|
// 임계값(Threshold)을 약간 높여 오작동 방지
|
||||||
if (x > 20f) {
|
if (x > 20f) {
|
||||||
sendGestureToLauncher("/gesture/next")
|
sendGestureToLauncher("/gesture/next")
|
||||||
@ -74,7 +79,7 @@ class MainActivity : ComponentActivity() , SensorEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WearApp(greetingName: String) {
|
fun WearApp(greetingName: String,sendGestureToLauncher : (String) -> Unit = {}) {
|
||||||
LunarLauncherTheme {
|
LunarLauncherTheme {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -83,19 +88,49 @@ fun WearApp(greetingName: String) {
|
|||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
TimeText()
|
TimeText()
|
||||||
Greeting(greetingName = greetingName)
|
Greeting(greetingName = greetingName,
|
||||||
|
sendGestureToLauncher = {text ->
|
||||||
|
sendGestureToLauncher(text)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Greeting(greetingName: String) {
|
fun Greeting(greetingName: String, sendGestureToLauncher : (String) -> Unit = {}) {
|
||||||
Text(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
// Text(
|
||||||
textAlign = TextAlign.Center,
|
// modifier = Modifier.fillMaxWidth(),
|
||||||
color = MaterialTheme.colors.primary,
|
// textAlign = TextAlign.Center,
|
||||||
text = stringResource(R.string.hello_world, greetingName)
|
// color = MaterialTheme.colors.primary,
|
||||||
)
|
// text = stringResource(R.string.hello_world, greetingName)
|
||||||
|
// )
|
||||||
|
Column(Modifier.fillMaxWidth().fillMaxHeight()) {
|
||||||
|
Row(Modifier.fillMaxWidth().weight(0.5f)) {
|
||||||
|
Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = {
|
||||||
|
sendGestureToLauncher("/gesture/next")
|
||||||
|
}) {
|
||||||
|
Text("B1")
|
||||||
|
}
|
||||||
|
Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = {
|
||||||
|
sendGestureToLauncher("/gesture/prev")
|
||||||
|
}) {
|
||||||
|
Text("B2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row(Modifier.fillMaxWidth().weight(0.5f)) {
|
||||||
|
Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = {
|
||||||
|
sendGestureToLauncher("/gesture/back")
|
||||||
|
}) {
|
||||||
|
Text("B3")
|
||||||
|
}
|
||||||
|
Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = {
|
||||||
|
sendGestureToLauncher("/gesture/refresh")
|
||||||
|
}) {
|
||||||
|
Text("B4")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(device = WearDevices.SMALL_ROUND, showSystemUi = true)
|
@Preview(device = WearDevices.SMALL_ROUND, showSystemUi = true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user