예제 #1
0
        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
            if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
                    GetString(Resource.String.ViewDatabaseSecure_key), true))
            {
                Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
            }

            _ioc = App.Kp2a.GetDb().Ioc;

            if (_ioc == null)
            {
                Finish();
                return;
            }

            SetContentView(Resource.Layout.QuickUnlock);

            var toolbar = FindViewById <Android.Support.V7.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.GetDb().KpDatabase.Name != "")
            {
                FindViewById(Resource.Id.filename_label).Visibility       = ViewStates.Visible;
                ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetDb().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;

            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(_quickUnlockLength, pwd);
            };



            Button btnLock = (Button)FindViewById(Resource.Id.QuickUnlock_buttonLock);

            btnLock.Text   = btnLock.Text.Replace("ß", "ss");
            btnLock.Click += (object sender, EventArgs e) =>
            {
                App.Kp2a.LockDatabase(false);
                Finish();
            };
            pwd.EditorAction += (sender, args) =>
            {
                if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
                {
                    OnUnlock(_quickUnlockLength, pwd);
                }
            };

            _intentReceiver = new QuickUnlockBroadcastReceiver(this);
            IntentFilter filter = new IntentFilter();

            filter.AddAction(Intents.DatabaseLocked);
            RegisterReceiver(_intentReceiver, filter);

            if ((int)Build.VERSION.SdkInt >= 23)
            {
                Kp2aLog.Log("requesting fingerprint permission");
                RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode);
            }
            else
            {
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            _design.ApplyTheme();

            //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps
            if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
                GetString(Resource.String.ViewDatabaseSecure_key), true))
            {
                Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
            }

            _ioc = App.Kp2a.GetDb().Ioc;

            if (_ioc == null)
            {
                Finish();
                return;
            }

            SetContentView(Resource.Layout.QuickUnlock);

            if (App.Kp2a.GetDb().KpDatabase.Name != "")
            {
                FindViewById(Resource.Id.filename_label).Visibility = ViewStates.Invisible;
                ((TextView) FindViewById(Resource.Id.qu_filename)).Text = App.Kp2a.GetDb().KpDatabase.Name;
            }
            else
            {
                if (
                    PreferenceManager.GetDefaultSharedPreferences(this)
                                     .GetBoolean(GetString(Resource.String.RememberRecentFiles_key),
                                                 Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default)))
                {
                    ((TextView) FindViewById(Resource.Id.qu_filename)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc);
                }
                else
                {
                    ((TextView) FindViewById(Resource.Id.qu_filename)).Text = "*****";
                }

            }

            TextView txtLabel = (TextView) FindViewById(Resource.Id.QuickUnlock_label);

            int quickUnlockLength = App.Kp2a.QuickUnlockKeyLength;

            txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] {quickUnlockLength});

            EditText pwd = (EditText) FindViewById(Resource.Id.QuickUnlock_password);
            pwd.SetEms(quickUnlockLength);

            Button btnUnlock = (Button) FindViewById(Resource.Id.QuickUnlock_button);
            btnUnlock.Click += (object sender, EventArgs e) =>
                {
                    OnUnlock(quickUnlockLength, pwd);
                };

            Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock);
            btnLock.Click += (object sender, EventArgs e) =>
                {
                    App.Kp2a.LockDatabase(false);
                    Finish();
                };
            pwd.EditorAction += (sender, args) =>
                {
                    if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
                        OnUnlock(quickUnlockLength, pwd);
                };

            _intentReceiver = new QuickUnlockBroadcastReceiver(this);
            IntentFilter filter = new IntentFilter();
            filter.AddAction(Intents.DatabaseLocked);
            RegisterReceiver(_intentReceiver, filter);
        }