// Overridden from Activity
        public override bool OnMenuItemSelected(int featureId, IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                SetResult(Result.Canceled);
                Finish();
                return(true);

            case Resource.Id.help:
                var adb = new IONAlertDialog(this);
                adb.SetTitle(Resource.String.help);
                adb.SetMessage(Resource.String.fluid_help_mixture_clarification);
                adb.SetNegativeButton(Resource.String.close, (sender, e) => {
                });
                adb.SetPositiveButton(Resource.String.settings, (sender, e) => {
                    var i = new Intent(this, typeof(AppPreferenceActivity));
                    StartActivity(i);
                });
                adb.Show();
                return(true);

            default:
                return(base.OnMenuItemSelected(featureId, item));
            }
        }
Beispiel #2
0
        public JobViewHolder(SwipeRecyclerView rv, Action <JobRow> onFavoriteClicked) : base(rv, Resource.Layout.view_holder_job, Resource.Layout.view_delete)
        {
            this.id         = foreground.FindViewById <TextView>(Resource.Id.id);
            this.name       = foreground.FindViewById <TextView>(Resource.Id.name);
            this.customer   = foreground.FindViewById <TextView>(Resource.Id.customer_no);
            this.dispatch   = foreground.FindViewById <TextView>(Resource.Id.dispatch_no);
            this.purchase   = foreground.FindViewById <TextView>(Resource.Id.purchase_no);
            this.favorite   = foreground.FindViewById <ImageView>(Resource.Id.check);
            favorite.Click += (s, e) => {
                onFavoriteClicked(record.data);
            };
            var b = background as TextView;

            b.SetText(Resource.String.delete);
            b.SetOnClickListener(new ViewClickAction((view) => {
                if (record == null)
                {
                    return;
                }
                var adb = new IONAlertDialog(view.Context);
                adb.SetTitle(Resource.String.job_delete_title);
                adb.SetMessage(Resource.String.job_delete_message);
                adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {});
                adb.SetPositiveButton(Resource.String.delete, (sender, e) => {
                    var ion = AppState.context;
                    ion.database.DeleteAsync(record.data);
                });
                adb.Show();
            }));
        }
        protected override void OnResume()
        {
            base.OnResume();

            displayName.Text = ion.portal.displayName;
            email.Text       = ion.portal.userEmail;

            if (!ion.hasNetworkConnection)
            {
                var adb = new IONAlertDialog(this);
                adb.SetTitle(Resource.String.network_error);
                adb.SetMessage(Resource.String.network_no_connection);
                adb.SetPositiveButton(Resource.String.ok, (sender, e) => {
                    SetResult(Result.Canceled);
                    Finish();
                });
                adb.Show();
                return;
            }

            if (!ion.portal.isLoggedIn)
            {
                var i = new Intent(this, typeof(PortalLoginActivity));
                StartActivityForResult(i, REQUEST_LOGIN);
            }
        }
        private void RequestConfirmAccess(int index, AccessCode code)
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.portal_access_code_confirm);
            adb.SetMessage(Resource.String.portal_access_code_confirm_access);

            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {});
            adb.SetPositiveButton(Resource.String.ok, async(sender, e) => {
                var pd = new ProgressDialog(this);
                pd.SetTitle(Resource.String.portal_access_code_confirming);
                pd.SetMessage(GetString(Resource.String.please_wait));
                pd.SetCancelable(false);
                pd.Show();

                var response = await ion.portal.RequestConfirmAccessCodeAsync(code);
                if (response.success)
                {
                    Toast.MakeText(this, Resource.String.portal_update_successful, ToastLength.Short).Show();
                    adapter.RemoveRecord(index);
                }
                else
                {
                    Toast.MakeText(this, Resource.String.portal_error_update_failed, ToastLength.Long).Show();
                }

                pd.Dismiss();
            });

            adb.Show();
        }
