add some more error logging
This commit is contained in:
@@ -185,48 +185,56 @@ namespace keepass2android
|
|||||||
|
|
||||||
public override View GetView(int position, View convertView, ViewGroup parent)
|
public override View GetView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
View currView;
|
try
|
||||||
if(convertView == null)
|
{
|
||||||
{
|
View currView;
|
||||||
LayoutInflater li = (LayoutInflater) _act.GetSystemService(LayoutInflaterService);
|
if (convertView == null)
|
||||||
currView = li.Inflate(Resource.Layout.icon, null);
|
{
|
||||||
}
|
LayoutInflater li = (LayoutInflater)_act.GetSystemService(LayoutInflaterService);
|
||||||
else
|
currView = li.Inflate(Resource.Layout.icon, null);
|
||||||
{
|
}
|
||||||
currView = convertView;
|
else
|
||||||
}
|
{
|
||||||
TextView tv = (TextView) currView.FindViewById(Resource.Id.icon_text);
|
currView = convertView;
|
||||||
ImageView iv = (ImageView) currView.FindViewById(Resource.Id.icon_image);
|
}
|
||||||
|
TextView tv = (TextView)currView.FindViewById(Resource.Id.icon_text);
|
||||||
if (position < (int)PwIcon.Count)
|
ImageView iv = (ImageView)currView.FindViewById(Resource.Id.icon_image);
|
||||||
{
|
|
||||||
tv.Text = "" + position;
|
|
||||||
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 (
|
if (position < (int)PwIcon.Count)
|
||||||
PreferenceManager.GetDefaultSharedPreferences(currView.Context)
|
{
|
||||||
.GetString("IconSetKey", currView.Context.PackageName) == currView.Context.PackageName)
|
tv.Text = "" + position;
|
||||||
{
|
var drawable = App.Kp2a.CurrentDb.DrawableFactory.GetIconDrawable(_act, App.Kp2a.CurrentDb.KpDatabase, (KeePassLib.PwIcon)position, null, false);
|
||||||
Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop;
|
drawable = new BitmapDrawable(Util.DrawableToBitmap(drawable));
|
||||||
Color color = new Color(189, 189, 189);
|
iv.SetImageDrawable(drawable);
|
||||||
iv.SetColorFilter(color, mMode);
|
//App.Kp2a.GetDb().DrawableFactory.AssignDrawableTo(iv, _act, App.Kp2a.GetDb().KpDatabase, (KeePassLib.PwIcon) position, null, false);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int pos = position - (int)PwIcon.Count;
|
|
||||||
var icon = _db.CustomIcons[pos];
|
|
||||||
tv.Text = pos.ToString();
|
|
||||||
iv.SetColorFilter(null);
|
|
||||||
iv.SetImageBitmap(icon.Image);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return currView;
|
if (PreferenceManager.GetDefaultSharedPreferences(currView.Context)
|
||||||
|
.GetString("IconSetKey", currView.Context.PackageName) == currView.Context.PackageName)
|
||||||
|
{
|
||||||
|
Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop;
|
||||||
|
Color color = new Color(189, 189, 189);
|
||||||
|
iv.SetColorFilter(color, mMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int pos = position - (int)PwIcon.Count;
|
||||||
|
var icon = _db.CustomIcons[pos];
|
||||||
|
tv.Text = pos.ToString();
|
||||||
|
iv.SetColorFilter(null);
|
||||||
|
iv.SetImageBitmap(icon.Image);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return currView;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Kp2aLog.LogUnexpectedError(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCustomIcon(int position)
|
public bool IsCustomIcon(int position)
|
||||||
|
|||||||
@@ -448,37 +448,49 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
base.OnStart();
|
|
||||||
Kp2aLog.Log("FileSelect.OnStart");
|
|
||||||
|
|
||||||
|
try
|
||||||
//if no database is loaded: load the most recent database
|
{
|
||||||
if ( (Intent.GetBooleanExtra(NoForwardToPasswordActivity, false)==false) && _dbHelper.HasRecentFiles() && !App.Kp2a.OpenDatabases.Any())
|
base.OnStart();
|
||||||
{
|
Kp2aLog.Log("FileSelect.OnStart");
|
||||||
var fileStorage = new LocalFileStorage(App.Kp2a);
|
|
||||||
ICursor filesCursor = _dbHelper.FetchAllFiles();
|
|
||||||
filesCursor = new FilteredCursor(filesCursor, cursor => !fileStorage.IsLocalBackup(IOConnectionInfo.FromPath(cursor.GetString(1))));
|
//if no database is loaded: load the most recent database
|
||||||
StartManagingCursor(filesCursor);
|
if ((Intent.GetBooleanExtra(NoForwardToPasswordActivity, false) == false) && _dbHelper.HasRecentFiles() &&
|
||||||
if (filesCursor.Count > 0)
|
!App.Kp2a.OpenDatabases.Any())
|
||||||
{
|
{
|
||||||
filesCursor.MoveToFirst();
|
var fileStorage = new LocalFileStorage(App.Kp2a);
|
||||||
IOConnectionInfo ioc = _dbHelper.CursorToIoc(filesCursor);
|
ICursor filesCursor = _dbHelper.FetchAllFiles();
|
||||||
if (App.Kp2a.GetFileStorage(ioc).RequiresSetup(ioc) == false)
|
filesCursor = new FilteredCursor(filesCursor,
|
||||||
{
|
cursor => !fileStorage.IsLocalBackup(IOConnectionInfo.FromPath(cursor.GetString(1))));
|
||||||
LaunchPasswordActivityForIoc(ioc);
|
StartManagingCursor(filesCursor);
|
||||||
}
|
if (filesCursor.Count > 0)
|
||||||
else
|
{
|
||||||
{
|
filesCursor.MoveToFirst();
|
||||||
App.Kp2a.GetFileStorage(ioc)
|
IOConnectionInfo ioc = _dbHelper.CursorToIoc(filesCursor);
|
||||||
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), ioc, 0, false);
|
if (App.Kp2a.GetFileStorage(ioc).RequiresSetup(ioc) == false)
|
||||||
|
{
|
||||||
|
LaunchPasswordActivityForIoc(ioc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
App.Kp2a.GetFileStorage(ioc)
|
||||||
|
.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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public override bool OnCreateOptionsMenu(IMenu menu) {
|
public override bool OnCreateOptionsMenu(IMenu menu) {
|
||||||
base.OnCreateOptionsMenu(menu);
|
base.OnCreateOptionsMenu(menu);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user