protected override void OnCreate(Bundle bundle) { new ActivityDesign(this).ApplyTheme(); base.OnCreate(bundle); SetContentView(Resource.Layout.plugin_list); PluginHost.TriggerRequests(this); ListView listView = FindViewById <ListView>(Android.Resource.Id.List); listView.ItemClick += (sender, args) => { Intent i = new Intent(this, typeof(PluginDetailsActivity)); i.PutExtra(Strings.ExtraPluginPackage, _items[args.Position].Package); StartActivity(i); }; FindViewById <Button>(Resource.Id.btnPluginsOnline).Click += delegate { Util.GotoUrl(this, "https://keepass2android.codeplex.com/wikipage?title=Available%20Plug-ins"); }; }
protected override void OnPrepareDialogBuilder(AlertDialog.Builder builder) { _populatorTask.Wait(); base.OnPrepareDialogBuilder(builder); var iconListPreferenceAdapter = new IconListPreferenceScreenAdapter(this, Context); String selectedValue = PreferenceManager.GetDefaultSharedPreferences(Context).GetString(Key, ""); for (int i = 0; i < IconSets.Count; i++) { if (selectedValue == IconSets[i].PackageName) { selectedEntry = i; break; } } builder.SetAdapter(iconListPreferenceAdapter, (sender, args) => { }); builder.SetNeutralButton(Resource.String.IconSet_install, (sender, args) => { Util.GotoUrl(Context, "market://search?q=keepass2android icon set"); }); }
public bool GotoUrl() { string url = _stringViews[PwDefs.UrlField].Text; if (url == null) { return(false); } // Default http:// if no protocol specified if ((!url.Contains(":") || (url.StartsWith("www.")))) { url = "http://" + url; } try { Util.GotoUrl(this, url); } catch (ActivityNotFoundException) { Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show(); } return(true); }
public Intent TryGetYubichallengeIntentOrPrompt(byte[] challenge, bool promptToInstall) { Intent chalIntent = new Intent("net.pp3345.ykdroid.intent.action.CHALLENGE_RESPONSE"); chalIntent.PutExtra("challenge", challenge); IList <ResolveInfo> activities = PackageManager.QueryIntentActivities(chalIntent, 0); bool isIntentSafe = activities.Count > 0; if (isIntentSafe) { return(chalIntent); } if (promptToInstall) { AlertDialog.Builder b = new AlertDialog.Builder(this); string message = GetString(Resource.String.NoChallengeApp) + " " + GetString(Resource.String.PleaseInstallApp, new Java.Lang.Object[] { "ykDroid" }); Intent yubichalIntent = new Intent("com.yubichallenge.NFCActivity.CHALLENGE"); IList <ResolveInfo> yubichallengeactivities = PackageManager.QueryIntentActivities(yubichalIntent, 0); bool hasYubichallenge = yubichallengeactivities.Count > 0; if (hasYubichallenge) { message += " " + GetString(Resource.String.AppOutdated, new Java.Lang.Object[] { "YubiChallenge" }); } b.SetMessage(message); b.SetPositiveButton(Android.Resource.String.Ok, delegate { Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "net.pp3345.ykdroid"); }); b.SetNegativeButton(Resource.String.cancel, delegate { }); b.Create().Show(); } return(null); }
private void OnItemSelected(string protocolId) { if (protocolId == "kp2a") { //send user to market page of regular edition to get more protocols Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "keepass2android.keepass2android"); return; } var field = typeof(Resource.String).GetField("filestoragehelp_" + protocolId); if (field == null) { //no help available ReturnProtocol(protocolId); } else { //set help: string help = GetString((int)field.GetValue(null)); new AlertDialog.Builder(this) .SetTitle(GetString(Resource.String.app_name)) .SetMessage(help) .SetPositiveButton(Android.Resource.String.Ok, (sender, args) => ReturnProtocol(protocolId)) .Create() .Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.about); SetTitle(Resource.String.app_name); SetVersion(); SetContributors(); FindViewById(Resource.Id.suggest).Click += delegate { try { Util.GotoUrl(Context, Resource.String.SuggestionsURL); } catch (ActivityNotFoundException) { Toast.MakeText(Context, Resource.String.no_url_handler, ToastLength.Long).Show(); } }; FindViewById(Resource.Id.rate).Click += delegate { try { Util.GotoMarket(Context); } catch (ActivityNotFoundException) { Toast.MakeText(Context, Resource.String.no_url_handler, ToastLength.Long).Show(); } }; FindViewById(Resource.Id.translate).Click += delegate { try { Util.GotoUrl(Context, Resource.String.TranslationURL); } catch (ActivityNotFoundException) { Toast.MakeText(Context, Resource.String.no_url_handler, ToastLength.Long).Show(); } }; FindViewById(Resource.Id.donate).Click += delegate { Util.GotoDonateUrl(Context); }; }
private void OnItemSelected(string protocolId) { if (protocolId == "kp2a") { //send user to market page of regular edition to get more protocols Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "keepass2android.keepass2android"); return; } if (protocolId.Contains(",")) { //bring up a selection dialog to select the variant of the file storage AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetItems(protocolId.Split(",").Select(singleProtocolId => App.Kp2a.GetStorageDisplayName(singleProtocolId)).ToArray(), delegate(object sender, DialogClickEventArgs args) { string[] singleProtocolIds = protocolId.Split(","); OnItemSelected(singleProtocolIds[args.Which]); }); builder.Show(); return; } var field = typeof(Resource.String).GetField("filestoragehelp_" + protocolId); if (field == null) { //no help available ReturnProtocol(protocolId); } else { //set help: string help = GetString((int)field.GetValue(null)); new AlertDialog.Builder(this) .SetTitle(GetString(Resource.String.app_name)) .SetMessage(help) .SetPositiveButton(Android.Resource.String.Ok, (sender, args) => ReturnProtocol(protocolId)) .Create() .Show(); } }
public KeyboardSwitchPrefManager(PreferenceFragment fragment) { var act = fragment.Activity; this._act = act; this._fragment = fragment; this._screen = (PreferenceScreen)_fragment.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key)); var keyboardSwapPref = _fragment.FindPreference("get_keyboardswap"); var pm = act.PackageManager; var intnt = Keepass2android.Kbbridge.ImeSwitcher.GetLaunchIntentForKeyboardSwap(act); if ((intnt != null) && pm.QueryIntentActivities(intnt, 0).Any()) { _screen.RemovePreference(keyboardSwapPref); } else { keyboardSwapPref.PreferenceClick += (sender, args) => { Util.GotoUrl(act, act.GetString(Resource.String.MarketURL) + "keepass2android.plugin.keyboardswap2"); }; } _switchPref = (CheckBoxPreference)_fragment.FindPreference("kp2a_switch_rooted"); _openKp2aAutoPref = (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key)); _openOnlyOnSearchPref = (CheckBoxPreference) _fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key)); _switchBackPref = (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.AutoSwitchBackKeyboard_key)); EnableSwitchPreferences(_switchPref.Checked); _switchPref.PreferenceChange += (sender, args) => { bool switchOnRooted = (bool)args.NewValue; EnableSwitchPreferences(switchOnRooted); }; }
public Intent TryGetYubichallengeIntentOrPrompt(byte[] challenge, bool promptToInstall) { Intent chalIntent = new Intent("com.yubichallenge.NFCActivity.CHALLENGE"); chalIntent.PutExtra("challenge", challenge); chalIntent.PutExtra("slot", 2); IList <ResolveInfo> activities = PackageManager.QueryIntentActivities(chalIntent, 0); bool isIntentSafe = activities.Count > 0; if (isIntentSafe) { return(chalIntent); } if (promptToInstall) { AlertDialog.Builder b = new AlertDialog.Builder(this); b.SetMessage(Resource.String.YubiChallengeNotInstalled); b.SetPositiveButton(Android.Resource.String.Ok, delegate { Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "com.yubichallenge"); }); b.SetNegativeButton(Resource.String.cancel, delegate { }); b.Create().Show(); } return(null); }
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); }
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); }
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); }