Beispiel #5
0
        /// <summary>
        /// Checks that the application has all of the permissions inline to actually start up.
        /// </summary>
        /// <returns>The permissions.</returns>
        private void EnsureBluetoothPermissions()
        {
            if (Permission.Granted != ContextCompat.CheckSelfPermission(this, Android.Manifest.Permission.AccessFineLocation))
            {
                var adb = new IONAlertDialog(this);
                adb.SetTitle(Resource.String.alert);
                adb.SetCancelable(false);
                adb.SetMessage(Resource.String.error_start_up_request_location_for_bluetooth);
                adb.SetPositiveButton(Resource.String.allow, (sender, e) => {
                    var d = sender as Dialog;
                    d.Dismiss();
                    ActivityCompat.RequestPermissions(this, new string[] { Android.Manifest.Permission.AccessFineLocation }, REQUEST_LOCATION_PERMISSIONS);
                });
                adb.SetNegativeButton(Resource.String.deny, (sender, e) => {
                    var d = sender as Dialog;
                    d.Dismiss();
                    ShowMissingPermissionsDialog(GetString(Resource.String.location));
                });

                adb.Show();
            }
            else
            {
                // We are all good and have all of our permissions. Start the application.
                Task.Factory.StartNew(InitApplication);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Toggles the recording session.
        /// </summary>
        public async void ToggleRecordingSession(IMenuItem item)
        {
            if (ion.dataLogManager.isRecording)
            {
                if (!await ion.dataLogManager.StopRecording())
                {
                    Log.D(this, "Failed to stop recording");
                }
            }
            else
            {
                if (ion.currentWorkbench.isEmpty && ion.currentAnalyzer.isEmpty)
                {
                    var adb = new IONAlertDialog(Activity);
                    adb.SetTitle(Resource.String.report_data_logging);
                    adb.SetMessage(Resource.String.report_error_workbench_and_analyzer_empty);
                    adb.SetPositiveButton(Resource.String.close, (sender, e) => { });
                    adb.Show();
                    return;
                }

                var interval = ion.preferences.report.dataLoggingInterval;
                Log.D(this, "Starting record with an interval of: " + interval.ToString());

                if (!await ion.dataLogManager.BeginRecording(interval))
                {
                    Error(Resource.String.report_error_failed_to_start_recording);
                    Log.D(this, "Failed to begin recording");
                }
            }
        }
Beispiel #7
0
        private async Task UploadSessions()
        {
            var pd = new ProgressDialog(this);

            pd.SetTitle(Resource.String.portal_uploading_sessions);
            pd.SetMessage(GetString(Resource.String.please_wait));
            pd.SetCancelable(false);
            pd.Show();

            var sessions = new List <SessionRow>();

            foreach (var sr in adapter.GetCheckedSessions())
            {
                sessions.Add(sr.data);
            }
            var result = await ion.portal.RequestUploadSessionsAsync(ion, sessions);

            pd.Dismiss();

            if (result.success)
            {
                Toast.MakeText(this, Resource.String.portal_upload_sessions_success, ToastLength.Long).Show();
            }
            else
            {
                var adb = new IONAlertDialog(this);
                adb.SetTitle(Resource.String.portal_error);
                adb.SetMessage(Resource.String.portal_error_upload_sessions_failed);
                adb.SetNegativeButton(Resource.String.cancel, (sender, args) => {
                });
                adb.Show();
            }
        }
Beispiel #8
0
        // Overridden from Activity;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            ActionBar.SetDisplayHomeAsUpEnabled(true);

            SetContentView(Resource.Layout.activity_fluid_manager);

            colorView     = FindViewById(Resource.Id.color);
            fluidNameView = FindViewById <TextView>(Resource.Id.name);
            pagerView     = FindViewById <ViewPager>(Resource.Id.content);
            pagerView.AddOnPageChangeListener(this);
            favoritesButton = FindViewById <Button>(Resource.Id.button1);
            libraryButton   = FindViewById <Button>(Resource.Id.button2);

            favoritesButton.Click += (sender, e) => {
                pagerView.SetCurrentItem(0, true);
            };

            libraryButton.Click += (sender, e) => {
                pagerView.SetCurrentItem(1, true);
            };

            ion = AppState.context;
            ion.fluidManager.onFluidPreferenceChanged += OnFluidPreferenceChanged;

            preferred                  = new FluidFragment(ion);
            preferred.emptyText        = GetString(Resource.String.fluid_empty_preferred);
            preferred.title            = GetString(Resource.String.favorites);
            preferred.onFluidSelected += OnFluidSelected;

            library                  = new FluidFragment(ion);
            library.emptyText        = GetString(Resource.String.fluid_empty_library);
            library.title            = GetString(Resource.String.library);
            library.onFluidSelected += OnFluidSelected;

            selectedFluid = Intent.GetStringExtra(EXTRA_SELECTED);
            if (selectedFluid == null)
            {
                selectedFluid = ion.fluidManager.lastUsedFluid.name;
            }

            adapter = new FluidFragmentAdapter(FragmentManager, new FluidFragment[] {
                preferred,
                library,
            });

            pagerView.Adapter = adapter;

            var help = FindViewById(Resource.Id.help);

            help.SetOnClickListener(new ViewClickAction((view) => {
                var adb = new IONAlertDialog(this);
                adb.SetTitle(Resource.String.fluid_safety_help);
                adb.SetMessage(Resource.String.fluid_safety_help_descriptions);
                adb.SetPositiveButton(Resource.String.ok, (s, e2) => {
                });
                adb.Show();
            }));
        }
        private void ShowHelpDialog()
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.help);
            adb.SetMessage(Resource.String.grid_help);
            adb.SetNegativeButton(Resource.String.close, (sender, args) => { });
            adb.Show();
        }
