예제 #1
0
        public MessagePage(Chat chat, DecryptedRecordData <MessageRecord> message) : base("MessagePage")
        {
            Subscribe <NewSecretKeyEvent>(NewSecretKey);

            _chat    = chat;
            _message = message;

            var transaction = message.Transaction;

            AddTitleRow("Title");

            AddHeaderRow("Message");

            var(text, detail) = ChatListView.GetMessageText(message);
            _text             = AddTextRow(null);
            _text.SetMultilineText(text, detail);

            AddFooterRow();

            AddHeaderRow("SecretKeyInfo");
            _keyView = new SecretKeyView(message.EncryptedRecord?.KeyInfo, true);
            AddViewRow(_keyView);
            AddButtonRow("Import", Import);
            AddFooterRow();

            AddHeaderRow("TransactionInfo");
            AddViewRow(new DataTransactionView(transaction));
            AddFooterRow();

            IsBusy = true;
            UIApp.Run(Update);
        }
예제 #2
0
        Task Share(ButtonRow arg)
        {
            var code = AppBase.Current.GetRequestCode(_node.ServiceNode, MessageServiceInfo.MessageDataChainIndex, ViewFriendSchemeAction.ActionName, _node.AccountId);

            UIApp.Share(code);
            return(Task.CompletedTask);
        }
예제 #3
0
        public TestPage() : base("TestPage")
        {
            if (UIApp.IsUWP)
            {
                NavigationPage.SetHasNavigationBar(this, false);
            }

            AddHeaderRow();
            AddButtonRow("Start", Start);
            AddButtonRow("Close", Close, true);
            AddFooterRow();

            var closeItem = new ExtToolbarItem("Close", null, async() =>
            {
                await Close(null);
            });

            ToolbarItems.Add(closeItem);

            UIApp.Run(async() =>
            {
                await Task.Delay(100);
                await Start(null);
            });
        }
예제 #4
0
        public void DecryptMessageRows()
        {
            UIApp.Run(async () =>
            {
                var rows = Rows;
                foreach (var row in rows)
                {
                    var message = row.Tag as DecryptedRecordData<MessageRecord>;

                    if (message.Record == null)
                        await message.Decrypt();

                    var (text, detail) = GetMessageText(message);

                    var invalid = message.DecryptetState != DecryptedDataRecordState.Decrypted;
                    if (invalid)
                    {
                        row.Label.FormattedText.Spans[0].SetColorStyle(Theme.ErrorColor);
                    }
                    else
                    {
                        row.Label.FormattedText.Spans[0].SetColorStyle(Theme.TextColor);
                    }

                    row.Label.FormattedText.Spans[0].Text = text;
                    row.Label.FormattedText.Spans[1].Text = $"\n{detail}";
                }

                _page.UpdateSuspendedLayout();
            });
        }
예제 #5
0
        public static async Task TaskAction(ExtContentPage page, TodoTask todoTask, TodoList todoList)
        {
            var submitAccount = TodoApp.Current.GetLastUsedSubmitAccount <SubmitAccount>(todoList.ListId.ToString());

            if (submitAccount == null || !todoList.IsLastUsedSecretKey(submitAccount) || todoTask.Status != TodoTaskStatusTypes.Open)
            {
                await page.Navigation.PushAsync(new TodoTaskPage(todoList, todoTask));
            }
            else
            {
                var editItem = Tr.Get("TodoListView.EditItem");
                var markDone = Tr.Get("TodoListView.MarkDone");

                var result = await page.DisplayActionSheet(Tr.Get("TodoListView.ItemTitle"), Tr.Get("Common.Cancel"), null, markDone, editItem);

                if (result == markDone)
                {
                    if (await page.ConfirmTextAsync(Tr.Get("TodoListView.ConfirmStatus")))
                    {
                        page.IsBusy = true;
                        UIApp.Run(() => TodoApp.Current.UpdateTodoItemStatus(submitAccount, TodoTaskStatusTypes.Closed, todoList, todoTask));
                    }
                }
                else if (result == editItem)
                {
                    await page.Navigation.PushAsync(new TodoTaskPage(todoList, todoTask));
                }
            }
        }
