コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            _design.ApplyTheme();
            base.OnCreate(bundle);


            SetContentView(Resource.Layout.filestorage_selection);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = RemoveTrailingColon(GetString(Resource.String.select_storage_type));

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            toolbar.NavigationClick += (sender, args) => OnBackPressed();

            _fileStorageAdapter = new FileStorageAdapter(this);
            var gridView = FindViewById <GridView>(Resource.Id.gridview);

            gridView.ItemClick +=
                (sender, args) => OnItemSelected((string)_fileStorageAdapter.GetItem(args.Position));
            gridView.Adapter = _fileStorageAdapter;
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.no_secure_display_layout);
            FindViewById <Button>(Resource.Id.btn_goto_settings).Click += (sender, args) =>
            {
                AppSettingsActivity.Launch(this);
            };
            FindViewById <Button>(Resource.Id.disable_secure_screen_check).Click += (sender, args) =>
            {
                var prefs = PreferenceManager.GetDefaultSharedPreferences(LocaleManager.LocalizedAppContext);
                prefs.Edit()
                .PutBoolean("no_secure_display_check", true)
                .Commit();
                Finish();
            };
            FindViewById <Button>(Resource.Id.btn_close).Click += (sender, args) =>
            {
                Finish();
            };

            var toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.mytoolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = AppNames.AppName;
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            SetContentView(Resource.Layout.preference);

            SetSupportActionBar(FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar));

            FragmentManager.FindFragmentById <SettingsFragment>(Resource.Id.settings_fragment).FindPreference(GetString(Resource.String.db_key)).Enabled = false;
        }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            Android.Util.Log.Debug("KP2A", "Creating GBA");

            AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);

            // Likely the app has been killed exit the activity
            if (!App.Kp2a.GetDb().Loaded)
            {
                Finish();
                return;
            }

            _prefs = PreferenceManager.GetDefaultSharedPreferences(this);


            SetContentView(ContentResourceId);

            if (FindViewById(Resource.Id.fabCancelAddNew) != null)
            {
                FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Gone;
                };

                FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Visible;
                };
            }


            if (FindViewById(Resource.Id.cancel_insert_element) != null)
            {
                FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements();
                FindViewById(Resource.Id.insert_element).Click        += (sender, args) => InsertElements();
                Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this);
            }


            SetResult(KeePass.ExitNormal);
        }
コード例 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.no_secure_display_layout);
            FindViewById <Button>(Resource.Id.btn_goto_settings).Click += (sender, args) =>
            {
                AppSettingsActivity.Launch(this);
            };

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = AppNames.AppName;
        }
コード例 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _activityDesign.ApplyTheme();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ImageViewActivity);
            var    uuid   = new PwUuid(MemUtil.HexStringToByteArray(Intent.GetStringExtra("EntryId")));
            string key    = Intent.GetStringExtra("EntryKey");
            var    binary = App.Kp2a.GetDb().Entries[uuid].Binaries.Get(key);

            SupportActionBar.Title = key;
            byte[] pbdata = binary.ReadData();

            var bmp = BitmapFactory.DecodeByteArray(pbdata, 0, pbdata.Length);

            FindViewById <ImageView>(Resource.Id.imageView).SetImageBitmap(bmp);
        }
コード例 #7
0
        protected override void OnCreate(Bundle bundle)
        {
            _design.ApplyTheme();
            base.OnCreate(bundle);


            Intent i = new Intent(this, typeof(PasswordActivity));

            i.SetAction(Intents.StartWithOtp);

            //things to consider:
            // PasswordActivity should be resumed if currently active -> this is why single top is used and why PasswordActivity is started
            // If PasswordActivity is not open already, it may be the wrong place to send our OTP to because maybe the user first needs to select
            //  a file (which might require UI action like entering credentials, all of which is handled in FileSelectActivity)
            // FileSelectActivity is not on the back stack, it finishes itself.
            // -> PasswordActivity needs to handle this and return to FSA.


            i.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop);
            try
            {
                string otp = GetOtpFromIntent(Intent);
                if (otp == null)
                {
                    throw new Exception("Otp must not be null!");
                }
                i.PutExtra(Intents.OtpExtraKey, otp);
            }
            catch (Exception e)
            {
                Kp2aLog.LogUnexpectedError(e);
                Toast.MakeText(this, "No Yubikey OTP found!", ToastLength.Long).Show();
                Finish();
                return;
            }

            if (App.Kp2a.GetDb().Loaded)
            {
                Toast.MakeText(this, GetString(Resource.String.otp_discarded_because_db_open), ToastLength.Long).Show();
            }
            else
            {
                StartActivity(i);
            }

            Finish();
        }
