mirror of
https://github.com/home-assistant/android
synced 2024-09-06 17:23:32 +00:00
Show server name in "Unable to connect to Home Assistant" dialog (#3995)
- Shows the server name instead of a generic "Home Assistant" to prevent confusion when the app cannot connect in the WebViewActivity, when using multiserver.
This commit is contained in:
parent
2da1a36c55
commit
ac7ba33ae7
|
@ -1215,8 +1215,14 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi
|
||||||
}
|
}
|
||||||
isShowingError = true
|
isShowingError = true
|
||||||
|
|
||||||
|
val serverName = if (serverManager.defaultServers.size > 1) presenter.getActiveServerName() else null
|
||||||
val alert = AlertDialog.Builder(this)
|
val alert = AlertDialog.Builder(this)
|
||||||
.setTitle(commonR.string.error_connection_failed)
|
.setTitle(
|
||||||
|
getString(
|
||||||
|
commonR.string.error_connection_failed_to,
|
||||||
|
serverName ?: getString(commonR.string.app_name)
|
||||||
|
)
|
||||||
|
)
|
||||||
.setOnDismissListener {
|
.setOnDismissListener {
|
||||||
isShowingError = false
|
isShowingError = false
|
||||||
alertDialog = null
|
alertDialog = null
|
||||||
|
|
|
@ -11,6 +11,7 @@ interface WebViewPresenter {
|
||||||
fun onViewReady(path: String?)
|
fun onViewReady(path: String?)
|
||||||
|
|
||||||
fun getActiveServer(): Int
|
fun getActiveServer(): Int
|
||||||
|
fun getActiveServerName(): String?
|
||||||
fun updateActiveServer()
|
fun updateActiveServer()
|
||||||
fun setActiveServer(id: Int)
|
fun setActiveServer(id: Int)
|
||||||
fun switchActiveServer(id: Int)
|
fun switchActiveServer(id: Int)
|
||||||
|
|
|
@ -117,6 +117,13 @@ class WebViewPresenterImpl @Inject constructor(
|
||||||
|
|
||||||
override fun getActiveServer(): Int = serverId
|
override fun getActiveServer(): Int = serverId
|
||||||
|
|
||||||
|
override fun getActiveServerName(): String? =
|
||||||
|
if (serverManager.isRegistered()) {
|
||||||
|
serverManager.getServer(serverId)?.friendlyName
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateActiveServer() {
|
override fun updateActiveServer() {
|
||||||
if (serverManager.isRegistered()) {
|
if (serverManager.isRegistered()) {
|
||||||
serverManager.getServer()?.let {
|
serverManager.getServer()?.let {
|
||||||
|
|
|
@ -244,6 +244,7 @@
|
||||||
<string name="entity_widget_desc">View any entity\'s current state and toggle it</string>
|
<string name="entity_widget_desc">View any entity\'s current state and toggle it</string>
|
||||||
<string name="error_auth_revoked">It appears that your authorization was revoked, please reconnect to Home Assistant.</string>
|
<string name="error_auth_revoked">It appears that your authorization was revoked, please reconnect to Home Assistant.</string>
|
||||||
<string name="error_connection_failed">Unable to connect to Home Assistant.</string>
|
<string name="error_connection_failed">Unable to connect to Home Assistant.</string>
|
||||||
|
<string name="error_connection_failed_to">Unable to connect to %1$s</string>
|
||||||
<string name="error_loading_entities">Error loading entities</string>
|
<string name="error_loading_entities">Error loading entities</string>
|
||||||
<string name="error_onboarding_connection_failed">Unable to connect to Home Assistant.</string>
|
<string name="error_onboarding_connection_failed">Unable to connect to Home Assistant.</string>
|
||||||
<string name="error_ssl">Unable to communicate with Home Assistant because of a SSL error. Please ensure your certificate is valid.</string>
|
<string name="error_ssl">Unable to communicate with Home Assistant because of a SSL error. Please ensure your certificate is valid.</string>
|
||||||
|
|
Loading…
Reference in a new issue