예제 #6
0
        Task ServiceNodeChanged(ServiceNodeButtonRow obj)
        {
            IsBusy = true;
            RemoveHeaderSection("Friends");
            UIApp.Run(Update);

            return(Task.CompletedTask);
        }
예제 #7
0
 async Task Delete(ButtonRow button)
 {
     if (await ConfirmAsync("ConfirmDelete"))
     {
         IsBusy = true;
         UIApp.Run(() => TodoApp.Current.DeleteList(_submitAccount.SubmitAccount, TodoList));
     }
 }
예제 #8
0
        protected override async Task ServiceNodesLoaded(ServiceNodesLoadedEvent arg)
        {
            await base.ServiceNodesLoaded(arg);

            await UIApp.Current.SetFinishedLoading();

            UIApp.Run(() => DownloadNoteData(false));
        }
예제 #9
0
        Task Copy(ButtonRow arg)
        {
            var code = AppBase.Current.GetRequestCode(_node.ServiceNode, MessageServiceInfo.MessageDataChainIndex, ViewFriendSchemeAction.ActionName, _node.AccountId);

            UIApp.CopyToClipboard(code);
            Toast("Copied");
            return(Task.CompletedTask);
        }
예제 #10
0
 async Task Unfriend(ButtonRow arg)
 {
     if (await ConfirmAsync("ConfirmUnfriend"))
     {
         IsBusy = true;
         UIApp.Run(() => _node.Unfriend(_friendAccountId));
     }
 }
예제 #11
0
        async Task Rename(ButtonRow arg)
        {
            IsBusy = true;

            if (await ConfirmAsync("RenameConfirm"))
            {
                UIApp.Run(() => _node.RenameInbox(_inboxItem.KeyIndex, _titleRow.Edit.Text));
            }
        }
예제 #12
0
        Task Submit(ButtonRow arg)
        {
            var text = _text.Edit.Text;

            if (!string.IsNullOrEmpty(text))
            {
                IsBusy = true;

                UIApp.Run(() => _node.SendMessage(_chat, text));
            }

            return(Task.CompletedTask);
        }
예제 #13
0
        async Task Name(ButtonRow button)
        {
            if (!await TodoPage.CheckSecretKey(TodoList, _submitAccount.SubmitAccount, this))
            {
                return;
            }

            var name = _nameEntry.Edit.Text;

            if (!string.IsNullOrEmpty(name) && !(name == TodoList.Name) && await ConfirmAsync("ConfirmName"))
            {
                IsBusy = true;
                UIApp.Run(() => TodoApp.Current.UpdateListName(_submitAccount.SubmitAccount, TodoList, name));
            }
        }
예제 #14
0
        public InboxesPage() : base("InboxesPage")
        {
            Subscribe <InboxRecordDownloadEvent>(InboxDownload);

            IsSuspendedLayout = true;

            AddTitleRow("Title");

            AddHeaderRow("Common.ServiceNode");
            _serviceNodeButton = AddRow(new ServiceNodeButtonRow(this, ServiceNodesPageSelectionFlags.ActiveRequired, "inboxes"));
            _serviceNodeButton.SelectionChanged = ServiceNodeChanged;
            AddInfoRow("Common.ServiceNodeInfo");
            AddFooterRow();

            IsBusy = true;

            UIApp.Run(Update);
        }
예제 #15
0
        public override void UpdateSubmitAccounts()
        {
            var index = NoteServiceInfo.NoteIndex;

            foreach (var serviceNode in ServiceNodeManager.Current.ServiceNodes)
            {
                foreach (var serviceAccount in serviceNode.ServiceAccounts.Values)
                {
                    var keyIndex = serviceAccount.KeyIndex;

                    if (!serviceNode.HasSubmitAccount(keyIndex, index))
                    {
                        serviceNode.AddSubmitAccount(new SubmitAccount(serviceNode, keyIndex, index, true));
                    }
                }
            }

            UIApp.Run(GenerateDefaultSecretKeys);
        }
