use of com.keepassdroid.database.PwDatabase in project KeePassDX by Kunzisoft.
the class EntryActivity method fillData.
protected void fillData() {
Database db = App.getDB();
PwDatabase pm = db.pm;
mEntry.startToDecodeReference(pm);
// Assign title
populateTitle(db.drawFactory.getIconDrawable(getResources(), mEntry.getIcon()), mEntry.getTitle());
// Assign basic fields
entryContentsView.assignUserName(mEntry.getUsername());
entryContentsView.assignUserNameCopyListener(view -> clipboardHelper.timeoutCopyToClipboard(mEntry.getUsername(), getString(R.string.copy_field, getString(R.string.entry_user_name))));
entryContentsView.assignPassword(mEntry.getPassword());
if (PreferencesUtil.allowCopyPassword(this)) {
entryContentsView.assignPasswordCopyListener(view -> clipboardHelper.timeoutCopyToClipboard(mEntry.getPassword(), getString(R.string.copy_field, getString(R.string.entry_password))));
}
entryContentsView.assignURL(mEntry.getUrl());
entryContentsView.setHiddenPasswordStyle(!mShowPassword);
entryContentsView.assignComment(mEntry.getNotes());
// Assign custom fields
if (mEntry.allowExtraFields()) {
entryContentsView.clearExtraFields();
for (Map.Entry<String, String> field : mEntry.getExtraFields().entrySet()) {
final String label = field.getKey();
final String value = field.getValue();
entryContentsView.addExtraField(label, value, view -> clipboardHelper.timeoutCopyToClipboard(value, getString(R.string.copy_field, label)));
}
}
// Assign dates
entryContentsView.assignCreationDate(mEntry.getCreationTime().getDate());
entryContentsView.assignModificationDate(mEntry.getLastModificationTime().getDate());
entryContentsView.assignLastAccessDate(mEntry.getLastAccessTime().getDate());
Date expires = mEntry.getExpiryTime().getDate();
if (mEntry.expires()) {
entryContentsView.assignExpiresDate(expires);
} else {
entryContentsView.assignExpiresDate(getString(R.string.never));
}
mEntry.endToDecodeReference(pm);
}
use of com.keepassdroid.database.PwDatabase in project KeePassDX by Kunzisoft.
the class ListNodesActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_sort:
SortDialogFragment sortDialogFragment;
PwDatabase database = App.getDB().pm;
/*
// TODO Recycle bin bottom
if (database.isRecycleBinAvailable() && database.isRecycleBinEnable()) {
sortDialogFragment =
SortDialogFragment.getInstance(
PrefsUtil.getListSort(this),
PrefsUtil.getAscendingSort(this),
PrefsUtil.getGroupsBeforeSort(this),
PrefsUtil.getRecycleBinBottomSort(this));
} else {
*/
sortDialogFragment = SortDialogFragment.getInstance(PreferencesUtil.getListSort(this), PreferencesUtil.getAscendingSort(this), PreferencesUtil.getGroupsBeforeSort(this));
// }
sortDialogFragment.show(getSupportFragmentManager(), "sortDialog");
return true;
default:
// Check the time lock before launching settings
MenuUtil.onDefaultMenuOptionsItemSelected(this, item, true);
return super.onOptionsItemSelected(item);
}
}
use of com.keepassdroid.database.PwDatabase in project KeePassDX by Kunzisoft.
the class AddGroup method run.
@Override
public void run() {
PwDatabase pm = mDb.pm;
// Generate new group
mGroup = pm.createGroup();
mGroup.initNewGroup(mName, pm.newGroupId());
mGroup.setIcon(mDb.pm.iconFactory.getIcon(mIconID));
pm.addGroupTo(mGroup, mParent);
// Commit to disk
SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave);
save.run();
}
use of com.keepassdroid.database.PwDatabase in project KeePassDX by Kunzisoft.
the class SearchDbHelper method search.
public PwGroup search(Database db, String qStr) {
PwDatabase pm = db.pm;
PwGroup group;
if (pm instanceof PwDatabaseV3) {
group = new PwGroupV3();
} else if (pm instanceof PwDatabaseV4) {
group = new PwGroupV4();
} else {
Log.d("SearchDbHelper", "Tried to search with unknown db");
return null;
}
group.setName(mCtx.getString(R.string.search_results));
group.setEntries(new ArrayList<>());
// Search all entries
Locale loc = Locale.getDefault();
qStr = qStr.toLowerCase(loc);
boolean isOmitBackup = omitBackup();
Queue<PwGroup> worklist = new LinkedList<PwGroup>();
if (pm.rootGroup != null) {
worklist.add(pm.rootGroup);
}
while (worklist.size() != 0) {
PwGroup top = worklist.remove();
if (pm.isGroupSearchable(top, isOmitBackup)) {
for (PwEntry entry : top.getChildEntries()) {
processEntries(entry, group.getChildEntries(), qStr, loc);
}
for (PwGroup childGroup : top.getChildGroups()) {
if (childGroup != null) {
worklist.add(childGroup);
}
}
}
}
return group;
}
use of com.keepassdroid.database.PwDatabase in project KeePassDX by Kunzisoft.
the class CreateDB method run.
@Override
public void run() {
// Create new database record
Database db = new Database();
App.setDB(db);
PwDatabase pm = PwDatabase.getNewDBInstance(mFilename);
pm.initNew(mFilename);
// Set Database state
db.pm = pm;
db.mUri = UriUtil.parseDefaultFile(mFilename);
db.setLoaded();
App.clearShutdown();
// Commit changes
SaveDB save = new SaveDB(ctx, db, mFinish, mDontSave);
mFinish = null;
save.run();
}
Aggregations