Esempio n. 1
0
        private void FabOnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                int divByZero = 42 / int.Parse("0");
            }
            catch (Exception exception)
            {
                //Crashes.TrackError(exception);

                //var messageWithStacktraceId = exception.Message + $" Stack ID: [{exception.StackTrace.GetHashCode()}]";
                //var wrappedException = new WrappedException(messageWithStacktraceId, exception.StackTrace);

                //Crashes.TrackError(wrappedException, null);
            }

            View view = (View)sender;

            Snackbar.Make(view, "Replace with your own action", Snackbar.LengthLong)
            .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show();
        }
Esempio n. 2
0
        private void ShowAlertDialog()
        {
            var builder = new AlertDialog.Builder(this);

            // There are two types of Alert Dialogs
            // https://material.io/guidelines/components/dialogs.html#dialogs-behavior
            // 1 - Alerts without title bars
            // 2 - Alerts with title bars
            // To remove the the Title Bar -> Remove the line: .SetTitle()
            builder.SetMessage("Isto é um AlertDialog")
            .SetTitle("Material Design")
            .SetPositiveButton("Positive", (o, args) => {
                Snackbar.Make(rootLayout, "Positive: Selected.", Snackbar.LengthShort).Show();
            })
            .SetNegativeButton("Negative", (o, args) => {
                Snackbar.Make(rootLayout, "Negative: Selected.", Snackbar.LengthShort).Show();
            })
            .SetNeutralButton("Neutral", NeutralSnackBar);

            builder.Create().Show();
        }
        public static void RequestPermissionsForApp(this AppCompatActivity activity)
        {
            var showRequestRationale =
                ActivityCompat.ShouldShowRequestPermissionRationale(activity,
                                                                    Manifest.Permission.AccessFineLocation) ||
                ActivityCompat.ShouldShowRequestPermissionRationale(activity,
                                                                    Manifest.Permission.AccessCoarseLocation);

            if (showRequestRationale)
            {
                var rootView = activity.FindViewById(AndroidResource.Id.Content);
                Snackbar.Make(rootView, Resource.String.request_location_permissions, Snackbar.LengthIndefinite)
                .SetAction(Resource.String.ok,
                           v => { activity.RequestPermissions(LocationPermissions, RC_LOCATION_PERMISSIONS); })
                .Show();
            }
            else
            {
                activity.RequestPermissions(LocationPermissions, RC_LOCATION_PERMISSIONS);
            }
        }
Esempio n. 4
0
        public Snackbar ShowSnackbar(View attachToView, string message, Action <View> action = null, int actionTextId = 0)
        {
            // don't show the message if there already
            if (_snackbar != null)
            {
                return(_snackbar);
            }

            _snackbar = Snackbar.Make(
                attachToView,
                message,
                Snackbar.LengthIndefinite);

            if (action != null && actionTextId != 0)
            {
                _snackbar.SetAction(actionTextId, action);
            }

            _snackbar.Show();
            return(this._snackbar);
        }
Esempio n. 5
0
 protected override void ProcessBarcode(string data)
 {
     if (Regex.IsMatch(data, "[a-zA-Z]{3}.*"))
     {
         if (data == EXIT_STRING)
         {
             FinishAffinity();
             System.Environment.Exit(0);
         }
         // first three characters are letters
         Intent intent = new Intent(this, typeof(MainActivity));
         intent.PutExtra(Intent.ExtraText, data);
         StartActivity(intent);
     }
     else
     {
         Snackbar.Make(FindViewById(Resource.Id.fab),
                       Resource.String.login_error,
                       Snackbar.LengthLong).Show();
     }
 }