コード例 #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            Util.MakeSecureDisplay(this);

            _ioc = App.Kp2a.CurrentDb.Ioc;

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

            filter.AddAction(Intents.DatabaseLocked);
            filter.AddAction(Intent.ActionScreenOff);
            RegisterReceiver(_intentReceiver, filter);
        }
コード例 #9
0
        protected override void OnCreate(Bundle bundle)
        {
            _design.ApplyTheme();
            base.OnCreate(bundle);



            Kp2aLog.Log("SelectStorageLocationActivity.OnCreate");


            if (IsStorageSelectionForSave)
            {
                throw new Exception("save is not yet implemented. In StartSelectFile, no handler for onCreate is passed.");
            }

            bool allowThirdPartyGet  = Intent.GetBooleanExtra(FileStorageSelectionActivity.AllowThirdPartyAppGet, false);
            bool allowThirdPartySend = Intent.GetBooleanExtra(FileStorageSelectionActivity.AllowThirdPartyAppSend, false);

            bool isRecreated = false;

            if (bundle == null)
            {
                State = new Bundle();
            }
            else
            {
                State = (Bundle)bundle.Clone();
                var selectedIocString = bundle.GetString(BundleKeySelectedIoc, null);
                if (selectedIocString != null)
                {
                    _selectedIoc = IOConnectionInfo.UnserializeFromString(selectedIocString);
                }
                isRecreated = true;
            }

            //todo: handle orientation change while dialog is shown

            if (!isRecreated)
            {
                StartFileStorageSelection(RequestCodeFileStorageSelectionForPrimarySelect, allowThirdPartyGet, allowThirdPartySend);
            }
        }
コード例 #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            //see comment to this in PasswordActivity.
            //Note that this activity is affected even though it's finished when the app is closed because it
            //seems that the "app launch intent" is re-delivered, so this might end up here.
            if ((_appTask == null) && (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory)))
            {
                _appTask = new NullTask();
            }
            else
            {
                _appTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
            }


            Kp2aLog.Log("KeePass.OnCreate");
        }
コード例 #11
0
ファイル: EntryActivity.cs プロジェクト: ypid/keepass2android
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);

            long usageCount = prefs.GetLong(GetString(Resource.String.UsageCount_key), 0);

            ISharedPreferencesEditor edit = prefs.Edit();

            edit.PutLong(GetString(Resource.String.UsageCount_key), usageCount + 1);
            edit.Commit();

            _showPassword =
                !prefs.GetBoolean(GetString(Resource.String.maskpass_key), Resources.GetBoolean(Resource.Boolean.maskpass_default));

            RequestWindowFeature(WindowFeatures.IndeterminateProgress);

            _activityDesign.ApplyTheme();
            base.OnCreate(savedInstanceState);



            SetEntryView();

            Database db = App.Kp2a.GetDb();

            // Likely the app has been killed exit the activity
            if (!db.Loaded || (App.Kp2a.QuickLocked))
            {
                Finish();
                return;
            }

            SetResult(KeePass.ExitNormal);

            Intent i    = Intent;
            PwUuid uuid = new PwUuid(MemUtil.HexStringToByteArray(i.GetStringExtra(KeyEntry)));

            _pos = i.GetIntExtra(KeyRefreshPos, -1);

            _appTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);

            Entry = db.Entries[uuid];

            // Refresh Menu contents in case onCreateMenuOptions was called before Entry was set
            ActivityCompat.InvalidateOptionsMenu(this);

            // Update last access time.
            Entry.Touch(false);

            if (PwDefs.IsTanEntry(Entry) && prefs.GetBoolean(GetString(Resource.String.TanExpiresOnUse_key), Resources.GetBoolean(Resource.Boolean.TanExpiresOnUse_default)) && ((Entry.Expires == false) || Entry.ExpiryTime > DateTime.Now))
            {
                PwEntry backupEntry = Entry.CloneDeep();
                Entry.ExpiryTime = DateTime.Now;
                Entry.Expires    = true;
                Entry.Touch(true);
                RequiresRefresh();
                UpdateEntry  update = new UpdateEntry(this, App.Kp2a, backupEntry, Entry, null);
                ProgressTask pt     = new ProgressTask(App.Kp2a, this, update);
                pt.Run();
            }
            FillData();

            SetupEditButtons();

            App.Kp2a.GetDb().LastOpenedEntry = new PwEntryOutput(Entry, App.Kp2a.GetDb().KpDatabase);

            _pluginActionReceiver = new PluginActionReceiver(this);
            RegisterReceiver(_pluginActionReceiver, new IntentFilter(Strings.ActionAddEntryAction));
            _pluginFieldReceiver = new PluginFieldReceiver(this);
            RegisterReceiver(_pluginFieldReceiver, new IntentFilter(Strings.ActionSetEntryField));

            new Thread(NotifyPluginsOnOpen).Start();

            //the rest of the things to do depends on the current app task:
            _appTask.CompleteOnCreateEntryActivity(this);
        }
