protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.multidataset_service_settings_activity); var preferences = MyPreferences.GetInstance(this); SetupSettingsSwitch(Resource.Id.settings_auth_responses_container, Resource.Id.settings_auth_responses_label, Resource.Id.settings_auth_responses_switch, preferences.IsResponseAuth(), new OnAuthResponseCheckedChange { preferences = preferences }); SetupSettingsSwitch(Resource.Id.settings_auth_datasets_container, Resource.Id.settings_auth_datasets_label, Resource.Id.settings_auth_datasets_switch, preferences.IsDatasetAuth(), new OnAuthDatasetCheckedChange { preferences = preferences }); SetupSettingsButton(Resource.Id.settings_clear_data_container, Resource.Id.settings_clear_data_label, Resource.Id.settings_clear_data_icon, new ClearDataButtonClick { Activity = this }); SetupSettingsButton(Resource.Id.settings_auth_credentials_container, Resource.Id.settings_auth_credentials_label, Resource.Id.settings_auth_credentials_icon, new AuthCredendialsButtonClick { Activity = this }); }
public void OnClick(View v) { if (MyPreferences.GetInstance(Activity).GetMasterPassword() != null) { Activity.BuildCurrentCredentialsDialog().Show(); } else { Activity.BuildNewCredentialsDialog().Show(); } }
Android.Support.V7.App.AlertDialog BuildNewCredentialsDialog() { EditText newPasswordField = (EditText)LayoutInflater.From(this) .Inflate(Resource.Layout.multidataset_service_settings_authentication_dialog, null) .FindViewById(Resource.Id.master_password_field); NewCredentialsDialog = PrepareCredentialsDialog() .SetMessage(Resource.String.settings_auth_enter_new_password) .SetView(newPasswordField) .SetPositiveButton(Resource.String.ok, (sender, e) => { var password = newPasswordField.Text; MyPreferences.GetInstance(this).SetMasterPassword(password); DismissNewCredentialsDialog(); }) .Create(); return(NewCredentialsDialog); }
Android.Support.V7.App.AlertDialog BuildClearDataDialog() { var builder = new Android.Support.V7.App.AlertDialog.Builder(this) .SetMessage(Resource.String.settings_clear_data_confirmation) .SetTitle(Resource.String.settings_clear_data_confirmation_title) .SetNegativeButton(Resource.String.cancel, (sender, args) => { // Do nothing... }) .SetPositiveButton(Resource.String.ok, (sender, args) => { SharedPrefsAutofillRepository.GetInstance(this).Clear(); MyPreferences.GetInstance(this).ClearCredentials(); DismissDataDialog(); }); ClearDataDialog = builder.Create(); return(ClearDataDialog); }