Search in sources :

Example 1 with PwDatabase

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);
}
Also used : PwDatabase(com.keepassdroid.database.PwDatabase) PwDatabase(com.keepassdroid.database.PwDatabase) Database(com.keepassdroid.database.Database) Map(java.util.Map) Date(java.util.Date)

Example 2 with PwDatabase

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);
    }
}
Also used : SortDialogFragment(com.keepassdroid.dialogs.SortDialogFragment) PwDatabase(com.keepassdroid.database.PwDatabase)

Example 3 with PwDatabase

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();
}
Also used : PwDatabase(com.keepassdroid.database.PwDatabase)

Example 4 with PwDatabase

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;
}
Also used : PwDatabaseV3(com.keepassdroid.database.PwDatabaseV3) Locale(java.util.Locale) PwGroupV3(com.keepassdroid.database.PwGroupV3) PwGroupV4(com.keepassdroid.database.PwGroupV4) PwDatabase(com.keepassdroid.database.PwDatabase) PwEntry(com.keepassdroid.database.PwEntry) PwGroup(com.keepassdroid.database.PwGroup) LinkedList(java.util.LinkedList) PwDatabaseV4(com.keepassdroid.database.PwDatabaseV4)

Example 5 with PwDatabase

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();
}
Also used : PwDatabase(com.keepassdroid.database.PwDatabase) PwDatabase(com.keepassdroid.database.PwDatabase) Database(com.keepassdroid.database.Database)

Aggregations

PwDatabase (com.keepassdroid.database.PwDatabase)10 PwGroup (com.keepassdroid.database.PwGroup)4 Database (com.keepassdroid.database.Database)3 PwEntry (com.keepassdroid.database.PwEntry)3 ProtectedString (com.keepassdroid.database.security.ProtectedString)2 EntryEditNewField (com.keepassdroid.view.EntryEditNewField)2 Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ScrollView (android.widget.ScrollView)1 PwDatabaseV3 (com.keepassdroid.database.PwDatabaseV3)1 PwDatabaseV4 (com.keepassdroid.database.PwDatabaseV4)1 PwDate (com.keepassdroid.database.PwDate)1 PwGroupId (com.keepassdroid.database.PwGroupId)1 PwGroupV3 (com.keepassdroid.database.PwGroupV3)1 PwGroupV4 (com.keepassdroid.database.PwGroupV4)1 PwIconStandard (com.keepassdroid.database.PwIconStandard)1 AddEntry (com.keepassdroid.database.edit.AddEntry)1 OnFinish (com.keepassdroid.database.edit.OnFinish)1 RunnableOnFinish (com.keepassdroid.database.edit.RunnableOnFinish)1