コード例 #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            Kp2aLog.Log("FileSelect.OnCreate");



            _dbHelper = App.Kp2a.FileDbHelper;
            SetContentView(Resource.Layout.file_selection);


            if (ShowRecentFiles())
            {
                _recentMode = true;


                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Visible;
                Android.Util.Log.Debug("KP2A", "Recent files visible");
            }
            else
            {
                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Invisible;
                Android.Util.Log.Debug("KP2A", "Recent files invisible");
#if NoNet
                ImageView imgView = FindViewById(Resource.Id.splashlogo) as ImageView;
                if (imgView != null)
                {
                    imgView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.splashlogo_offline));
                }
#endif
            }

            Button openFileButton = (Button)FindViewById(Resource.Id.start_open_file);

            EventHandler openFileButtonClick = (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SelectStorageLocationActivity));
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppGet, true);
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppSend, false);
                intent.PutExtra(SelectStorageLocationActivity.ExtraKeyWritableRequirements, (int)SelectStorageLocationActivity.WritableRequirements.WriteDesired);
                intent.PutExtra(FileStorageSetupDefs.ExtraIsForSave, false);
                StartActivityForResult(intent, RequestCodeSelectIoc);
            };
            openFileButton.Click += openFileButtonClick;

            //CREATE NEW
            Button       createNewButton      = (Button)FindViewById(Resource.Id.start_create);
            EventHandler createNewButtonClick = (sender, e) =>
            {
                //ShowFilenameDialog(false, true, true, Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path), "", Intents.RequestCodeFileBrowseForCreate)
                Intent i = new Intent(this, typeof(CreateDatabaseActivity));
                i.PutExtra("MakeCurrent", Intent.GetBooleanExtra("MakeCurrent", true));

                i.SetFlags(ActivityFlags.ForwardResult);
                StartActivity(i);
                Finish();
            };
            createNewButton.Click += createNewButtonClick;

            /*//CREATE + IMPORT
             *          Button createImportButton = (Button)FindViewById(Resource.Id.start_create_import);
             *          createImportButton.Click += (object sender, EventArgs e) =>
             *          {
             *                  openButton.Visibility = ViewStates.Gone;
             *                  createButton.Visibility = ViewStates.Visible;
             *                  enterFilenameDetails.Text = GetString(Resource.String.enter_filename_details_create_import);
             *                  enterFilenameDetails.Visibility = enterFilenameDetails.Text == "" ? ViewStates.Gone : ViewStates.Visible;
             *                  // Set the initial value of the filename
             *                  EditText filename = (EditText)FindViewById(Resource.Id.file_filename);
             *                  filename.Text = Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path);
             *
             *          };*/

            FindViewById <Switch>(Resource.Id.local_backups_switch).CheckedChange += (sender, args) => { FillData(); };

            FillData();

            if (savedInstanceState != null)
            {
                _recentMode = savedInstanceState.GetBoolean(BundleKeyRecentMode, _recentMode);
            }
        }