Beispiel #10
0
        private void RequestDeleteSessions(IEnumerable <SessionRow> sessions)
        {
            var adb = new IONAlertDialog(Activity);

            adb.SetTitle(Resource.String.report_sessions_delete_request);
            adb.SetMessage(Resource.String.report_sessions_delete_warning);
            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => { });
            adb.SetPositiveButton(Resource.String.delete, (sender, e) => {
                DeleteCheckedSessions(sessions);
            });
            adb.Show();
        }
        private void InvalidateLocationForSensor(GaugeDeviceSensor sensor, View container)
        {
            var wb   = container.FindViewById <ImageView>(Resource.Id.workbench);
            var anal = container.FindViewById <ImageView>(Resource.Id.analyzer);

            if (ion.currentWorkbench.ContainsSensor(sensor))
            {
                wb.SetBackgroundResource(0);
                wb.SetImageResource(Resource.Drawable.ic_devices_on_workbench);
                wb.SetOnClickListener(new ViewClickAction((v) => {
                    var adb = new IONAlertDialog(Activity);
                    adb.SetTitle(Resource.String.workbench_remove);
                    adb.SetMessage(Resource.String.workbench_remove_sensor);
                    adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { });
                    adb.SetPositiveButton(Resource.String.remove, (sender, e) => {
                        ion.currentWorkbench.Remove(sensor);
                    });
                    adb.Show();
                }));
            }
            else
            {
                wb.SetBackgroundResource(Resource.Drawable.xml_rect_gold_black_bordered);
                wb.SetImageResource(Resource.Drawable.ic_devices_add_to_workbench);
                wb.SetOnClickListener(new ViewClickAction((v) => {
                    AddSensorToWorkbench(sensor);
                }));
            }

            if (ion.currentAnalyzer.HasSensor(sensor))
            {
                anal.SetBackgroundResource(0);
                anal.SetImageResource(Resource.Drawable.ic_devices_on_analyzer);
                anal.SetOnClickListener(new ViewClickAction((c) => {
                    var adb = new IONAlertDialog(Activity);
                    adb.SetTitle(Resource.String.analyzer_remove_sensor);
                    adb.SetMessage(Resource.String.analyzer_remove_sensor_remote);
                    adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { });
                    adb.SetPositiveButton(Resource.String.remove, (sender, e) => {
                        ion.currentAnalyzer.RemoveSensor(sensor);
                    });
                    adb.Show();
                }));
            }
            else
            {
                anal.SetBackgroundResource(Resource.Drawable.xml_rect_gold_black_bordered);
                anal.SetImageResource(Resource.Drawable.ic_devices_add_to_analyzer);
                anal.SetOnClickListener(new ViewClickAction((c) => {
                    AddSensorToAnalyzer(sensor);
                }));
            }
        }
