protected override void OnCreate(Bundle bundle) { _design.ApplyTheme(); base.OnCreate(bundle); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); SetContentView(Resource.Layout.create_database); _appTask = AppTask.GetTaskInOnCreate(bundle, Intent); SetDefaultIoc(); FindViewById(Resource.Id.keyfile_filename).Visibility = ViewStates.Gone; var keyfileCheckbox = FindViewById <CheckBox>(Resource.Id.use_keyfile); if (bundle != null) { _keyfileFilename = bundle.GetString(KeyfilefilenameBundleKey, null); if (_keyfileFilename != null) { FindViewById <TextView>(Resource.Id.keyfile_filename).Text = FileSelectHelper.ConvertFilenameToIocPath(_keyfileFilename); FindViewById(Resource.Id.keyfile_filename).Visibility = ViewStates.Visible; keyfileCheckbox.Checked = true; } if (bundle.GetString(Util.KeyFilename, null) != null) { _ioc = new IOConnectionInfo { Path = bundle.GetString(Util.KeyFilename), UserName = bundle.GetString(Util.KeyServerusername), Password = bundle.GetString(Util.KeyServerpassword), CredSaveMode = (IOCredSaveMode)bundle.GetInt(Util.KeyServercredmode), }; } } UpdateIocView(); keyfileCheckbox.CheckedChange += (sender, args) => { if (keyfileCheckbox.Checked) { if (_restoringInstanceState) { return; } Util.ShowBrowseDialog(this, RequestCodeKeyFile, false, true); } else { FindViewById(Resource.Id.keyfile_filename).Visibility = ViewStates.Gone; _keyfileFilename = null; } }; FindViewById(Resource.Id.btn_change_location).Click += (sender, args) => { Intent intent = new Intent(this, typeof(FileStorageSelectionActivity)); StartActivityForResult(intent, RequestCodeDbFilename); }; Button generatePassword = (Button)FindViewById(Resource.Id.generate_button); generatePassword.Click += (sender, e) => { GeneratePasswordActivity.LaunchWithoutLockCheck(this); }; FindViewById(Resource.Id.btn_create).Click += (sender, evt) => { CreateDatabase(Intent.GetBooleanExtra("MakeCurrent", true)); }; ImageButton btnTogglePassword = (ImageButton)FindViewById(Resource.Id.toggle_password); btnTogglePassword.Click += (sender, e) => { _showPassword = !_showPassword; MakePasswordMaskedOrVisible(); }; Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop; Android.Graphics.Color color = new Android.Graphics.Color(224, 224, 224); btnTogglePassword.SetColorFilter(color, mMode); Util.SetNoPersonalizedLearning(FindViewById(Resource.Id.root)); }
protected override void OnCreate(Bundle bundle) { _design.ApplyTheme(); base.OnCreate(bundle); //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps Util.MakeSecureDisplay(this); _ioc = App.Kp2a.GetDbForQuickUnlock()?.Ioc; if (_ioc == null) { Finish(); return; } SetContentView(Resource.Layout.QuickUnlock); var toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.mytoolbar); SetSupportActionBar(toolbar); var collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar); collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs)); if (App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name != "") { FindViewById(Resource.Id.filename_label).Visibility = ViewStates.Visible; ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name; } else { if ( PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.RememberRecentFiles_key), Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default))) { ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc); } else { ((TextView)FindViewById(Resource.Id.filename_label)).Text = "*****"; } } TextView txtLabel = (TextView)FindViewById(Resource.Id.QuickUnlock_label); _quickUnlockLength = App.Kp2a.QuickUnlockKeyLength; if (PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.QuickUnlockHideLength_key), false)) { txtLabel.Text = GetString(Resource.String.QuickUnlock_label_secure); } else { txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] { _quickUnlockLength }); } EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); pwd.SetEms(_quickUnlockLength); Util.MoveBottomBarButtons(Resource.Id.QuickUnlock_buttonLock, Resource.Id.QuickUnlock_button, Resource.Id.bottom_bar, this); Button btnUnlock = (Button)FindViewById(Resource.Id.QuickUnlock_button); btnUnlock.Click += (object sender, EventArgs e) => { OnUnlock(pwd); }; Button btnLock = (Button)FindViewById(Resource.Id.QuickUnlock_buttonLock); btnLock.Text = btnLock.Text.Replace("ß", "ss"); btnLock.Click += (object sender, EventArgs e) => { App.Kp2a.Lock(false); Finish(); }; pwd.EditorAction += (sender, args) => { if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down))) { OnUnlock(pwd); } }; _intentReceiver = new QuickUnlockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); Util.SetNoPersonalizedLearning(FindViewById <EditText>(Resource.Id.QuickUnlock_password)); if (bundle != null) { numFailedAttempts = bundle.GetInt(NumFailedAttemptsKey, 0); } }