コード例 #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            Android.Util.Log.Debug("KP2A", "Creating GBA");

            AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);

            // Likely the app has been killed exit the activity
            if (!App.Kp2a.GetDb().Loaded)
            {
                Finish();
                return;
            }

            _prefs = PreferenceManager.GetDefaultSharedPreferences(this);


            SetContentView(ContentResourceId);

            if (FindViewById(Resource.Id.enable_autofill) != null)
            {
                FindViewById(Resource.Id.enable_autofill).Click += (sender, args) =>
                {
                    var intent = new Intent(Settings.ActionRequestSetAutofillService);
                    intent.SetData(Android.Net.Uri.Parse("package:" + PackageName));
                    try
                    {
                        StartActivity(intent);
                    }
                    catch (ActivityNotFoundException e)
                    {
                        //this exception was reported by many Huawei users
                        Kp2aLog.LogUnexpectedError(e);
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.autofill_enable)
                        .SetMessage(Resource.String.autofill_enable_failed)
                        .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { })
                        .Show();
                        const string autofillservicewasenabled = "AutofillServiceWasEnabled";
                        _prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit();
                        UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, false);
                    }
                };
            }

            if (FindViewById(Resource.Id.fabCancelAddNew) != null)
            {
                FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Gone;
                };

                FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Visible;
                };
            }


            if (FindViewById(Resource.Id.cancel_insert_element) != null)
            {
                FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements();
                FindViewById(Resource.Id.insert_element).Click        += (sender, args) => InsertElements();
                Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this);
            }

            if (FindViewById(Resource.Id.show_autofill_info) != null)
            {
                FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html");
                Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this);
            }

            if (FindViewById(Resource.Id.configure_notification_channels) != null)
            {
                FindViewById(Resource.Id.configure_notification_channels).Click += (sender, args) =>
                {
                    Intent intent = new Intent(Settings.ActionChannelNotificationSettings);
                    intent.PutExtra(Settings.ExtraChannelId, App.NotificationChannelIdQuicklocked);
                    intent.PutExtra(Settings.ExtraAppPackage, PackageName);
                    try
                    {
                        StartActivity(intent);
                    }
                    catch (Exception e)
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle("Unexpected error")
                        .SetMessage(
                            "Opening the settings failed. Please report this to [email protected] including information about your device vendor and OS. Please try to configure the notifications by long pressing a KP2A notification. Details: " + e.ToString())
                        .Show();
                    }
                    UpdateAndroid8NotificationInfo(true);
                };
                FindViewById(Resource.Id.ignore_notification_channel).Click += (sender, args) =>
                {
                    UpdateAndroid8NotificationInfo(true);
                };
            }



            string lastInfoText;

            if (IsTimeForInfotext(out lastInfoText))
            {
                FingerprintUnlockMode um;
                Enum.TryParse(_prefs.GetString(Database.GetFingerprintModePrefKey(App.Kp2a.GetDb().Ioc), ""), out um);
                bool isFingerprintEnabled = (um == FingerprintUnlockMode.FullUnlock);

                string masterKeyKey = "MasterKey" + isFingerprintEnabled;
                string emergencyKey = "Emergency";
                string backupKey    = "Backup";

                List <string> applicableInfoTextKeys = new List <string> {
                    masterKeyKey
                };

                if (App.Kp2a.GetFileStorage(App.Kp2a.GetDb().Ioc).UserShouldBackup)
                {
                    applicableInfoTextKeys.Add(backupKey);
                }
                if (App.Kp2a.GetDb().Entries.Count > 15)
                {
                    applicableInfoTextKeys.Add(emergencyKey);
                }

                List <string> enabledInfoTextKeys = new List <string>();
                foreach (string key in applicableInfoTextKeys)
                {
                    if (!InfoTextWasDisabled(key))
                    {
                        enabledInfoTextKeys.Add(key);
                    }
                }

                if (enabledInfoTextKeys.Any())
                {
                    string infoTextKey = "", infoHead = "", infoMain = "", infoNote = "";

                    if (enabledInfoTextKeys.Count > 1)
                    {
                        foreach (string key in enabledInfoTextKeys)
                        {
                            if (key == lastInfoText)
                            {
                                enabledInfoTextKeys.Remove(key);
                                break;
                            }
                        }
                        infoTextKey = enabledInfoTextKeys[new Random().Next(enabledInfoTextKeys.Count)];
                    }

                    if (infoTextKey == masterKeyKey)
                    {
                        infoHead = GetString(Resource.String.masterkey_infotext_head);
                        infoMain = GetString(Resource.String.masterkey_infotext_main);
                        if (isFingerprintEnabled)
                        {
                            infoNote = GetString(Resource.String.masterkey_infotext_fingerprint_note);
                        }
                    }
                    else if (infoTextKey == emergencyKey)
                    {
                        infoHead = GetString(Resource.String.emergency_infotext_head);
                        infoMain = GetString(Resource.String.emergency_infotext_main);
                    }
                    else if (infoTextKey == backupKey)
                    {
                        infoHead = GetString(Resource.String.backup_infotext_head);
                        infoMain = GetString(Resource.String.backup_infotext_main);
                        infoNote = GetString(Resource.String.backup_infotext_note, GetString(Resource.String.menu_app_settings), GetString(Resource.String.menu_db_settings), GetString(Resource.String.export_prefs));
                    }



                    FindViewById <TextView>(Resource.Id.info_head).Text = infoHead;
                    FindViewById <TextView>(Resource.Id.info_main).Text = infoMain;
                    var additionalInfoText = FindViewById <TextView>(Resource.Id.info_additional);
                    additionalInfoText.Text       = infoNote;
                    additionalInfoText.Visibility = string.IsNullOrEmpty(infoNote) ? ViewStates.Gone : ViewStates.Visible;

                    if (infoTextKey != "")
                    {
                        RegisterInfoTextDisplay(infoTextKey);
                        FindViewById(Resource.Id.info_ok).Click += (sender, args) =>
                        {
                            UpdateBottomBarElementVisibility(Resource.Id.infotext, false);
                        };
                        FindViewById(Resource.Id.info_dont_show_again).Click += (sender, args) =>
                        {
                            UpdateBottomBarElementVisibility(Resource.Id.infotext, false);
                            DisableInfoTextDisplay(infoTextKey);
                        };

                        UpdateBottomBarElementVisibility(Resource.Id.infotext, true);
                    }
                }
            }



            SetResult(KeePass.ExitNormal);
        }
