allow to open AutoOpenEntries manually if they are not "Enabled" (but "Visible"). Don't suggest to configure fingerprint unlock for child databases.
This commit is contained in:
@@ -68,7 +68,7 @@ namespace keepass2android
|
||||
if (key == strVisible)
|
||||
return Application.Context.GetString(Resource.String.Visible_title);
|
||||
if (key == strEnabled)
|
||||
return Application.Context.GetString(Resource.String.Enabled_title);
|
||||
return Application.Context.GetString(Resource.String.child_db_Enabled_title);
|
||||
if (key == strUiKeyFile)
|
||||
return Application.Context.GetString(Resource.String.keyfile_heading);
|
||||
if (key == strUiDatabaseFile)
|
||||
|
||||
@@ -209,7 +209,6 @@ namespace keepass2android
|
||||
private void OnOpen(AutoExecItem item)
|
||||
{
|
||||
KeeAutoExecExt.AutoOpenEntry(this, item, true);
|
||||
|
||||
}
|
||||
|
||||
private void OnEnableCopy(AutoExecItem item)
|
||||
|
||||
@@ -634,7 +634,7 @@ namespace keepass2android
|
||||
|
||||
bool disabledForDatabase = _prefs.GetBoolean(fingerprintinfohidden_prefskey + App.Kp2a.CurrentDb.CurrentFingerprintPrefKey, false);
|
||||
bool disabledForAll = _prefs.GetBoolean(fingerprintinfohidden_prefskey, false);
|
||||
if (!disabledForAll && !disabledForDatabase)
|
||||
if (!disabledForAll && !disabledForDatabase && !App.Kp2a.IsChildDatabase(App.Kp2a.CurrentDb))
|
||||
{
|
||||
|
||||
FingerprintModule fpModule = new FingerprintModule(this);
|
||||
|
||||
@@ -322,6 +322,9 @@ namespace keepass2android
|
||||
|
||||
PasswordActivity.Launch(activity,ioc,ck,new ActivityLaunchModeSimple(), !
|
||||
bRestoreFocus);
|
||||
|
||||
App.Kp2a.RegisterChildDatabase(ioc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_pressed="true" >
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="2dip" />
|
||||
<solid android:color="#bbb" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="2dip" />
|
||||
<solid android:color="#ccc"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item >
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="2dip" />
|
||||
<solid android:color="#ccc" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -748,7 +748,7 @@
|
||||
<string name="EnableCopyForThisDevice_Info">This will create and enable a copy of the child database settings. These copied settings can then be adjusted specifically for this device.</string>
|
||||
|
||||
<string name="Visible_title">Visible</string>
|
||||
<string name="Enabled_title">Enabled</string>
|
||||
<string name="child_db_Enabled_title">Open automatically</string>
|
||||
<string name="database_file_heading">Database file</string>
|
||||
<string name="if_device_text">Enable for %1$s</string>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ using Java.IO;
|
||||
using Java.Net;
|
||||
using keepass2android.Io;
|
||||
using keepass2android.Utils;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
using Object = Java.Lang.Object;
|
||||
@@ -37,6 +38,7 @@ namespace keepass2android
|
||||
|
||||
private readonly SelectCurrentDbActivity _context;
|
||||
internal List<Database> _displayedDatabases;
|
||||
internal List<AutoExecItem> _autoExecItems;
|
||||
|
||||
public OpenDatabaseAdapter(SelectCurrentDbActivity context)
|
||||
{
|
||||
@@ -75,7 +77,7 @@ namespace keepass2android
|
||||
btn = new Button(_context);
|
||||
btn.LayoutParameters = new GridView.LayoutParams((int) convertDpToPixel(140, _context),
|
||||
(int) convertDpToPixel(150, _context));
|
||||
btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg);
|
||||
|
||||
btn.SetPadding((int) convertDpToPixel(4, _context),
|
||||
(int) convertDpToPixel(20, _context),
|
||||
(int) convertDpToPixel(4, _context),
|
||||
@@ -89,11 +91,12 @@ namespace keepass2android
|
||||
int pos;
|
||||
int.TryParse(((Button) sender).Tag.ToString(), out pos);
|
||||
if (pos < _displayedDatabases.Count)
|
||||
_context.OnItemSelected(_displayedDatabases[pos]);
|
||||
_context.OnDatabaseSelected(_displayedDatabases[pos]);
|
||||
else if (pos < _displayedDatabases.Count + _autoExecItems.Count)
|
||||
_context.OnAutoExecItemSelected(_autoExecItems[pos - _displayedDatabases.Count]);
|
||||
else
|
||||
{
|
||||
_context.OnOpenOther();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -111,9 +114,18 @@ namespace keepass2android
|
||||
drawable = App.Kp2a.GetResourceDrawable("ic_storage_" + Util.GetProtocolId(db.Ioc));
|
||||
displayName = db.KpDatabase.Name;
|
||||
displayName += "\n" + App.Kp2a.GetFileStorage(db.Ioc).GetDisplayName(db.Ioc);
|
||||
btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg);
|
||||
}
|
||||
else if (position < _displayedDatabases.Count + _autoExecItems.Count)
|
||||
{
|
||||
var item = _autoExecItems[position - _displayedDatabases.Count];
|
||||
drawable = App.Kp2a.GetResourceDrawable("ic_nav_changedb");
|
||||
displayName = item.Entry.Strings.ReadSafe(PwDefs.TitleField);
|
||||
btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg_dark);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg);
|
||||
displayName = _context.GetString(Resource.String.start_open_file);
|
||||
drawable = App.Kp2a.GetResourceDrawable("ic_nav_changedb");
|
||||
}
|
||||
@@ -129,21 +141,41 @@ namespace keepass2android
|
||||
|
||||
public override int Count
|
||||
{
|
||||
get { return _displayedDatabases.Count+1; }
|
||||
get { return _displayedDatabases.Count+_autoExecItems.Count+1; }
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
string thisDevice = KeeAutoExecExt.ThisDeviceId;
|
||||
_displayedDatabases = App.Kp2a.OpenDatabases.ToList();
|
||||
_autoExecItems = App.Kp2a.OpenDatabases
|
||||
.SelectMany(db => KeeAutoExecExt.GetAutoExecItems(db.KpDatabase))
|
||||
.Where(item =>
|
||||
item.Visible
|
||||
&&
|
||||
KeeAutoExecExt.IsDeviceEnabled(item, thisDevice, out _)
|
||||
&&
|
||||
!_displayedDatabases.Any(displayedDb =>
|
||||
{
|
||||
IOConnectionInfo itemIoc;
|
||||
return KeeAutoExecExt.TryGetDatabaseIoc(item, out itemIoc) &&
|
||||
displayedDb.Ioc.IsSameFileAs(itemIoc);
|
||||
}))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAutoExecItemSelected(AutoExecItem autoExecItem)
|
||||
{
|
||||
KeeAutoExecExt.AutoOpenEntry(this, autoExecItem, true);
|
||||
}
|
||||
|
||||
private void OnOpenOther()
|
||||
{
|
||||
StartFileSelect(true, true);
|
||||
}
|
||||
|
||||
private void OnItemSelected(Database selectedDatabase)
|
||||
private void OnDatabaseSelected(Database selectedDatabase)
|
||||
{
|
||||
App.Kp2a.CurrentDb = selectedDatabase;
|
||||
LaunchingOther = true;
|
||||
@@ -177,7 +209,7 @@ namespace keepass2android
|
||||
|
||||
_adapter = new OpenDatabaseAdapter(this);
|
||||
var gridView = FindViewById<GridView>(Resource.Id.gridview);
|
||||
gridView.ItemClick += (sender, args) => OnItemSelected(_adapter._displayedDatabases[args.Position]);
|
||||
|
||||
gridView.Adapter = _adapter;
|
||||
|
||||
if (!string.IsNullOrEmpty(Intent.GetStringExtra(Util.KeyFilename)))
|
||||
|
||||
@@ -346,7 +346,8 @@ namespace keepass2android
|
||||
|
||||
private readonly List<IOConnectionInfo> _openAttempts = new List<IOConnectionInfo>(); //stores which files have been attempted to open. Used to avoid that we repeatedly try to load files which failed to load.
|
||||
private readonly List<Database> _openDatabases = new List<Database>();
|
||||
private Database _currentDatabase;
|
||||
private readonly List<IOConnectionInfo> _childDatabases = new List<IOConnectionInfo>(); //list of databases which were opened as child databases
|
||||
private Database _currentDatabase;
|
||||
|
||||
public IEnumerable<Database> OpenDatabases
|
||||
{
|
||||
@@ -354,6 +355,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
public readonly HashSet<PwGroup> dirty = new HashSet<PwGroup>(new PwGroupEqualityFromIdComparer());
|
||||
|
||||
public HashSet<PwGroup> DirtyGroups { get { return dirty; } }
|
||||
|
||||
public bool AttemptedToOpenBefore(IOConnectionInfo ioc)
|
||||
@@ -1087,6 +1089,16 @@ namespace keepass2android
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void RegisterChildDatabase(IOConnectionInfo ioc)
|
||||
{
|
||||
_childDatabases.Add(ioc);
|
||||
}
|
||||
|
||||
public bool IsChildDatabase(Database db)
|
||||
{
|
||||
return _childDatabases.Any(ioc => ioc.IsSameFileAs(db.Ioc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ namespace keepass2android
|
||||
{
|
||||
//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);
|
||||
|
||||
@@ -1906,6 +1906,11 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\config_child_db.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\storagetype_button_bg_dark.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||
|
||||
Reference in New Issue
Block a user