Esempio n. 6
0
 // Called when user responds to in app permissions request
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     switch (requestCode)
     {
     case RequestWriteSettingsPermissionId:
         if (Settings.System.CanWrite(this))
         {
             //Permission granted
             HandleBrightnessPermissionGranted();
         }
         else
         {
             //Permission Denied
             var snack = Snackbar.Make(_coordinatorLayout, Resources.GetString(Resource.String.app_permissions_error2), Snackbar.LengthShort);
             snack.View.Elevation = Resources.GetDimensionPixelSize(Resource.Dimension.snack_bar_elevation);
             snack.Show();
         }
         break;
     }
 }
        private void ShowInternal(ToastImpl toast, IDataTemplateSelector selector, View snackbarHolderView, object content, float duration, ToastPosition position, IDataContext context)
        {
            Snackbar snackbar;

            if (selector == null)
            {
                snackbar = Snackbar.Make(snackbarHolderView, content.ToStringSafe("(null)"), (int)duration);
            }
            else
            {
                snackbar = (Snackbar)selector.SelectTemplate(content, snackbarHolderView);
            }
            if (snackbar == null)
            {
                toast.FromToast(_defaultPresenter.ShowAsync(content, duration, position, context));
            }
            else
            {
                toast.Show(snackbar, duration);
            }
        }
Esempio n. 8
0
        void RegisterUser(string name, string phone, string email, string password)
        {
            if (!DisruptionLibraries.UltraWebClient.IsConnected())
            {
                Snackbar.Make(rootView, "No internet connection", Snackbar.LengthShort).Show();
                return;
            }

            TaskCompletionListener.Success += TaskCompletionListener_Success;
            TaskCompletionListener.Failure += TaskCompletionListener_Failure;
            try
            {
                Helpers.AppDataHelper.GetFirebaseAuth().CreateUserWithEmailAndPassword(email, password)
                .AddOnSuccessListener(this, TaskCompletionListener)
                .AddOnFailureListener(this, TaskCompletionListener);
            }
            catch (System.Exception e)
            {
                Logger.Log(e.Message, " User Registration  ");
            }
        }
Esempio n. 9
0
        void DisplayMessage(string message, int duration, string actionText, ICommand actionCommand)
        {
            var context = CrossCurrentActivity.Current.Activity ?? Android.App.Application.Context as Activity;

            var snack = Snackbar.Make(context.FindViewById <View>(Resource.Id.Content), message, Snackbar.LengthIndefinite);


            snack.SetDuration(duration * 1000);
            if (actionCommand != null)
            {
                snack.SetAction(actionText, (view) =>
                {
                    if (actionCommand?.CanExecute(null) == true)
                    {
                        actionCommand.Execute(null);
                    }
                });
            }

            snack.Show();
        }