예제 #16
0
        async Task Inbox(ButtonRow arg)
        {
            var node = _node;

            if (node == null)
            {
                return;
            }

            var edit   = T("EditName");
            var share  = T("Share");
            var copy   = T("Copy");
            var cancel = Tr.Get("Common.Cancel");

            var actions = new List <string> {
                edit, copy
            };

            if (UIApp.CanShare)
            {
                actions.Add(share);
            }

            var record = arg.Tag as InboxNameRecordInfo;
            var result = await DisplayActionSheet(Tr.Get("Common.Action"), cancel, null, actions.ToArray());

            if (result == edit)
            {
                await Navigation.PushAsync(new EditInboxPage(node, arg.Tag as InboxNameRecordInfo));
            }
            else if (result == copy)
            {
                var code = AppBase.Current.GetRequestCode(node.ServiceNode, MessageServiceInfo.MessageDataChainIndex, ViewFriendSchemeAction.ActionName, node.AccountId, record.KeyIndex);
                UIApp.CopyToClipboard(code);
                Toast("Copied");
            }
            else if (result == share)
            {
                var code = AppBase.Current.GetRequestCode(_node.ServiceNode, MessageServiceInfo.MessageDataChainIndex, ViewFriendSchemeAction.ActionName, _node.AccountId, record.KeyIndex);
                UIApp.Share(code);
            }
        }
예제 #17
0
 public SettingsPage()
 {
     IsSuspendedLayout = true;
     UIApp.Run(Update);
 }
예제 #18
0
 public override void OnOpen()
 {
     IsBusy = true;
     UIApp.Run(Update);
 }