Beispiel #12
0
        private void RequestDeleteJob()
        {
            var adb = new IONAlertDialog(Activity);

            adb.SetTitle(Resource.String.job_delete_title);
            adb.SetMessage(Resource.String.job_delete_message);
            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {
            });
            adb.SetPositiveButton(Resource.String.delete, (sender, e) => {
                DeleteJob();
            });
            adb.Show();
        }
Beispiel #13
0
        /// <summary>
        /// Shows a dialog to the user explaining that the application cannot start due to missing permissions.
        /// </summary>
        /// <param name="permissions">A comma separated string of permissions</param>
        /// <returns>The missing permissions dialog.</returns>
        private void ShowMissingPermissionsDialog(string permissions)
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.error_start_up_fail);
            adb.SetMessage(string.Format(GetString(Resource.String.error_start_up_failed_to_acquire_permissions), permissions));
            adb.SetCancelable(false);
            adb.SetNegativeButton(Resource.String.close, (sender, e) => {
                var d = sender as Dialog;
                d.Dismiss();
                Finish();
            });
            adb.Show();
        }
        // Overridden from PreferenceActivity
        public override void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
        {
            base.OnSharedPreferenceChanged(prefs, key);

            if (GetString(Resource.String.pkey_location_gps).Equals(key))
            {
                if (ion.locationManager.isEnabled && ion.appPrefs._location.allowsGps && !ion.locationManager.supportsAltitudeTracking)
                {
                    // TODO [email protected]: implement a dialog that will let the user know that they are not getting live updates
                    var adb = new IONAlertDialog(this);
                    adb.SetTitle("US HELP");
//          adb.Show();
                }
            }
        }
        private void RequestDeleteSession(SessionRecord record)
        {
            var context = recyclerView.Context;
            var adb     = new IONAlertDialog(context);

            adb.SetTitle(Resource.String.report_delete_session);
            adb.SetMessage(Resource.String.report_delete_session_message);

            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {
                var d = sender as Dialog;
                if (d != null)
                {
                    d.Cancel();
                }
            });
            adb.SetPositiveButton(Resource.String.delete, async(sender, e) => {
                var pd = new ProgressDialog(context);
                pd.SetTitle(Resource.String.please_wait);
                pd.SetMessage(context.GetString(Resource.String.deleting));
                pd.Indeterminate = true;
                pd.Show();

                // First we have to delete all the records
                var ion      = AppState.context;
                var database = AppState.context.database;

                try {
                    database.BeginTransaction();

                    var results = database.Table <SensorMeasurementRow>().Delete(smr => smr.frn_SID == record.data._id);
                    Log.D(this, "Deleted " + results + " sensor measurement rows");
                    database.Commit();

                    Log.D(this, "Deleted session: " + record.data._id + " = " + await AppState.context.database.DeleteAsync <SessionRow>(record.data));
                    var index = records.IndexOf(record);
                    records.RemoveAt(index);
                    NotifyItemRemoved(index);
                } catch (Exception ex) {
                    Log.E(this, "Failed to delete records", ex);
                    database.Rollback();
                    Toast.MakeText(context, Resource.String.error_failed_to_delete, ToastLength.Short).Show();
                } finally {
                    pd.Dismiss();
                }
            });

            adb.Show();
        }
        private void ResolveForgotPassword()
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.portal_password_reset);
            var view = LayoutInflater.From(this).Inflate(Resource.Layout.dialog_portal_password_reset, null, false);

            adb.SetView(view);
            adb.SetCancelable(true);

            var edit = view.FindViewById <EditText>(Resource.Id.password);

            var d = adb.Show();

            view.FindViewById(Resource.Id.cancel).Click += (sender, e) => {
                d.Dismiss();
            };

            view.FindViewById(Resource.Id.ok).Click += async(sender, e) => {
                if (!string.IsNullOrEmpty(edit.Text))
                {
                    var pd = new ProgressDialog(this);
                    pd.SetTitle(Resource.String.working);
                    pd.SetMessage(GetString(Resource.String.please_wait));
                    pd.SetCancelable(false);
                    pd.Show();

                    var response = await ion.portal.RequestResetUserPasswordAsync(edit.Text);

                    if (response.success)
                    {
                        Toast.MakeText(this, Resource.String.portal_password_reset_sent, ToastLength.Long).Show();
                        d.Dismiss();
                    }
                    else
                    {
                        Toast.MakeText(this, Resource.String.portal_error_failed_to_login, ToastLength.Long).Show();
                    }

                    pd.Dismiss();
                }
                else
                {
                    Toast.MakeText(this, Resource.String.portal_error_email_invalid, ToastLength.Long).Show();
                }
            };
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var ret = inflater.Inflate(Resource.Layout.fragment_job_edit_sessions, container, false);

            current             = ret.FindViewById(Resource.Id.remove);
            currentList         = current.FindViewById <RecyclerView>(Resource.Id.list);
            removeButton        = current.FindViewById(Resource.Id.button);
            removeButton.Click += (sender, e) => {
                var success = RemoveSelected();

                if (success)
                {
                    Alert(GetString(Resource.String.job_saved));
                    InternalRefreshSessions();
                }
                else
                {
                    Error(GetString(Resource.String.job_error_failed_to_save));
                }
            };

            available        = ret.FindViewById(Resource.Id.add);
            availableList    = available.FindViewById <RecyclerView>(Resource.Id.list);
            addButton        = available.FindViewById(Resource.Id.button);
            addButton.Click += (sender, e) => {
                var checkedSessions = availableAdapter.GetCheckedSessions();
                if (checkedSessions.Where(x => x.data.frn_JID != 0).Count() > 0)
                {
                    var dialog = new IONAlertDialog(Activity);
                    // TODO [email protected]: Check this this verbage is ok
                    dialog.SetTitle(Resource.String.job_link_break_title);
                    dialog.SetMessage(GetString(Resource.String.job_link_ensure_break_request));
                    dialog.SetNegativeButton(Resource.String.cancel, (s2, e2) => {});
                    dialog.SetPositiveButton(Resource.String.job_link, (s2, e2) => {
                        AddSelected();
                    });
                    dialog.Show();
                }
                else
                {
                    AddSelected();
                }
            };

            return(ret);
        }
