mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Handle new Google drive style content URLs
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
* Add .kdbx Twofish support from drizzt
|
* Add .kdbx Twofish support from drizzt
|
||||||
* Improve password generator randomness
|
* Improve password generator randomness
|
||||||
|
* Handle new Google Drive style links (closes: #74)
|
||||||
|
|
||||||
KeePassDroid (2.0.4)
|
KeePassDroid (2.0.4)
|
||||||
* Fix notification icons (closes: #60)
|
* Fix notification icons (closes: #60)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.database.PwDatabaseV3Debug;
|
import com.keepassdroid.database.PwDatabaseV3Debug;
|
||||||
@@ -54,7 +55,9 @@ public class TestData {
|
|||||||
|
|
||||||
Database Db = new Database();
|
Database Db = new Database();
|
||||||
Db.LoadData(ctx, is, password, keyfile, Importer.DEBUG);
|
Db.LoadData(ctx, is, password, keyfile, Importer.DEBUG);
|
||||||
Db.mFilename = filename;
|
Uri.Builder b = new Uri.Builder();
|
||||||
|
|
||||||
|
Db.mUri = b.scheme("file").path(filename).build();
|
||||||
|
|
||||||
return Db;
|
return Db;
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,12 @@
|
|||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kdbx" />
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kdbx" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kdbx" />
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kdbx" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:mimeType="application/octet-stream" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.keepassdroid.GroupActivityV3" android:configChanges="orientation|keyboardHidden"
|
<activity android:name="com.keepassdroid.GroupActivityV3" android:configChanges="orientation|keyboardHidden"
|
||||||
android:theme="@style/NoTitleBar">
|
android:theme="@style/NoTitleBar">
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.SyncFailedException;
|
import java.io.SyncFailedException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
import com.keepassdroid.database.PwDatabaseV3;
|
import com.keepassdroid.database.PwDatabaseV3;
|
||||||
@@ -49,7 +51,7 @@ import com.keepassdroid.search.SearchDbHelper;
|
|||||||
public class Database {
|
public class Database {
|
||||||
public Set<PwGroup> dirty = new HashSet<PwGroup>();
|
public Set<PwGroup> dirty = new HashSet<PwGroup>();
|
||||||
public PwDatabase pm;
|
public PwDatabase pm;
|
||||||
public String mFilename;
|
public Uri mUri;
|
||||||
public SearchDbHelper searchHelper;
|
public SearchDbHelper searchHelper;
|
||||||
public boolean readOnly = false;
|
public boolean readOnly = false;
|
||||||
public boolean passwordEncodingError = false;
|
public boolean passwordEncodingError = false;
|
||||||
@@ -70,22 +72,25 @@ public class Database {
|
|||||||
LoadData(ctx, is, password, keyfile, new UpdateStatus(), !Importer.DEBUG);
|
LoadData(ctx, is, password, keyfile, new UpdateStatus(), !Importer.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadData(Context ctx, String filename, String password, String keyfile) throws IOException, FileNotFoundException, InvalidDBException {
|
public void LoadData(Context ctx, Uri uri, String password, String keyfile) throws IOException, FileNotFoundException, InvalidDBException {
|
||||||
LoadData(ctx, filename, password, keyfile, new UpdateStatus(), !Importer.DEBUG);
|
LoadData(ctx, uri, password, keyfile, new UpdateStatus(), !Importer.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadData(Context ctx, String filename, String password, String keyfile, UpdateStatus status) throws IOException, FileNotFoundException, InvalidDBException {
|
public void LoadData(Context ctx, Uri uri, String password, String keyfile, UpdateStatus status) throws IOException, FileNotFoundException, InvalidDBException {
|
||||||
LoadData(ctx, filename, password, keyfile, status, !Importer.DEBUG);
|
LoadData(ctx, uri, password, keyfile, status, !Importer.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadData(Context ctx, String filename, String password, String keyfile, UpdateStatus status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException {
|
public void LoadData(Context ctx, Uri uri, String password, String keyfile, UpdateStatus status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException {
|
||||||
File file = new File(filename);
|
mUri = uri;
|
||||||
FileInputStream fis = new FileInputStream(file);
|
readOnly = false;
|
||||||
|
if (uri.getScheme().equals("file")) {
|
||||||
|
File file = new File(uri.getPath());
|
||||||
|
readOnly = !file.canWrite();
|
||||||
|
}
|
||||||
|
|
||||||
LoadData(ctx, fis, password, keyfile, status, debug);
|
InputStream is = ctx.getContentResolver().openInputStream(uri);
|
||||||
|
|
||||||
readOnly = !file.canWrite();
|
LoadData(ctx, is, password, keyfile, status, debug);
|
||||||
mFilename = filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadData(Context ctx, InputStream is, String password, String keyfile, boolean debug) throws IOException, InvalidDBException {
|
public void LoadData(Context ctx, InputStream is, String password, String keyfile, boolean debug) throws IOException, InvalidDBException {
|
||||||
@@ -138,36 +143,51 @@ public class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveData() throws IOException, PwDbOutputException {
|
public void SaveData(Context ctx) throws IOException, PwDbOutputException {
|
||||||
SaveData(mFilename);
|
SaveData(ctx, mUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveData(String filename) throws IOException, PwDbOutputException {
|
public void SaveData(Context ctx, Uri uri) throws IOException, PwDbOutputException {
|
||||||
File tempFile = new File(filename + ".tmp");
|
if (uri.getScheme().equals("data")) {
|
||||||
FileOutputStream fos = new FileOutputStream(tempFile);
|
String filename = uri.getPath();
|
||||||
//BufferedOutputStream bos = new BufferedOutputStream(fos);
|
File tempFile = new File(filename + ".tmp");
|
||||||
|
FileOutputStream fos = new FileOutputStream(tempFile);
|
||||||
|
//BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||||
|
|
||||||
//PwDbV3Output pmo = new PwDbV3Output(pm, bos, App.getCalendar());
|
//PwDbV3Output pmo = new PwDbV3Output(pm, bos, App.getCalendar());
|
||||||
PwDbOutput pmo = PwDbOutput.getInstance(pm, fos);
|
PwDbOutput pmo = PwDbOutput.getInstance(pm, fos);
|
||||||
pmo.output();
|
pmo.output();
|
||||||
//bos.flush();
|
//bos.flush();
|
||||||
//bos.close();
|
//bos.close();
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
// Force data to disk before continuing
|
// Force data to disk before continuing
|
||||||
try {
|
try {
|
||||||
fos.getFD().sync();
|
fos.getFD().sync();
|
||||||
} catch (SyncFailedException e) {
|
} catch (SyncFailedException e) {
|
||||||
// Ignore if fsync fails. We tried.
|
// Ignore if fsync fails. We tried.
|
||||||
|
}
|
||||||
|
|
||||||
|
File orig = new File(filename);
|
||||||
|
|
||||||
|
if (!tempFile.renameTo(orig)) {
|
||||||
|
throw new IOException("Failed to store database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OutputStream os;
|
||||||
|
try {
|
||||||
|
os = ctx.getContentResolver().openOutputStream(uri);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IOException("Failed to store database.");
|
||||||
|
}
|
||||||
|
|
||||||
|
PwDbOutput pmo = PwDbOutput.getInstance(pm, os);
|
||||||
|
pmo.output();
|
||||||
|
os.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
File orig = new File(filename);
|
mUri = uri;
|
||||||
|
|
||||||
if ( ! tempFile.renameTo(orig) ) {
|
|
||||||
throw new IOException("Failed to store database.");
|
|
||||||
}
|
|
||||||
|
|
||||||
mFilename = filename;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +196,7 @@ public class Database {
|
|||||||
drawFactory.clear();
|
drawFactory.clear();
|
||||||
|
|
||||||
pm = null;
|
pm = null;
|
||||||
mFilename = null;
|
mUri = null;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
passwordEncodingError = false;
|
passwordEncodingError = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2015 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -188,9 +188,9 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
|||||||
OnFinish onFinish = act.new AfterSave(new Handler());
|
OnFinish onFinish = act.new AfterSave(new Handler());
|
||||||
|
|
||||||
if ( mIsNew ) {
|
if ( mIsNew ) {
|
||||||
task = AddEntry.getInstance(App.getDB(), newEntry, onFinish);
|
task = AddEntry.getInstance(EntryEditActivity.this, App.getDB(), newEntry, onFinish);
|
||||||
} else {
|
} else {
|
||||||
task = new UpdateEntry(App.getDB(), mEntry, newEntry, onFinish);
|
task = new UpdateEntry(EntryEditActivity.this, App.getDB(), mEntry, newEntry, onFinish);
|
||||||
}
|
}
|
||||||
ProgressTask pt = new ProgressTask(act, task, R.string.saving_database);
|
ProgressTask pt = new ProgressTask(act, task, R.string.saving_database);
|
||||||
pt.run();
|
pt.run();
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public abstract class GroupActivity extends GroupBaseActivity {
|
|||||||
int GroupIconID = data.getExtras().getInt(GroupEditActivity.KEY_ICON_ID);
|
int GroupIconID = data.getExtras().getInt(GroupEditActivity.KEY_ICON_ID);
|
||||||
GroupActivity act = GroupActivity.this;
|
GroupActivity act = GroupActivity.this;
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
AddGroup task = AddGroup.getInstance(App.getDB(), GroupName, GroupIconID, mGroup, act.new RefreshTask(handler), false);
|
AddGroup task = AddGroup.getInstance(this, App.getDB(), GroupName, GroupIconID, mGroup, act.new RefreshTask(handler), false);
|
||||||
ProgressTask pt = new ProgressTask(act, task, R.string.saving_database);
|
ProgressTask pt = new ProgressTask(act, task, R.string.saving_database);
|
||||||
pt.run();
|
pt.run();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2013 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -33,6 +33,7 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -60,6 +61,7 @@ import com.keepassdroid.fileselect.BrowserDialog;
|
|||||||
import com.keepassdroid.intents.Intents;
|
import com.keepassdroid.intents.Intents;
|
||||||
import com.keepassdroid.settings.AppSettingsActivity;
|
import com.keepassdroid.settings.AppSettingsActivity;
|
||||||
import com.keepassdroid.utils.Interaction;
|
import com.keepassdroid.utils.Interaction;
|
||||||
|
import com.keepassdroid.utils.StrUtil;
|
||||||
import com.keepassdroid.utils.Util;
|
import com.keepassdroid.utils.Util;
|
||||||
|
|
||||||
public class PasswordActivity extends LockingActivity {
|
public class PasswordActivity extends LockingActivity {
|
||||||
@@ -76,6 +78,7 @@ public class PasswordActivity extends LockingActivity {
|
|||||||
|
|
||||||
private String mFileName;
|
private String mFileName;
|
||||||
private String mKeyFile;
|
private String mKeyFile;
|
||||||
|
private Uri mUri = null;
|
||||||
private boolean mRememberKeyfile;
|
private boolean mRememberKeyfile;
|
||||||
SharedPreferences prefs;
|
SharedPreferences prefs;
|
||||||
|
|
||||||
@@ -84,10 +87,12 @@ public class PasswordActivity extends LockingActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Launch(Activity act, String fileName, String keyFile) throws FileNotFoundException {
|
public static void Launch(Activity act, String fileName, String keyFile) throws FileNotFoundException {
|
||||||
|
/*
|
||||||
File dbFile = new File(fileName);
|
File dbFile = new File(fileName);
|
||||||
if ( ! dbFile.exists() ) {
|
if ( ! dbFile.exists() ) {
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
Intent i = new Intent(act, PasswordActivity.class);
|
Intent i = new Intent(act, PasswordActivity.class);
|
||||||
i.putExtra(KEY_FILENAME, fileName);
|
i.putExtra(KEY_FILENAME, fileName);
|
||||||
@@ -263,8 +268,21 @@ public class PasswordActivity extends LockingActivity {
|
|||||||
// Clear the shutdown flag
|
// Clear the shutdown flag
|
||||||
App.clearShutdown();
|
App.clearShutdown();
|
||||||
|
|
||||||
|
Uri uri;
|
||||||
|
if (mUri != null) {
|
||||||
|
uri = mUri;
|
||||||
|
} else {
|
||||||
|
uri = Uri.parse(fileName);
|
||||||
|
|
||||||
|
String scheme = uri.getScheme();
|
||||||
|
if (scheme == null || scheme.equals("")) {
|
||||||
|
Uri.Builder builder = new Uri.Builder();
|
||||||
|
builder.scheme("file").authority("").path(fileName);
|
||||||
|
uri = builder.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
LoadDB task = new LoadDB(db, PasswordActivity.this, fileName, pass, keyfile, new AfterLoad(handler, db));
|
LoadDB task = new LoadDB(db, PasswordActivity.this, uri, pass, keyfile, new AfterLoad(handler, db));
|
||||||
ProgressTask pt = new ProgressTask(PasswordActivity.this, task, R.string.loading_database);
|
ProgressTask pt = new ProgressTask(PasswordActivity.this, task, R.string.loading_database);
|
||||||
pt.run();
|
pt.run();
|
||||||
}
|
}
|
||||||
@@ -346,27 +364,32 @@ public class PasswordActivity extends LockingActivity {
|
|||||||
Intent i = args[0];
|
Intent i = args[0];
|
||||||
String action = i.getAction();;
|
String action = i.getAction();;
|
||||||
if ( action != null && action.equals(VIEW_INTENT) ) {
|
if ( action != null && action.equals(VIEW_INTENT) ) {
|
||||||
mFileName = i.getDataString();
|
Uri incoming = i.getData();
|
||||||
|
if (incoming.getScheme().equals("file")) {
|
||||||
|
mFileName = incoming.getPath();
|
||||||
|
|
||||||
if ( ! mFileName.substring(0, 7).equals("file://") ) {
|
if (mFileName.length() == 0) {
|
||||||
|
// No file name
|
||||||
|
return R.string.FileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
File dbFile = new File(mFileName);
|
||||||
|
if (!dbFile.exists()) {
|
||||||
|
// File does not exist
|
||||||
|
return R.string.FileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
mKeyFile = getKeyFile(mFileName);
|
||||||
|
}
|
||||||
|
else if (incoming.getScheme().equals("content")) {
|
||||||
|
mUri = incoming;
|
||||||
|
mFileName = mUri.toString();
|
||||||
|
mKeyFile = getKeyFile(mFileName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
return R.string.error_can_not_handle_uri;
|
return R.string.error_can_not_handle_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
mFileName = URLDecoder.decode(mFileName.substring(7, mFileName.length()));
|
|
||||||
|
|
||||||
if ( mFileName.length() == 0 ) {
|
|
||||||
// No file name
|
|
||||||
return R.string.FileNotFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
File dbFile = new File(mFileName);
|
|
||||||
if ( ! dbFile.exists() ) {
|
|
||||||
// File does not exist
|
|
||||||
return R.string.FileNotFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
mKeyFile = getKeyFile(mFileName);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mFileName = i.getStringExtra(KEY_FILENAME);
|
mFileName = i.getStringExtra(KEY_FILENAME);
|
||||||
mKeyFile = i.getStringExtra(KEY_KEYFILE);
|
mKeyFile = i.getStringExtra(KEY_KEYFILE);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -93,7 +93,7 @@ public class SetPasswordDialog extends CancelDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPassword sp = new SetPassword(App.getDB(), pass, keyfile, new AfterSave(mFinish, new Handler()));
|
SetPassword sp = new SetPassword(getContext(), App.getDB(), pass, keyfile, new AfterSave(mFinish, new Handler()));
|
||||||
final ProgressTask pt = new ProgressTask(getContext(), sp, R.string.saving_database);
|
final ProgressTask pt = new ProgressTask(getContext(), sp, R.string.saving_database);
|
||||||
boolean valid = sp.validatePassword(getContext(), new OnClickListener() {
|
boolean valid = sp.validatePassword(getContext(), new OnClickListener() {
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
import com.keepassdroid.database.PwEntry;
|
import com.keepassdroid.database.PwEntry;
|
||||||
@@ -27,16 +29,18 @@ import com.keepassdroid.database.PwGroup;
|
|||||||
public class AddEntry extends RunnableOnFinish {
|
public class AddEntry extends RunnableOnFinish {
|
||||||
protected Database mDb;
|
protected Database mDb;
|
||||||
private PwEntry mEntry;
|
private PwEntry mEntry;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
public static AddEntry getInstance(Database db, PwEntry entry, OnFinish finish) {
|
public static AddEntry getInstance(Context ctx, Database db, PwEntry entry, OnFinish finish) {
|
||||||
return new AddEntry(db, entry, finish);
|
return new AddEntry(ctx, db, entry, finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AddEntry(Database db, PwEntry entry, OnFinish finish) {
|
protected AddEntry(Context ctx, Database db, PwEntry entry, OnFinish finish) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mEntry = entry;
|
mEntry = entry;
|
||||||
|
this.ctx = ctx;
|
||||||
|
|
||||||
mFinish = new AfterAdd(mFinish);
|
mFinish = new AfterAdd(mFinish);
|
||||||
}
|
}
|
||||||
@@ -46,7 +50,7 @@ public class AddEntry extends RunnableOnFinish {
|
|||||||
mDb.pm.addEntryTo(mEntry, mEntry.getParent());
|
mDb.pm.addEntryTo(mEntry, mEntry.getParent());
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDB save = new SaveDB(mDb, mFinish);
|
SaveDB save = new SaveDB(ctx, mDb, mFinish);
|
||||||
save.run();
|
save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2013 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
import com.keepassdroid.database.PwGroup;
|
import com.keepassdroid.database.PwGroup;
|
||||||
@@ -29,15 +31,16 @@ public class AddGroup extends RunnableOnFinish {
|
|||||||
private int mIconID;
|
private int mIconID;
|
||||||
private PwGroup mGroup;
|
private PwGroup mGroup;
|
||||||
private PwGroup mParent;
|
private PwGroup mParent;
|
||||||
|
private Context ctx;
|
||||||
protected boolean mDontSave;
|
protected boolean mDontSave;
|
||||||
|
|
||||||
|
|
||||||
public static AddGroup getInstance(Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) {
|
public static AddGroup getInstance(Context ctx, Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) {
|
||||||
return new AddGroup(db, name, iconid, parent, finish, dontSave);
|
return new AddGroup(ctx, db, name, iconid, parent, finish, dontSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AddGroup(Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) {
|
private AddGroup(Context ctx, Database db, String name, int iconid, PwGroup parent, OnFinish finish, boolean dontSave) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
@@ -45,6 +48,7 @@ public class AddGroup extends RunnableOnFinish {
|
|||||||
mIconID = iconid;
|
mIconID = iconid;
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
mDontSave = dontSave;
|
mDontSave = dontSave;
|
||||||
|
this.ctx = ctx;
|
||||||
|
|
||||||
mFinish = new AfterAdd(mFinish);
|
mFinish = new AfterAdd(mFinish);
|
||||||
}
|
}
|
||||||
@@ -62,7 +66,7 @@ public class AddGroup extends RunnableOnFinish {
|
|||||||
//mParent.sortGroupsByName();
|
//mParent.sortGroupsByName();
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDB save = new SaveDB(mDb, mFinish, mDontSave);
|
SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave);
|
||||||
save.run();
|
save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2015 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.app.App;
|
import com.keepassdroid.app.App;
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
@@ -32,12 +35,14 @@ public class CreateDB extends RunnableOnFinish {
|
|||||||
|
|
||||||
private String mFilename;
|
private String mFilename;
|
||||||
private boolean mDontSave;
|
private boolean mDontSave;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
public CreateDB(String filename, OnFinish finish, boolean dontSave) {
|
public CreateDB(Context ctx, String filename, OnFinish finish, boolean dontSave) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mFilename = filename;
|
mFilename = filename;
|
||||||
mDontSave = dontSave;
|
mDontSave = dontSave;
|
||||||
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,11 +56,12 @@ public class CreateDB extends RunnableOnFinish {
|
|||||||
|
|
||||||
// Set Database state
|
// Set Database state
|
||||||
db.pm = pm;
|
db.pm = pm;
|
||||||
db.mFilename = mFilename;
|
Uri.Builder b = new Uri.Builder();
|
||||||
|
db.mUri = b.scheme("path").path(mFilename).build();
|
||||||
db.setLoaded();
|
db.setLoaded();
|
||||||
|
|
||||||
// Commit changes
|
// Commit changes
|
||||||
SaveDB save = new SaveDB(db, mFinish, mDontSave);
|
SaveDB save = new SaveDB(ctx, db, mFinish, mDontSave);
|
||||||
mFinish = null;
|
mFinish = null;
|
||||||
save.run();
|
save.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2013 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
import com.keepassdroid.database.PwEntry;
|
import com.keepassdroid.database.PwEntry;
|
||||||
@@ -33,22 +35,19 @@ public class DeleteEntry extends RunnableOnFinish {
|
|||||||
private Database mDb;
|
private Database mDb;
|
||||||
private PwEntry mEntry;
|
private PwEntry mEntry;
|
||||||
private boolean mDontSave;
|
private boolean mDontSave;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
public DeleteEntry(Database db, PwEntry entry, OnFinish finish) {
|
public DeleteEntry(Context ctx, Database db, PwEntry entry, OnFinish finish) {
|
||||||
super(finish);
|
this(ctx, db, entry, finish, false);
|
||||||
|
|
||||||
mDb = db;
|
|
||||||
mEntry = entry;
|
|
||||||
mDontSave = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteEntry(Database db, PwEntry entry, OnFinish finish, boolean dontSave) {
|
public DeleteEntry(Context ctx, Database db, PwEntry entry, OnFinish finish, boolean dontSave) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mEntry = entry;
|
mEntry = entry;
|
||||||
mDontSave = dontSave;
|
mDontSave = dontSave;
|
||||||
|
this.ctx = ctx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ public class DeleteEntry extends RunnableOnFinish {
|
|||||||
mFinish = new AfterDelete(mFinish, parent, mEntry, recycle);
|
mFinish = new AfterDelete(mFinish, parent, mEntry, recycle);
|
||||||
|
|
||||||
// Commit database
|
// Commit database
|
||||||
SaveDB save = new SaveDB(mDb, mFinish, mDontSave);
|
SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave);
|
||||||
save.run();
|
save.run();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2013 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -68,7 +68,7 @@ public class DeleteGroup extends RunnableOnFinish {
|
|||||||
// Remove child entries
|
// Remove child entries
|
||||||
List<PwEntry> childEnt = new ArrayList<PwEntry>(mGroup.childEntries);
|
List<PwEntry> childEnt = new ArrayList<PwEntry>(mGroup.childEntries);
|
||||||
for ( int i = 0; i < childEnt.size(); i++ ) {
|
for ( int i = 0; i < childEnt.size(); i++ ) {
|
||||||
DeleteEntry task = new DeleteEntry(mDb, childEnt.get(i), null, true);
|
DeleteEntry task = new DeleteEntry(mAct, mDb, childEnt.get(i), null, true);
|
||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class DeleteGroup extends RunnableOnFinish {
|
|||||||
mDb.pm.getGroups().remove(mGroup);
|
mDb.pm.getGroups().remove(mGroup);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
SaveDB save = new SaveDB(mDb, mFinish, mDontSave);
|
SaveDB save = new SaveDB(mAct, mDb, mFinish, mDontSave);
|
||||||
save.run();
|
save.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2013 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.android.keepass.R;
|
import com.android.keepass.R;
|
||||||
@@ -39,19 +40,19 @@ import com.keepassdroid.database.exception.InvalidPasswordException;
|
|||||||
import com.keepassdroid.database.exception.KeyFileEmptyException;
|
import com.keepassdroid.database.exception.KeyFileEmptyException;
|
||||||
|
|
||||||
public class LoadDB extends RunnableOnFinish {
|
public class LoadDB extends RunnableOnFinish {
|
||||||
private String mFileName;
|
private Uri mUri;
|
||||||
private String mPass;
|
private String mPass;
|
||||||
private String mKey;
|
private String mKey;
|
||||||
private Database mDb;
|
private Database mDb;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
private boolean mRememberKeyfile;
|
private boolean mRememberKeyfile;
|
||||||
|
|
||||||
public LoadDB(Database db, Context ctx, String fileName, String pass, String key, OnFinish finish) {
|
public LoadDB(Database db, Context ctx, Uri uri, String pass, String key, OnFinish finish) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mCtx = ctx;
|
mCtx = ctx;
|
||||||
mFileName = fileName;
|
mUri = uri;
|
||||||
mPass = pass;
|
mPass = pass;
|
||||||
mKey = key;
|
mKey = key;
|
||||||
|
|
||||||
@@ -62,9 +63,9 @@ public class LoadDB extends RunnableOnFinish {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
mDb.LoadData(mCtx, mFileName, mPass, mKey, mStatus);
|
mDb.LoadData(mCtx, mUri, mPass, mKey, mStatus);
|
||||||
|
|
||||||
saveFileData(mFileName, mKey);
|
saveFileData(mUri, mKey);
|
||||||
|
|
||||||
} catch (ArcFourException e) {
|
} catch (ArcFourException e) {
|
||||||
finish(false, mCtx.getString(R.string.error_arc4));
|
finish(false, mCtx.getString(R.string.error_arc4));
|
||||||
@@ -104,12 +105,12 @@ public class LoadDB extends RunnableOnFinish {
|
|||||||
finish(true);
|
finish(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFileData(String fileName, String key) {
|
private void saveFileData(Uri uri, String key) {
|
||||||
if ( ! mRememberKeyfile ) {
|
if ( ! mRememberKeyfile ) {
|
||||||
key = "";
|
key = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
App.getFileHistory().createFile(fileName, key);
|
App.getFileHistory().createFile(uri, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
@@ -27,19 +29,22 @@ import com.keepassdroid.database.exception.PwDbOutputException;
|
|||||||
public class SaveDB extends RunnableOnFinish {
|
public class SaveDB extends RunnableOnFinish {
|
||||||
private Database mDb;
|
private Database mDb;
|
||||||
private boolean mDontSave;
|
private boolean mDontSave;
|
||||||
|
private Context mCtx;
|
||||||
|
|
||||||
public SaveDB(Database db, OnFinish finish, boolean dontSave) {
|
public SaveDB(Context ctx, Database db, OnFinish finish, boolean dontSave) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mDontSave = dontSave;
|
mDontSave = dontSave;
|
||||||
|
mCtx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaveDB(Database db, OnFinish finish) {
|
public SaveDB(Context ctx, Database db, OnFinish finish) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mDontSave = false;
|
mDontSave = false;
|
||||||
|
mCtx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +52,7 @@ public class SaveDB extends RunnableOnFinish {
|
|||||||
|
|
||||||
if ( ! mDontSave ) {
|
if ( ! mDontSave ) {
|
||||||
try {
|
try {
|
||||||
mDb.SaveData();
|
mDb.SaveData(mCtx);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
finish(false, e.getMessage());
|
finish(false, e.getMessage());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -35,23 +35,21 @@ public class SetPassword extends RunnableOnFinish {
|
|||||||
private String mKeyfile;
|
private String mKeyfile;
|
||||||
private Database mDb;
|
private Database mDb;
|
||||||
private boolean mDontSave;
|
private boolean mDontSave;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
public SetPassword(Database db, String password, String keyfile, OnFinish finish) {
|
public SetPassword(Context ctx, Database db, String password, String keyfile, OnFinish finish) {
|
||||||
super(finish);
|
this(ctx, db, password, keyfile, finish, false);
|
||||||
|
|
||||||
mDb = db;
|
|
||||||
mPassword = password;
|
|
||||||
mKeyfile = keyfile;
|
|
||||||
mDontSave = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetPassword(Database db, String password, String keyfile, OnFinish finish, boolean dontSave) {
|
public SetPassword(Context ctx, Database db, String password, String keyfile, OnFinish finish, boolean dontSave) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mPassword = password;
|
mPassword = password;
|
||||||
mKeyfile = keyfile;
|
mKeyfile = keyfile;
|
||||||
mDontSave = dontSave;
|
mDontSave = dontSave;
|
||||||
|
this.ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validatePassword(Context ctx, DialogInterface.OnClickListener onclick) {
|
public boolean validatePassword(Context ctx, DialogInterface.OnClickListener onclick) {
|
||||||
@@ -86,7 +84,7 @@ public class SetPassword extends RunnableOnFinish {
|
|||||||
|
|
||||||
// Save Database
|
// Save Database
|
||||||
mFinish = new AfterSave(backupKey, mFinish);
|
mFinish = new AfterSave(backupKey, mFinish);
|
||||||
SaveDB save = new SaveDB(mDb, mFinish, mDontSave);
|
SaveDB save = new SaveDB(ctx, mDb, mFinish, mDontSave);
|
||||||
save.run();
|
save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database.edit;
|
package com.keepassdroid.database.edit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import com.keepassdroid.Database;
|
import com.keepassdroid.Database;
|
||||||
import com.keepassdroid.database.PwEntry;
|
import com.keepassdroid.database.PwEntry;
|
||||||
import com.keepassdroid.database.PwGroup;
|
import com.keepassdroid.database.PwGroup;
|
||||||
@@ -27,13 +29,15 @@ public class UpdateEntry extends RunnableOnFinish {
|
|||||||
private Database mDb;
|
private Database mDb;
|
||||||
private PwEntry mOldE;
|
private PwEntry mOldE;
|
||||||
private PwEntry mNewE;
|
private PwEntry mNewE;
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
public UpdateEntry(Database db, PwEntry oldE, PwEntry newE, OnFinish finish) {
|
public UpdateEntry(Context ctx, Database db, PwEntry oldE, PwEntry newE, OnFinish finish) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mOldE = oldE;
|
mOldE = oldE;
|
||||||
mNewE = newE;
|
mNewE = newE;
|
||||||
|
this.ctx = ctx;
|
||||||
|
|
||||||
// Keep backup of original values in case save fails
|
// Keep backup of original values in case save fails
|
||||||
PwEntry backup;
|
PwEntry backup;
|
||||||
@@ -50,7 +54,7 @@ public class UpdateEntry extends RunnableOnFinish {
|
|||||||
|
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDB save = new SaveDB(mDb, mFinish);
|
SaveDB save = new SaveDB(ctx, mDb, mFinish);
|
||||||
save.run();
|
save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2014 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -167,7 +167,7 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
new LaunchGroupActivity(filename));
|
new LaunchGroupActivity(filename));
|
||||||
|
|
||||||
// Create the new database
|
// Create the new database
|
||||||
CreateDB create = new CreateDB(filename, password, true);
|
CreateDB create = new CreateDB(FileSelectActivity.this, filename, password, true);
|
||||||
ProgressTask createTask = new ProgressTask(
|
ProgressTask createTask = new ProgressTask(
|
||||||
FileSelectActivity.this, create,
|
FileSelectActivity.this, create,
|
||||||
R.string.progress_create);
|
R.string.progress_create);
|
||||||
@@ -237,25 +237,22 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class LaunchGroupActivity extends FileOnFinish {
|
private class LaunchGroupActivity extends FileOnFinish {
|
||||||
private String mFilename;
|
private Uri mUri;
|
||||||
|
|
||||||
public LaunchGroupActivity(String filename) {
|
public LaunchGroupActivity(String filename) {
|
||||||
super(null);
|
super(null);
|
||||||
|
|
||||||
mFilename = filename;
|
Uri.Builder b = new Uri.Builder();
|
||||||
|
mUri = b.scheme("file").authority("").path(filename).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mSuccess) {
|
if (mSuccess) {
|
||||||
// Add to recent files
|
// Add to recent files
|
||||||
fileHistory.createFile(mFilename, getFilename());
|
fileHistory.createFile(mUri, getFilename());
|
||||||
|
|
||||||
GroupActivity.Launch(FileSelectActivity.this);
|
GroupActivity.Launch(FileSelectActivity.this);
|
||||||
|
|
||||||
} else {
|
|
||||||
File file = new File(mFilename);
|
|
||||||
file.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,7 +410,7 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
new AsyncTask<String, Void, Void>() {
|
new AsyncTask<String, Void, Void>() {
|
||||||
protected java.lang.Void doInBackground(String... args) {
|
protected java.lang.Void doInBackground(String... args) {
|
||||||
String filename = args[0];
|
String filename = args[0];
|
||||||
fileHistory.deleteFile(filename);
|
fileHistory.deleteFile(Uri.parse(args[0]));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Brian Pellin.
|
* Copyright 2013-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -30,6 +30,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
public class RecentFileHistory {
|
public class RecentFileHistory {
|
||||||
@@ -124,15 +125,15 @@ public class RecentFileHistory {
|
|||||||
return db.exists();
|
return db.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createFile(String fileName, String keyFile) {
|
public void createFile(Uri uri, String keyFile) {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
// Remove any existing instance of the same filename
|
// Remove any existing instance of the same filename
|
||||||
deleteFile(fileName, false);
|
deleteFile(uri, false);
|
||||||
|
|
||||||
databases.add(0, fileName);
|
databases.add(0, uri.toString());
|
||||||
keyfiles.add(0, keyFile);
|
keyfiles.add(0, keyFile);
|
||||||
|
|
||||||
trimLists();
|
trimLists();
|
||||||
@@ -189,15 +190,19 @@ public class RecentFileHistory {
|
|||||||
EditorCompat.apply(edit);
|
EditorCompat.apply(edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFile(String filename) {
|
public void deleteFile(Uri uri) {
|
||||||
deleteFile(filename, true);
|
deleteFile(uri, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFile(String filename, boolean save) {
|
public void deleteFile(Uri uri, boolean save) {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
String uriName = uri.toString();
|
||||||
|
String fileName = uri.getPath();
|
||||||
|
|
||||||
for (int i = 0; i < databases.size(); i++) {
|
for (int i = 0; i < databases.size(); i++) {
|
||||||
if (filename.equals(databases.get(i))) {
|
String entry = databases.get(i);
|
||||||
|
if (uriName.equals(entry) || fileName.equals(entry)) {
|
||||||
databases.remove(i);
|
databases.remove(i);
|
||||||
keyfiles.remove(i);
|
keyfiles.remove(i);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Brian Pellin.
|
* Copyright 2009-2016 Brian Pellin.
|
||||||
*
|
*
|
||||||
* This file is part of KeePassDroid.
|
* This file is part of KeePassDroid.
|
||||||
*
|
*
|
||||||
@@ -91,7 +91,7 @@ public class RoundsPreference extends DialogPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
SaveDB save = new SaveDB(App.getDB(), new AfterSave(getContext(), handler, oldRounds));
|
SaveDB save = new SaveDB(getContext(), App.getDB(), new AfterSave(getContext(), handler, oldRounds));
|
||||||
ProgressTask pt = new ProgressTask(getContext(), save, R.string.saving_database);
|
ProgressTask pt = new ProgressTask(getContext(), save, R.string.saving_database);
|
||||||
pt.run();
|
pt.run();
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class PwEntryView extends ClickView {
|
|||||||
|
|
||||||
private void deleteEntry() {
|
private void deleteEntry() {
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
DeleteEntry task = new DeleteEntry(App.getDB(), mPw, mAct.new RefreshTask(handler));
|
DeleteEntry task = new DeleteEntry(mAct, App.getDB(), mPw, mAct.new RefreshTask(handler));
|
||||||
ProgressTask pt = new ProgressTask(mAct, task, R.string.saving_database);
|
ProgressTask pt = new ProgressTask(mAct, task, R.string.saving_database);
|
||||||
pt.run();
|
pt.run();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user