Esempio n. 10
0
 void RequestLocationPermission()
 {
     if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.AccessFineLocation))
     {
         var layout = FindViewById(Android.Resource.Id.Content);
         Snackbar.Make(layout,
                       Resource.String.permission_location_rationale,
                       Snackbar.LengthIndefinite)
         .SetAction(Resource.String.ok,
                    new Action <View>(delegate
         {
             ActivityCompat.RequestPermissions(this, REQUIRED_PERMISSIONS,
                                               RC_REQUEST_LOCATION_PERMISSION);
         })
                    ).Show();
     }
     else
     {
         ActivityCompat.RequestPermissions(this, REQUIRED_PERMISSIONS, RC_REQUEST_LOCATION_PERMISSION);
     }
 }
    //get result of persmissions
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
    {
        if (requestCode == REQUEST_CAMERA_WriteExternalStorage)
        {
            if (PermissionUtil.VerifyPermissions(grantResults))
            {
                // All required permissions have been granted, display Camera.

                ShowCamera();
            }
            else
            {
                // permissions did not grant, push up a snackbar to notificate USERS
                Snackbar.Make(layout, Resource.String.permissions_not_granted, Snackbar.LengthShort).Show();
            }
        }
        else
        {
            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var view = LayoutInflater.From(Activity).Inflate(Resource.Layout.dialog_register_course, null, false);

            var classSearchView      = view.FindViewById <ResourceSearchView>(Resource.Id.classSearchView);
            var registerForCourseBtn = view.FindViewById <Button>(Resource.Id.registerForCourseBtn);
            var loadingCircle        = view.FindViewById <ProgressBar>(Resource.Id.loadingCircle);

            classSearchView.SetupSearch <Class>(PresentSirApi.Instance.GetClasses, null, Resource.Drawable.ic_teacher_at_the_blackboard);

            registerForCourseBtn.Click += async delegate
            {
                loadingCircle.Visibility = ViewStates.Visible;

                using (var validator = new Validator())
                {
                    validator.ValidateIsNotEmpty(classSearchView, true);

                    if (validator.PassedValidation)
                    {
                        var response = await PresentSirApi.Instance.RegisterForClass(studentId, classSearchView.SelectedItemId.Value);

                        if (response.Data != null)
                        {
                            OnStudentRegisterForClass?.Invoke(this, response.Data);
                            Dismiss();
                        }
                        else
                        {
                            Snackbar.Make(registerForCourseBtn, "Something went wrong. Please retry.", Snackbar.LengthLong).Show();
                        }
                    }
                }
            };

            return(new AlertDialog.Builder(Activity)
                   .SetTitle("Register for class")
                   .SetView(view)
                   .Create());
        }
Esempio n. 13
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            switch (requestCode)
            {
            case FILE_SELECT_CODE:
                if (resultCode == Result.Ok)
                {
                    // Get the Uri of the selected file
                    Android.Net.Uri uri = data.Data;

                    // Get the path
                    filePath = getPath(this, uri);

                    var extension = System.IO.Path.GetExtension(filePath);

                    var filename = System.IO.Path.GetFileName(filePath);

                    //Checking if text File
                    if (extension == ".txt")
                    {
                        txtVal.Visibility = ViewStates.Visible;

                        Toast.MakeText(this, filename + " has been chosen", ToastLength.Long).Show();
                    }
                    else
                    {
                        Snackbar
                        .Make(mLayout, "Please select a text File (.txt)", Snackbar.LengthLong)
                        .SetAction("Ok", (view) => { })
                        .Show();           // Show

                        btnSearch.Enabled = false;
                        //Toast.MakeText(this, "", ToastLength.Long).Show();
                    }
                }
                break;
            }

            base.OnActivityResult(requestCode, resultCode, data);
        }
        private Task HandleTask(ToastModel model)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            Execute.BeginOnUIThread(() =>
            {
                var toastContainerComponent = default(ToastContainerComponent);

                var activity = _contextProvider.CurrentActivity;

                if (activity is ActivityBase activityBase)
                {
                    toastContainerComponent =
                        activityBase.ViewComponents.FirstOrDefault(x => x.Key == nameof(ToastContainerComponent)) as
                        ToastContainerComponent;
                }

                var view = toastContainerComponent == null
                    ? activity.FindViewById <ViewGroup>(Android.Resource.Id.Content).GetChildAt(0)
                    : activity.FindViewById <ViewGroup>(toastContainerComponent.ContainerId);

                if (view == null)
                {
                    taskCompletionSource.TrySetResult(false);
                    return;
                }

                var snackbar = Snackbar
                               .Make(view, model.Label, Snackbar.LengthLong)
                               .SetAction(model.CommandAction.Title, x => { model.CommandAction.Command.Execute(x); });
                var snackbarView = snackbar.View;
                snackbarView.SetBackgroundResource(_toastSettings.NotificationBgColor);
                snackbar.SetActionTextColor(snackbarView.GetColor(_toastSettings.NotificationTextColor));
                var callback = new SnackbarCallback(taskCompletionSource, model.AltCommandAction);
                snackbar.AddCallback(callback);
                snackbar.Show();
            });

            return(taskCompletionSource.Task);
        }