Beispiel #18
0
        private void NavigateToPdf()
        {
            if (pdfs == null)
            {
                pdfs               = new FileBrowserFragment(GetString(Resource.String.report_archive_empty));
                pdfs.folder        = ion.dataLogReportFolder;
                pdfs.filter        = new FileExtensionFilter(true, new string[] { FileExtensions.EXT_PDF });
                pdfs.onFileClicked = (file) => {
                    try {
                        var i = new Intent(Intent.ActionView);
                        i.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(file.fullPath)), MIME_PDF);
                        i.SetFlags(ActivityFlags.NoHistory);
                        StartActivity(Intent.CreateChooser(i, GetString(Resource.String.open_with)));
                    } catch (Exception e) {
                        Log.E(this, "Failed to start pdf activity chooser", e);
                        var adb = new IONAlertDialog(this);
                        adb.SetTitle(Resource.String.error_failed_to_open_file);
                        adb.SetMessage(Resource.String.error_pdf_viewer_missing);
                        adb.SetNegativeButton(Resource.String.cancel, (sender, ex) => {
                        });
                        adb.Show();
                    }
                };
            }
            newReport.SetBackgroundResource(Resource.Drawable.xml_tab_gray_black);
            savedReports.SetBackgroundResource(Resource.Drawable.xml_tab_gold_white);

            header.SetText(Resource.String.report_archive);
            header.SetBackgroundColor(Resource.Color.orange.AsResourceColor(this));

            tab1.SetBackgroundResource(Resource.Drawable.xml_tab_gray_black);
            tab1.SetText(Resource.String.spreadsheet);

            tab2.SetBackgroundResource(Resource.Drawable.xml_tab_white_light_blue);
            tab2.SetText(Resource.String.pdf);

            tab1.SetOnClickListener(new ViewClickAction((view) => {
                NavigateToSpreadsheets();
            }));

            tab2.SetOnClickListener(new ViewClickAction((view) => {
                NavigateToPdf();
            }));

            NavigateToFragment(pdfs);
        }
        /// <summary>
        /// Downloads the calibration certificates.
        /// </summary>
        private void RequestDownloadCalibrationCertificates()
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.report_certificates_download);
            adb.SetMessage(Resource.String.report_certificates_download_request);
            adb.SetNegativeButton(Resource.String.cancel, (obj, args) => {
                var dialog = obj as Dialog;
                if (dialog != null)
                {
                    dialog.Dismiss();
                }
            });

            adb.SetPositiveButton(Resource.String.ok, (obj, args) => {
                var dialog = obj as Dialog;
                if (dialog != null)
                {
                    dialog.Dismiss();
                }

                if (HasInternetConnection())
                {
                    var serials = new List <ISerialNumber>();

                    foreach (var d in ion.deviceManager.devices)
                    {
                        serials.Add(d.serialNumber);
                    }

                    var task         = new DownloadCalibrationCertificateTask(this, ion);
                    task.onCompleted = () => {
                        fragment.folder = ion.calibrationCertificateFolder;
                    };
                    task.Execute(serials);
                }
                else
                {
                    Alert(Resource.String.error_no_internet_connection);
                }
            });

            adb.Show();
        }
        /// <summary>
        /// Shows a dialog verifying that the user really desires to shut down the application.
        /// </summary>
        private void RequestShutdown()
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.request_shutdown);
            adb.SetMessage(Resource.String.request_shutdown_message);
            adb.SetNegativeButton(Resource.String.cancel, (o, e) => {
                var dialog = o as Dialog;
                dialog.Dismiss();
            });
            adb.SetPositiveButton(Resource.String.ok, (o, e) => {
//#if DEBUG == false
                TryUploadLogs();
//#endif
                var dialog = o as Dialog;
                dialog.Dismiss();
                Shutdown();
            });
            adb.Show();
        }