コード例 #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            Kp2aLog.Log("FileSelect.OnCreate");
            Kp2aLog.Log("FileSelect:apptask=" + Intent.GetStringExtra("KP2A_APPTASK"));

            if (Intent.Action == Intent.ActionSend)
            {
                AppTask = new SearchUrlTask {
                    UrlToSearchFor = Intent.GetStringExtra(Intent.ExtraText)
                };
            }
            else
            {
                //see PasswordActivity for an explanation
                if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
                {
                    AppTask = new NullTask();
                }
                else
                {
                    AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
                }
            }


            _dbHelper = App.Kp2a.FileDbHelper;
            SetContentView(Resource.Layout.file_selection);


            if (ShowRecentFiles())
            {
                _recentMode = true;


                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Visible;
                Android.Util.Log.Debug("KP2A", "Recent files visible");
            }
            else
            {
                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Invisible;
                Android.Util.Log.Debug("KP2A", "Recent files invisible");
#if NoNet
                ImageView imgView = FindViewById(Resource.Id.splashlogo) as ImageView;
                if (imgView != null)
                {
                    imgView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.splashlogo_offline));
                }
#endif
            }

            Button openFileButton = (Button)FindViewById(Resource.Id.start_open_file);

            EventHandler openFileButtonClick = (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SelectStorageLocationActivity));
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppGet, true);
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppSend, false);
                intent.PutExtra(SelectStorageLocationActivity.ExtraKeyWritableRequirements, (int)SelectStorageLocationActivity.WritableRequirements.WriteDesired);
                intent.PutExtra(FileStorageSetupDefs.ExtraIsForSave, false);
                StartActivityForResult(intent, RequestCodeSelectIoc);
            };
            openFileButton.Click += openFileButtonClick;

            //CREATE NEW
            Button       createNewButton      = (Button)FindViewById(Resource.Id.start_create);
            EventHandler createNewButtonClick = (sender, e) =>
            {
                //ShowFilenameDialog(false, true, true, Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path), "", Intents.RequestCodeFileBrowseForCreate)
                Intent i = new Intent(this, typeof(CreateDatabaseActivity));
                this.AppTask.ToIntent(i);
                StartActivityForResult(i, 0);
            };
            createNewButton.Click += createNewButtonClick;

            /*//CREATE + IMPORT
             * Button createImportButton = (Button)FindViewById(Resource.Id.start_create_import);
             * createImportButton.Click += (object sender, EventArgs e) =>
             * {
             *      openButton.Visibility = ViewStates.Gone;
             *      createButton.Visibility = ViewStates.Visible;
             *      enterFilenameDetails.Text = GetString(Resource.String.enter_filename_details_create_import);
             *      enterFilenameDetails.Visibility = enterFilenameDetails.Text == "" ? ViewStates.Gone : ViewStates.Visible;
             *      // Set the initial value of the filename
             *      EditText filename = (EditText)FindViewById(Resource.Id.file_filename);
             *      filename.Text = Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path);
             *
             * };*/

            FillData();

            if (savedInstanceState != null)
            {
                AppTask     = AppTask.CreateFromBundle(savedInstanceState);
                _recentMode = savedInstanceState.GetBoolean(BundleKeyRecentMode, _recentMode);
            }
        }