Esempio n. 15
0
        protected override void OnResume()
        {
            base.OnResume();
            // read preferences
            ISharedPreferences sharedPref = PreferenceManager.GetDefaultSharedPreferences(this);

            scanTech = sharedPref.GetString(KEY_PREF_SCAN_TECHNOLOGY, VALUE_PREF_SCAN_NONE);
            if (scanTech == VALUE_PREF_SCAN_NONE)
            {
                Snackbar.Make(FindViewById(Resource.Id.fab),
                              "Please select scanning technology!", Snackbar.LengthLong)
                .SetAction(Resource.String.action_settings, view =>
                {
                    Intent intent = new Intent(view.Context, typeof(SettingsActivity));
                    intent.PutExtra(PreferenceActivity.ExtraShowFragment,
                                    // typeof(SettingsActivity.ScannerPreferenceFragment).Name
                                    "TechStoreX.SettingsActivity.ScannerPreferenceFragment");
                    intent.PutExtra(PreferenceActivity.ExtraNoHeaders, true);
                    StartActivity(intent);
                }).Show();
            }
            //if (useDataWedge) {
            else if (scanTech == VALUE_PREF_SCAN_DATAWEDGE)
            {
                //Register for the intent to receive the scanned data using intent callback.
                //The action and category name used must be same as the names used in the profile creation.
                IntentFilter filter = new IntentFilter();
                filter.AddAction(PackageName + ".SCAN");
                filter.AddCategory(Intent.CategoryDefault);
                RegisterReceiver(receiver, filter);
            }
            // check permissions in runtime
            if ((int)Android.OS.Build.VERSION.SdkInt >= 23)
            {
                RequestPermissions();
            }
            // set up logout timer
            logoutTime = int.Parse(sharedPref.GetString(KEY_PREF_TIMEOUT, VALUE_PREF_TIMEOUT_DEFAULT));
            LogoutTimerUtility.StartLogoutTimer(this, this, logoutTime);
        }
        private void Loginbtn_Click(object sender, EventArgs e)
        {
            string email, password;

            email    = Emailtxt.EditText.Text;
            password = passwordtxt.EditText.Text;

            ShowProgressDialog();

            TaskComletionListener taskComletionListener = new TaskComletionListener();

            taskComletionListener.Success += TaskComletionListener_Success;
            taskComletionListener.Failure += TaskComletionListener_Failure;

            if (!email.Contains("@"))
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "Please Enter Right Email", Snackbar.LengthShort).Show();
                return;
            }
            else if (password == null)
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "please Enter password", Snackbar.LengthShort).Show();
                return;
            }


            try
            {
                mAuth.SignInWithEmailAndPassword(email, password)
                .AddOnSuccessListener(this, taskComletionListener)
                .AddOnFailureListener(this, taskComletionListener);
            }
            catch (Exception)
            {
                CloseProgressDialog();
                Snackbar.Make(rootview, "Oppse Some thing is Wrong !!", Snackbar.LengthShort).Show();
            }
        }
 /// <inheritdoc />
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions,
                                                 [GeneratedEnum] Permission[] grantResults)
 {
     Log.Info(Tag, "onRequestPermissionResult");
     if (requestCode == RequestPermissionsRequestCode)
     {
         if (grantResults.Length <= 0)
         {
             // If user interaction was interrupted, the permission request is cancelled and you
             // receive empty arrays.
             Log.Info(Tag, "User interaction was cancelled.");
         }
         else if (grantResults[0] == Permission.Granted)
         {
             // Permission was granted.
             _service.RequestLocationUpdates();
         }
         else
         {
             // Permission denied.
             SetButtonsState(false);
             Snackbar.Make(
                 FindViewById(Resource.Id.activity_main),
                 Resource.String.permission_denied_explanation,
                 Snackbar.LengthIndefinite)
             .SetAction(Resource.String.settings, view =>
             {
                 // Build intent that displays the App settings screen.
                 var intent = new Intent();
                 intent.SetAction(
                     Settings.ActionApplicationDetailsSettings);
                 var uri = Uri.Parse("package" + ApplicationContext.PackageName);
                 intent.SetData(uri);
                 intent.SetFlags(ActivityFlags.NewTask);
                 StartActivity(intent);
             })
             .Show();
         }
     }
 }