Beispiel #21
0
        public void RequestDeleteJob(JobRecord record)
        {
            var context = recyclerView.Context;
            var adb     = new IONAlertDialog(context);

            adb.SetTitle(Resource.String.job_delete_title);
            adb.SetMessage(Resource.String.job_delete_message);

            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {
                var d = sender as Dialog;
                if (d != null)
                {
                    d.Cancel();
                }
            });
            adb.SetPositiveButton(Resource.String.delete, (sender, e) => {
                Log.V(this, "Deleted job: " + record.data._id + " = " + AppState.context.database.DeleteAsync <JobRow>(record.data));
            });

            adb.Show();
        }
        /// <summary>
        /// Shows a dialog that will request that the user enable location so that we may scan.
        /// </summary>
        public void RequestFineLocationPermission(Action onDeny = null)
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.error_location_disabled);
            adb.SetMessage(Resource.String.error_start_up_request_location_for_bluetooth);
            adb.SetCancelable(false);
            adb.SetNegativeButton(Resource.String.close, (sender, e) => {
                var d = sender as Dialog;
                d.Dismiss();
                if (onDeny != null)
                {
                    onDeny();
                }
            });
            adb.SetPositiveButton(Resource.String.allow, (sender, e) => {
                var d = sender as Dialog;
                d.Dismiss();
                ActivityCompat.RequestPermissions(this, new string[] { Android.Manifest.Permission.AccessFineLocation }, REQUEST_LOCATION_PERMISSIONS);
            });
            adb.Show();
        }
        /// <summary>
        /// Shows a dialog that will turn explaining to the user that bluetooth is off.
        /// </summary>
        public void RequestBluetoothAdapterOn(Action onDeny = null)
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.bluetooth_disabled);
            adb.SetMessage(Resource.String.error_bluetooth_scan_module_off);
            adb.SetCancelable(false);
            adb.SetNegativeButton(Resource.String.cancel, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();
                if (onDeny != null)
                {
                    onDeny();
                }
            });
            adb.SetPositiveButton(Resource.String.enable_bluetooth, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();
                ShowEnableBluetoothDialog();
            });
            adb.Show();
        }
