Search in sources :

Example 1 with ProgressTask

use of com.keepassdroid.tasks.ProgressTask in project KeePassDX by Kunzisoft.

the class GroupActivity method approveEditGroup.

@Override
public void approveEditGroup(Bundle bundle) {
    String GroupName = bundle.getString(GroupEditDialogFragment.KEY_NAME);
    int GroupIconID = bundle.getInt(GroupEditDialogFragment.KEY_ICON_ID);
    switch(editGroupDialogAction) {
        case CREATION:
            // If edit group creation
            Handler handler = new Handler();
            AddGroup task = new AddGroup(this, App.getDB(), GroupName, GroupIconID, mCurrentGroup, new AfterAddNode(handler), false);
            ProgressTask pt = new ProgressTask(this, task, R.string.saving_database);
            pt.run();
            break;
        case UPDATE:
            // TODO UpdateGroup
            break;
    }
    editGroupDialogAction = EditGroupDialogAction.NONE;
}
Also used : AddGroup(com.keepassdroid.database.edit.AddGroup) ProgressTask(com.keepassdroid.tasks.ProgressTask) Handler(android.os.Handler)

Example 2 with ProgressTask

use of com.keepassdroid.tasks.ProgressTask in project KeePassDX by Kunzisoft.

the class GroupActivity method deleteGroup.

private void deleteGroup(PwGroup group) {
    // TODO Verify trash recycle bin
    Handler handler = new Handler();
    DeleteGroup task = new DeleteGroup(this, App.getDB(), group, new AfterDeleteNode(handler, group));
    ProgressTask pt = new ProgressTask(this, task, R.string.saving_database);
    pt.run();
}
Also used : ProgressTask(com.keepassdroid.tasks.ProgressTask) Handler(android.os.Handler) DeleteGroup(com.keepassdroid.database.edit.DeleteGroup)

Example 3 with ProgressTask

use of com.keepassdroid.tasks.ProgressTask in project KeePassDX by Kunzisoft.

the class RoundsPreferenceDialogFragmentCompat method onDialogClosed.

@Override
public void onDialogClosed(boolean positiveResult) {
    if (positiveResult) {
        long rounds;
        try {
            String strRounds = mRoundsView.getText().toString();
            rounds = Long.parseLong(strRounds);
        } catch (NumberFormatException e) {
            Toast.makeText(getContext(), R.string.error_rounds_not_number, Toast.LENGTH_LONG).show();
            return;
        }
        if (rounds < 1) {
            rounds = 1;
        }
        long oldRounds = mPM.getNumRounds();
        try {
            mPM.setNumRounds(rounds);
        } catch (NumberFormatException e) {
            Toast.makeText(getContext(), R.string.error_rounds_too_large, Toast.LENGTH_LONG).show();
            mPM.setNumRounds(Integer.MAX_VALUE);
        }
        Handler handler = new Handler();
        SaveDB save = new SaveDB(getContext(), App.getDB(), new AfterSave(getContext(), handler, oldRounds));
        ProgressTask pt = new ProgressTask(getContext(), save, R.string.saving_database);
        pt.run();
    }
}
Also used : ProgressTask(com.keepassdroid.tasks.ProgressTask) Handler(android.os.Handler) SaveDB(com.keepassdroid.database.edit.SaveDB)

Example 4 with ProgressTask

use of com.keepassdroid.tasks.ProgressTask in project KeePassDX by Kunzisoft.

the class FileSelectActivity method onAssignKeyDialogPositiveClick.

@Override
public void onAssignKeyDialogPositiveClick(boolean masterPasswordChecked, String masterPassword, boolean keyFileChecked, Uri keyFile) {
    try {
        String databaseFilename = databaseUri.getPath();
        // Prep an object to collect a password once the database has
        // been created
        FileOnFinish launchActivityOnFinish = new FileOnFinish(new LaunchGroupActivity(databaseFilename));
        AssignPasswordOnFinish assignPasswordOnFinish = new AssignPasswordOnFinish(launchActivityOnFinish);
        // Create the new database
        CreateDB create = new CreateDB(FileSelectActivity.this, databaseFilename, assignPasswordOnFinish, true);
        ProgressTask createTask = new ProgressTask(FileSelectActivity.this, create, R.string.progress_create);
        createTask.run();
        assignPasswordHelper = new AssignPasswordHelper(this, masterPassword, keyFile);
    } catch (Exception e) {
        String error = "Unable to create database with this password and key file";
        Toast.makeText(this, error, Toast.LENGTH_LONG).show();
        Log.e(TAG, error + " " + e.getMessage());
    }
}
Also used : CreateDB(com.keepassdroid.database.edit.CreateDB) ProgressTask(com.keepassdroid.tasks.ProgressTask) AssignPasswordHelper(com.keepassdroid.password.AssignPasswordHelper) FileOnFinish(com.keepassdroid.database.edit.FileOnFinish) FileNotFoundException(java.io.FileNotFoundException) ContentFileNotFoundException(com.keepassdroid.database.exception.ContentFileNotFoundException) IOException(java.io.IOException)

Example 5 with ProgressTask

use of com.keepassdroid.tasks.ProgressTask in project KeePassDX by Kunzisoft.

the class AssignPasswordHelper method assignPasswordInDatabase.

public void assignPasswordInDatabase(FileOnFinish fileOnFinish) {
    SetPassword sp = new SetPassword(context, App.getDB(), masterPassword, keyfile, new AfterSave(fileOnFinish, new Handler()));
    final ProgressTask pt = new ProgressTask(context, sp, R.string.saving_database);
    boolean valid = sp.validatePassword(context, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            pt.run();
        }
    });
    if (valid) {
        pt.run();
    }
}
Also used : ProgressTask(com.keepassdroid.tasks.ProgressTask) DialogInterface(android.content.DialogInterface) Handler(android.os.Handler) SetPassword(com.keepassdroid.database.edit.SetPassword)

Aggregations

ProgressTask (com.keepassdroid.tasks.ProgressTask)8 Handler (android.os.Handler)6 Database (com.keepassdroid.database.Database)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ScrollView (android.widget.ScrollView)1 PwDatabase (com.keepassdroid.database.PwDatabase)1 PwGroup (com.keepassdroid.database.PwGroup)1 PwGroupId (com.keepassdroid.database.PwGroupId)1 AddEntry (com.keepassdroid.database.edit.AddEntry)1 AddGroup (com.keepassdroid.database.edit.AddGroup)1 CreateDB (com.keepassdroid.database.edit.CreateDB)1 DeleteEntry (com.keepassdroid.database.edit.DeleteEntry)1 DeleteGroup (com.keepassdroid.database.edit.DeleteGroup)1 FileOnFinish (com.keepassdroid.database.edit.FileOnFinish)1 LoadDB (com.keepassdroid.database.edit.LoadDB)1 OnFinish (com.keepassdroid.database.edit.OnFinish)1 RunnableOnFinish (com.keepassdroid.database.edit.RunnableOnFinish)1