Esempio n. 18
0
        protected async Task GetLocationPermissionAsync()
        {
            const string permission = Manifest.Permission.AccessFineLocation;

            if (CheckSelfPermission(permission) == (int)Permission.Granted)
            {
                await GetLocationAsync();

                return;
            }

            if (ShouldShowRequestPermissionRationale(permission))
            {
                //Explain to the user why we need to read the contacts
                Snackbar.Make(FindViewById <View>(Resource.Id.action_bar), "Location access is required to show coffee shops nearby.", Snackbar.LengthIndefinite)
                .SetAction("OK", v => RequestPermissions(PermissionsLocation, RequestLocationId))
                .Show();
                return;
            }

            RequestPermissions(PermissionsLocation, RequestLocationId);
        }
Esempio n. 19
0
        private void GetLocationPermission()
        {
            //Check to see if any permission in our group is available, if one, then all are
            const string permission = Manifest.Permission.AccessFineLocation;

            if (CheckSelfPermission(permission) == (int)Permission.Granted)
            {
                RequestLocationUpdates();
                return;
            }

            if (ShouldShowRequestPermissionRationale(permission))
            {
                //Explain to the user why we need to read the contacts
                Snackbar.Make(_layout, "Location access is required to show coffee shops nearby.", Snackbar.LengthIndefinite)
                .SetAction("OK", v => RequestPermissions(PermissionsLocation, RequestLocationId))
                .Show();
                return;
            }
            //Finally request permissions with the list of permissions and Id
            RequestPermissions(PermissionsLocation, RequestLocationId);
        }
Esempio n. 20
0
 private void MusicPlay()
 {
     if (MenuViewModel.currentImage.HighestEmotion != null && !MusicPlayer.IsPlaying())
     {
         int[] musicLabels = { Resource.Raw.Anger,   Resource.Raw.Contempt, Resource.Raw.Disgust, Resource.Raw.Fear, Resource.Raw.Happiness, Resource.Raw.Neutral,
                               Resource.Raw.Sadness, Resource.Raw.Surprise };
         var   index = MenuViewModel.GetHighestEmotionIndex();
         if (index != -1)
         {
             MusicPlayer.Play(musicLabels[index]);
         }
     }
     else if (MusicPlayer.IsPlaying())
     {
         Snackbar.Make(FindViewById(Resource.Id.menuActivity), Resource.String.info_music_is_playing, Snackbar.LengthShort).Show();
     }
     else
     {
         Log.Debug(TAG, Resources.GetString(Resource.String.warning_playing_music));
         Snackbar.Make(FindViewById(Resource.Id.menuActivity), Resource.String.warning_playing_music, Snackbar.LengthShort).Show();
     }
 }
        /// <summary>
        /// Displaies the snack bar.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event Arguments</param>
        private void DisplaySnackBar(Object sender, EventArgs e)
        {
            // Intermittent Crash: Java.Lang.ClassCastException has been thrown
            // android.support.design.widget.Snackbar$SnackbarLayout cannot be cast to
            // android.support.design.internal.SnackbarContentLayout

            try {
                Snackbar.Make(myCoordinatorLayout, "You have a message", Snackbar.LengthLong)
                .SetAction("Read Message", delegate {
                    TextView outputTextView = FindViewById <TextView>(Resource.Id.textViewSnackbarsOutput);
                    outputTextView.Text     = "Follow the white rabbit.";
                })
                .Show();
            } catch (Java.Lang.ClassCastException exception) {
                var alertDialog = new Android.App.AlertDialog.Builder(this);

                alertDialog.SetMessage(exception.Message);
                alertDialog.SetPositiveButton("OK", delegate {});

                alertDialog.Show();
            }
        }