Beispiel #24
0
        public Dialog Show()
        {
            var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_report_export_options, null, false);

            var tabHost = view.FindViewById <TabHost>(Android.Resource.Id.TabHost);
            var tab1    = view.FindViewById(Resource.Id.tab_1);
            var tab2    = view.FindViewById(Resource.Id.tab_2);

            var adb = new IONAlertDialog(context);

            adb.SetTitle(Resource.String.report_choose_export_format);
            adb.SetView(view);
            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {
            });
            adb.SetPositiveButton(Resource.String.export, (sender, e) => {
                Toast.MakeText(context, "EXPORT", ToastLength.Long).Show();
            });
            var ret = adb.Create();

            ret.Show();
            return(ret);
        }
 /// <summary>
 /// Starts an activity that will allow the user to view the given pdf.
 /// </summary>
 private void StartPdfActivity(IFile file)
 {
     try {
         Intent i = new Intent(Intent.ActionView);
         i.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(file.fullPath)), "application/pdf");
         i.SetFlags(ActivityFlags.NoHistory);
         StartActivity(Intent.CreateChooser(i, GetString(Resource.String.open_with)));
     } catch (Exception e) {
         Log.E(this, "Failed to start PDF activity chooser", e);
         var adb = new IONAlertDialog(this);
         adb.SetTitle(Resource.String.error_failed_to_open_file);
         adb.SetMessage(Resource.String.error_pdf_viewer_missing);
         adb.SetNegativeButton(Resource.String.cancel, (obj, args) => {
             var dialog = obj as Dialog;
             if (dialog != null)
             {
                 dialog.Dismiss();
             }
         });
         adb.Show();
     }
 }
        public async Task <bool> StartLocalIONAsync()
        {
            bool result = false;

            try {
                result = await service.InitLocalION();
            } catch (Exception e) {
                Log.E(this, "Failed to start LocalION", e);
            }

            if (!result)
            {
                var adb = new IONAlertDialog(this);
                // TODO-LOCALIZE [email protected]:
                adb.SetTitle("US Error");
                adb.SetMessage("US Failed to start remote ION. Please check your internet connection. If the issue persists, please contact Appion at " + AppionConstants.EMAIL_SUPPORT);
                adb.SetNegativeButton(Resource.String.close, (sender, args) => {});
                adb.Show();
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Shows a dialog that will prompt a user to renable their gps.
        /// </summary>
        /// <param name="onDeny">On deny.</param>
        public void RequestLocationServicesEnabled(Action onDeny = null)
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.bluetooth_location_off);
            adb.SetMessage(Resource.String.bluetooth_requires_location);
            adb.SetCancelable(true);
            adb.SetNegativeButton(Resource.String.cancel, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();
                if (onDeny != null)
                {
                    onDeny();
                }
            });
            adb.SetPositiveButton(Resource.String.enable, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();
                var intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
                StartActivity(intent);
            });
            adb.Show();
        }
        private void ResolveRegister()
        {
            var adb = new IONAlertDialog(this);

            adb.SetTitle(Resource.String.register);
            var view = LayoutInflater.From(this).Inflate(Resource.Layout.dialog_portal_register, null, false);

            adb.SetView(view);
            adb.SetCancelable(true);

            var email           = view.FindViewById <EditText>(Resource.Id.email);
            var password        = view.FindViewById <EditText>(Resource.Id.password);
            var passwordConfirm = view.FindViewById <EditText>(Resource.Id.passwordConfirm);
            var icon            = view.FindViewById <ImageView>(Resource.Id.icon);

            password.TextChanged += (sender, e) => {
                if (password.Text.Equals(passwordConfirm.Text) && ion.portal.IsPasswordValid(password.Text))
                {
                    icon.SetColorFilter(Android.Graphics.Color.Green);
                    icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_check));
                }
                else
                {
                    icon.SetColorFilter(Android.Graphics.Color.Red);
                    icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_x));
                }
            };

            passwordConfirm.TextChanged += (sender, e) => {
                if (password.Text.Equals(passwordConfirm.Text) && ion.portal.IsPasswordValid(password.Text))
                {
                    icon.SetColorFilter(Android.Graphics.Color.Green);
                    icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_check));
                }
                else
                {
                    icon.SetColorFilter(Android.Graphics.Color.Red);
                    icon.SetImageBitmap(cache.GetBitmap(Resource.Drawable.ic_x));
                }
            };

            icon.Click += (sender, e) => {
                var dialog = new IONAlertDialog(this);
                dialog.SetMessage(GetString(Resource.String.portal_error_password_invalid));
                dialog.SetCancelable(true);
                dialog.SetNegativeButton(Resource.String.cancel, (sender2, e2) => {});
                dialog.Show();
            };

            var d = adb.Show();

            view.FindViewById(Resource.Id.cancel).Click += (sender, e) => {
                d.Dismiss();
            };

            view.FindViewById(Resource.Id.register).Click += async(sender, e) => {
                if (string.IsNullOrEmpty(email.Text))
                {
                    Toast.MakeText(this, Resource.String.portal_error_email_invalid, ToastLength.Long).Show();
                    return;
                }

                if (!password.Text.Equals(passwordConfirm.Text))
                {
                    Toast.MakeText(this, Resource.String.portal_error_passwords_dont_match, ToastLength.Long).Show();
                    return;
                }

                if (!ion.portal.IsPasswordValid(password.Text))
                {
                    Toast.MakeText(this, Resource.String.portal_error_password_invalid, ToastLength.Long).Show();
                    return;
                }

                if (password.Text.Equals(passwordConfirm.Text))
                {
                    var pd = new ProgressDialog(this);
                    pd.SetTitle(Resource.String.working);
                    pd.SetMessage(GetString(Resource.String.please_wait));
                    pd.SetCancelable(false);
                    pd.Show();

                    var response = await ion.portal.RegisterUser(email.Text, password.Text);

                    if (response.success)
                    {
                        Toast.MakeText(this, Resource.String.portal_password_reset_sent, ToastLength.Long).Show();
                        this.username.Text = email.Text;
                        this.password.Text = password.Text;
                        d.Dismiss();
                    }
                    else
                    {
                        Toast.MakeText(this, response.message, ToastLength.Long).Show();
                    }

                    pd.Dismiss();
                }
                else
                {
                    Toast.MakeText(this, Resource.String.portal_error_passwords_dont_match, ToastLength.Long).Show();
                }
            };
        }
