Exemplo n.º 1
0
        private async void ThemeDeleteExecute(ThemeCustomInfo theme)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.DeleteThemeAlert, Strings.Resources.AppName, Strings.Resources.Delete, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            try
            {
                var file = await StorageFile.GetFileFromPathAsync(theme.Path);

                await file.DeleteAsync();
            }
            catch { }

            if (Settings.Appearance[Settings.Appearance.RequestedTheme].Custom == theme.Path)
            {
                await SetThemeAsync(new ThemeBundledInfo { Parent = theme.Parent });
            }
            else
            {
                await RefreshThemesAsync();
            }
        }
Exemplo n.º 2
0
    private void GetMerchantsPageAndFill(int page)
    {
        MerchantElement[] merchantsList = merchantListParent.GetComponentsInChildren <MerchantElement>(false);
        foreach (var m in merchantsList)
        {
            DestroyImmediate(m.gameObject);
        }

        GetMerchantsRequest request = new GetMerchantsRequest()
        {
            CustomerKey = MundiPaggSession.CurrentSession.CustomerKey,
            PageNumber  = page,
            PageSize    = 10
        };

        MundiPaggClientAPI.GetMerchants(request,
                                        result =>
        {
            merchantsResult = result;

            SetupMerchantsResult();
            UpdatePaginationView();
        },
                                        error =>
        {
            MessagePopup.Open(error.ErrorCode.ToString(), error.GetErrorMessage());
        }
                                        );
    }
Exemplo n.º 3
0
        //public static void ProcessError(IDispatcherWrapper fragment, Error error, Type request, params object[] args)
        //{
        //    if (error.Code == 406 || error.Message == null)
        //    {
        //        return null;
        //    }

        //    if (request is TL_account_saveSecureValue || request is TL_account_getAuthorizationForm)
        //    {
        //        if (error.Message.Contains("PHONE_NUMBER_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidPhoneNumber);
        //        }
        //        else if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred + "\n" + error.Message);
        //        }
        //    }
        //    else if (request is TL_channels_joinChannel ||
        //     request is TL_channels_editAdmin ||
        //     request is TL_channels_inviteToChannel ||
        //     request is TL_messages_addChatUser ||
        //     request is TL_messages_startBot ||
        //     request is TL_channels_editBanned)
        //    {
        //        if (fragment != null)
        //        {
        //            ShowAddUserAlert(error.Message, fragment, (Boolean)args[0]);
        //        }
        //        else
        //        {
        //            if (error.Message.equals("PEER_FLOOD"))
        //            {
        //                NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.needShowAlert, 1);
        //            }
        //        }
        //    }
        //    else if (request is TL_messages_createChat)
        //    {
        //        if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowFloodWaitAlert(fragment, error.Message);
        //        }
        //        else
        //        {
        //            ShowAddUserAlert(fragment, error.Message, false);
        //        }
        //    }
        //    else if (request is TL_channels_createChannel)
        //    {
        //        if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowFloodWaitAlert(fragment, error.Message);
        //        }
        //        else
        //        {
        //            ShowAddUserAlert(fragment, error.Message, false);
        //        }
        //    }
        //    else if (request is TL_messages_editMessage)
        //    {
        //        if (!error.Message.Equals("MESSAGE_NOT_MODIFIED"))
        //        {
        //            if (fragment != null)
        //            {
        //                ShowSimpleAlert(fragment, Strings.Resources.EditMessageError);
        //            }
        //            else
        //            {
        //                ShowSimpleToast(fragment, Strings.Resources.EditMessageError);
        //            }
        //        }
        //    }
        //    else if (request is TL_messages_sendMessage ||
        //              request is TL_messages_sendMedia ||

        //              request is TL_messages_sendBroadcast ||
        //              request is TL_messages_sendInlineBotResult ||

        //              request is TL_messages_forwardMessages)
        //    {
        //        if (error.Message.Equals("PEER_FLOOD"))
        //        {
        //            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.needShowAlert, 0);
        //        }
        //    }
        //    else if (request is TL_messages_importChatInvite)
        //    {
        //        if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else if (error.Message.Equals("USERS_TOO_MUCH"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.JoinToGroupErrorFull);
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.JoinToGroupErrorNotExist);
        //        }
        //    }
        //    else if (request is TL_messages_getAttachedStickers)
        //    {
        //        if (fragment != null && fragment.getParentActivity() != null)
        //        {
        //            Toast.makeText(fragment.getParentActivity(), Strings.Resources.ErrorOccurred + "\n" + error.text, Toast.LENGTH_SHORT).show();
        //        }
        //    }
        //    else if (request is TL_account_confirmPhone || request is TL_account_verifyPhone || request is TL_account_verifyEmail)
        //    {
        //        if (error.Message.Contains("PHONE_CODE_EMPTY") || error.Message.Contains("PHONE_CODE_INVALID") || error.Message.Contains("CODE_INVALID") || error.Message.Contains("CODE_EMPTY"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidCode);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EXPIRED") || error.Message.Contains("EMAIL_VERIFY_EXPIRED"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.CodeExpired);
        //        }
        //        else if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, error.Message);
        //        }
        //    }
        //    else if (request is TL_auth_resendCode)
        //    {
        //        if (error.Message.Contains("PHONE_NUMBER_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidPhoneNumber);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EMPTY") || error.Message.Contains("PHONE_CODE_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidCode);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EXPIRED"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.CodeExpired);
        //        }
        //        else if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else if (error.Code != -1000)
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred + "\n" + error.Message);
        //        }
        //    }
        //    else if (request is TL_account_sendConfirmPhoneCode)
        //    {
        //        if (error.Code == 400)
        //        {
        //            return ShowSimpleAlert(fragment, Strings.Resources.CancelLinkExpired);
        //        }
        //        else if (error.Message != null)
        //        {
        //            if (error.Message.StartsWith("FLOOD_WAIT"))
        //            {
        //                return ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //            }
        //            else
        //            {
        //                return ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred);
        //            }
        //        }
        //    }
        //    else if (request is TL_account_changePhone)
        //    {
        //        if (error.Message.Contains("PHONE_NUMBER_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidPhoneNumber);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EMPTY") || error.Message.Contains("PHONE_CODE_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidCode);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EXPIRED"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.CodeExpired);
        //        }
        //        else if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, error.Message);
        //        }
        //    }
        //    else if (request is TL_account_sendChangePhoneCode)
        //    {
        //        if (error.Message.Contains("PHONE_NUMBER_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidPhoneNumber);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EMPTY") || error.Message.Contains("PHONE_CODE_INVALID"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.InvalidCode);
        //        }
        //        else if (error.Message.Contains("PHONE_CODE_EXPIRED"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.CodeExpired);
        //        }
        //        else if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else if (error.Message.StartsWith("PHONE_NUMBER_OCCUPIED"))
        //        {
        //            ShowSimpleAlert(fragment, LocaleController.formatString("ChangePhoneNumberOccupied", R.string.ChangePhoneNumberOccupied, (String)args[0]));
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred);
        //        }
        //    }
        //    else if (request is TL_updateUserName)
        //    {
        //        switch (error.Message)
        //        {
        //            case "USERNAME_INVALID":
        //                ShowSimpleAlert(fragment, Strings.Resources.UsernameInvalid);
        //                break;
        //            case "USERNAME_OCCUPIED":
        //                ShowSimpleAlert(fragment, Strings.Resources.UsernameInUse);
        //                break;
        //            default:
        //                ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred);
        //                break;
        //        }
        //    }
        //    else if (request is TL_contacts_importContacts)
        //    {
        //        if (error == null || error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.FloodWait);
        //        }
        //        else
        //        {
        //            ShowSimpleAlert(fragment, Strings.Resources.ErrorOccurred + "\n" + error.Message);
        //        }
        //    }
        //    else if (request is TL_account_getPassword || request is TL_account_getTmpPassword)
        //    {
        //        if (error.Message.StartsWith("FLOOD_WAIT"))
        //        {
        //            ShowSimpleToast(fragment, getFloodWaitString(error.Message));
        //        }
        //        else
        //        {
        //            ShowSimpleToast(fragment, error.Message);
        //        }
        //    }
        //    else if (request is TL_payments_sendPaymentForm)
        //    {
        //        switch (error.Message)
        //        {
        //            case "BOT_PRECHECKOUT_FAILED":
        //                ShowSimpleToast(fragment, Strings.Resources.PaymentPrecheckoutFailed);
        //                break;
        //            case "PAYMENT_FAILED":
        //                ShowSimpleToast(fragment, Strings.Resources.PaymentFailed);
        //                break;
        //            default:
        //                ShowSimpleToast(fragment, error.Message);
        //                break;
        //        }
        //    }
        //    else if (request is TL_payments_validateRequestedInfo)
        //    {
        //        switch (error.Message)
        //        {
        //            case "SHIPPING_NOT_AVAILABLE":
        //                ShowSimpleToast(fragment, Strings.Resources.PaymentNoShippingMethod);
        //                break;
        //            default:
        //                ShowSimpleToast(fragment, error.Message);
        //                break;
        //        }
        //    }
        //}

        private static async void ShowPeerFloodAlert(IDispatcherContext fragment, int reason)
        {
            var dialog = new MessagePopup();

            dialog.Title             = Strings.Resources.AppName;
            dialog.PrimaryButtonText = Strings.Resources.OK;

            if (reason != 2)
            {
                dialog.SecondaryButtonText   = Strings.Resources.MoreInfo;
                dialog.SecondaryButtonClick += (s, args) =>
                {
                    MessageHelper.NavigateToUsername(null, null, "spambot", null, null, null, null);
                };
            }

            if (reason == 0)
            {
                dialog.Message = Strings.Resources.NobodyLikesSpam1;
            }
            else if (reason == 1)
            {
                dialog.Message = Strings.Resources.NobodyLikesSpam2;
            }
            else if (reason == 2)
            {
                //builder.setMessage((String)args[1]);
            }

            await dialog.ShowQueuedAsync();
        }
Exemplo n.º 4
0
        public async Task <bool> CheckDeviceAccessAsync()
        {
            var access = DeviceAccessInformation.CreateFromDeviceClass(DeviceClass.Location);

            if (access.CurrentStatus == DeviceAccessStatus.Unspecified)
            {
                var accessStatus = await Geolocator.RequestAccessAsync();

                if (accessStatus == GeolocationAccessStatus.Allowed)
                {
                    return(true);
                }

                return(false);
            }
            else if (access.CurrentStatus != DeviceAccessStatus.Allowed)
            {
                var message = Strings.Resources.PermissionNoLocationPosition;

                var confirm = await MessagePopup.ShowAsync(message, Strings.Resources.AppName, Strings.Resources.PermissionOpenSettings, Strings.Resources.OK);

                if (confirm == ContentDialogResult.Primary)
                {
                    await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                }

                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
    private void OpenAndSetupSalePopup()
    {
        salePopup.Open();
        salePopup.OnSaleClick =
            creditCardTransaction =>
        {
            SaleRequest request = new SaleRequest()
            {
                MerchantKey = currentMerchant.MerchantKey,
                CreditCardTransactionCollection = new CreditCardTransaction[] { creditCardTransaction }
            };
            MundiPaggClientAPI.Sale(request,
                                    result =>
            {
                salePopup.Close();

                float transactionCost = creditCardTransaction.AmountInCents / 100f;
                CreditCardTransactionResult transactionResult = result.CreditCardTransactionResultCollection[0];

                if (transactionResult.Success)
                {
                    MessagePopup.Open("Sucesso", string.Format("Compra de R$ {0:0.00} efetuada com sucesso!", transactionCost));
                }
                else
                {
                    MessagePopup.Open("Erro", transactionResult.AcquirerMessage);
                }
            },
                                    error =>
            {
                MessagePopup.Open(error.ErrorCode.ToString(), error.GetErrorMessage());
            }
                                    );
        };
    }
Exemplo n.º 6
0
        public virtual void OnNewPlayStop(Category category)
        {
            int  diff;
            Time stopTime = new Time {
                MSeconds = (int)player.CurrentTime
            };

            Log.Debug("New play stop time: " + stopTime);
            diff = stopTime.MSeconds - startTime.MSeconds;

            if (diff < 0)
            {
                MessagePopup.PopupMessage(mainWindow, MessageType.Warning,
                                          Catalog.GetString("The stop time is smaller than the start time. " +
                                                            "The play will not be added."));
                return;
            }
            if (diff < 500)
            {
                int correction = 500 - diff;
                if (startTime.MSeconds - correction > 0)
                {
                    startTime = startTime - correction;
                }
                else
                {
                    stopTime = stopTime + correction;
                }
            }
            AddNewPlay(startTime, stopTime, category);
        }
Exemplo n.º 7
0
        private async void DisableExecute()
        {
            var state = _passwordState;

            if (state == null)
            {
                return;
            }

            var message = Strings.Resources.TurnPasswordOffQuestion;

            if (state.HasPassportData)
            {
                message += Environment.NewLine + Environment.NewLine + Strings.Resources.TurnPasswordOffPassport;
            }

            var confirm = await MessagePopup.ShowAsync(message, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var response = await ProtoService.SendAsync(new SetPassword(_password, string.Empty, string.Empty, false, string.Empty));

            if (response is PasswordState passwordState)
            {
                Update(passwordState, false);
            }
            else
            {
            }
        }
        private async void ForgotExecute()
        {
            if (_parameters == null)
            {
                // TODO: ...
                return;
            }

            if (_parameters.HasRecoveryEmailAddress)
            {
                IsLoading = true;

                var response = await ProtoService.SendAsync(new RequestAuthenticationPasswordRecovery());

                if (response is Error error)
                {
                    IsLoading = false;
                    await MessagePopup.ShowAsync(error.Message, Strings.Resources.AppName, Strings.Resources.OK);
                }
            }
            else
            {
                await MessagePopup.ShowAsync(Strings.Resources.RestorePasswordNoEmailText, Strings.Resources.RestorePasswordNoEmailTitle, Strings.Resources.OK);

                IsResettable = true;
            }
        }
Exemplo n.º 9
0
        private void AddNewPlay(Time start, Time stop, Category category)
        {
            Pixbuf miniature;

            Log.Debug(String.Format("New play created start:{0} stop:{1} category:{2}",
                                    start, stop, category));
            /* Get the current frame and get a thumbnail from it */
            if (projectType == ProjectType.CaptureProject)
            {
                if (!capturer.Capturing)
                {
                    MessagePopup.PopupMessage(capturer, MessageType.Info,
                                              Catalog.GetString("You can't create a new play if the capturer " +
                                                                "is not recording."));
                    return;
                }
                miniature = capturer.CurrentMiniatureFrame;
            }
            else if (projectType == ProjectType.FileProject)
            {
                miniature = player.CurrentMiniatureFrame;
            }
            else
            {
                miniature = null;
            }

            /* Add the new created play to the project and update the GUI*/
            var play = openedProject.AddPlay(category, start, stop, miniature);

            mainWindow.AddPlay(play);
            /* Tag subcategories of the new play */
            LaunchPlayTagger(play);
        }
Exemplo n.º 10
0
        private void SaveCaptureProject(Project project)
        {
            MessageDialog md;
            string        filePath = project.Description.File.FilePath;

            Log.Debug("Saving capture project: " + project);
            md = new MessageDialog(mainWindow as Gtk.Window, DialogFlags.Modal,
                                   MessageType.Info, ButtonsType.None,
                                   Catalog.GetString("Loading newly created project..."));
            md.Show();

            /* scan the new file to build a new PreviewMediaFile with all the metadata */
            try {
                Log.Debug("Reloading saved file: " + filePath);
                project.Description.File = PreviewMediaFile.DiscoverFile(filePath);
                Core.DB.AddProject(project);
            } catch (Exception ex) {
                Log.Exception(ex);
                Log.Debug("Backing up project to file");
                string projectFile = filePath + "-" + DateTime.Now;
                projectFile = projectFile.Replace("-", "_").Replace(" ", "_").Replace(":", "_");
                Project.Export(OpenedProject, projectFile);
                MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                          Catalog.GetString("An error occured saving the project:\n") + ex.Message + "\n\n" +
                                          Catalog.GetString("The video file and a backup of the project has been " +
                                                            "saved. Try to import it later:\n") +
                                          filePath + "\n" + projectFile);
            }
            /* we need to set the opened project to null to avoid calling again CloseOpendProject() */
            /* FIXME: */
            //project = null;
            SetProject(project, ProjectType.FileProject, new CaptureSettings());
            md.Destroy();
        }
Exemplo n.º 11
0
    public void UnlockWithMessage(int ModelSkinNeither, int num, string titleMessage, string textMessage)
    {
        if (ModelSkinNeither == 0)
        {
            if (unlockData.modelUnlocks[num])
            {
                return;
            }
            else
            {
                unlockData.modelUnlocks[num] = true;
            }
        }
        else if (ModelSkinNeither == 1)
        {
            if (unlockData.matUnlocks[num])
            {
                return;
            }
            else
            {
                unlockData.matUnlocks[num] = true;
            }
        }
        SaveUnlockData();
        GameObject newMessagePanel = (GameObject)Instantiate(unlockPrefab, Vector3.zero, Quaternion.identity, null);

        newMessagePanel.transform.SetParent(mainCanvas, false);
        MessagePopup mp = newMessagePanel.GetComponent <MessagePopup>();

        mp.titleString = titleMessage;
        mp.textString  = textMessage;
        mp.special     = true;
    }
Exemplo n.º 12
0
        protected virtual void OnDeleteButtonPressed(object sender, System.EventArgs e)
        {
            List <ProjectDescription> deletedProjects = new List <ProjectDescription>();

            if (selectedProjects == null)
            {
                return;
            }

            foreach (ProjectDescription selectedProject in selectedProjects)
            {
                if (openedProject != null &&
                    selectedProject.File.FilePath == openedProject.Description.File.FilePath)
                {
                    MessagePopup.PopupMessage(this, MessageType.Warning,
                                              Catalog.GetString("This Project is actually in use.") + "\n" +
                                              Catalog.GetString("Close it first to allow its removal from the database"));
                    continue;
                }
                MessageDialog md = new MessageDialog(this, DialogFlags.Modal,
                                                     MessageType.Question,
                                                     ButtonsType.YesNo,
                                                     Catalog.GetString("Do you really want to delete:") +
                                                     "\n" + selectedProject.Title);
                if (md.Run() == (int)ResponseType.Yes)
                {
                    DB.RemoveProject(selectedProject.UUID);
                    deletedProjects.Add(selectedProject);
                }
                md.Destroy();
            }
            projectlistwidget1.RemoveProjects(deletedProjects);
            Clear();
        }
Exemplo n.º 13
0
        private async void Initialize()
        {
            if (!Settings.IsContactsSyncRequested)
            {
                Settings.IsContactsSyncRequested = true;

                var confirm = await MessagePopup.ShowAsync(Strings.Resources.ContactsPermissionAlert, Strings.Resources.AppName, Strings.Resources.ContactsPermissionAlertContinue, Strings.Resources.ContactsPermissionAlertNotNow);

                if (confirm != Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                {
                    Settings.IsContactsSyncEnabled = false;
                    await _contactsService.RemoveAsync();
                }

                if (Settings.IsContactsSyncEnabled)
                {
                    ProtoService.Send(new GetContacts(), async result =>
                    {
                        if (result is Telegram.Td.Api.Users users)
                        {
                            await _contactsService.SyncAsync(users);
                        }
                    });
                }
            }
        }
Exemplo n.º 14
0
        private async void SendExecute()
        {
            var response = await ProtoService.SendAsync(new ImportContacts(new[] { new Contact(_phoneCode + _phoneNumber, _firstName, _lastName, string.Empty, 0) }));

            if (response is ImportedContacts imported)
            {
                if (imported.UserIds.Count > 0)
                {
                    var create = await ProtoService.SendAsync(new CreatePrivateChat(imported.UserIds[0], false));

                    if (create is Chat chat)
                    {
                        NavigationService.NavigateToChat(chat);
                    }
                    else
                    {
                        await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
                    }
                }
                else
                {
                    await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
                }
            }
            else
            {
                await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
            }
        }
Exemplo n.º 15
0
        public override View Run()
        {
            var view = new View
            {
                BackgroundColor = Color.FromHex("#F9AA33").ToNative(),
                Layout          = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };
            var btn3 = new Button
            {
                Text = "Open Prompt popup",
            };

            view.Add(btn3);
            btn3.Clicked += async(s, e) =>
            {
                try
                {
                    var result = await new PromptPopup("Prompt", "Your name", placeholder: "Name").Open();
                    await new MessagePopup("Result", $"Your name is {result}", "OK").Open();
                }
                catch (TaskCanceledException)
                {
                    _ = new MessagePopup("Result", $"Prompt is canceld", "OK").Open();
                }
            };


            return(view);
        }
Exemplo n.º 16
0
        private async void TerminateExecute(ConnectedWebsite session)
        {
            var bot = ProtoService.GetUser(session.BotUserId);

            if (bot == null)
            {
                return;
            }

            var dialog = new MessagePopup();

            dialog.Title               = Strings.Resources.AppName;
            dialog.Message             = string.Format(Strings.Resources.TerminateWebSessionQuestion, session.DomainName);
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;
            dialog.CheckBoxLabel       = string.Format(Strings.Resources.TerminateWebSessionStop, bot.FirstName);

            var terminate = await dialog.ShowQueuedAsync();

            if (terminate == ContentDialogResult.Primary)
            {
                var response = await ProtoService.SendAsync(new DisconnectWebsite(session.Id));

                if (response is Ok)
                {
                    Items.Remove(session);
                }
                else if (response is Error error)
                {
                    Logs.Logger.Error(Logs.Target.API, "auth.resetWebAuthotization error " + error);
                }

                ProtoService.Send(new BlockUser(bot.Id));
            }
        }
Exemplo n.º 17
0
        private async void CallDeleteExecute(TLCallGroup group)
        {
            var popup = new MessagePopup
            {
                Title               = Strings.Resources.DeleteCalls,
                Message             = Strings.Resources.DeleteSelectedCallsText,
                PrimaryButtonText   = Strings.Resources.Delete,
                SecondaryButtonText = Strings.Resources.Cancel,
                CheckBoxLabel       = Strings.Resources.DeleteCallsForEveryone
            };

            var confirm = await popup.ShowQueuedAsync();

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var response = await ProtoService.SendAsync(new DeleteMessages(group.ChatId, group.Items.Select(x => x.Id).ToArray(), popup.IsChecked == true));

            if (response is Ok)
            {
                Items.Remove(group);
            }
        }
        private async void RevokeLinkExecute(Chat chat)
        {
            if (chat.Type is ChatTypeSupergroup super)
            {
                var supergroup = ProtoService.GetSupergroup(super.SupergroupId);
                if (supergroup == null)
                {
                    return;
                }

                var dialog = new MessagePopup();
                dialog.Title               = Strings.Resources.AppName;
                dialog.Message             = string.Format(Strings.Resources.RevokeLinkAlert, MeUrlPrefixConverter.Convert(CacheService, supergroup.Username, true), chat.Title);
                dialog.PrimaryButtonText   = Strings.Resources.RevokeButton;
                dialog.SecondaryButtonText = Strings.Resources.Cancel;

                var confirm = await dialog.ShowQueuedAsync();

                if (confirm == ContentDialogResult.Primary)
                {
                    var response = await ProtoService.SendAsync(new SetSupergroupUsername(supergroup.Id, string.Empty));

                    if (response is Ok)
                    {
                        HasTooMuchUsernames = false;
                        AdminedPublicChannels.Clear();
                    }
                }
            }
        }
Exemplo n.º 19
0
        private bool Next()
        {
            if (openedProject != null)
            {
                MessagePopup.PopupMessage(playlistWidget as Gtk.Widget, MessageType.Error,
                                          Catalog.GetString("Please, close the opened project to play the playlist."));
                Stop();
                return(false);
            }

            if (!playlist.HasNext())
            {
                Stop();
                return(false);
            }

            var plNode = playlist.Next();

            playlistWidget.SetActivePlay(plNode, playlist.GetCurrentIndex());

            if (!plNode.Valid)
            {
                return(Next());
            }

            LoadPlaylistPlay(plNode);
            return(true);
        }
Exemplo n.º 20
0
        private async void UpdateLocationExecute()
        {
            var location = await _locationService.GetPositionAsync();

            if (location == null)
            {
                var confirm = await MessagePopup.ShowAsync(Strings.Resources.GpsDisabledAlert, Strings.Resources.AppName, Strings.Resources.ConnectingToProxyEnable, Strings.Resources.Cancel);

                if (confirm == ContentDialogResult.Primary)
                {
                    await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                }

                return;
            }

            var geopoint = new Geopoint(new BasicGeoposition {
                Latitude = location.Latitude, Longitude = location.Longitude
            });

            Location = location;
            Settings.Appearance.UpdateNightMode();

            var result = await MapLocationFinder.FindLocationsAtAsync(geopoint, MapLocationDesiredAccuracy.Low);

            if (result.Status == MapLocationFinderStatus.Success)
            {
                Town = result.Locations[0].Address.Town;
            }
        }
Exemplo n.º 21
0
        public void Handle(UpdateServiceNotification update)
        {
            var caption = update.Content.GetCaption();

            if (caption == null)
            {
                return;
            }

            var text = caption.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            BeginOnUIThread(async() =>
            {
                if (update.Type.StartsWith("AUTH_KEY_DROP_"))
                {
                    var confirm = await MessagePopup.ShowAsync(text, Strings.Resources.AppName, Strings.Resources.LogOut, Strings.Resources.Cancel);
                    if (confirm == ContentDialogResult.Primary)
                    {
                        _protoService.Send(new Destroy());
                    }
                }
                else
                {
                    await MessagePopup.ShowAsync(text, Strings.Resources.AppName, Strings.Resources.OK);
                }
            });
        }
Exemplo n.º 22
0
        private async void ChatsClearExecute()
        {
            var chats = SelectedItems.ToList();

            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureClearHistoryFewChats, Locale.Declension("ChatsSelected", chats.Count), Strings.Resources.ClearHistory, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Delegate?.ShowChatsUndo(chats, UndoType.Clear, items =>
                {
                    foreach (var undo in items)
                    {
                        _deletedChats.Remove(undo.Id);
                        Items.Handle(undo.Id, undo.Positions);
                    }
                }, items =>
                {
                    var clear = items.FirstOrDefault();
                    if (clear == null)
                    {
                        return;
                    }

                    ProtoService.Send(new DeleteChatHistory(clear.Id, false, false));
                });
            }

            Delegate?.SetSelectionMode(false);
            SelectedItems.Clear();
        }
Exemplo n.º 23
0
        private static void ProcessExecutionError(Exception ex)
        {
            string logFile = Constants.SOFTWARE_NAME + "-" + DateTime.Now + ".log";
            string message;

            logFile = logFile.Replace("/", "-");
            logFile = logFile.Replace(" ", "-");
            logFile = logFile.Replace(":", "-");
            logFile = System.IO.Path.Combine(Config.HomeDir(), logFile);

            if (ex.InnerException != null)
            {
                message = String.Format("{0}\n{1}\n{2}\n{3}\n{4}", ex.Message, ex.InnerException.Message, ex.Source, ex.StackTrace, ex.InnerException.StackTrace);
            }
            else
            {
                message = String.Format("{0}\n{1}\n{2}", ex.Message, ex.Source, ex.StackTrace);
            }

            using (StreamWriter s = new StreamWriter(logFile)) {
                s.WriteLine(message);
                s.WriteLine("\n\n\nStackTrace:");
                s.WriteLine(System.Environment.StackTrace);
            }
            Log.Exception(ex);
            //TODO Add bug reports link
            MessagePopup.PopupMessage(null, MessageType.Error,
                                      Catalog.GetString("The application has finished with an unexpected error.") + "\n" +
                                      Catalog.GetString("A log has been saved at: ") + logFile + "\n" +
                                      Catalog.GetString("Please, fill a bug report "));

            Application.Quit();
        }
Exemplo n.º 24
0
        public async Task <bool> VerifyRightsAsync(Chat chat, Func <ChatPermissions, bool> permission, string global, string forever, string temporary)
        {
            if (chat.Type is ChatTypeSupergroup super)
            {
                var supergroup = ProtoService.GetSupergroup(super.SupergroupId);
                if (supergroup == null)
                {
                    return(false);
                }

                if (supergroup.Status is ChatMemberStatusRestricted restricted && !permission(restricted.Permissions))
                {
                    if (restricted.IsForever())
                    {
                        await MessagePopup.ShowAsync(forever, Strings.Resources.AppName, Strings.Resources.OK);
                    }
                    else
                    {
                        await MessagePopup.ShowAsync(string.Format(temporary, BindConvert.Current.BannedUntil(restricted.RestrictedUntilDate)), Strings.Resources.AppName, Strings.Resources.OK);
                    }

                    return(true);
                }
                else if (supergroup.Status is ChatMemberStatusMember)
                {
                    if (!permission(chat.Permissions))
                    {
                        await MessagePopup.ShowAsync(global, Strings.Resources.AppName, Strings.Resources.OK);

                        return(true);
                    }
                }
            }
Exemplo n.º 25
0
        private async void AddExecute()
        {
            var chat = _chat;

            if (chat == null)
            {
                return;
            }

            var selected = await SharePopup.PickChatAsync(Strings.Resources.SelectContact);

            var user = CacheService.GetUser(selected);

            if (user == null)
            {
                return;
            }

            var confirm = await MessagePopup.ShowAsync(string.Format(Strings.Resources.AddToTheGroup, user.GetFullName()), Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var response = await ProtoService.SendAsync(new AddChatMember(chat.Id, user.Id, CacheService.Options.ForwardedMessageCountMax));

            if (response is Error error)
            {
            }
        }
Exemplo n.º 26
0
    public void OnEGLoginFailed(string errorMessage)
#endif
    {
        PopupNetworkLoading.DestroyPopup();
        MessagePopup.Create(Localization.instance.Get("LoginFailMessage"));
        Debug.LogWarning(errorMessage);
    }
Exemplo n.º 27
0
        protected override async void DeleteExecute()
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureDeletePhoto, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary && _selectedItem is GalleryChatPhoto chatPhoto)
            {
                Function function;
                if (chatPhoto.MessageId == 0)
                {
                    function = new SetChatPhoto(_chat.Id, null);
                }
                else
                {
                    function = new DeleteMessages(_chat.Id, new[] { chatPhoto.MessageId }, true);
                }

                var response = await ProtoService.SendAsync(function);

                if (response is Ok)
                {
                    var index = Items.IndexOf(chatPhoto);
                    if (index < Items.Count - 1 && chatPhoto.MessageId != 0)
                    {
                        SelectedItem = Items[index > 0 ? index - 1 : index + 1];
                        Items.Remove(chatPhoto);
                        TotalItems--;
                    }
                    else
                    {
                        NavigationService.GoBack();
                    }
                }
            }
        }
        private async void UnblockExecute(User user)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureUnblockContact, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                ProtoService.Send(new UnblockUser(user.Id));
            }
        }
Exemplo n.º 29
0
        public async void Handle(UpdateTermsOfService update)
        {
            var terms = update.TermsOfService;

            if (terms == null)
            {
                return;
            }

            async void DeleteAccount()
            {
                var decline = await MessagePopup.ShowAsync(Strings.Resources.TosUpdateDecline, Strings.Resources.TermsOfService, Strings.Resources.DeclineDeactivate, Strings.Resources.Back);

                if (decline != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                var delete = await MessagePopup.ShowAsync(Strings.Resources.TosDeclineDeleteAccount, Strings.Resources.AppName, Strings.Resources.Deactivate, Strings.Resources.Cancel);

                if (delete != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                _protoService.Send(new DeleteAccount("Decline ToS update"));
            }

            if (terms.ShowPopup)
            {
                await Task.Delay(2000);

                BeginOnUIThread(async() =>
                {
                    var confirm = await MessagePopup.ShowAsync(terms.Text, Strings.Resources.PrivacyPolicyAndTerms, Strings.Resources.Agree, Strings.Resources.Cancel);
                    if (confirm != ContentDialogResult.Primary)
                    {
                        DeleteAccount();
                        return;
                    }

                    if (terms.MinUserAge > 0)
                    {
                        var age = await MessagePopup.ShowAsync(string.Format(Strings.Resources.TosAgeText, terms.MinUserAge), Strings.Resources.TosAgeTitle, Strings.Resources.Agree, Strings.Resources.Cancel);
                        if (age != ContentDialogResult.Primary)
                        {
                            DeleteAccount();
                            return;
                        }
                    }

                    _protoService.Send(new AcceptTermsOfService(update.TermsOfServiceId));
                });
            }
        }
Exemplo n.º 30
0
        private async void CopyExecute()
        {
            var dataPackage = new DataPackage();

            dataPackage.SetText(_inviteLink);
            ClipboardEx.TrySetContent(dataPackage);

            await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.AppName, Strings.Resources.OK);
        }