예제 #19
0
        public ChatPage(Chat chat) : base("ChatPage")
        {
            Subscribe <MessageSentEvent>(MessageSent);
            Subscribe <ChatMessageDownloadEvent>(MessagesDownloaded);

            IsSuspendedLayout = true;

            _node = chat.Node;
            _chat = chat;

            var title = AddTitleRow("Title");

            var friend = chat.Node.GetFriend(chat.FriendAccountId);
            var name   = friend?.Profile?.RealName;

            if (name == null)
            {
                name = $"Account {chat.FriendAccountId}";
            }

            title.Label.Text = name;
            SetTitle(name);

            _text = new EntryRow(Icons.StickyNote);
            _text.Edit.Placeholder = T("TypeText");
            _text.SetDetailViewIcon(Icons.Pencil);

            _text.RowLayout.Children.Remove(_text.FontIcon);
            _text.RowLayout.Children.Remove(_text.Label);

            _text.VerticalOptions   = LayoutOptions.FillAndExpand;
            _text.HorizontalOptions = LayoutOptions.FillAndExpand;

            _submit                 = new ButtonRow(Icons.RowSubmit, Submit);
            _submit.RowStyle        = Theme.SubmitButton;
            _submit.FontIcon.Margin = new Thickness(0, 0, 0, 0);
            _submit.WidthRequest    = _submit.HeightRequest = 40;

            AbsoluteLayout.SetLayoutBounds(_submit.FontIcon, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            Status.AddBusyView(_submit);
            Status.AddBusyView(_text);

            _text.Edit.TextChanged += Edit_TextChanged;
            Edit_TextChanged(_text.Edit, null);

            var layout = new StackLayout();

            layout.Orientation = StackOrientation.Horizontal;

            layout.Children.Add(_text);
            layout.Children.Add(_submit);

            AddView(layout);

            _listView = new ChatListView(chat, this, layout);

            ToolbarItems.Add(new ExtToolbarItem(T("Info"), null, Info));

            IsBusy = true;
            UIApp.Run(Update);
        }
예제 #20
0
 Task ServiceNodeChanged(ServiceNodeButtonRow obj)
 {
     IsBusy = true;
     UIApp.Run(Update);
     return(Task.CompletedTask);
 }
예제 #21
0
        public ContactPage(MessageNode node, long friendAccountId, short keyIndex = -1, Chat chat = null) : base("ContactPage")
        {
            Subscribe <ProfileDataResultEvent>(ProfileData);
            Subscribe <UnfriendEvent>(Unfriend);

            _node            = node;
            _chat            = chat;
            _friendAccountId = friendAccountId;
            _friendKeyIndex  = keyIndex;

            AddTitleRow("Title");

            if (!_self)
            {
                if (_chat == null)
                {
                    var friend     = node.GetFriend(friendAccountId);
                    var invitation = node.GetInvitation(friendAccountId);

                    if (invitation != null)
                    {
                        AddHeaderRow("PendingInvitation");

                        if (invitation.HasFriendAccountApproval)
                        {
                            var row = AddButtonRow("ApproveButton", Approve);
                            row.SetDetailViewIcon(Icons.UserPlus);
                            row.Tag = invitation;
                        }

                        if (invitation.HasAccountApproval)
                        {
                            var row = AddButtonRow("AwaitingApprovalButton", Awaiting);
                            row.SetDetailViewIcon(Icons.UserClock);
                            row.Tag = invitation;
                        }

                        AddInfoRow("PendingInvitationInfo");
                        AddFooterRow();
                    }

                    if (friend == null && invitation == null)
                    {
                        AddHeaderRow("Invitation");

                        var b = AddButtonRow("InviteButton", Invite);
                        b.SetDetailViewIcon(Icons.UserPlus);
                        AddInfoRow("InvitationInfo");

                        AddFooterRow();
                    }

                    var chats = _node.GetChats(_friendAccountId);
                    if (chats.Count > 0)
                    {
                        AddHeaderRow("Chats");

                        foreach (var c in chats)
                        {
                            var b = AddButtonRow(Time.DateTimeString(c.LastTimestamp), OpenChat);
                            b.SetDetailViewIcon(Icons.Comments);
                            b.Tag = c;
                        }

                        AddFooterRow();
                    }

                    if (friend != null)
                    {
                        AddHeaderRow("Misc");

                        var button = AddButtonRow("Unfriend", Unfriend);
                        button.RowStyle = Theme.CancelButton;
                        button.SetDetailViewIcon(Icons.UserSlash);

                        AddFooterRow();
                    }
                }
                else
                {
                    AddHeaderRow("NofificationHeader");

                    var _notification = AddSwitchRow("Notification");
                    _notification.Switch.IsToggled    = UIApp.Current.IsPushChannelSubscribed(_chat.Index);
                    _notification.Switch.ToggledAsync = Notification_Toggled;
                    _notification.SetDetailViewIcon(Icons.Bell);

                    AddFooterRow();


                    AddHeaderRow("Misc");

                    var button = AddButtonRow("ViewInboxes", ViewInboxes);
                    button.SetDetailViewIcon(Icons.Inbox);

                    button = AddButtonRow("ManageSecretKeys", ManageSecretKeys);
                    button.SetDetailViewIcon(Icons.Key);

                    button = AddButtonRow("RemoveChat", RemoveChat);
                    button.SetDetailViewIcon(Icons.CommentSlash);

                    button          = AddButtonRow("Unfriend", Unfriend);
                    button.RowStyle = Theme.CancelButton;
                    button.SetDetailViewIcon(Icons.UserSlash);

                    AddFooterRow();
                }
            }
            else
            {
                AddHeaderRow("Misc");

                AddButtonRow("InboxesPage.Inboxes", Inboxes).SetDetailViewIcon(Icons.Inbox);

                if (UIApp.CanShare)
                {
                    var b = AddButtonRow("Share", Share);
                    b.SetDetailViewIcon(Icons.Share);
                }
                var button = AddButtonRow("Copy", Copy);
                button.SetDetailViewIcon(Icons.Copy);

                AddFooterRow();
            }

            IsBusy = true;
            UIApp.Run(Update);
        }