Esempio n. 22
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions,
                                                 Permission[] grantResults)
 {
     if (grantResults[0] != Permission.Granted)
     {
         var snack = Snackbar.Make(_layout, "Permisiuni pentru telefon refuzate",
                                   Snackbar.LengthShort);
         snack.Show();
     }
     else if (grantResults[1] != Permission.Granted || grantResults[2] != Permission.Granted)
     {
         var snack = Snackbar.Make(_layout, "Permisiuni pentru locatie refuzate",
                                   Snackbar.LengthShort);
         snack.Show();
     }
     else if (grantResults[3] != Permission.Granted)
     {
         var snack = Snackbar.Make(_layout, "Permisiuni pentru camera refuzate",
                                   Snackbar.LengthShort);
         snack.Show();
     }
 }
        //public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        //{
        //    var layout = FindViewById(Android.Resource.Id.Content);
        //    if (requestCode == RC_REQUEST_LOCATION_PERMISSION)
        //    {
        //        if (grantResults.Length == 1 && grantResults[0] == Permission.Granted)
        //        {
        //            Log.Debug(TAG, "User granted permission for location.");
        //            AppAndroid.StartLocationService();
        //        }
        //        else
        //        {
        //            Log.Warn(TAG, "User did not grant permission for the location.");
        //        }
        //    }
        //    if (requestCode == REQUEST_CAMERA)
        //    {
        //        // Received permission result for camera permission.
        //        Log.Info(TAG, "Received response for Camera permission request.");

        //        // Check if the only required permission has been granted
        //        if (grantResults.Length == 1 && grantResults[0] == Permission.Granted)
        //        {
        //            // Camera permission has been granted, preview can be displayed
        //            Log.Info(TAG, "CAMERA permission has now been granted. Showing preview.");
        //            Snackbar.Make(layout, "CAMERA permission has now been granted. Showing preview.", Snackbar.LengthShort).Show();
        //        }
        //        else
        //        {
        //            Log.Info(TAG, "CAMERA permission was NOT granted.");
        //            Snackbar.Make(layout, "CAMERA permission was NOT granted.", Snackbar.LengthShort).Show();
        //        }
        //    }
        //    //else if (requestCode == REQUEST_CONTACTS)
        //    //{
        //    //    Log.Info(TAG, "Received response for contact permissions request.");

        //    //    // We have requested multiple permissions for contacts, so all of them need to be
        //    //    // checked.
        //    //    if (PermissionUtil.VerifyPermissions(grantResults))
        //    //    {
        //    //        // All required permissions have been granted, display contacts fragment.
        //    //        Snackbar.Make(layout, "Contacts permissions were granted.", Snackbar.LengthShort).Show();
        //    //    }
        //    //    else
        //    //    {
        //    //        Log.Info(TAG, "Contacts permissions were NOT granted.");
        //    //        Snackbar.Make(layout, "Contacts permissions were NOT granted.", Snackbar.LengthShort).Show();
        //    //    }
        //    //}
        //    else
        //    {
        //        PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        //        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        //        //base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        //    }

        //}

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            var layout = FindViewById(Android.Resource.Id.Content);

            if (requestCode == RC_REQUEST_LOCATION_PERMISSION)
            {
                if (grantResults.Length == 1 && grantResults[0] == Permission.Granted)
                {
                    Log.Debug(TAG, "User granted permission for location.");
                    AppAndroid.StartLocationService();
                }
                else
                {
                    Log.Warn(TAG, "User did not grant permission for the location.");
                }
            }
            if (requestCode == REQUEST_CAMERA)
            {
                // Received permission result for camera permission.
                Log.Info(TAG, "Received response for Camera permission request.");

                // Check if the only required permission has been granted
                if (grantResults.Length == 1 && grantResults[0] == Permission.Granted)
                {
                    // Camera permission has been granted, preview can be displayed
                    Log.Info(TAG, "CAMERA permission has now been granted. Showing preview.");
                    Snackbar.Make(layout, "CAMERA permission has now been granted. Showing preview.", Snackbar.LengthShort).Show();
                }
                else
                {
                    Log.Info(TAG, "CAMERA permission was NOT granted.");
                    Snackbar.Make(layout, "CAMERA permission was NOT granted.", Snackbar.LengthShort).Show();
                }
            }
            else
            {
                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
Esempio n. 24
0
        private void ListViewClientes_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            View   anchor        = sender as View;
            string idServicio    = e.View.FindViewById <TextView>(Resource.Id.textServicioIdItem).Text;
            var    db            = new SQLite.SQLiteConnection(sqlPath);
            Guid   idServicioAux = Guid.Parse(idServicio);
            var    servicio      = db.Table <MServicio1>().First(x => x.Id == idServicioAux);

            string textoMostrar = servicio.Titulo;

            if (textoMostrar.Length > 30)
            {
                textoMostrar = textoMostrar.Substring(0, 30) + " ..";
            }
            //textoMostrar += ". Deuda: " + Utilidades.ponerpuntos(clienteAux.Cliente.Deuda.ToString());
            Snackbar.Make(anchor, textoMostrar, Snackbar.LengthIndefinite)
            .SetAction("ACEPTAR", v =>
            {
                ((ReservasNuevoActivity)Activity).establecerServicio(servicio);
            })
            .Show();
        }
