add some more error logging
This commit is contained in:
		@@ -185,29 +185,30 @@ namespace keepass2android
 | 
			
		||||
 | 
			
		||||
			public override View GetView(int position, View convertView, ViewGroup parent)
 | 
			
		||||
			{
 | 
			
		||||
				View currView;
 | 
			
		||||
				if(convertView == null)
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
					LayoutInflater li = (LayoutInflater) _act.GetSystemService(LayoutInflaterService); 
 | 
			
		||||
                    View currView;
 | 
			
		||||
                    if (convertView == null)
 | 
			
		||||
                    {
 | 
			
		||||
                        LayoutInflater li = (LayoutInflater)_act.GetSystemService(LayoutInflaterService);
 | 
			
		||||
                        currView = li.Inflate(Resource.Layout.icon, null);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        currView = convertView;
 | 
			
		||||
                    }
 | 
			
		||||
				TextView tv = (TextView) currView.FindViewById(Resource.Id.icon_text);
 | 
			
		||||
				ImageView iv = (ImageView) currView.FindViewById(Resource.Id.icon_image);
 | 
			
		||||
                    TextView tv = (TextView)currView.FindViewById(Resource.Id.icon_text);
 | 
			
		||||
                    ImageView iv = (ImageView)currView.FindViewById(Resource.Id.icon_image);
 | 
			
		||||
 | 
			
		||||
                    if (position < (int)PwIcon.Count)
 | 
			
		||||
                    {
 | 
			
		||||
                        tv.Text = "" + position;
 | 
			
		||||
					var drawable = App.Kp2a.CurrentDb						.DrawableFactory.GetIconDrawable(_act, App.Kp2a.CurrentDb.KpDatabase, (KeePassLib.PwIcon) position, null, false);
 | 
			
		||||
                        var drawable = App.Kp2a.CurrentDb.DrawableFactory.GetIconDrawable(_act, App.Kp2a.CurrentDb.KpDatabase, (KeePassLib.PwIcon)position, null, false);
 | 
			
		||||
                        drawable = new BitmapDrawable(Util.DrawableToBitmap(drawable));
 | 
			
		||||
                        iv.SetImageDrawable(drawable);
 | 
			
		||||
                        //App.Kp2a.GetDb().DrawableFactory.AssignDrawableTo(iv, _act, App.Kp2a.GetDb().KpDatabase, (KeePassLib.PwIcon) position, null, false);
 | 
			
		||||
 | 
			
		||||
					if (
 | 
			
		||||
						PreferenceManager.GetDefaultSharedPreferences(currView.Context)
 | 
			
		||||
                        if (PreferenceManager.GetDefaultSharedPreferences(currView.Context)
 | 
			
		||||
                                .GetString("IconSetKey", currView.Context.PackageName) == currView.Context.PackageName)
 | 
			
		||||
                        {
 | 
			
		||||
                            Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop;
 | 
			
		||||
@@ -228,6 +229,13 @@ namespace keepass2android
 | 
			
		||||
 | 
			
		||||
                    return currView;
 | 
			
		||||
                }
 | 
			
		||||
                catch (System.Exception e)
 | 
			
		||||
                {
 | 
			
		||||
                    Kp2aLog.LogUnexpectedError(e);
 | 
			
		||||
                    throw;
 | 
			
		||||
                }
 | 
			
		||||
				
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			public bool IsCustomIcon(int position)
 | 
			
		||||
			{
 | 
			
		||||
 
 | 
			
		||||
@@ -448,17 +448,22 @@ namespace keepass2android
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		protected override void OnStart()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                base.OnStart();
 | 
			
		||||
			    Kp2aLog.Log("FileSelect.OnStart");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                //if no database is loaded: load the most recent database
 | 
			
		||||
			if ( (Intent.GetBooleanExtra(NoForwardToPasswordActivity, false)==false) &&  _dbHelper.HasRecentFiles() && !App.Kp2a.OpenDatabases.Any())
 | 
			
		||||
                if ((Intent.GetBooleanExtra(NoForwardToPasswordActivity, false) == false) && _dbHelper.HasRecentFiles() &&
 | 
			
		||||
                    !App.Kp2a.OpenDatabases.Any())
 | 
			
		||||
                {
 | 
			
		||||
                    var fileStorage = new LocalFileStorage(App.Kp2a);
 | 
			
		||||
                    ICursor filesCursor = _dbHelper.FetchAllFiles();
 | 
			
		||||
                filesCursor = new FilteredCursor(filesCursor, cursor => !fileStorage.IsLocalBackup(IOConnectionInfo.FromPath(cursor.GetString(1))));
 | 
			
		||||
                    filesCursor = new FilteredCursor(filesCursor,
 | 
			
		||||
                        cursor => !fileStorage.IsLocalBackup(IOConnectionInfo.FromPath(cursor.GetString(1))));
 | 
			
		||||
                    StartManagingCursor(filesCursor);
 | 
			
		||||
                    if (filesCursor.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
@@ -471,11 +476,18 @@ namespace keepass2android
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            App.Kp2a.GetFileStorage(ioc)
 | 
			
		||||
			                .PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), ioc, 0, false);
 | 
			
		||||
                                .PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), ioc,
 | 
			
		||||
                                    0, false);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
			
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                Kp2aLog.LogUnexpectedError(e);
 | 
			
		||||
                Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
 | 
			
		||||
                Finish();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user