private void PerformSpecifiedEmergencyAction(ConstantsAndTypes.HELP_NOW_TYPES emergencyType) { try { switch (emergencyType) { case ConstantsAndTypes.HELP_NOW_TYPES.EmergencyTelephone: Log.Info(TAG, "PerformSpecifiedEmergencyAction: User confirmed Emergency Action for Call"); _cyclingEmergencyCalls = true; EmergencyMakeCall(); break; case ConstantsAndTypes.HELP_NOW_TYPES.EmergencySms: Log.Info(TAG, "PerformSpecifiedEmergencyAction: User confirmed Emergency Action for Sms"); EmergencySmsSend(); break; case ConstantsAndTypes.HELP_NOW_TYPES.EmergencyEmail: Log.Info(TAG, "PerformSpecifiedEmergencyAction: User confirmed Emergency Action for Email"); EmergencyEmailSend(); break; } } catch (Exception e) { Log.Error(TAG, "PerformSpecifiedEmergencyAction Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, "Performing a selected Emergency Action", "HelpNowActivity.PerformSpecifiedEmergencyAction"); } } }
private void GetEmergencyTitleAndQuestionForNowType(ConstantsAndTypes.HELP_NOW_TYPES emergencyType, out string resourceStringTitle, out string resourceStringQuestion) { try { resourceStringTitle = ""; resourceStringQuestion = ""; switch (emergencyType) { case ConstantsAndTypes.HELP_NOW_TYPES.EmergencyTelephone: resourceStringTitle = GetString(Resource.String.emergencyCallButtonPressedTitle); resourceStringQuestion = GetString(Resource.String.emergencyCallButtonPressedText); break; case ConstantsAndTypes.HELP_NOW_TYPES.EmergencySms: resourceStringTitle = GetString(Resource.String.emergencySmsButtonPressedTitle); resourceStringQuestion = GetString(Resource.String.emergencySmsButtonPressedText); break; case ConstantsAndTypes.HELP_NOW_TYPES.EmergencyEmail: resourceStringTitle = GetString(Resource.String.emergencyEmailButtonPressedTitle); resourceStringQuestion = GetString(Resource.String.emergencyEmailButtonPressedText); break; } } catch (Exception e) { Log.Error(TAG, "GetEmergencyTitleAndQuestionForNowType: Exception - " + e.Message); resourceStringTitle = ""; resourceStringQuestion = ""; if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, "Getting the Title and Question for the Emergency Type", "HelpNowActivity.GetEmergencyTitleAndQuestionForNowType"); } } }
private void ShowEmergencyDialogAlert(ConstantsAndTypes.HELP_NOW_TYPES emergencyType) { var resourceStringTitle = ""; var resourceStringQuestion = ""; try { if (emergencyType == ConstantsAndTypes.HELP_NOW_TYPES.EmergencySms) { if (!(PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.SendSms) && PermissionsHelper.PermissionGranted(this, ConstantsAndTypes.AppPermission.SendSms))) { if (GlobalData.Settings.Find(setting => setting.SettingKey == "NagSendSms").SettingValue == "False") { CheckPermission(ConstantsAndTypes.AppPermission.SendSms); return; } else { Toast.MakeText(this, Resource.String.SendSmsPermissionDenialToast, ToastLength.Short).Show(); return; } } } if (emergencyType == ConstantsAndTypes.HELP_NOW_TYPES.EmergencyTelephone) { if (!(PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.MakeCalls) && PermissionsHelper.PermissionGranted(this, ConstantsAndTypes.AppPermission.MakeCalls))) { if (GlobalData.Settings.Find(setting => setting.SettingKey == "NagMakeCalls").SettingValue == "False") { CheckPermission(ConstantsAndTypes.AppPermission.MakeCalls); return; } else { Toast.MakeText(this, Resource.String.MakeCallsPermissionDenialToast, ToastLength.Short).Show(); return; } } } StopSpeaking(); GetEmergencyTitleAndQuestionForNowType(emergencyType, out resourceStringTitle, out resourceStringQuestion); SayText(resourceStringQuestion); _emergencyType = emergencyType; AlertHelper alertHelper = new AlertHelper(this); if (alertHelper != null) { alertHelper.AlertTitle = resourceStringTitle; alertHelper.AlertMessage = resourceStringQuestion; alertHelper.AlertIconResourceID = Resource.Drawable.SymbolStop; alertHelper.AlertPositiveCaption = GetString(Resource.String.emergencyConfirmationPositive); alertHelper.AlertNegativeCaption = GetString(Resource.String.emergencyConfirmationNegative); alertHelper.InstanceId = "emergencyAlert"; alertHelper.ShowAlert(); } } catch (Exception e) { Log.Error(TAG, "ShowEmergencyDialogAlert: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, "Showing Emergency Alert Dialog", "HelpNowActivity.ShowEmergencyDialogAlert"); } } }