Beispiel #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            textRegistrationStatus = FindViewById <TextView>(Resource.Id.textRegistrationStatus);
            textRegistrationId     = FindViewById <TextView>(Resource.Id.textRegistrationId);
            textLastMsg            = FindViewById <TextView>(Resource.Id.textLastMessage);
            buttonRegister         = FindViewById <Button>(Resource.Id.buttonRegister);

            Log.Info("C2DM-Sharp-UI", "Hello World");

            this.buttonRegister.Click += delegate
            {
                if (!registered)
                {
                    Log.Info("C2DM-Sharp", "Registering...");
                    PushClient.Register(this, senderIdEmail);
                }
                else
                {
                    Log.Info("C2DM-Sharp", "Unregistering...");
                    PushClient.UnRegister(this);
                }

                RunOnUiThread(() =>
                {
                    //Disable the button so that we can't click it again
                    //until we get back to the activity from a notification
                    this.buttonRegister.Enabled = false;
                });
            };
        }
Beispiel #2
0
        private void Start( )
        {
            //Check to ensure everything's setup right
            PushClient.CheckDevice(Application.Context);
            PushClient.CheckManifest(Application.Context);

            PushClient.Register(Application.Context, PushHandlerBroadcastReceiver.SENDER_IDS);

            SetContentView(Resource.Layout.Auth);
            activityIsVisible = true;

            MenuId    = Resource.Menu.EmptyMenu;
            LegacyBar = FindViewById <LegacyBar.Library.Bar.LegacyBar>(Resource.Id.ActionBar);
            LegacyBar.SetHomeLogo(Resource.Drawable.Icon);

            txtLicense  = FindViewById <EditText>(Resource.Id.txtLicense);
            txtPassword = FindViewById <EditText>(Resource.Id.txtPassword);
            lblError    = FindViewById <TextView>(Resource.Id.lblError);
            btnLogin    = FindViewById <Button>(Resource.Id.btnLogin);

            txtLicense.Text = GetSharedPreferences(Application.Context.PackageName, FileCreationMode.Private).GetString("License", String.Empty);

            var encryptedPassword = GetSharedPreferences(Application.Context.PackageName, FileCreationMode.Private).GetString("Password", null);

            txtPassword.Text = encryptedPassword != null
                                                                   ? Crypto.DecryptStringAES(encryptedPassword, SharedSecret)
                                                                   : String.Empty;

            lblError.Text   = String.Empty;
            btnLogin.Click += btnLogin_Click;

            LegacyBar.ProgressBarVisibility = ViewStates.Visible;
            ThreadPool.QueueUserWorkItem(o => GetAreas( ));
        }
Beispiel #3
0
 private async Task TryEnablePush(PushClient helper, Uri uri, bool silent = false)
 {
     if (!silent)
     {
         LoadingText = "Enabling...";
     }
     await AsyncTasks.Within2(helper.Register(uri), TimeSpan.FromSeconds(10));
 }
Beispiel #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (!PushClient.IsRegistered(this))
            {
                PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new GroeneTeam.App());
        }
Beispiel #5
0
        async void OnLogin(object sender, EventArgs e)
        {
            viewModel.Username = username.Text;
            viewModel.Password = password.Text;
            try
            {
                await viewModel.Login();

                PushClient.Register(this, PushConstants.ProjectNumber);

                StartActivity(typeof(ConversationsActivity));
            }
            catch (Exception exc)
            {
                DisplayError(exc);
            }
        }
Beispiel #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            textRegistrationStatus = FindViewById <TextView>(Resource.Id.textRegistrationStatus);
            textRegistrationId     = FindViewById <TextView>(Resource.Id.textRegistrationId);
            textLastMsg            = FindViewById <TextView>(Resource.Id.textLastMessage);
            buttonRegister         = FindViewById <Button>(Resource.Id.buttonRegister);

            Log.Info(TAG, "Hello World");

            //Check to ensure everything's setup right
            PushClient.CheckDevice(this);
            PushClient.CheckManifest(this);


            this.buttonRegister.Click += delegate
            {
                if (!registered)
                {
                    Log.Info(TAG, "Registering...");

                    //Call to register
                    PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
                }
                else
                {
                    Log.Info(TAG, "Unregistering...");

                    //Call to unregister
                    PushClient.UnRegister(this);
                }

                RunOnUiThread(() =>
                {
                    //Disable the button so that we can't click it again
                    //until we get back to the activity from a notification
                    this.buttonRegister.Enabled = false;
                });
            };
        }
Beispiel #7
0
        public void RegisterDeviceForPushNotifications(bool force = false)
        {
            //Check to ensure everything's setup right
            PushClient.CheckDevice(_context);
            PushClient.CheckManifest(_context);

            //Get the stored latest registration id
            var registrationId = PushClient.GetRegistrationId(_context);


            var          registered = !string.IsNullOrEmpty(registrationId);
            const string tag        = "PushSharp-GCM";

            if (!registered || force)
            {
                //Call to register
                var registerIdDebug = _appSettings.Data.GCM.SenderId;
                PushClient.Register(_context, registerIdDebug);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.LiveSurvey);
            this.SetOrientationBackground(Resource.Id.LiveSurvey);
            VM     = (ParticipateLiveVM)AppModel.VM;
            layout = FindViewById <LinearLayout>(Resource.Id.liveOptionLayout);

            PushClient.CheckDevice(this);
            PushClient.CheckManifest(this);
            if (AppModel.GCMNote != null)
            {
                CleanGCMNote();
            }
            ShowLoading();
            AppModel.GCMNote = new GCMNotifier();
            AppModel.GCMNote.RegistrationUpdated += GCMNote_RegistrationUpdated;
            PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

            VM.PropertyChanged += (e, a) =>
            {
                RunOnUiThread(() =>
                {
                    if (a.PropertyName == "NotificationMessage")
                    {
                        Toast.MakeText(this, VM.NotificationMessage, ToastLength.Long).Show();
                    }
                    if (a.PropertyName == "CurrentQuestion")
                    {
                        ClearComponents();
                        InitComponents();
                    }
                    if (a.PropertyName == "IsClosed")
                    {
                        this.Finish();
                        StartActivity(typeof(Home));
                    }
                });
            };
        }
Beispiel #9
0
        private ProgressBar progressBar;                  // Progress spinner to use for table operations

        // Called when the activity initially gets created
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // Initialize the progress bar
            progressBar            = FindViewById <ProgressBar>(Resource.Id.loadingProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            try
            {
                // Check to ensure everything's setup right
                PushClient.CheckDevice(this);
                PushClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

                CurrentPlatform.Init();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    Constants.ApplicationURL,
                    progressHandler);

                // Get the Mobile Service Table instance to use
                todoTable = client.GetTable <TodoItem>();

                textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

                // Create an adapter to bind the items with the view
                adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);
                listViewTodo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }