fix: 处理未知导航目标并调整接待按钮布局

- 在 NavController.goTo 中添加未知位置检查,若位置不存在则重定向到默认会议室
- 调整接待按钮的显示逻辑,当按钮可见时隐藏动画表情视图
- 修改接待按钮的布局约束和文本样式,使其在横竖屏下均占满宽度并增大字体
This commit is contained in:
2026-04-20 17:22:55 +08:00
parent ab37e39565
commit 8698dfacf2
4 changed files with 36 additions and 19 deletions

View File

@@ -174,7 +174,13 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
binding.animatedEmojiView.currentExpression = expression
},
setReceptionButtonVisible = { visible ->
binding.btnReception.visibility = if (visible) android.view.View.VISIBLE else android.view.View.GONE
if (visible) {
binding.btnReception.visibility = android.view.View.VISIBLE
binding.animatedEmojiView.visibility = android.view.View.GONE
} else {
binding.btnReception.visibility = android.view.View.GONE
binding.animatedEmojiView.visibility = android.view.View.VISIBLE
}
}
)
taskController.restoreState(

View File

@@ -14,7 +14,18 @@ class NavController(private val robot: Robot) {
}
fun goTo(location: String, backwards: Boolean = false): Boolean {
robot.goTo(location, backwards)
var targetLocation = location
val knownLocations = getAllLocations()
// Check if the location is known, ignoring case
val isKnown = knownLocations.any { it.equals(targetLocation, ignoreCase = true) }
if (!isKnown) {
Log.w(TAG, "Unknown location requested: $targetLocation, redirecting to 会议室")
targetLocation = "会议室"
}
robot.goTo(targetLocation, backwards)
return true
}

View File

@@ -66,16 +66,16 @@
<Button
android:id="@+id/btnReception"
style="@style/Widget.App.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:paddingStart="48dp"
android:paddingTop="16dp"
android:paddingEnd="48dp"
android:paddingBottom="16dp"
android:text="是的"
android:textSize="20sp"
android:text="是的,请带我去"
android:textSize="48sp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

View File

@@ -66,16 +66,16 @@
<Button
android:id="@+id/btnReception"
style="@style/Widget.App.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp"
android:paddingStart="48dp"
android:paddingTop="16dp"
android:paddingEnd="48dp"
android:paddingBottom="16dp"
android:text="是的"
android:textSize="20sp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:text="是的,请带我去"
android:textSize="48sp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />