Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PullRequestView"/> class.
        /// </summary>
        /// <param name="source">The source of elements for this view.</param>
        public PullRequestView(IPullRequestSource source, TextView?descriptionView)
            : base(LoadingContents)
        {
            Width  = Dim.Fill();
            Height = Dim.Fill();

            m_pullRequestSource = source;
            m_descriptionView   = descriptionView;

            // Override the color scheme to our main theme for this view.
            //
            ColorScheme = CustomColorSchemes.Main;

            if (m_descriptionView != null)
            {
                // Subscribe to selection change.
                //
                SelectedItemChanged += HandleSelectedPullRequestChanged;
            }

            OpenSelectedItem += HandleOpenSelectedItem;

            // Initialize background refresh task.
            //
            m_refreshTask = RefreshTask.Create(this);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_dialogs);

            _openAlertButton       = FindViewById <Button>(Resource.Id.activity_dialogs_alert_button);
            _openConfirmButton     = FindViewById <Button>(Resource.Id.activity_dialogs_confirm_button);
            _openActionSheetButton = FindViewById <Button>(Resource.Id.activity_dialogs_actionsheet_button);

            _alertResultTextView       = FindViewById <TextView>(Resource.Id.activity_dialogs_alert_result_label);
            _confirmResultTextView     = FindViewById <TextView>(Resource.Id.activity_dialogs_confirm_result_label);
            _actionSheetResultTextView = FindViewById <TextView>(Resource.Id.activity_dialogs_actionsheet_result_label);

            _openDialogUntilDismissButton      = FindViewById <Button>(Resource.Id.activity_dialogs_dialog_dismiss_button);
            _dialogDismissResultTextView       = FindViewById <TextView>(Resource.Id.activity_dialogs_dialog_dismiss_result_label);
            _openDialogUntilResultButton       = FindViewById <Button>(Resource.Id.activity_dialogs_dialog_result_button);
            _dialogDismissResultResultTextView = FindViewById <TextView>(Resource.Id.activity_dialogs_dialog_result_label);
            _openTwoDialogsButton = FindViewById <Button>(Resource.Id.activity_dialogs_two_dialogs_button);

            _openAlertButton.SetCommand(ViewModel.OpenAlertCommand);
            _openConfirmButton.SetCommand(ViewModel.OpenConfirmCommand);
            _openActionSheetButton.SetCommand(ViewModel.OpenActionSheetCommand);

            _openDialogUntilDismissButton.SetCommand(ViewModel.OpenDialogUntilDismissCommand);
            _openDialogUntilResultButton.SetCommand(ViewModel.OpenDialogUntilResultCommand);
            _openTwoDialogsButton.SetCommand(ViewModel.OpenTwoDialogsCommand);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_connectivity);

            _connectionTextView = FindViewById <TextView>(Resource.Id.textViewConnection);
            _typesTextView      = FindViewById <TextView>(Resource.Id.textViewTypes);
        }
        bool TextView.IOnEditorActionListener.OnEditorAction(TextView?v, ImeAction actionId, KeyEvent?e)
        {
            if ((e is not null) && (e.KeyCode == Keycode.Enter) && (e.Action == KeyEventActions.Up))
            {
                ((IEntryController)Element).SendCompleted();
            }

            return(true);
        }
Esempio n. 5
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            _incrementLabel = view.FindViewById <TextView>(Resource.Id.textView1);

            _incrementButton = view.FindViewById <Button>(Resource.Id.button2);
            _incrementButton.SetCommand(ViewModel.IncrementCommand);
            _incrementButton.Click += (sender, e) => _incrementLabel.Text = "changed";
        }
Esempio n. 6
0
            public bool OnEditorAction(TextView?v, [GeneratedEnum] ImeAction actionId, KeyEvent?e)
            {
                if (actionId == ImeAction.Done || (actionId == ImeAction.ImeNull && e?.KeyCode == Keycode.Enter && e?.Action == KeyEventActions.Up))
                {
                    // TODO: Dismiss keyboard for hardware / physical keyboards

                    Handler?.VirtualView?.Completed();
                }

                return(true);
            }
Esempio n. 7
0
 bool TextView.IOnEditorActionListener.OnEditorAction(TextView?view, ImeAction actionId, KeyEvent?e)
 {
     if (view != null && binding != null && ((e != null && e.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) || e == null))
     {
         if (view.Id == Resource.Id.tbInput)
         {
             CommandSubmit();
             return(true);
         }
     }
     return(false);
 }