Beispiel #29
0
        private async Task GetAddress()
        {
            if (!ion.appPrefs._location.allowsGps)
            {
                var adb = new IONAlertDialog(Activity);
                adb.SetTitle(Resource.String.location_settings_not_enabled);
                adb.SetMessage(Resource.String.location_settings_enabled_required);

                adb.SetNegativeButton(Resource.String.cancel, (sender, e) => { });
                adb.SetPositiveButton(Resource.String.allow, (sender, e) => {
                    ion.appPrefs._location.allowsGps = true;
                });

                adb.Show();
                return;
            }

            var dialog = new ProgressDialog(Activity);

            dialog.SetCanceledOnTouchOutside(false);
            dialog.SetTitle(Resource.String.please_wait);
            dialog.SetMessage(GetString(Resource.String.location_determining_address));
            dialog.Show();

            var usAddress = addressView.Text.Trim();

            if (string.IsNullOrEmpty(usAddress))
            {
                // Get current address based on coordinates
                var address = await PollGeocode();

                if (address == null)
                {
                    Toast.MakeText(Activity, Resource.String.location_undetermined, ToastLength.Long).Show();
                }
                else
                {
                    try {
                        addressView.Text = address.GetAddressLine(0) + ", " + address.GetAddressLine(1);
                        coordinates.Text = address.Latitude + ", " + address.Longitude;
                    } catch (Exception e) {
                        Log.E(this, "Failed to set address content", e);
                    }
                }
            }
            else
            {
                // Get coordinates based on given address
                var address = await PollGeocode(usAddress);

                if (address == null)
                {
                    Alert(Resource.String.location_undetermined);
                }
                else
                {
                    coordinates.Text = address.Latitude + ", " + address.Longitude;
                }
            }


            await Task.Delay(500);

            dialog.Dismiss();
        }