コード例 #15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            Android.Util.Log.Debug("KP2A", "Creating GBA");

            AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);

            // Likely the app has been killed exit the activity
            if (!App.Kp2a.GetDb().Loaded)
            {
                Finish();
                return;
            }

            _prefs = PreferenceManager.GetDefaultSharedPreferences(this);


            SetContentView(ContentResourceId);

            if (FindViewById(Resource.Id.enable_autofill) != null)
            {
                FindViewById(Resource.Id.enable_autofill).Click += (sender, args) =>
                {
                    var intent = new Intent(Settings.ActionRequestSetAutofillService);
                    intent.SetData(Android.Net.Uri.Parse("package:" + PackageName));
                    StartActivity(intent);
                };
            }

            if (FindViewById(Resource.Id.fabCancelAddNew) != null)
            {
                FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Gone;
                };

                FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Visible;
                };
            }


            if (FindViewById(Resource.Id.cancel_insert_element) != null)
            {
                FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements();
                FindViewById(Resource.Id.insert_element).Click        += (sender, args) => InsertElements();
                Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this);
            }

            if (FindViewById(Resource.Id.show_autofill_info) != null)
            {
                FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html");
                Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this);
            }



            SetResult(KeePass.ExitNormal);
        }
コード例 #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _activityDesign.ApplyTheme();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.fingerprint_setup);

            Enum.TryParse(
                PreferenceManager.GetDefaultSharedPreferences(this).GetString(App.Kp2a.GetDb().CurrentFingerprintModePrefKey, ""),
                out _unlockMode);

            _fpIcon     = FindViewById <ImageView>(Resource.Id.fingerprint_icon);
            _fpTextView = FindViewById <TextView>(Resource.Id.fingerprint_status);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            int[] radioButtonIds =
            {
                Resource.Id.radio_fingerprint_quickunlock, Resource.Id.radio_fingerprint_unlock,
                Resource.Id.radio_fingerprint_disabled
            };
            _radioButtons        = radioButtonIds.Select(FindViewById <RadioButton>).ToArray();
            _radioButtons[0].Tag = FingerprintUnlockMode.QuickUnlock.ToString();
            _radioButtons[1].Tag = FingerprintUnlockMode.FullUnlock.ToString();
            _radioButtons[2].Tag = FingerprintUnlockMode.Disabled.ToString();
            foreach (RadioButton r in _radioButtons)
            {
                r.CheckedChange += (sender, args) =>
                {
                    var rbSender = ((RadioButton)sender);
                    if (!rbSender.Checked)
                    {
                        return;
                    }
                    foreach (RadioButton rOther in _radioButtons)
                    {
                        if (rOther == sender)
                        {
                            continue;
                        }
                        rOther.Checked = false;
                    }
                    FingerprintUnlockMode newMode;
                    Enum.TryParse(rbSender.Tag.ToString(), out newMode);
                    ChangeUnlockMode(_unlockMode, newMode);
                };
            }

            CheckCurrentRadioButton();

            int errorId = Resource.String.fingerprint_os_error;

            SetError(errorId);

            FindViewById(Resource.Id.cancel_button).Click += (sender, args) =>
            {
                _enc.StopListening();
                _unlockMode = FingerprintUnlockMode.Disabled;                 //cancelling a FingerprintEncryption means a new key has been created but not been authenticated to encrypt something. We can't keep the previous state.
                StoreUnlockMode();
                FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Visible;
                FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone;
                _enc = null;
                CheckCurrentRadioButton();
            };

            FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone;
            FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone;
            FindViewById <CheckBox>(Resource.Id.show_keyboard_while_fingerprint).Checked =
                Util.GetShowKeyboardDuringFingerprintUnlock(this);

            FindViewById <CheckBox>(Resource.Id.show_keyboard_while_fingerprint).CheckedChange += (sender, args) =>
            {
                PreferenceManager.GetDefaultSharedPreferences(this)
                .Edit()
                .PutBoolean(GetString(Resource.String.ShowKeyboardWhileFingerprint_key), args.IsChecked)
                .Commit();
            };
            if ((int)Build.VERSION.SdkInt >= 23)
            {
                RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode);
            }
            else
            {
                TrySetupSamsung();
            }

            UpdateKeyboardCheckboxVisibility();
        }