Esempio n. 8
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _popup?.Dispose();
                _popup = null;
                _textView?.Dispose();
                _textView = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_yellow);

            _incrementLabel = FindViewById <TextView>(Resource.Id.textView1);

            _incrementButton = FindViewById <Button>(Resource.Id.button2);
            _incrementButton.SetCommand(ViewModel.IncrementCommand);
            _incrementButton.Click += (sender, e) => _incrementLabel.Text = "changed";
        }
Esempio n. 10
0
        public static ISourceItemBindingBuilder <TSourceItem, string> BindDefault <TSourceItem>(
            this BindingSet <TSourceItem> bindingSet,
            TextView?textView)
            where TSourceItem : class
        {
            if (bindingSet == null)
            {
                throw new ArgumentNullException(nameof(bindingSet));
            }

            return(bindingSet.Bind(textView)
                   .For(v => v.TextBinding()));
        }
Esempio n. 11
0
 private TextView CreateTextView()
 {
     _textView?.Dispose();
     _textView = new TextView(this)
     {
         TextSize         = 16,
         Text             = "Native Android",
         LayoutParameters = new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.WrapContent,
             ViewGroup.LayoutParams.WrapContent)
     };
     _textView.SetPadding(3, 3, 3, 3);
     return(_textView);
 }
