Fixed display bug after Sync

Fixed problem with opening FTP/WebDav databases
removed English text from start page
removed debug-logging in GDrive-storage implementation
This commit is contained in:
Philipp Crocoll 2013-10-28 21:53:18 +01:00
parent 868f3aa231
commit 81ed3d9955
7 changed files with 1794 additions and 1696 deletions

View File

@ -55,7 +55,7 @@ namespace keepass2android
//check if remote file was modified: //check if remote file was modified:
if (cachingFileStorage.GetBaseVersionHash(ioc) != hash) if (cachingFileStorage.GetBaseVersionHash(ioc) != hash)
{ {
//remote file is unmodified //remote file is modified
if (cachingFileStorage.HasLocalChanges(ioc)) if (cachingFileStorage.HasLocalChanges(ioc))
{ {
//conflict! need to merge //conflict! need to merge
@ -72,6 +72,8 @@ namespace keepass2android
_saveDb = null; _saveDb = null;
}), false, remoteData); }), false, remoteData);
_saveDb.Run(); _saveDb.Run();
_app.GetDb().MarkAllGroupsAsDirty();
} }
else else
{ {

View File

@ -119,11 +119,11 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
public void setPathWithoutVerify(String path) throws UnsupportedEncodingException, InvalidPathException public void setPathWithoutVerify(String path) throws UnsupportedEncodingException, InvalidPathException
{ {
Log.d(TAG, "setPath: "+path); //Log.d(TAG, "setPath: "+path);
mAccount = extractAccount(path); mAccount = extractAccount(path);
mAccountLocalPath = path.substring(getProtocolPrefix().length()+encode(mAccount).length()+1); mAccountLocalPath = path.substring(getProtocolPrefix().length()+encode(mAccount).length()+1);
Log.d(TAG, " mAccount=" + mAccount); //Log.d(TAG, " mAccount=" + mAccount);
Log.d(TAG, " mAccountLocalPath=" + mAccountLocalPath); //Log.d(TAG, " mAccountLocalPath=" + mAccountLocalPath);
} }
public GDrivePath(String parentPath, File fileToAppend) throws UnsupportedEncodingException, FileNotFoundException, IOException, InvalidPathException public GDrivePath(String parentPath, File fileToAppend) throws UnsupportedEncodingException, FileNotFoundException, IOException, InvalidPathException
@ -166,13 +166,13 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
for (int i=0;i<parts.length;i++) for (int i=0;i<parts.length;i++)
{ {
String part = parts[i]; String part = parts[i];
Log.d(TAG, "parsing part " + part); //Log.d(TAG, "parsing part " + part);
int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP); int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP);
if (indexOfSeparator < 0) if (indexOfSeparator < 0)
throw new FileNotFoundException("invalid path " + mAccountLocalPath); throw new FileNotFoundException("invalid path " + mAccountLocalPath);
String id = part.substring(indexOfSeparator+NAME_ID_SEP.length()); String id = part.substring(indexOfSeparator+NAME_ID_SEP.length());
String name = decode(part.substring(0, indexOfSeparator)); String name = decode(part.substring(0, indexOfSeparator));
Log.d(TAG, " name=" + name); //Log.d(TAG, " name=" + name);
FileSystemEntryData thisFolder = accountData.mFolderCache.get(id); FileSystemEntryData thisFolder = accountData.mFolderCache.get(id);
if (thisFolder == null) if (thisFolder == null)
{ {
@ -220,7 +220,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
for (int i=0;i<parts.length;i++) for (int i=0;i<parts.length;i++)
{ {
String part = parts[i]; String part = parts[i];
Log.d(TAG, "parsing part " + part); //Log.d(TAG, "parsing part " + part);
int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP); int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP);
if (indexOfSeparator < 0) if (indexOfSeparator < 0)
{ {
@ -295,11 +295,11 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
thisFile.parentIds.add(parent.getId()); thisFile.parentIds.add(parent.getId());
} }
mAccountData.get(path.getAccount()).mFolderCache.put(thisFile.id, thisFile); mAccountData.get(path.getAccount()).mFolderCache.put(thisFile.id, thisFile);
try { /*try {
Log.d(TAG, "Added "+path.getFullPath()+" to cache"); Log.d(TAG, "Added "+path.getFullPath()+" to cache");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }*/
return thisFile; return thisFile;
} }
@ -336,14 +336,14 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private File getFileForPath(GDrivePath path, Drive driveService) private File getFileForPath(GDrivePath path, Drive driveService)
throws IOException, InvalidPathException { throws IOException, InvalidPathException {
Log.d(TAG,"getFileForPath... "); //Log.d(TAG,"getFileForPath... ");
try try
{ {
//throw new IOException("argh"); //throw new IOException("argh");
String driveId = path.getGDriveId(); String driveId = path.getGDriveId();
Log.d(TAG, "id"+driveId); //Log.d(TAG, "id"+driveId);
File file = driveService.files().get(driveId).execute(); File file = driveService.files().get(driveId).execute();
Log.d(TAG,"...done."); //Log.d(TAG,"...done.");
return file; return file;
} }
catch (IOException e) catch (IOException e)
@ -409,7 +409,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
{ {
File file = getDriveService(parentGdrivePath.getAccount()).files().insert(body).execute(); File file = getDriveService(parentGdrivePath.getAccount()).files().insert(body).execute();
Log.d(TAG, "created folder "+newDirName+" in "+parentPath+". id: "+file.getId()); //Log.d(TAG, "created folder "+newDirName+" in "+parentPath+". id: "+file.getId());
//add to cache to avoid network traffic if this folder is accessed (which is likely to happen soon) //add to cache to avoid network traffic if this folder is accessed (which is likely to happen soon)
FileSystemEntryData newCacheEntry = new FileSystemEntryData(); FileSystemEntryData newCacheEntry = new FileSystemEntryData();
@ -537,12 +537,12 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
try try
{ {
Log.d(TAG, "getFileEntry "+filename); //Log.d(TAG, "getFileEntry "+filename);
GDrivePath gdrivePath = new GDrivePath(filename); GDrivePath gdrivePath = new GDrivePath(filename);
FileEntry res = convertToFileEntry( FileEntry res = convertToFileEntry(
getFileForPath(gdrivePath, getDriveService(gdrivePath.getAccount())), getFileForPath(gdrivePath, getDriveService(gdrivePath.getAccount())),
filename); filename);
Log.d(TAG, "getFileEntry res"+res); //Log.d(TAG, "getFileEntry res"+res);
return res; return res;
} }
catch (Exception e) catch (Exception e)
@ -580,22 +580,22 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private Drive getDriveService(String accountName) private Drive getDriveService(String accountName)
{ {
Log.d(TAG, "getDriveService "+accountName); //Log.d(TAG, "getDriveService "+accountName);
AccountData accountData = mAccountData.get(accountName); AccountData accountData = mAccountData.get(accountName);
Log.d(TAG, "accountData "+accountData); //Log.d(TAG, "accountData "+accountData);
return accountData.drive; return accountData.drive;
} }
@Override @Override
public void onActivityResult(final JavaFileStorage.FileStorageSetupActivity setupAct, int requestCode, int resultCode, Intent data) { public void onActivityResult(final JavaFileStorage.FileStorageSetupActivity setupAct, int requestCode, int resultCode, Intent data) {
Log.d(TAG, "ActivityResult: "+requestCode+"/"+resultCode); //Log.d(TAG, "ActivityResult: "+requestCode+"/"+resultCode);
switch (requestCode) { switch (requestCode) {
case REQUEST_ACCOUNT_PICKER: case REQUEST_ACCOUNT_PICKER:
Log.d(TAG, "ActivityResult: REQUEST_ACCOUNT_PICKER"); //Log.d(TAG, "ActivityResult: REQUEST_ACCOUNT_PICKER");
if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) { if (accountName != null) {
Log.d(TAG, "Initialize Account name="+accountName); //Log.d(TAG, "Initialize Account name="+accountName);
initializeAccountOrPath(setupAct, accountName); initializeAccountOrPath(setupAct, accountName);
return; return;
@ -609,10 +609,10 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
case REQUEST_AUTHORIZATION: case REQUEST_AUTHORIZATION:
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
for (String k: data.getExtras().keySet()) //for (String k: data.getExtras().keySet())
{ //{
Log.d(TAG, data.getExtras().get(k).toString()); //Log.d(TAG, data.getExtras().get(k).toString());
} //}
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) { if (accountName != null) {
Log.d(TAG, "Account name="+accountName); Log.d(TAG, "Account name="+accountName);
@ -669,7 +669,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
AccountData newAccountData = new AccountData(); AccountData newAccountData = new AccountData();
newAccountData.drive = createDriveService(accountName, activity); newAccountData.drive = createDriveService(accountName, activity);
mAccountData.put(accountName, newAccountData); mAccountData.put(accountName, newAccountData);
Log.d(TAG, "Added account data for " + accountName); //Log.d(TAG, "Added account data for " + accountName);
newAccountData.mFolderCache = buildFoldersCache(accountName); newAccountData.mFolderCache = buildFoldersCache(accountName);
About about = newAccountData.drive.about().get().execute(); About about = newAccountData.drive.about().get().execute();
@ -704,7 +704,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
} }
} else if ( isCancelled()) { } else if ( isCancelled()) {
// cancel handling here // cancel handling here
Log.d(TAG,"Async Task cancelled!"); //Log.d(TAG,"Async Task cancelled!");
activity.setResult(Activity.RESULT_CANCELED); activity.setResult(Activity.RESULT_CANCELED);
activity.finish(); activity.finish();
@ -742,12 +742,12 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private HashMap<String,FileSystemEntryData> buildFoldersCache(String accountName) throws IOException { private HashMap<String,FileSystemEntryData> buildFoldersCache(String accountName) throws IOException {
HashMap<String, FileSystemEntryData> folderCache = new HashMap<String, GoogleDriveFileStorage.FileSystemEntryData>(); HashMap<String, FileSystemEntryData> folderCache = new HashMap<String, GoogleDriveFileStorage.FileSystemEntryData>();
Log.d(TAG,"buildFoldersCache"); //Log.d(TAG,"buildFoldersCache");
FileList folders=getDriveService(accountName).files().list().setQ("mimeType='"+FOLDER_MIME_TYPE+"' and trashed=false and hidden=false") FileList folders=getDriveService(accountName).files().list().setQ("mimeType='"+FOLDER_MIME_TYPE+"' and trashed=false and hidden=false")
.setFields("items(id,title,parents),nextPageToken") .setFields("items(id,title,parents),nextPageToken")
.execute(); .execute();
for(File fl: folders.getItems()){ for(File fl: folders.getItems()){
Log.d(TAG,"buildFoldersCache: " + fl.getTitle()); //Log.d(TAG,"buildFoldersCache: " + fl.getTitle());
FileSystemEntryData thisFolder = new FileSystemEntryData(); FileSystemEntryData thisFolder = new FileSystemEntryData();
thisFolder.id = fl.getId(); thisFolder.id = fl.getId();
thisFolder.displayName = fl.getTitle(); thisFolder.displayName = fl.getTitle();
@ -759,13 +759,13 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
folderCache.put(thisFolder.id, thisFolder); folderCache.put(thisFolder.id, thisFolder);
} }
Log.d(TAG,"that's it!"); //Log.d(TAG,"that's it!");
return folderCache; return folderCache;
} }
private void finishActivityWithSuccess(FileStorageSetupActivity setupActivity) { private void finishActivityWithSuccess(FileStorageSetupActivity setupActivity) {
Log.d("KP2AJ", "Success with authentcating!"); //Log.d("KP2AJ", "Success with authentcating!");
Activity activity = (Activity)setupActivity; Activity activity = (Activity)setupActivity;
if (setupActivity.getProcessName().equals(PROCESS_NAME_FILE_USAGE_SETUP)) if (setupActivity.getProcessName().equals(PROCESS_NAME_FILE_USAGE_SETUP))
@ -780,13 +780,14 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
if (setupActivity.getProcessName().equals(PROCESS_NAME_SELECTFILE)) if (setupActivity.getProcessName().equals(PROCESS_NAME_SELECTFILE))
{ {
Intent data = new Intent(); Intent data = new Intent();
if (setupActivity.getState() == null) /*if (setupActivity.getState() == null)
Log.d(TAG, "getState is null"); Log.d(TAG, "getState is null");
else else
if (setupActivity.getState().getString(EXTRA_PATH) == null) if (setupActivity.getState().getString(EXTRA_PATH) == null)
Log.d(TAG, "setupActivity.getState().getString(EXTRA_PATH) is null"); Log.d(TAG, "setupActivity.getState().getString(EXTRA_PATH) is null");
else else
Log.d(TAG,setupActivity.getState().getString(EXTRA_PATH)); Log.d(TAG,setupActivity.getState().getString(EXTRA_PATH));
*/
String path = setupActivity.getState().getString(EXTRA_PATH); String path = setupActivity.getState().getString(EXTRA_PATH);
if (path != null) if (path != null)
data.putExtra(EXTRA_PATH, path); data.putExtra(EXTRA_PATH, path);
@ -838,7 +839,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
{ {
GoogleAccountCredential credential = createCredential(activity); GoogleAccountCredential credential = createCredential(activity);
Log.d(TAG, "starting REQUEST_ACCOUNT_PICKER"); //Log.d(TAG, "starting REQUEST_ACCOUNT_PICKER");
activity.startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); activity.startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
} }

View File

@ -388,12 +388,8 @@ namespace keepass2android
return filename; return filename;
} }
private void OnCreateButton(object sender, EventArgs evt) private void OnCreateButton(string filename)
{ {
Dialog dialog = (Dialog)sender;
String filename = ((EditText)dialog.FindViewById(Resource.Id.file_filename)).Text;
// Make sure file name exists // Make sure file name exists
if (filename.Length == 0) if (filename.Length == 0)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -26,12 +26,12 @@
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_keepass2android" /> android:src="@drawable/ic_keepass2android" />
<TextView <TextView
android:id="@+id/label_test" android:id="@+id/label_app_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="Welcome to Keepass2Android!" android:layout_marginBottom="16dp"
android:text="Keepass2Android"
android:visibility="visible" /> android:visibility="visible" />

View File

@ -206,8 +206,9 @@ namespace keepass2android
return ((int)Android.OS.Build.VERSION.SdkInt >= 14) && (activity.ActionBar != null); return ((int)Android.OS.Build.VERSION.SdkInt >= 14) && (activity.ActionBar != null);
} }
public delegate void FileSelectedHandler(string filename);
public static void ShowFilenameDialog(Activity activity, EventHandler onOpen, EventHandler onCreate, bool showBrowseButton, public static void ShowFilenameDialog(Activity activity, FileSelectedHandler onOpen, FileSelectedHandler onCreate, bool showBrowseButton,
string defaultFilename, string detailsText, int requestCodeBrowse) string defaultFilename, string detailsText, int requestCodeBrowse)
{ {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@ -228,11 +229,19 @@ namespace keepass2android
// Open button // Open button
if (onOpen != null) if (onOpen != null)
openButton.Click += onOpen; openButton.Click += (sender, args) =>
{
String fileName = ((EditText) dialog.FindViewById(Resource.Id.file_filename)).Text;
onOpen(fileName);
};
// Create button // Create button
if (onCreate != null) if (onCreate != null)
createButton.Click += onCreate; createButton.Click += (sender, args) =>
{
String fileName = ((EditText)dialog.FindViewById(Resource.Id.file_filename)).Text;
onCreate(fileName);
};
Button cancelButton = (Button) dialog.FindViewById(Resource.Id.fnv_cancel); Button cancelButton = (Button) dialog.FindViewById(Resource.Id.fnv_cancel);
cancelButton.Click += (sender, e) => dialog.Dismiss(); cancelButton.Click += (sender, e) => dialog.Dismiss();

View File

@ -284,10 +284,8 @@ namespace keepass2android
LaunchPasswordActivityForIoc(ioc); LaunchPasswordActivityForIoc(ioc);
} }
private void OnOpenButton(object sender, EventArgs evt) private void OnOpenButton(String fileName)
{ {
Dialog dialog = (Dialog) sender;
String fileName = ((EditText)dialog.FindViewById(Resource.Id.file_filename)).Text;
IOConnectionInfo ioc = new IOConnectionInfo IOConnectionInfo ioc = new IOConnectionInfo
{ {