mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Handle removing recently used files.
This commit is contained in:
@@ -110,6 +110,7 @@
|
|||||||
<string name="progress_title">Working...</string>
|
<string name="progress_title">Working...</string>
|
||||||
<string name="remember_keyfile_summary">Remembers the location of keyfiles</string>
|
<string name="remember_keyfile_summary">Remembers the location of keyfiles</string>
|
||||||
<string name="remember_keyfile_title">Save keyfile</string>
|
<string name="remember_keyfile_title">Save keyfile</string>
|
||||||
|
<string name="remove_from_filelist">Remove</string>
|
||||||
<string name="rijndael">Rijndael (AES)</string>
|
<string name="rijndael">Rijndael (AES)</string>
|
||||||
<string name="root">Root</string>
|
<string name="root">Root</string>
|
||||||
<string name="rounds">Encryption Rounds</string>
|
<string name="rounds">Encryption Rounds</string>
|
||||||
|
|||||||
@@ -187,6 +187,11 @@ public class FileDbHelper {
|
|||||||
mDb.update(FILE_TABLE, vals, null, null);
|
mDb.update(FILE_TABLE, vals, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteFile(String filename) {
|
||||||
|
mDb.delete(FILE_TABLE, KEY_FILE_FILENAME + " = ?", new String[] {filename});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Cursor fetchAllFiles() {
|
public Cursor fetchAllFiles() {
|
||||||
Cursor ret;
|
Cursor ret;
|
||||||
ret = mDb.query(FILE_TABLE, new String[] {KEY_FILE_ID, KEY_FILE_FILENAME, KEY_FILE_KEYFILE }, null, null, null, null, KEY_FILE_UPDATED + " DESC", Integer.toString(MAX_FILES));
|
ret = mDb.query(FILE_TABLE, new String[] {KEY_FILE_ID, KEY_FILE_FILENAME, KEY_FILE_KEYFILE }, null, null, null, null, KEY_FILE_UPDATED + " DESC", Integer.toString(MAX_FILES));
|
||||||
|
|||||||
@@ -28,13 +28,18 @@ import android.content.ActivityNotFoundException;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.ContextMenu;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CursorAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SimpleCursorAdapter;
|
import android.widget.SimpleCursorAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
|
|
||||||
import com.android.keepass.R;
|
import com.android.keepass.R;
|
||||||
import com.keepassdroid.AboutDialog;
|
import com.keepassdroid.AboutDialog;
|
||||||
@@ -52,7 +57,8 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
private static final int MENU_DONATE = Menu.FIRST;
|
private static final int MENU_DONATE = Menu.FIRST;
|
||||||
private static final int MENU_ABOUT = Menu.FIRST + 1;
|
private static final int MENU_ABOUT = Menu.FIRST + 1;
|
||||||
private static final int MENU_APP_SETTINGS = Menu.FIRST + 2;
|
private static final int MENU_APP_SETTINGS = Menu.FIRST + 2;
|
||||||
|
|
||||||
|
private static final int CMENU_CLEAR = Menu.FIRST;
|
||||||
|
|
||||||
private FileDbHelper mDbHelper;
|
private FileDbHelper mDbHelper;
|
||||||
|
|
||||||
@@ -165,7 +171,8 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fillData();
|
fillData();
|
||||||
|
|
||||||
|
registerForContextMenu(getListView());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LaunchGroupActivity extends FileOnFinish {
|
private class LaunchGroupActivity extends FileOnFinish {
|
||||||
@@ -310,4 +317,37 @@ public class FileSelectActivity extends ListActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||||
|
ContextMenuInfo menuInfo) {
|
||||||
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
|
||||||
|
menu.add(0, CMENU_CLEAR, 0, R.string.remove_from_filelist);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
|
super.onContextItemSelected(item);
|
||||||
|
|
||||||
|
if ( item.getItemId() == CMENU_CLEAR ) {
|
||||||
|
AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
|
|
||||||
|
TextView tv = (TextView) acmi.targetView;
|
||||||
|
String filename = tv.getText().toString();
|
||||||
|
mDbHelper.deleteFile(filename);
|
||||||
|
|
||||||
|
refreshList();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshList() {
|
||||||
|
CursorAdapter ca = (CursorAdapter) getListAdapter();
|
||||||
|
Cursor cursor = ca.getCursor();
|
||||||
|
cursor.requery();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user