feat(asr): 添加无网络对话框自定义布局
- 创建新的对话框布局文件 dialog_no_network.xml - 使用自定义布局替换原有的 AlertDialog 标题和消息设置 - 添加透明背景支持以改善对话框外观 - 保持原有的网络检查提示功能不变
这个提交包含在:
父节点
ac53fa1f86
当前提交
fe52fdd3f6
@ -192,12 +192,18 @@ object AsrHelper : OfflineCmdListener {
|
|||||||
val activity = runCatching { AppManager.getInstance().getActivity() }.getOrNull()
|
val activity = runCatching { AppManager.getInstance().getActivity() }.getOrNull()
|
||||||
?: return@post
|
?: return@post
|
||||||
if (activity.isFinishing || activity.isDestroyed) return@post
|
if (activity.isFinishing || activity.isDestroyed) return@post
|
||||||
|
|
||||||
|
val contentView = LayoutInflater.from(activity)
|
||||||
|
.inflate(R.layout.dialog_no_network, null)
|
||||||
|
|
||||||
noNetworkDialog = AlertDialog.Builder(activity)
|
noNetworkDialog = AlertDialog.Builder(activity)
|
||||||
.setTitle("当前无网络,请检查网络连接")
|
.setView(contentView)
|
||||||
.setMessage("语音输入“退出”,退出应用。或者输入“返回”,返回初始页面。")
|
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.create()
|
.create()
|
||||||
.also { it.show() }
|
.also { dialog ->
|
||||||
|
dialog.show()
|
||||||
|
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/tv_message"
|
||||||
|
android:layout_width="340dp"
|
||||||
|
android:layout_height="159dp"
|
||||||
|
android:background="@drawable/bg_dialog">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前无网络,请检查网络连接"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#40FF5E"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/iv"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="语音输入“退出”,退出应用。或者输入“返回”,返回初始页面。"
|
||||||
|
android:textColor="#40FF5E"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/iv"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
正在加载...
在新工单中引用
屏蔽一个用户