Esempio n. 12
0
    protected override void OnCreate(Bundle?savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.activity_main);

        /*
         * https://docs.microsoft.com/en-us/dotnet/csharp/nullable-warnings
         *
         * add "!" to suppress
         *
         * warning CS8600: Converting null literal or possible null value to non-nullable type.
         * warning CS8602: Dereference of a possibly null reference.
         */

        text_view_response = this.FindViewById <TextView>(Resource.Id.text_view_response);

        Button?button_http_request_dotnet = this.FindViewById <Button>(Resource.Id.button_http_request_dotnet);

        button_http_request_dotnet !.Click += async(s, e) =>
        {
            text_view_response !.Text = "here be .NET HtttpClient response";

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept
            .Add
            (
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json")
            );
            client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");

            Task <string> stringTask = client.GetStringAsync(url);

            var msg = await stringTask;                                     // add async

            Console.Write(msg);

            text_view_response.Text = msg;
        };

        Button?button_http_request_android = this.FindViewById <Button>(Resource.Id.button_http_request_android);

        button_http_request_android !.SetOnClickListener(new ButttonClickListener());

        return;
    }
 bool TextView.IOnEditorActionListener.OnEditorAction(TextView?view, ImeAction actionId, KeyEvent?e)
 {
     if (view != null && binding != null && ((e != null && e.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) || e == null))
     {
         if (view.Id == Resource.Id.tbPhoneNumber)
         {
             OnClick(binding.btnSendSms);
             binding.tbSmsCode.RequestFocus();
             return(true);
         }
         else if (view.Id == Resource.Id.tbSmsCode)
         {
             OnClick(binding.btnSubmit);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 14
0
        bool TextView.IOnEditorActionListener.OnEditorAction(TextView?v, ImeAction actionId, KeyEvent?e)
        {
            if (v is null)
            {
                return(true);
            }

            if (actionId != ImeAction.Done &&
                (actionId != ImeAction.ImeNull || (e != null && e.KeyCode != Keycode.Enter)))
            {
                return(true);
            }

            HideKeyboard(v);
            DoneEdit();

            return(true);
        }
Esempio n. 15
0
        public static void RunUiLoop(Config config, IPullRequestSource source)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Application.Init();
            Application.Current.ColorScheme = CustomColorSchemes.Main;

            Toplevel top = Application.Top;

            top.X      = Pos.Center();
            top.Y      = Pos.Center();
            top.Height = Dim.Fill();
            top.Width  = Dim.Fill();

            Dim computedHeight = Dim.Sized(0);

            // We intentionally initialize the status bar first, as the status
            // bar hooks events on the source, and the pull request view, will
            // drive API calls on the source which will trigger those events.
            // To avoid races here, make sure to hook first, run later.
            //
            StatusBar?statusBar = null;

            if (config.StatusBarEnabled)
            {
                computedHeight += StatusBarHeight;
                statusBar       = new StatusBar(source);
            }

            TextView?descriptionView = null;

            if (config.DescriptionEnabled)
            {
                computedHeight += DescriptionHeight;

                descriptionView = new TextView()
                {
                    Height   = Dim.Fill(),
                    Width    = Dim.Fill(),
                    ReadOnly = true,
                };
            }

            using PullRequestView requestView = new PullRequestView(source, descriptionView);

            using Window contentWindow = new Window(ActionableTitle)
                  {
                      Width       = Dim.Fill(),
                      Height      = Dim.Fill() - computedHeight,
                      ColorScheme = WindowTheme,
                  };

            contentWindow.Add(requestView);
            top.Add(contentWindow);

            if (config.DescriptionEnabled)
            {
                Window descriptionWindow = new Window("Description:")
                {
                    Width       = Dim.Fill(),
                    Height      = DescriptionHeight,
                    Y           = Pos.Bottom(contentWindow),
                    ColorScheme = WindowTheme,
                };

                descriptionWindow.Add(descriptionView);
                top.Add(descriptionWindow);
            }

            if (config.StatusBarEnabled)
            {
                Window statusWindow = new Window("Status:")
                {
                    Width       = Dim.Fill(),
                    Height      = StatusBarHeight,
                    Y           = Pos.Bottom(top.Subviews.Last()),
                    ColorScheme = WindowTheme,
                };

                statusWindow.Add(statusBar);
                top.Add(statusWindow);
            }

            // Start processing data within the view now that everything is constructed.
            //
            requestView.Start();

            Application.Run();
        }
Esempio n. 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            PrepareDirs();

            EnClient = ((MainApplication)ApplicationContext).GetEnClient();

            buttonEn        = FindViewById <Button>(Resource.Id.btn_enable_en);
            buttonEn.Click += async delegate
            {
                Logger.D("EnableEnAsync clicked");

                await EnableEnAsync();
            };

            buttonGetTekHistory        = FindViewById <Button>(Resource.Id.btn_get_teks);
            buttonGetTekHistory.Click += async delegate
            {
                Logger.D("buttonGetTekHistory clicked");

                List <TemporaryExposureKey> teks = await GetTekHistory();

                ShowTekHistory(teks);
                await SaveTekHistoryAsync(teks);
            };

            buttonProvideDiagnosisKeys        = FindViewById <Button>(Resource.Id.btn_provide_diagnosis_keys);
            buttonProvideDiagnosisKeys.Click += async delegate
            {
                Logger.D("buttonProvideDiagnosisKeys clicked");

                await ProvideDiagnosisKeys();
            };

            buttonProvideDiagnosisKeysV1        = FindViewById <Button>(Resource.Id.btn_provide_diagnosis_keys_legacy_v1);
            buttonProvideDiagnosisKeysV1.Click += async delegate
            {
                Logger.D("buttonProvideDiagnosisKeysV1 clicked");

                await ProvideDiagnosisKeysV1();
            };

            buttonRequestPreauthorizedKeys        = FindViewById <Button>(Resource.Id.btn_request_preauthorize_keys);
            buttonRequestPreauthorizedKeys.Click += async delegate
            {
                Logger.D("buttonRequestPreauthorizedKeys clicked");

                await RequestPreAuthorizeKeys();
            };

            buttonRequestReleaseKeys        = FindViewById <Button>(Resource.Id.btn_request_release_keys);
            buttonRequestReleaseKeys.Click += async delegate
            {
                Logger.D("buttonRequestReleaseKeys clicked");

                await RequestReleaseKeys();
            };

            buttonUploadDiagnosisKeys        = FindViewById <Button>(Resource.Id.btn_upload_diagnosis_keys);
            buttonUploadDiagnosisKeys.Click += async delegate
            {
                Logger.D("buttonUploadDiagnosisKeys clicked");

                await UploadDiagnosisKeys();
            };

            buttonDownloadDiagnosisKeys        = FindViewById <Button>(Resource.Id.btn_download_diagnosis_keys);
            buttonDownloadDiagnosisKeys.Click += async delegate
            {
                Logger.D("buttonDownloadDiagnosisKeys clicked");

                await DownloadDiagnosisKeys();
            };

            status = FindViewById <TextView>(Resource.Id.tv_status);

            serverInfo = FindViewById <TextView>(Resource.Id.tv_server_info);
        }