Esempio n. 25
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ideaTitleLbl       = FindViewById <TextView>(Resource.Id.itemTitle);
            ideaDescriptionLbl = FindViewById <TextView>(Resource.Id.itemDescription);
            detailsView        = FindViewById <LinearLayout>(Resource.Id.detailsView);
            addNoteFab         = FindViewById <FloatingActionButton>(Resource.Id.addNotefab);
            var editNoteBtn = FindViewById <Button>(Resource.Id.editNoteBtn);

            noteHolder     = FindViewById <CardView>(Resource.Id.noteHolder);
            noteContentLbl = FindViewById <TextView>(Resource.Id.noteContent);

            addNoteFab.Click += AddNoteFab_Click;
            var swipeListener = new OnSwipeListener(this);

            swipeListener.OnSwipeRight += SwipeListener_OnSwipeRight;
            swipeListener.OnSwipeLeft  += SwipeListener_OnSwipeLeft;
            ideaDescriptionLbl.SetOnTouchListener(swipeListener);
            detailsView.SetOnTouchListener(swipeListener);

            editNoteBtn.Click += delegate
            {
                var dialog = new AddNoteDialog(ideasList[Global.IdeaScrollPosition].Note);
                dialog.Show(FragmentManager, "ADDNOTEFRAG");
                dialog.OnError    += () => Snackbar.Make(addNoteFab, "Invalid note. Entry fields cannot be empty.", Snackbar.LengthLong).Show();
                dialog.OnNoteSave += (Note note) => SaveNote(note);
            };

            bookmarkedItems = await DBSerializer.DeserializeDBAsync <List <Idea> >(Global.BOOKMARKS_PATH);

            bookmarkedItems = bookmarkedItems ?? new List <Idea>();
            idea            = Global.Categories[Global.CategoryScrollPosition].Items[Global.IdeaScrollPosition];
            ideasList       = Global.Categories[Global.CategoryScrollPosition].Items;
            notes           = await DBSerializer.DeserializeDBAsync <List <Note> >(Global.NOTES_PATH);

            notes = notes ?? new List <Note>();

            SetupUI();
        }
