X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/3708951fadf9a58d2d8431d00ce7306279032ce9..f7fb16963b2fba0b65245f0d5eed6ccc98c7952c:/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java diff --git a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java index a86ca5a8..25cb714d 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java @@ -22,7 +22,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.lang.Thread.UncaughtExceptionHandler; -import java.net.URLEncoder; import java.util.ArrayList; import android.accounts.Account; @@ -223,11 +222,12 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements AccountUtils.getCurrentOwnCloudAccount(this)); String remotepath = new String(); for (int j = mDirectories.getCount() - 2; j >= 0; --j) { - remotepath += "/" + URLEncoder.encode(mDirectories.getItem(j)); + remotepath += "/" + mDirectories.getItem(j); } if (!remotepath.endsWith("/")) remotepath += "/"; - remotepath += URLEncoder.encode(new File(filepath).getName()); + remotepath += new File(filepath).getName(); + remotepath = Uri.encode(remotepath, "/"); i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath); i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath); @@ -309,9 +309,10 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements // Clear intent extra, so rotating the screen will not return us to this directory getIntent().removeExtra(FileDetailFragment.EXTRA_FILE); - } else { - mCurrentDir = mStorageManager.getFileByPath("/"); } + + if (mCurrentDir == null) + mCurrentDir = mStorageManager.getFileByPath("/"); // Drop-Down navigation and file list restore mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); @@ -414,10 +415,21 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements } // Figure out the path where the dir needs to be created - String path = FileDisplayActivity.this.mCurrentDir.getRemotePath(); + String path; + if (mCurrentDir == null) { + if (!mStorageManager.fileExists("/")) { + OCFile file = new OCFile("/"); + mStorageManager.saveFile(file); + mCurrentDir = mStorageManager.getFileByPath("/"); + } else { + Log.wtf("FileDisplay", "OMG NO!"); + return; + } + } + path = FileDisplayActivity.this.mCurrentDir.getRemotePath(); // Create directory - path += directoryName + "/"; + path += Uri.encode(directoryName) + "/"; Thread thread = new Thread(new DirectoryCreator(path, a)); thread.start();