コード例 #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            Android.Util.Log.Debug("KP2A", "Creating GBA");

            AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);

            // Likely the app has been killed exit the activity
            if (!App.Kp2a.GetDb().Loaded)
            {
                Finish();
                return;
            }

            _prefs = PreferenceManager.GetDefaultSharedPreferences(this);


            SetContentView(ContentResourceId);

            if (FindViewById(Resource.Id.enable_autofill) != null)
            {
                FindViewById(Resource.Id.enable_autofill).Click += (sender, args) =>
                {
                    var intent = new Intent(Settings.ActionRequestSetAutofillService);
                    intent.SetData(Android.Net.Uri.Parse("package:" + PackageName));
                    try
                    {
                        StartActivity(intent);
                    }
                    catch (ActivityNotFoundException e)
                    {
                        //this exception was reported by many Huawei users
                        Kp2aLog.LogUnexpectedError(e);
                        new AlertDialog.Builder(this)
                        .SetTitle(Resource.String.autofill_enable)
                        .SetMessage(Resource.String.autofill_enable_failed)
                        .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { })
                        .Show();
                        const string autofillservicewasenabled = "AutofillServiceWasEnabled";
                        _prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit();
                        UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, false);
                    }
                };
            }


            if (FindViewById(Resource.Id.info_dont_show_autofill_again) != null)
            {
                FindViewById(Resource.Id.info_dont_show_autofill_again).Click += (sender, args) =>
                {
                    _prefs.Edit().PutBoolean(autofillservicewasenabled_prefskey, true).Commit();
                    UpdateAutofillInfo();
                };
            }

            if (FindViewById(Resource.Id.fabCancelAddNew) != null)
            {
                FindViewById(Resource.Id.fabAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Gone;
                };

                FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) =>
                {
                    FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewGroup).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNewEntry).Visibility  = ViewStates.Gone;
                    FindViewById(Resource.Id.fabAddNew).Visibility       = ViewStates.Visible;
                };
            }


            if (FindViewById(Resource.Id.cancel_insert_element) != null)
            {
                FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements();
                FindViewById(Resource.Id.insert_element).Click        += (sender, args) => InsertElements();
                Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this);
            }

            if (FindViewById(Resource.Id.show_autofill_info) != null)
            {
                FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html");
                Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this);
            }

            if (FindViewById(Resource.Id.configure_notification_channels) != null)
            {
                FindViewById(Resource.Id.configure_notification_channels).Click += (sender, args) =>
                {
                    Intent intent = new Intent(Settings.ActionChannelNotificationSettings);
                    intent.PutExtra(Settings.ExtraChannelId, App.NotificationChannelIdQuicklocked);
                    intent.PutExtra(Settings.ExtraAppPackage, PackageName);
                    try
                    {
                        StartActivity(intent);
                    }
                    catch (Exception e)
                    {
                        new AlertDialog.Builder(this)
                        .SetTitle("Unexpected error")
                        .SetMessage(
                            "Opening the settings failed. Please report this to [email protected] including information about your device vendor and OS. Please try to configure the notifications by long pressing a KP2A notification. Details: " + e.ToString())
                        .Show();
                    }
                    UpdateAndroid8NotificationInfo(true);
                };
                FindViewById(Resource.Id.ignore_notification_channel).Click += (sender, args) =>
                {
                    UpdateAndroid8NotificationInfo(true);
                };
            }



            SetResult(KeePass.ExitNormal);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.generate_password);
            SetResult(KeePass.ExitNormal);

            var prefs = GetPreferences(FileCreationMode.Private);

            ((CheckBox)FindViewById(Resource.Id.cb_uppercase)).Checked = prefs.GetBoolean("cb_uppercase", true);
            ((CheckBox)FindViewById(Resource.Id.cb_lowercase)).Checked = prefs.GetBoolean("cb_lowercase", true);
            ((CheckBox)FindViewById(Resource.Id.cb_digits)).Checked    = prefs.GetBoolean("cb_digits", true);
            ((CheckBox)FindViewById(Resource.Id.cb_minus)).Checked     = prefs.GetBoolean("cb_minus", false);
            ((CheckBox)FindViewById(Resource.Id.cb_underline)).Checked = prefs.GetBoolean("cb_underline", false);
            ((CheckBox)FindViewById(Resource.Id.cb_space)).Checked     = prefs.GetBoolean("cb_space", false);
            ((CheckBox)FindViewById(Resource.Id.cb_specials)).Checked  = prefs.GetBoolean("cb_specials", false);
            ((CheckBox)FindViewById(Resource.Id.cb_brackets)).Checked  = prefs.GetBoolean("cb_brackets", false);
            ((EditText)FindViewById(Resource.Id.length)).Text          = prefs.GetInt("length", 12).ToString(CultureInfo.InvariantCulture);

            foreach (int id in _buttonIds)
            {
                Button button = (Button)FindViewById(id);
                button.Click += (sender, e) =>
                {
                    Button b = (Button)sender;

                    EditText editText = (EditText)FindViewById(Resource.Id.length);
                    editText.Text = b.Text;
                };
            }

            Button genPassButton = (Button)FindViewById(Resource.Id.generate_password_button);

            genPassButton.Click += (sender, e) => {
                String password = GeneratePassword();

                EditText txtPassword = (EditText)FindViewById(Resource.Id.password_edit);
                txtPassword.Text = password;
            };



            View acceptButton = FindViewById(Resource.Id.accept_button);

            acceptButton.Click += (sender, e) => {
                EditText password = (EditText)FindViewById(Resource.Id.password_edit);

                Intent intent = new Intent();
                intent.PutExtra("keepass2android.password.generated_password", password.Text);

                SetResult(KeePass.ResultOkPasswordGenerator, intent);

                Finish();
            };


            View cancelButton = FindViewById(Resource.Id.cancel_button);

            cancelButton.Click += (sender, e) =>
            {
                SetResult(Result.Canceled);

                Finish();
            };


            EditText txtPasswordToSet = (EditText)FindViewById(Resource.Id.password_edit);

            txtPasswordToSet.Text = GeneratePassword();

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
        }