Esempio n. 26
0
        private void RequestPhoneStatePermission()
        {
            Log.Info(TAG, "ReadPhoneState  permission has NOT been granted. Requesting permission.");

            if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.ReadPhoneState))
            {
                // Provide an additional rationale to the user if the permission was not granted
                // and the user would benefit from additional context for the use of the permission.
                // For example if the user has previously denied the permission.
                Log.Info(TAG, "Displaying ReadPhoneState  permission rationale to provide additional context.");

                Snackbar.Make(layout, Resource.String.permission_phonestate_rationale,
                              Snackbar.LengthIndefinite).SetAction(Resource.String.ok, new Action <View>(delegate(View obj) {
                    ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.ReadPhoneState }, REQUEST_PHONE_STATE);
                })).Show();
            }
            else
            {
                // Camera permission has not been granted yet. Request it directly.
                ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.ReadPhoneState }, REQUEST_PHONE_STATE);
            }
        }
        void StartFingerprintScan(object sender, EventArgs args)
        {
            Permission permissionResult = ContextCompat.CheckSelfPermission(this,
                                                                            Manifest.Permission.UseFingerprint);

            if (permissionResult == Permission.Granted)
            {
                _initialPanel.Visibility        = ViewStates.Gone;
                _authenticatedPanel.Visibility  = ViewStates.Gone;
                _errorPanel.Visibility          = ViewStates.Gone;
                _scanInProgressPanel.Visibility = ViewStates.Visible;
                _dialogFrag.Init();
                _dialogFrag.Show(FragmentManager, DIALOG_FRAGMENT_TAG);
            }
            else
            {
                Snackbar.Make(FindViewById(Android.Resource.Id.Content),
                              Resource.String.missing_fingerprint_permissions,
                              Snackbar.LengthLong)
                .Show();
            }
        }
Esempio n. 28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            drawerLayout = this.FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            //Set hamburger items menu
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            //setup navigation view
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            //handle navigation
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                switch (e.MenuItem.ItemId)
                {
                //PDV - Pedido de Vendas
                case Resource.Id.nav_home_pdv:
                    ListItemClicked(0);
                    break;
                }

                Snackbar.Make(drawerLayout, "Você selecionou o menu: " + e.MenuItem.TitleFormatted, Snackbar.LengthLong)
                .Show();

                drawerLayout.CloseDrawers();
            };


            //if first time you will want to go ahead and click first item.
            if (savedInstanceState == null)
            {
                ListItemClicked(0);
            }
        }
Esempio n. 29
0
        private void SignUpUser(string email, string pass)
        {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            process = new ProgressDialog(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            if (Error())
            {
                auth.CreateUserWithEmailAndPassword(email, pass)
                .AddOnCompleteListener(this, this);
                process.SetMessage("Validando informacion, espere.");
                process.Show();
            }
            else
            {
                if (process.IsShowing)
                {
                    process.Dismiss();
                }
                Snackbar snackBar = Snackbar.Make(signupLayout, "Register Failed, campos vacios " + emailError, Snackbar.LengthShort);
                snackBar.Show();
            }
        }
Esempio n. 30
0
        /**
         * Requests the Internet permission.
         * If the permission has been denied previously, a SnackBar will prompt the user to grant the
         * permission, otherwise it is requested directly.
         */
        void RequestInternetPermission()
        {
            //Log.Info (TAG, "Internet permission has NOT been granted. Requesting permission.");

            if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Android.Manifest.Permission.AccessCoarseLocation))
            {
                // Provide an additional rationale to the user if the permission was not granted
                // and the user would benefit from additional context for the use of the permission.
                // For example if the user has previously denied the permission.
                //Log.Info (TAG, "Displaying Intenet permission rationale to provide additional context.");

                Snackbar
                .Make(layout, "Message sent", Snackbar.LengthLong)
                .SetAction("OK", (view) => { ActivityCompat.RequestPermissions(this, new String[] { Android.Manifest.Permission.Internet }, REQUEST_INTERNET); })
                .Show();
            }
            else
            {
                // Camera permission has not been granted yet. Request it directly.
                ActivityCompat.RequestPermissions(this, new String[] { Android.Manifest.Permission.Internet }, REQUEST_INTERNET);
            }
        }