mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-08-13 17:03:49 -04:00
added UI for kdb support
fixed issue with not keeping "meta stream entries" (database color, default username) and num encryption rounds fixed issues with recycle bin (wasn't updating group list correctly, couldn't access newly created recycle bin group)
This commit is contained in:
parent
bc235b3ba5
commit
8de5588cff
@ -15,5 +15,13 @@ namespace KeePassLib
|
|||||||
void Save(PwDatabase kpDatabase, Stream stream);
|
void Save(PwDatabase kpDatabase, Stream stream);
|
||||||
|
|
||||||
bool CanHaveEntriesInRootGroup { get; }
|
bool CanHaveEntriesInRootGroup { get; }
|
||||||
|
bool CanHaveMultipleAttachments { get; }
|
||||||
|
bool CanHaveCustomFields { get; }
|
||||||
|
bool HasDefaultUsername { get; }
|
||||||
|
bool HasDatabaseName { get; }
|
||||||
|
bool SupportsAttachmentKeys { get; }
|
||||||
|
bool SupportsTags { get; }
|
||||||
|
bool SupportsOverrideUrl { get; }
|
||||||
|
bool CanRecycle { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -426,11 +426,13 @@ namespace KeePassLib
|
|||||||
public byte[] HashOfFileOnDisk
|
public byte[] HashOfFileOnDisk
|
||||||
{
|
{
|
||||||
get { return m_pbHashOfFileOnDisk; }
|
get { return m_pbHashOfFileOnDisk; }
|
||||||
|
set { m_pbHashOfFileOnDisk = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] HashOfLastIO
|
public byte[] HashOfLastIO
|
||||||
{
|
{
|
||||||
get { return m_pbHashOfLastIO; }
|
get { return m_pbHashOfLastIO; }
|
||||||
|
set { m_pbHashOfLastIO = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UseFileTransactions
|
public bool UseFileTransactions
|
||||||
|
@ -26,6 +26,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
private Dictionary<PwUuid, AdditionalGroupData> _groupData = new Dictionary<PwUuid, AdditionalGroupData>();
|
private Dictionary<PwUuid, AdditionalGroupData> _groupData = new Dictionary<PwUuid, AdditionalGroupData>();
|
||||||
private static readonly DateTime _expireNever = new DateTime(2999,12,28,23,59,59);
|
private static readonly DateTime _expireNever = new DateTime(2999,12,28,23,59,59);
|
||||||
|
private List<PwEntryV3> _metaStreams;
|
||||||
|
|
||||||
public void PopulateDatabaseFromStream(PwDatabase db, Stream s, IStatusLogger slLogger)
|
public void PopulateDatabaseFromStream(PwDatabase db, Stream s, IStatusLogger slLogger)
|
||||||
{
|
{
|
||||||
@ -34,6 +35,8 @@ namespace keepass2android
|
|||||||
|
|
||||||
var hashingStream = new HashingStreamEx(s, false, new SHA256Managed());
|
var hashingStream = new HashingStreamEx(s, false, new SHA256Managed());
|
||||||
|
|
||||||
|
_metaStreams = new List<PwEntryV3>();
|
||||||
|
|
||||||
string password = "";//no need to distinguish between null and "" because empty passwords are invalid (and null is not allowed)
|
string password = "";//no need to distinguish between null and "" because empty passwords are invalid (and null is not allowed)
|
||||||
KcpPassword passwordKey = (KcpPassword)db.MasterKey.GetUserKey(typeof(KcpPassword));
|
KcpPassword passwordKey = (KcpPassword)db.MasterKey.GetUserKey(typeof(KcpPassword));
|
||||||
if (passwordKey != null)
|
if (passwordKey != null)
|
||||||
@ -54,6 +57,7 @@ namespace keepass2android
|
|||||||
var dbv3 = importer.OpenDatabase(hashingStream, password, keyfileStream);
|
var dbv3 = importer.OpenDatabase(hashingStream, password, keyfileStream);
|
||||||
|
|
||||||
db.Name = dbv3.Name;
|
db.Name = dbv3.Name;
|
||||||
|
db.KeyEncryptionRounds = (ulong) dbv3.NumKeyEncRounds;
|
||||||
db.RootGroup = ConvertGroup(dbv3.RootGroup);
|
db.RootGroup = ConvertGroup(dbv3.RootGroup);
|
||||||
if (dbv3.Algorithm == PwEncryptionAlgorithm.Rjindal)
|
if (dbv3.Algorithm == PwEncryptionAlgorithm.Rjindal)
|
||||||
{
|
{
|
||||||
@ -126,7 +130,11 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
var entry = groupV3.GetEntryAt(i);
|
var entry = groupV3.GetEntryAt(i);
|
||||||
if (entry.IsMetaStream)
|
if (entry.IsMetaStream)
|
||||||
|
{
|
||||||
|
_metaStreams.Add(entry);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
pwGroup.AddEntry(ConvertEntry(entry), true);
|
pwGroup.AddEntry(ConvertEntry(entry), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +260,6 @@ namespace keepass2android
|
|||||||
|
|
||||||
AssignParent(kpDatabase.RootGroup, db, groupV3s);
|
AssignParent(kpDatabase.RootGroup, db, groupV3s);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (PwEntry e in kpDatabase.RootGroup.GetEntries(true))
|
foreach (PwEntry e in kpDatabase.RootGroup.GetEntries(true))
|
||||||
{
|
{
|
||||||
PwEntryV3 entryV3 = ConvertEntry(e, db);
|
PwEntryV3 entryV3 = ConvertEntry(e, db);
|
||||||
@ -263,12 +269,25 @@ namespace keepass2android
|
|||||||
db.Entries.Add(entryV3);
|
db.Entries.Add(entryV3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add meta stream entries:
|
||||||
|
if (db.Groups.Any())
|
||||||
|
{
|
||||||
|
foreach (var metaEntry in _metaStreams)
|
||||||
|
{
|
||||||
|
metaEntry.GroupId = db.Groups.First().Id.Id;
|
||||||
|
db.Entries.Add(metaEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HashingStreamEx hashedStream = new HashingStreamEx(stream, true, null);
|
HashingStreamEx hashedStream = new HashingStreamEx(stream, true, null);
|
||||||
PwDbV3Output output = new PwDbV3Output(db, hashedStream);
|
PwDbV3Output output = new PwDbV3Output(db, hashedStream);
|
||||||
output.Output();
|
output.Output();
|
||||||
hashedStream.Close();
|
hashedStream.Close();
|
||||||
HashOfLastStream = hashedStream.Hash;
|
HashOfLastStream = hashedStream.Hash;
|
||||||
|
|
||||||
|
kpDatabase.HashOfLastIO = kpDatabase.HashOfFileOnDisk = HashOfLastStream;
|
||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +296,46 @@ namespace keepass2android
|
|||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanHaveMultipleAttachments
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanHaveCustomFields
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasDefaultUsername
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasDatabaseName
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsAttachmentKeys
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsTags
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsOverrideUrl
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanRecycle
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
private void AssignParent(PwGroup kpParent, PwDatabaseV3 dbV3, Dictionary<int, PwGroupV3> groupV3s)
|
private void AssignParent(PwGroup kpParent, PwDatabaseV3 dbV3, Dictionary<int, PwGroupV3> groupV3s)
|
||||||
{
|
{
|
||||||
PwGroupV3 parentV3;
|
PwGroupV3 parentV3;
|
||||||
@ -304,6 +363,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
PwGroupV3 toGroup = new PwGroupV3();
|
PwGroupV3 toGroup = new PwGroupV3();
|
||||||
toGroup.Name = fromGroup.Name;
|
toGroup.Name = fromGroup.Name;
|
||||||
|
//todo remove
|
||||||
Android.Util.Log.Debug("KP2A", "save kdb: group " + fromGroup.Name);
|
Android.Util.Log.Debug("KP2A", "save kdb: group " + fromGroup.Name);
|
||||||
|
|
||||||
toGroup.TCreation = new PwDate(ConvertTime(fromGroup.CreationTime));
|
toGroup.TCreation = new PwDate(ConvertTime(fromGroup.CreationTime));
|
||||||
|
@ -38,5 +38,45 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanHaveMultipleAttachments
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanHaveCustomFields
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasDefaultUsername
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasDatabaseName
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsAttachmentKeys
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsTags
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsOverrideUrl
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanRecycle
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return CanRecycleGroup(_entry.ParentGroup);
|
return App.GetDb().DatabaseFormat.CanRecycle && CanRecycleGroup(_entry.ParentGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,8 @@ namespace keepass2android
|
|||||||
if(pgParent != null)
|
if(pgParent != null)
|
||||||
{
|
{
|
||||||
pgParent.Entries.Remove(pe);
|
pgParent.Entries.Remove(pe);
|
||||||
|
//TODO check if RecycleBin is deleted
|
||||||
|
//TODO no recycle bin in KDB
|
||||||
|
|
||||||
if ((DeletePermanently) || (!CanRecycle))
|
if ((DeletePermanently) || (!CanRecycle))
|
||||||
{
|
{
|
||||||
@ -85,7 +86,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
else // Recycle
|
else // Recycle
|
||||||
{
|
{
|
||||||
EnsureRecycleBin(ref pgRecycleBin, ref bUpdateGroupList);
|
EnsureRecycleBinExists(ref pgRecycleBin, ref bUpdateGroupList);
|
||||||
|
|
||||||
pgRecycleBin.AddEntry(pe, true, true);
|
pgRecycleBin.AddEntry(pe, true, true);
|
||||||
pe.Touch(false);
|
pe.Touch(false);
|
||||||
@ -97,6 +98,9 @@ namespace keepass2android
|
|||||||
Db.Dirty.Add(pgParent);
|
Db.Dirty.Add(pgParent);
|
||||||
// Mark new parent dirty
|
// Mark new parent dirty
|
||||||
Db.Dirty.Add(pgRecycleBin);
|
Db.Dirty.Add(pgRecycleBin);
|
||||||
|
// mark root dirty if recycle bin was created
|
||||||
|
if (bUpdateGroupList)
|
||||||
|
Db.Dirty.Add(Db.Root);
|
||||||
} else {
|
} else {
|
||||||
// Let's not bother recovering from a failure to save a deleted entry. It is too much work.
|
// Let's not bother recovering from a failure to save a deleted entry. It is too much work.
|
||||||
App.LockDatabase(false);
|
App.LockDatabase(false);
|
||||||
|
@ -56,7 +56,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return CanRecycleGroup(_group);
|
return App.GetDb().DatabaseFormat.CanRecycle && CanRecycleGroup(_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
else // Recycle
|
else // Recycle
|
||||||
{
|
{
|
||||||
bool bDummy = false;
|
bool groupListUpdateRequired = false;
|
||||||
EnsureRecycleBin(ref pgRecycleBin, ref bDummy);
|
EnsureRecycleBinExists(ref pgRecycleBin, ref groupListUpdateRequired);
|
||||||
|
|
||||||
pgRecycleBin.AddGroup(pg, true, true);
|
pgRecycleBin.AddGroup(pg, true, true);
|
||||||
pg.Touch(false);
|
pg.Touch(false);
|
||||||
@ -106,6 +106,10 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
//Mark old parent dirty:
|
//Mark old parent dirty:
|
||||||
Db.Dirty.Add(pgParent);
|
Db.Dirty.Add(pgParent);
|
||||||
|
|
||||||
|
// mark root dirty if recycle bin was created
|
||||||
|
if (groupListUpdateRequired)
|
||||||
|
Db.Dirty.Add(Db.Root);
|
||||||
} else {
|
} else {
|
||||||
// Let's not bother recovering from a failure to save a deleted group. It is too much work.
|
// Let's not bother recovering from a failure to save a deleted group. It is too much work.
|
||||||
App.LockDatabase(false);
|
App.LockDatabase(false);
|
||||||
|
@ -66,7 +66,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void EnsureRecycleBin(ref PwGroup pgRecycleBin,
|
protected void EnsureRecycleBinExists(ref PwGroup pgRecycleBin,
|
||||||
ref bool bGroupListUpdateRequired)
|
ref bool bGroupListUpdateRequired)
|
||||||
{
|
{
|
||||||
if ((Db == null) || (Db.KpDatabase == null)) { return; }
|
if ((Db == null) || (Db.KpDatabase == null)) { return; }
|
||||||
@ -87,7 +87,7 @@ namespace keepass2android
|
|||||||
};
|
};
|
||||||
|
|
||||||
Db.KpDatabase.RootGroup.AddGroup(pgRecycleBin, true);
|
Db.KpDatabase.RootGroup.AddGroup(pgRecycleBin, true);
|
||||||
|
Db.Groups[pgRecycleBin.Uuid] = pgRecycleBin;
|
||||||
Db.KpDatabase.RecycleBinUuid = pgRecycleBin.Uuid;
|
Db.KpDatabase.RecycleBinUuid = pgRecycleBin.Uuid;
|
||||||
|
|
||||||
bGroupListUpdateRequired = true;
|
bGroupListUpdateRequired = true;
|
||||||
|
@ -31,9 +31,13 @@ namespace Kp2aUnitTests
|
|||||||
//runner.AddTests(new List<Type> { typeof(TestSaveDb) });
|
//runner.AddTests(new List<Type> { typeof(TestSaveDb) });
|
||||||
//runner.AddTests(new List<Type> { typeof(TestCachingFileStorage) });
|
//runner.AddTests(new List<Type> { typeof(TestCachingFileStorage) });
|
||||||
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdb1WithKeyfileOnly"));
|
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdb1WithKeyfileOnly"));
|
||||||
runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadEditSaveWithSyncKdb"));
|
|
||||||
runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadAndSave_TestIdenticalFiles_kdb"));
|
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadEditSaveWithSyncKdb"));
|
||||||
runner.AddTests(typeof(TestSaveDb).GetMethod("TestCreateSaveAndLoad_TestIdenticalFiles_kdb"));
|
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadAndSave_TestIdenticalFiles_kdb"));
|
||||||
|
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestCreateSaveAndLoad_TestIdenticalFiles_kdb"));
|
||||||
|
|
||||||
|
runner.AddTests(typeof(TestSaveDb).GetMethod("TestSaveTwice_kdb"));
|
||||||
|
|
||||||
//runner.AddTests(typeof(TestLoadDb).GetMethod("LoadAndSaveFromRemote1And1Ftp"));
|
//runner.AddTests(typeof(TestLoadDb).GetMethod("LoadAndSaveFromRemote1And1Ftp"));
|
||||||
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdbpWithPasswordOnly"));
|
//runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdbpWithPasswordOnly"));
|
||||||
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadKdbxAndSaveKdbp_TestIdenticalFiles"));
|
//runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadKdbxAndSaveKdbp_TestIdenticalFiles"));
|
||||||
|
@ -373,6 +373,32 @@ namespace Kp2aUnitTests
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestSaveTwice_kdb()
|
||||||
|
{
|
||||||
|
var filename = DefaultDirectory + "savetwice.kdb";
|
||||||
|
//create the default database:
|
||||||
|
IKp2aApp app = SetupAppWithDatabase(filename);
|
||||||
|
DisplayGroups(app, "After create 1");
|
||||||
|
//save it and reload it so we have a base version
|
||||||
|
Android.Util.Log.Debug("KP2A", "-- Save first version -- ");
|
||||||
|
SaveDatabase(app);
|
||||||
|
Android.Util.Log.Debug("KP2A", "-- Load DB -- ");
|
||||||
|
app = LoadDatabase(filename, DefaultPassword, DefaultKeyfile);
|
||||||
|
DisplayGroups(app, "After reload");
|
||||||
|
|
||||||
|
//save the database (first time):
|
||||||
|
Android.Util.Log.Debug("KP2A", "-- Save db first time ");
|
||||||
|
SaveDatabase(app);
|
||||||
|
|
||||||
|
Android.Util.Log.Debug("KP2A", "-- Save db second time ");
|
||||||
|
SaveDatabase(app);
|
||||||
|
|
||||||
|
//make sure the right question was asked
|
||||||
|
Assert.AreEqual(null, ((TestKp2aApp)app).LastYesNoCancelQuestionTitle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
@ -261,9 +261,8 @@ namespace keepass2android
|
|||||||
|
|
||||||
TextView keyView = (TextView) ees.FindViewById(Resource.Id.title);
|
TextView keyView = (TextView) ees.FindViewById(Resource.Id.title);
|
||||||
keyView.RequestFocus();
|
keyView.RequestFocus();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
SetAddExtraStringEnabled();
|
||||||
|
|
||||||
((CheckBox)FindViewById(Resource.Id.entry_expires_checkbox)).CheckedChange += (sender, e) =>
|
((CheckBox)FindViewById(Resource.Id.entry_expires_checkbox)).CheckedChange += (sender, e) =>
|
||||||
{
|
{
|
||||||
@ -280,6 +279,12 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetAddExtraStringEnabled()
|
||||||
|
{
|
||||||
|
if (!App.Kp2a.GetDb().DatabaseFormat.CanHaveCustomFields)
|
||||||
|
((Button)FindViewById(Resource.Id.add_advanced)).Visibility = ViewStates.Gone;
|
||||||
|
}
|
||||||
|
|
||||||
private void MakePasswordVisibleOrHidden()
|
private void MakePasswordVisibleOrHidden()
|
||||||
{
|
{
|
||||||
TextView password = (TextView) FindViewById(Resource.Id.entry_password);
|
TextView password = (TextView) FindViewById(Resource.Id.entry_password);
|
||||||
@ -663,7 +668,12 @@ namespace keepass2android
|
|||||||
foreach (KeyValuePair<string, ProtectedBinary> pair in State.Entry.Binaries.OrderBy(p => p.Key) )
|
foreach (KeyValuePair<string, ProtectedBinary> pair in State.Entry.Binaries.OrderBy(p => p.Key) )
|
||||||
{
|
{
|
||||||
String key = pair.Key;
|
String key = pair.Key;
|
||||||
Button binaryButton = new Button(this) {Text = key};
|
String label = key;
|
||||||
|
if ((String.IsNullOrEmpty(label) || (!App.Kp2a.GetDb().DatabaseFormat.SupportsAttachmentKeys)))
|
||||||
|
{
|
||||||
|
label = "<attachment>";
|
||||||
|
}
|
||||||
|
Button binaryButton = new Button(this) {Text = label};
|
||||||
|
|
||||||
binaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuDelete),null, null, null);
|
binaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuDelete),null, null, null);
|
||||||
binaryButton.Click += (sender, e) =>
|
binaryButton.Click += (sender, e) =>
|
||||||
@ -680,6 +690,9 @@ namespace keepass2android
|
|||||||
|
|
||||||
Button addBinaryButton = new Button(this) {Text = GetString(Resource.String.add_binary)};
|
Button addBinaryButton = new Button(this) {Text = GetString(Resource.String.add_binary)};
|
||||||
addBinaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuAdd) , null, null, null);
|
addBinaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuAdd) , null, null, null);
|
||||||
|
addBinaryButton.Enabled = true;
|
||||||
|
if (!App.Kp2a.GetDb().DatabaseFormat.CanHaveMultipleAttachments)
|
||||||
|
addBinaryButton.Enabled = !State.Entry.Binaries.Any();
|
||||||
addBinaryButton.Click += (sender, e) =>
|
addBinaryButton.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
Util.ShowBrowseDialog(this, Intents.RequestCodeFileBrowseForBinary, false);
|
Util.ShowBrowseDialog(this, Intents.RequestCodeFileBrowseForBinary, false);
|
||||||
@ -837,8 +850,26 @@ namespace keepass2android
|
|||||||
|
|
||||||
PopulateBinaries();
|
PopulateBinaries();
|
||||||
|
|
||||||
|
if (App.Kp2a.GetDb().DatabaseFormat.SupportsOverrideUrl)
|
||||||
|
{
|
||||||
PopulateText(Resource.Id.entry_override_url, State.Entry.OverrideUrl);
|
PopulateText(Resource.Id.entry_override_url, State.Entry.OverrideUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FindViewById(Resource.Id.entry_override_url_label).Visibility = ViewStates.Gone;
|
||||||
|
FindViewById(Resource.Id.entry_override_url).Visibility = ViewStates.Gone;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (App.Kp2a.GetDb().DatabaseFormat.SupportsTags)
|
||||||
|
{
|
||||||
PopulateText(Resource.Id.entry_tags, StrUtil.TagsToString(State.Entry.Tags, true));
|
PopulateText(Resource.Id.entry_tags, StrUtil.TagsToString(State.Entry.Tags, true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FindViewById(Resource.Id.entry_tags_label).Visibility = ViewStates.Gone;
|
||||||
|
FindViewById(Resource.Id.entry_tags).Visibility = ViewStates.Gone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UpdateExpires();
|
UpdateExpires();
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,12 @@ namespace keepass2android
|
|||||||
rounds.Enabled = db.CanWrite;
|
rounds.Enabled = db.CanWrite;
|
||||||
|
|
||||||
Preference defaultUser = FindPreference(GetString(Resource.String.default_username_key));
|
Preference defaultUser = FindPreference(GetString(Resource.String.default_username_key));
|
||||||
|
if (!db.DatabaseFormat.HasDefaultUsername)
|
||||||
|
{
|
||||||
|
((PreferenceScreen) FindPreference(GetString(Resource.String.db_key))).RemovePreference(defaultUser);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
defaultUser.Enabled = db.CanWrite;
|
defaultUser.Enabled = db.CanWrite;
|
||||||
((EditTextPreference)defaultUser).EditText.Text = db.KpDatabase.DefaultUserName;
|
((EditTextPreference)defaultUser).EditText.Text = db.KpDatabase.DefaultUserName;
|
||||||
((EditTextPreference)defaultUser).Text = db.KpDatabase.DefaultUserName;
|
((EditTextPreference)defaultUser).Text = db.KpDatabase.DefaultUserName;
|
||||||
@ -111,7 +117,16 @@ namespace keepass2android
|
|||||||
pt.Run();
|
pt.Run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Preference databaseName = FindPreference(GetString(Resource.String.database_name_key));
|
Preference databaseName = FindPreference(GetString(Resource.String.database_name_key));
|
||||||
|
if (!db.DatabaseFormat.HasDatabaseName)
|
||||||
|
{
|
||||||
|
((PreferenceScreen) FindPreference(GetString(Resource.String.db_key))).RemovePreference(databaseName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
databaseName.Enabled = db.CanWrite;
|
databaseName.Enabled = db.CanWrite;
|
||||||
((EditTextPreference) databaseName).EditText.Text = db.KpDatabase.Name;
|
((EditTextPreference) databaseName).EditText.Text = db.KpDatabase.Name;
|
||||||
((EditTextPreference) databaseName).Text = db.KpDatabase.Name;
|
((EditTextPreference) databaseName).Text = db.KpDatabase.Name;
|
||||||
@ -138,7 +153,7 @@ namespace keepass2android
|
|||||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, save);
|
ProgressTask pt = new ProgressTask(App.Kp2a, this, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
Preference changeMaster = FindPreference(GetString(Resource.String.master_pwd_key));
|
Preference changeMaster = FindPreference(GetString(Resource.String.master_pwd_key));
|
||||||
if (App.Kp2a.GetDb().CanWrite)
|
if (App.Kp2a.GetDb().CanWrite)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user