desktop: specifying port in connect remote host page (#3432)
* desktop: specifying port in connect remote host page * shorter string --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
parent
324f614e00
commit
0c1d78ab08
@ -1392,10 +1392,10 @@ object ChatController {
|
|||||||
chatModel.remoteHosts.addAll(hosts)
|
chatModel.remoteHosts.addAll(hosts)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun startRemoteHost(rhId: Long?, multicast: Boolean = false): Pair<RemoteHostInfo?, String>? {
|
suspend fun startRemoteHost(rhId: Long?, multicast: Boolean = false): Triple<RemoteHostInfo?, String, String>? {
|
||||||
val r = sendCmd(null, CC.StartRemoteHost(rhId, multicast))
|
val r = sendCmd(null, CC.StartRemoteHost(rhId, multicast))
|
||||||
if (r is CR.RemoteHostStarted) return r.remoteHost_ to r.invitation
|
if (r is CR.RemoteHostStarted) return Triple(r.remoteHost_, r.invitation, r.ctrlPort)
|
||||||
apiErrorAlert("listRemoteHosts", generalGetString(MR.strings.error_alert_title), r)
|
apiErrorAlert("startRemoteHost", generalGetString(MR.strings.error_alert_title), r)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1851,7 +1851,7 @@ object ChatController {
|
|||||||
generalGetString(MR.strings.remote_host_was_disconnected_toast).format(disconnectedHost.hostDeviceName.ifEmpty { disconnectedHost.remoteHostId.toString() })
|
generalGetString(MR.strings.remote_host_was_disconnected_toast).format(disconnectedHost.hostDeviceName.ifEmpty { disconnectedHost.remoteHostId.toString() })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (chatModel.remoteHostId == r.remoteHostId_) {
|
if (chatModel.remoteHostId() == r.remoteHostId_) {
|
||||||
chatModel.currentRemoteHost.value = null
|
chatModel.currentRemoteHost.value = null
|
||||||
switchUIRemoteHost(null)
|
switchUIRemoteHost(null)
|
||||||
}
|
}
|
||||||
@ -3774,7 +3774,7 @@ sealed class CR {
|
|||||||
// remote events (desktop)
|
// remote events (desktop)
|
||||||
@Serializable @SerialName("remoteHostList") class RemoteHostList(val remoteHosts: List<RemoteHostInfo>): CR()
|
@Serializable @SerialName("remoteHostList") class RemoteHostList(val remoteHosts: List<RemoteHostInfo>): CR()
|
||||||
@Serializable @SerialName("currentRemoteHost") class CurrentRemoteHost(val remoteHost_: RemoteHostInfo?): CR()
|
@Serializable @SerialName("currentRemoteHost") class CurrentRemoteHost(val remoteHost_: RemoteHostInfo?): CR()
|
||||||
@Serializable @SerialName("remoteHostStarted") class RemoteHostStarted(val remoteHost_: RemoteHostInfo?, val invitation: String): CR()
|
@Serializable @SerialName("remoteHostStarted") class RemoteHostStarted(val remoteHost_: RemoteHostInfo?, val invitation: String, val ctrlPort: String): CR()
|
||||||
@Serializable @SerialName("remoteHostSessionCode") class RemoteHostSessionCode(val remoteHost_: RemoteHostInfo?, val sessionCode: String): CR()
|
@Serializable @SerialName("remoteHostSessionCode") class RemoteHostSessionCode(val remoteHost_: RemoteHostInfo?, val sessionCode: String): CR()
|
||||||
@Serializable @SerialName("newRemoteHost") class NewRemoteHost(val remoteHost: RemoteHostInfo): CR()
|
@Serializable @SerialName("newRemoteHost") class NewRemoteHost(val remoteHost: RemoteHostInfo): CR()
|
||||||
@Serializable @SerialName("remoteHostConnected") class RemoteHostConnected(val remoteHost: RemoteHostInfo): CR()
|
@Serializable @SerialName("remoteHostConnected") class RemoteHostConnected(val remoteHost: RemoteHostInfo): CR()
|
||||||
|
@ -56,7 +56,7 @@ fun annotatedStringResource(id: StringResource): AnnotatedString {
|
|||||||
fun annotatedStringResource(id: StringResource, vararg args: Any?): AnnotatedString {
|
fun annotatedStringResource(id: StringResource, vararg args: Any?): AnnotatedString {
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
return remember(id) {
|
return remember(id) {
|
||||||
escapedHtmlToAnnotatedString(id.localized().format(args), density)
|
escapedHtmlToAnnotatedString(id.localized().format(args = args), density)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,8 @@ private fun ConnectMobileViewLayout(
|
|||||||
title: String,
|
title: String,
|
||||||
invitation: String?,
|
invitation: String?,
|
||||||
deviceName: String?,
|
deviceName: String?,
|
||||||
sessionCode: String?
|
sessionCode: String?,
|
||||||
|
port: String?
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||||
@ -169,13 +170,14 @@ private fun ConnectMobileViewLayout(
|
|||||||
) {
|
) {
|
||||||
AppBarTitle(title)
|
AppBarTitle(title)
|
||||||
SectionView {
|
SectionView {
|
||||||
if (invitation != null && sessionCode == null) {
|
if (invitation != null && sessionCode == null && port != null) {
|
||||||
QRCode(
|
QRCode(
|
||||||
invitation, Modifier
|
invitation, Modifier
|
||||||
.padding(start = DEFAULT_PADDING, top = DEFAULT_PADDING_HALF, end = DEFAULT_PADDING, bottom = DEFAULT_PADDING_HALF)
|
.padding(start = DEFAULT_PADDING, top = DEFAULT_PADDING_HALF, end = DEFAULT_PADDING, bottom = DEFAULT_PADDING_HALF)
|
||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
)
|
)
|
||||||
SectionTextFooter(annotatedStringResource(MR.strings.open_on_mobile_and_scan_qr_code))
|
SectionTextFooter(annotatedStringResource(MR.strings.open_on_mobile_and_scan_qr_code))
|
||||||
|
SectionTextFooter(annotatedStringResource(MR.strings.waiting_for_mobile_to_connect_on_port, port))
|
||||||
|
|
||||||
if (remember { controller.appPrefs.developerTools.state }.value) {
|
if (remember { controller.appPrefs.developerTools.state }.value) {
|
||||||
val clipboard = LocalClipboardManager.current
|
val clipboard = LocalClipboardManager.current
|
||||||
@ -232,6 +234,7 @@ fun connectMobileDevice(rh: RemoteHostInfo, connecting: MutableState<Boolean>) {
|
|||||||
private fun showAddingMobileDevice(connecting: MutableState<Boolean>) {
|
private fun showAddingMobileDevice(connecting: MutableState<Boolean>) {
|
||||||
ModalManager.start.showModalCloseable { close ->
|
ModalManager.start.showModalCloseable { close ->
|
||||||
val invitation = rememberSaveable { mutableStateOf<String?>(null) }
|
val invitation = rememberSaveable { mutableStateOf<String?>(null) }
|
||||||
|
val port = rememberSaveable { mutableStateOf<String?>(null) }
|
||||||
val pairing = remember { chatModel.newRemoteHostPairing }
|
val pairing = remember { chatModel.newRemoteHostPairing }
|
||||||
val sessionCode = when (val state = pairing.value?.second) {
|
val sessionCode = when (val state = pairing.value?.second) {
|
||||||
is RemoteHostSessionState.PendingConfirmation -> state.sessionCode
|
is RemoteHostSessionState.PendingConfirmation -> state.sessionCode
|
||||||
@ -247,7 +250,8 @@ private fun showAddingMobileDevice(connecting: MutableState<Boolean>) {
|
|||||||
title = if (cachedSessionCode == null) stringResource(MR.strings.link_a_mobile) else stringResource(MR.strings.verify_connection),
|
title = if (cachedSessionCode == null) stringResource(MR.strings.link_a_mobile) else stringResource(MR.strings.verify_connection),
|
||||||
invitation = invitation.value,
|
invitation = invitation.value,
|
||||||
deviceName = remoteDeviceName,
|
deviceName = remoteDeviceName,
|
||||||
sessionCode = cachedSessionCode
|
sessionCode = cachedSessionCode,
|
||||||
|
port = port.value
|
||||||
)
|
)
|
||||||
val oldRemoteHostId by remember { mutableStateOf(chatModel.currentRemoteHost.value?.remoteHostId) }
|
val oldRemoteHostId by remember { mutableStateOf(chatModel.currentRemoteHost.value?.remoteHostId) }
|
||||||
LaunchedEffect(remember { chatModel.currentRemoteHost }.value) {
|
LaunchedEffect(remember { chatModel.currentRemoteHost }.value) {
|
||||||
@ -266,6 +270,7 @@ private fun showAddingMobileDevice(connecting: MutableState<Boolean>) {
|
|||||||
if (r != null) {
|
if (r != null) {
|
||||||
connecting.value = true
|
connecting.value = true
|
||||||
invitation.value = r.second
|
invitation.value = r.second
|
||||||
|
port.value = r.third
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDispose {
|
onDispose {
|
||||||
@ -284,6 +289,7 @@ private fun showConnectMobileDevice(rh: RemoteHostInfo, connecting: MutableState
|
|||||||
ModalManager.start.showModalCloseable { close ->
|
ModalManager.start.showModalCloseable { close ->
|
||||||
val pairing = remember { chatModel.newRemoteHostPairing }
|
val pairing = remember { chatModel.newRemoteHostPairing }
|
||||||
val invitation = rememberSaveable { mutableStateOf<String?>(null) }
|
val invitation = rememberSaveable { mutableStateOf<String?>(null) }
|
||||||
|
val port = rememberSaveable { mutableStateOf<String?>(null) }
|
||||||
val sessionCode = when (val state = pairing.value?.second) {
|
val sessionCode = when (val state = pairing.value?.second) {
|
||||||
is RemoteHostSessionState.PendingConfirmation -> state.sessionCode
|
is RemoteHostSessionState.PendingConfirmation -> state.sessionCode
|
||||||
else -> null
|
else -> null
|
||||||
@ -298,6 +304,7 @@ private fun showConnectMobileDevice(rh: RemoteHostInfo, connecting: MutableState
|
|||||||
invitation = invitation.value,
|
invitation = invitation.value,
|
||||||
deviceName = pairing.value?.first?.hostDeviceName ?: rh.hostDeviceName,
|
deviceName = pairing.value?.first?.hostDeviceName ?: rh.hostDeviceName,
|
||||||
sessionCode = cachedSessionCode,
|
sessionCode = cachedSessionCode,
|
||||||
|
port = port.value
|
||||||
)
|
)
|
||||||
var remoteHostId by rememberSaveable { mutableStateOf<Long?>(null) }
|
var remoteHostId by rememberSaveable { mutableStateOf<Long?>(null) }
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
@ -307,6 +314,7 @@ private fun showConnectMobileDevice(rh: RemoteHostInfo, connecting: MutableState
|
|||||||
connecting.value = true
|
connecting.value = true
|
||||||
remoteHostId = rh_?.remoteHostId
|
remoteHostId = rh_?.remoteHostId
|
||||||
invitation.value = inv
|
invitation.value = inv
|
||||||
|
port.value = r.third
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaunchedEffect(remember { chatModel.currentRemoteHost }.value) {
|
LaunchedEffect(remember { chatModel.currentRemoteHost }.value) {
|
||||||
@ -343,7 +351,8 @@ private fun showConnectedMobileDevice(rh: RemoteHostInfo, disconnectHost: () ->
|
|||||||
title = stringResource(MR.strings.connected_to_mobile),
|
title = stringResource(MR.strings.connected_to_mobile),
|
||||||
invitation = null,
|
invitation = null,
|
||||||
deviceName = rh.hostDeviceName,
|
deviceName = rh.hostDeviceName,
|
||||||
sessionCode = sessionCode
|
sessionCode = sessionCode,
|
||||||
|
port = null,
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(DEFAULT_PADDING_HALF))
|
Spacer(Modifier.height(DEFAULT_PADDING_HALF))
|
||||||
SectionItemView(disconnectHost) {
|
SectionItemView(disconnectHost) {
|
||||||
|
@ -1662,7 +1662,8 @@
|
|||||||
<string name="remote_host_was_disconnected_toast"><![CDATA[Remote host was disconnected: <b>%s</b>]]></string>
|
<string name="remote_host_was_disconnected_toast"><![CDATA[Remote host was disconnected: <b>%s</b>]]></string>
|
||||||
<string name="disconnect_desktop_question">Disconnect desktop?</string>
|
<string name="disconnect_desktop_question">Disconnect desktop?</string>
|
||||||
<string name="only_one_device_can_work_at_the_same_time">Only one device can work at the same time</string>
|
<string name="only_one_device_can_work_at_the_same_time">Only one device can work at the same time</string>
|
||||||
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Open <i>Use from desktop</i> in mobile app and scan QR code]]></string>
|
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Open <i>Use from desktop</i> in mobile app and scan QR code.]]></string>
|
||||||
|
<string name="waiting_for_mobile_to_connect_on_port"><![CDATA[Waiting for mobile to connect on port <i>%s</i>]]></string>
|
||||||
<string name="bad_desktop_address">Bad desktop address</string>
|
<string name="bad_desktop_address">Bad desktop address</string>
|
||||||
<string name="desktop_incompatible_version">Incompatible version</string>
|
<string name="desktop_incompatible_version">Incompatible version</string>
|
||||||
<string name="desktop_app_version_is_incompatible">Desktop app version %s is not compatible with this app.</string>
|
<string name="desktop_app_version_is_incompatible">Desktop app version %s is not compatible with this app.</string>
|
||||||
|
@ -1465,7 +1465,7 @@
|
|||||||
<string name="new_mobile_device">Nuovo dispositivo mobile</string>
|
<string name="new_mobile_device">Nuovo dispositivo mobile</string>
|
||||||
<string name="desktop_address">Indirizzo desktop</string>
|
<string name="desktop_address">Indirizzo desktop</string>
|
||||||
<string name="only_one_device_can_work_at_the_same_time">Solo un dispositivo può funzionare nello stesso momento</string>
|
<string name="only_one_device_can_work_at_the_same_time">Solo un dispositivo può funzionare nello stesso momento</string>
|
||||||
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Apri <i>Usa dal desktop</i> nell\'app mobile e scansiona il codice QR]]></string>
|
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Apri <i>Usa dal desktop</i> nell\'app mobile e scansiona il codice QR.]]></string>
|
||||||
<string name="desktop_incompatible_version">Versione incompatibile</string>
|
<string name="desktop_incompatible_version">Versione incompatibile</string>
|
||||||
<string name="new_desktop"><![CDATA[<i>(nuovo)</i>]]></string>
|
<string name="new_desktop"><![CDATA[<i>(nuovo)</i>]]></string>
|
||||||
<string name="unlink_desktop_question">Scollegare il desktop?</string>
|
<string name="unlink_desktop_question">Scollegare il desktop?</string>
|
||||||
|
@ -1463,7 +1463,7 @@
|
|||||||
<string name="new_mobile_device">Nieuw mobiel apparaat</string>
|
<string name="new_mobile_device">Nieuw mobiel apparaat</string>
|
||||||
<string name="desktop_address">Desktop adres</string>
|
<string name="desktop_address">Desktop adres</string>
|
||||||
<string name="only_one_device_can_work_at_the_same_time">Er kan slechts één apparaat tegelijkertijd werken</string>
|
<string name="only_one_device_can_work_at_the_same_time">Er kan slechts één apparaat tegelijkertijd werken</string>
|
||||||
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Open <i>Gebruik vanaf desktop</i> in de mobiele app en scan de QR-code]]></string>
|
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[Open <i>Gebruik vanaf desktop</i> in de mobiele app en scan de QR-code.]]></string>
|
||||||
<string name="desktop_incompatible_version">Incompatibele versie</string>
|
<string name="desktop_incompatible_version">Incompatibele versie</string>
|
||||||
<string name="new_desktop"><![CDATA[<i>(nieuw)</i>]]></string>
|
<string name="new_desktop"><![CDATA[<i>(nieuw)</i>]]></string>
|
||||||
<string name="unlink_desktop_question">Desktop ontkoppelen?</string>
|
<string name="unlink_desktop_question">Desktop ontkoppelen?</string>
|
||||||
|
@ -1465,7 +1465,7 @@
|
|||||||
<string name="new_mobile_device">新移动设备</string>
|
<string name="new_mobile_device">新移动设备</string>
|
||||||
<string name="desktop_address">桌面地址</string>
|
<string name="desktop_address">桌面地址</string>
|
||||||
<string name="only_one_device_can_work_at_the_same_time">同一时刻只有一台设备可以工作</string>
|
<string name="only_one_device_can_work_at_the_same_time">同一时刻只有一台设备可以工作</string>
|
||||||
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[在移动应用中打开<i>从桌面使用</i>并扫描二维码]]></string>
|
<string name="open_on_mobile_and_scan_qr_code"><![CDATA[在移动应用中打开<i>从桌面使用</i>并扫描二维码.]]></string>
|
||||||
<string name="desktop_incompatible_version">不兼容的版本</string>
|
<string name="desktop_incompatible_version">不兼容的版本</string>
|
||||||
<string name="new_desktop"><![CDATA[<i>(新)</i>]]></string>
|
<string name="new_desktop"><![CDATA[<i>(新)</i>]]></string>
|
||||||
<string name="unlink_desktop_question">取消链接桌面端?</string>
|
<string name="unlink_desktop_question">取消链接桌面端?</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user