public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.menu_donate: return(Util.GotoDonateUrl(this)); case Resource.Id.menu_lock: App.Kp2a.LockDatabase(); return(true); case Resource.Id.menu_search: case Resource.Id.menu_search_advanced: OnSearchRequested(); return(true); case Resource.Id.menu_app_settings: DatabaseSettingsActivity.Launch(this); return(true); case Resource.Id.menu_sync: Synchronize(); return(true); case Resource.Id.menu_work_offline: App.Kp2a.OfflineMode = App.Kp2a.OfflineModePreference = true; UpdateOfflineModeMenu(); return(true); case Resource.Id.menu_work_online: App.Kp2a.OfflineMode = App.Kp2a.OfflineModePreference = false; UpdateOfflineModeMenu(); Synchronize(); return(true); case Resource.Id.menu_sort: ChangeSort(); return(true); case Android.Resource.Id.Home: //Currently the action bar only displays the home button when we come from a previous activity. //So we can simply Finish. See this page for information on how to do this in more general (future?) cases: //http://developer.android.com/training/implementing-navigation/ancestral.html AppTask.SetActivityResult(this, KeePass.ExitNormal); Finish(); //OverridePendingTransition(Resource.Animation.anim_enter_back, Resource.Animation.anim_leave_back); return(true); } return(base.OnOptionsItemSelected(item)); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (AppTask.TryGetFromActivityResult(data, ref AppTask)) { //make sure the app task is passed to the calling activity AppTask.SetActivityResult(this, KeePass.ExitNormal); } if ((GroupEditActivity.RequestCodeGroupEdit == requestCode) && (resultCode == Result.Ok)) { String groupName = data.Extras.GetString(GroupEditActivity.KeyName); int groupIconId = data.Extras.GetInt(GroupEditActivity.KeyIconId); PwUuid groupCustomIconId = new PwUuid(MemUtil.HexStringToByteArray(data.Extras.GetString(GroupEditActivity.KeyCustomIconId))); String strGroupUuid = data.Extras.GetString(GroupEditActivity.KeyGroupUuid); GroupBaseActivity act = this; Handler handler = new Handler(); RunnableOnFinish task; if (strGroupUuid == null) { task = AddGroup.GetInstance(this, App.Kp2a, groupName, groupIconId, groupCustomIconId, Group, new RefreshTask(handler, this), false); } else { PwUuid groupUuid = new PwUuid(MemUtil.HexStringToByteArray(strGroupUuid)); task = new EditGroup(this, App.Kp2a, groupName, (PwIcon)groupIconId, groupCustomIconId, App.Kp2a.GetDb().Groups[groupUuid], new RefreshTask(handler, this)); } ProgressTask pt = new ProgressTask(App.Kp2a, act, task); pt.Run(); } if (resultCode == KeePass.ExitCloseAfterTaskComplete) { AppTask.SetActivityResult(this, KeePass.ExitCloseAfterTaskComplete); Finish(); } if (resultCode == KeePass.ExitReloadDb) { AppTask.SetActivityResult(this, KeePass.ExitReloadDb); Finish(); } }