public void displayAppRequests() { if (_webView == null) { return; } Utils.sendUiCommand(_webView, "clearAppRequests"); var app_pages = Node.customAppManager.getAppPages(); lock (app_pages) { foreach (CustomAppPage page in app_pages.Values) { if (page.accepted) { continue; } Friend f = FriendList.getFriend(page.hostUserAddress); CustomApp app = Node.customAppManager.getApp(page.appId); string text = f.nickname + " wants to use " + app.name + " with you."; Utils.sendUiCommand(_webView, "addAppRequest", Crypto.hashToString(page.sessionId), text); } if (VoIPManager.isInitiated() && !VoIPManager.currentCallAccepted) { Friend f = VoIPManager.currentCallContact; string text = f.nickname + " is calling you."; Utils.sendUiCommand(_webView, "addAppRequest", Crypto.hashToString(VoIPManager.currentCallSessionId), text); } } }
public void displayAppRequests() { if (_webView == null) { return; } Utils.sendUiCommand(_webView, "clearAppRequests"); var app_pages = Node.customAppManager.getAppPages(); lock (app_pages) { foreach (CustomAppPage page in app_pages.Values) { if (page.accepted) { continue; } Friend f = FriendList.getFriend(page.hostUserAddress); CustomApp app = Node.customAppManager.getApp(page.appId); string text = string.Format(SpixiLocalization._SL("global-app-wants-to-use"), f.nickname, app.name); Utils.sendUiCommand(_webView, "addAppRequest", Crypto.hashToString(page.sessionId), text, SpixiLocalization._SL("global-app-accept"), SpixiLocalization._SL("global-app-reject")); } if (VoIPManager.isInitiated()) { if (VoIPManager.currentCallAccepted) { if (VoIPManager.currentCallCalleeAccepted) { displayCallBar(VoIPManager.currentCallSessionId, SpixiLocalization._SL("global-call-in-call") + " - " + VoIPManager.currentCallContact.nickname, VoIPManager.currentCallStartedTime); } else { displayCallBar(VoIPManager.currentCallSessionId, SpixiLocalization._SL("global-call-dialing") + " " + VoIPManager.currentCallContact.nickname + "...", 0); } } else { Friend f = VoIPManager.currentCallContact; string text = SpixiLocalization._SL("global-call-incoming") + " - " + f.nickname; string accept_html = "<div style='background:#2fd63b;border-radius:16px;width:64px;height:64px;display:table-cell;vertical-align:middle;text-align:center;'><i class='fas fa-phone'></i></div>"; string reject_html = "<div style='background:#de0a61;border-radius:16px;width:64px;height:64px;display:table-cell;vertical-align:middle;text-align:center;'><i class='fas fa-phone-slash'></i></div>"; Utils.sendUiCommand(_webView, "addAppRequest", Crypto.hashToString(VoIPManager.currentCallSessionId), text, accept_html, reject_html); } } } }
private void onNavigating(object sender, WebNavigatingEventArgs e) { string current_url = HttpUtility.UrlDecode(e.Url); e.Cancel = true; if (current_url.Equals("ixian:onload", StringComparison.Ordinal)) { onLoad(); } else if (current_url.Equals("ixian:back", StringComparison.Ordinal)) { friend.chat_page = null; Navigation.PopAsync(Config.defaultXamarinAnimations); } else if (current_url.Equals("ixian:request", StringComparison.Ordinal)) { Navigation.PushAsync(new WalletReceivePage(friend), Config.defaultXamarinAnimations); } else if (current_url.Equals("ixian:details", StringComparison.Ordinal)) { Navigation.PushAsync(new ContactDetails(friend, true), Config.defaultXamarinAnimations); } else if (current_url.Equals("ixian:send", StringComparison.Ordinal)) { Navigation.PushAsync(new WalletSendPage(friend.walletAddress), Config.defaultXamarinAnimations); } else if (current_url.Equals("ixian:accept", StringComparison.Ordinal)) { onAcceptFriendRequest(); } else if (current_url.Equals("ixian:call", StringComparison.Ordinal)) { if (VoIPManager.isInitiated()) { VoIPManager.hangupCall(null); } else { VoIPManager.initiateCall(friend); } } else if (current_url.Equals("ixian:sendfile", StringComparison.Ordinal)) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed onSendFile(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } else if (current_url.Contains("ixian:acceptfile:")) { string id = current_url.Substring("ixian:acceptfile:".Length); FriendMessage fm = friend.messages.Find(x => x.transferId == id); if (fm != null) { onAcceptFile(fm); } else { Logging.error("Cannot find message with transfer id: {0}", id); } } else if (current_url.Contains("ixian:openfile:")) { string id = current_url.Substring("ixian:openfile:".Length); FriendMessage fm = friend.messages.Find(x => x.transferId == id); // Open file in default app. May not work, check https://forums.xamarin.com/discussion/103042/how-to-open-pdf-or-txt-file-in-default-app-on-xamarin-forms //Device.OpenUri(new Uri(transfer.filePath)); if (File.Exists(fm.filePath)) { DependencyService.Get <IFileOperations>().open(fm.filePath); } } else if (current_url.Contains("ixian:chat:")) { string msg = current_url.Substring("ixian:chat:".Length); onSend(msg); } else if (current_url.Contains("ixian:viewPayment:")) { string tx_id = current_url.Substring("ixian:viewPayment:".Length); onViewPayment(tx_id); } else if (current_url.Contains("ixian:app:")) { string app_id = current_url.Substring("ixian:app:".Length); onApp(app_id); } else if (current_url.StartsWith("ixian:appAccept:")) { string session_id = current_url.Substring("ixian:appAccept:".Length); onAppAccept(session_id); } else if (current_url.StartsWith("ixian:appReject:")) { string session_id = current_url.Substring("ixian:appReject:".Length); onAppReject(session_id); } else if (current_url.StartsWith("ixian:hangUp:")) { string session_id = current_url.Substring("ixian:hangUp:".Length); VoIPManager.hangupCall(Crypto.stringToHash(session_id)); } else { // Otherwise it's just normal navigation e.Cancel = false; return; } e.Cancel = true; }