Exemplo n.º 1
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();
            }));
        }
        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();
        }
Exemplo n.º 3
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();
            }));
        }
        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);
            }
        }
Exemplo n.º 5
0
        /// <Docs>To be added.</Docs>
        /// <remarks>To be added.</remarks>
        /// <summary>
        /// Raises the post execute event.
        /// </summary>
        /// <param name="result">Result.</param>
        protected override void OnPostExecute(List <ISerialNumber> result)
        {
            Log.D(this, "Finished downloading");
            dialog.Dismiss();

            var sb = new StringBuilder();

            if (result.Count > 0)
            {
                for (int i = 0; i < result.Count - 1; i++)
                {
                    sb.Append(result[i].ToString()).Append(", ");
                }
                sb.Append(result[result.Count - 1]);
            }

            var d = new IONAlertDialog(context, Resource.String.download_error);

            d.SetMessage(string.Format(context.GetString(Resource.String.report_certificates_error_download_fails_1sarg, sb.ToString())));
            d.SetNegativeButton(Resource.String.ok, (obj, args) => {
                var dialog = obj as Dialog;
                if (dialog != null)
                {
                    dialog.Dismiss();
                }
            });
            d.Show();

            if (onCompleted != null)
            {
                onCompleted();
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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");
                }
            }
        }
Exemplo n.º 8
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();
            }
        }
        // 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));
            }
        }
        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();
        }
        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);
                }));
            }
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
        }
        /// <summary>
        /// Sends a support email to appion.
        /// </summary>
        /// <returns>The app suppory email.</returns>
        public static void SendAppSupportEmail(this IONPortalService service, IION ion, Activity activity)
        {
            var dump = ion.CreateApplicationDump();

            var i = new Intent(Intent.ActionSend);

            try {
                var file = ion.fileManager.CreateTemporaryFile("HostDetails.json");
                var s    = file.OpenForWriting();
                var w    = new StreamWriter(s);
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(dump, Formatting.Indented);
                w.Write(json);
                w.Dispose();
                s.Dispose();
                i.PutExtra(Intent.ExtraStream, Android.Net.Uri.FromFile(new Java.IO.File(file.fullPath)));
            } catch (Exception e) {
                Log.E(THIS, "Failed to create the application dump", e);
            }

            i.SetFlags(ActivityFlags.NewTask | ActivityFlags.NoHistory);
            i.PutExtra(Intent.ExtraEmail, new string[] { AppionConstants.EMAIL_SUPPORT });
            i.SetType(AppionConstants.MIME_RFC822);

            try {
                var chooser = Intent.CreateChooser(i, activity.GetString(Resource.String.preferences_send_feedback));
                chooser.SetFlags(ActivityFlags.NewTask | ActivityFlags.NoHistory);
                activity.StartActivity(chooser);
            } catch (Exception e) {
                Log.E(THIS, "Failed to start e-mail activity for support message", e);
                var adb = new IONAlertDialog(activity, Resource.String.preferences_send_feedback);
                adb.SetMessage(Resource.String.preferences_send_feedback_failed);
                adb.SetNegativeButton(Resource.String.cancel, (obj, args) => {
                    var dialog = obj as Dialog;
                    dialog.Dismiss();
                });
                adb.SetPositiveButton(Resource.String.ok, (obj, args) => {
                    var dialog = obj as Dialog;
                    dialog.Dismiss();

                    try {
                        activity.StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + activity.PackageName)));
                    } catch (Exception ee) {
                        Log.E(THIS, "Failed to start activity for maket with package name.", ee);
                        activity.StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("http://play.google.com/store/apps/details?id=" + activity.PackageName)));
                    }
                });

                adb.Show();
            }
        }
Exemplo n.º 15
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();
                }
            };
        }
Exemplo n.º 19
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);
        }
        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);
        }
        /// <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();
        }
Exemplo n.º 22
0
        /// <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();
        }
Exemplo n.º 23
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();
        }
Exemplo n.º 24
0
        /// <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();
        }
Exemplo n.º 25
0
        /// <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();
        }
Exemplo n.º 26
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();
     }
 }
Exemplo n.º 28
0
        /// <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();
        }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Saves the screentshot report to the application's screenshot archive.
        /// </summary>
        private async void SaveScreenshotReport()
        {
            var pd = new ProgressDialog(this);

            pd.SetTitle(GetString(Resource.String.saving));
            pd.SetMessage(GetString(Resource.String.please_wait));
            pd.Indeterminate = true;
            pd.Show();

            var task = Task.Factory.StartNew(() => {
                var report = new ScreenshotReport();

                report.screenshot = screenshot;
                report.title      = GetString(Resource.String.app_name) + " " + GetString(Resource.String.report_screenshot);
                report.subtitle   = nameView.Text;
//        report.created = createdDate;
                report.notes = notesView.Text;

                report.tableData = new string[, ] {
                    { GetString(Resource.String.date), createdDate.ToShortDateString() + " " + createdDate.ToShortTimeString() },
                    { GetString(Resource.String.app_version), ion.version },
                    { GetString(Resource.String.location_address_1), addressView1.Text },
                    { GetString(Resource.String.location_address_2), addressView2.Text },
                    { GetString(Resource.String.location_city), cityView.Text },
                    { GetString(Resource.String.location_state_province_region), stateView.Text },
                    { GetString(Resource.String.location_country), countryView.Text },
                    { GetString(Resource.String.zip), zipView.Text },
                };

                try {
                    // TODO [email protected]: throw error if already exists
                    var dir  = ion.screenshotReportFolder;
                    var file = dir.GetFile(report.subtitle + ".pdf", EFileAccessResponse.CreateIfMissing);
                    using (var stream = file.OpenForWriting()) {
                        ScreenshotReportPdfExporter.Export(report, stream);
                    }

                    return(new Result());
                } catch (Exception e) {
                    Log.E(this, "Failed to create screenshot pdf report", e);
                    return(new Result(GetString(Resource.String.report_screenshot_error_export_failed)));
                }
            });

            var result = await task;

            pd.Dismiss();

            if (result.success)
            {
                Alert(Resource.String.report_screenshot_saved);
            }
            else
            {
                var err = new IONAlertDialog(this, "ERROR");
                err.SetMessage(result.errorReason);
                err.SetNegativeButton(Resource.String.cancel, (obj, args) => {
                    var d = obj as Dialog;
                    if (d != null)
                    {
                        d.Dismiss();
                    }
                });
                err.Show();
            }

            Finish();
        }