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

View File

@ -119,11 +119,11 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
public void setPathWithoutVerify(String path) throws UnsupportedEncodingException, InvalidPathException
{
Log.d(TAG, "setPath: "+path);
//Log.d(TAG, "setPath: "+path);
mAccount = extractAccount(path);
mAccountLocalPath = path.substring(getProtocolPrefix().length()+encode(mAccount).length()+1);
Log.d(TAG, " mAccount=" + mAccount);
Log.d(TAG, " mAccountLocalPath=" + mAccountLocalPath);
//Log.d(TAG, " mAccount=" + mAccount);
//Log.d(TAG, " mAccountLocalPath=" + mAccountLocalPath);
}
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++)
{
String part = parts[i];
Log.d(TAG, "parsing part " + part);
//Log.d(TAG, "parsing part " + part);
int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP);
if (indexOfSeparator < 0)
throw new FileNotFoundException("invalid path " + mAccountLocalPath);
String id = part.substring(indexOfSeparator+NAME_ID_SEP.length());
String name = decode(part.substring(0, indexOfSeparator));
Log.d(TAG, " name=" + name);
//Log.d(TAG, " name=" + name);
FileSystemEntryData thisFolder = accountData.mFolderCache.get(id);
if (thisFolder == null)
{
@ -220,7 +220,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
for (int i=0;i<parts.length;i++)
{
String part = parts[i];
Log.d(TAG, "parsing part " + part);
//Log.d(TAG, "parsing part " + part);
int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP);
if (indexOfSeparator < 0)
{
@ -295,11 +295,11 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
thisFile.parentIds.add(parent.getId());
}
mAccountData.get(path.getAccount()).mFolderCache.put(thisFile.id, thisFile);
try {
/*try {
Log.d(TAG, "Added "+path.getFullPath()+" to cache");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}*/
return thisFile;
}
@ -336,14 +336,14 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private File getFileForPath(GDrivePath path, Drive driveService)
throws IOException, InvalidPathException {
Log.d(TAG,"getFileForPath... ");
//Log.d(TAG,"getFileForPath... ");
try
{
//throw new IOException("argh");
String driveId = path.getGDriveId();
Log.d(TAG, "id"+driveId);
//Log.d(TAG, "id"+driveId);
File file = driveService.files().get(driveId).execute();
Log.d(TAG,"...done.");
//Log.d(TAG,"...done.");
return file;
}
catch (IOException e)
@ -409,7 +409,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
{
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)
FileSystemEntryData newCacheEntry = new FileSystemEntryData();
@ -537,12 +537,12 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
try
{
Log.d(TAG, "getFileEntry "+filename);
//Log.d(TAG, "getFileEntry "+filename);
GDrivePath gdrivePath = new GDrivePath(filename);
FileEntry res = convertToFileEntry(
getFileForPath(gdrivePath, getDriveService(gdrivePath.getAccount())),
filename);
Log.d(TAG, "getFileEntry res"+res);
//Log.d(TAG, "getFileEntry res"+res);
return res;
}
catch (Exception e)
@ -580,22 +580,22 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private Drive getDriveService(String accountName)
{
Log.d(TAG, "getDriveService "+accountName);
//Log.d(TAG, "getDriveService "+accountName);
AccountData accountData = mAccountData.get(accountName);
Log.d(TAG, "accountData "+accountData);
//Log.d(TAG, "accountData "+accountData);
return accountData.drive;
}
@Override
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) {
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) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
Log.d(TAG, "Initialize Account name="+accountName);
//Log.d(TAG, "Initialize Account name="+accountName);
initializeAccountOrPath(setupAct, accountName);
return;
@ -609,10 +609,10 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
case REQUEST_AUTHORIZATION:
if (resultCode == Activity.RESULT_OK) {
for (String k: data.getExtras().keySet())
{
Log.d(TAG, data.getExtras().get(k).toString());
}
//for (String k: data.getExtras().keySet())
//{
//Log.d(TAG, data.getExtras().get(k).toString());
//}
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
Log.d(TAG, "Account name="+accountName);
@ -669,7 +669,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
AccountData newAccountData = new AccountData();
newAccountData.drive = createDriveService(accountName, activity);
mAccountData.put(accountName, newAccountData);
Log.d(TAG, "Added account data for " + accountName);
//Log.d(TAG, "Added account data for " + accountName);
newAccountData.mFolderCache = buildFoldersCache(accountName);
About about = newAccountData.drive.about().get().execute();
@ -704,7 +704,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
}
} else if ( isCancelled()) {
// cancel handling here
Log.d(TAG,"Async Task cancelled!");
//Log.d(TAG,"Async Task cancelled!");
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
@ -742,12 +742,12 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
private HashMap<String,FileSystemEntryData> buildFoldersCache(String accountName) throws IOException {
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")
.setFields("items(id,title,parents),nextPageToken")
.execute();
for(File fl: folders.getItems()){
Log.d(TAG,"buildFoldersCache: " + fl.getTitle());
//Log.d(TAG,"buildFoldersCache: " + fl.getTitle());
FileSystemEntryData thisFolder = new FileSystemEntryData();
thisFolder.id = fl.getId();
thisFolder.displayName = fl.getTitle();
@ -759,13 +759,13 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
folderCache.put(thisFolder.id, thisFolder);
}
Log.d(TAG,"that's it!");
//Log.d(TAG,"that's it!");
return folderCache;
}
private void finishActivityWithSuccess(FileStorageSetupActivity setupActivity) {
Log.d("KP2AJ", "Success with authentcating!");
//Log.d("KP2AJ", "Success with authentcating!");
Activity activity = (Activity)setupActivity;
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))
{
Intent data = new Intent();
if (setupActivity.getState() == null)
/*if (setupActivity.getState() == null)
Log.d(TAG, "getState is null");
else
if (setupActivity.getState().getString(EXTRA_PATH) == null)
Log.d(TAG, "setupActivity.getState().getString(EXTRA_PATH) is null");
else
Log.d(TAG,setupActivity.getState().getString(EXTRA_PATH));
*/
String path = setupActivity.getState().getString(EXTRA_PATH);
if (path != null)
data.putExtra(EXTRA_PATH, path);
@ -838,7 +839,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
{
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);
}

View File

@ -388,12 +388,8 @@ namespace keepass2android
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
if (filename.Length == 0)
{

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -206,8 +206,9 @@ namespace keepass2android
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)
{
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@ -228,11 +229,19 @@ namespace keepass2android
// Open button
if (onOpen != null)
openButton.Click += onOpen;
openButton.Click += (sender, args) =>
{
String fileName = ((EditText) dialog.FindViewById(Resource.Id.file_filename)).Text;
onOpen(fileName);
};
// Create button
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);
cancelButton.Click += (sender, e) => dialog.Dismiss();

View File

@ -284,10 +284,8 @@ namespace keepass2android
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
{