X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/635fcd3e281e81b4632b92b161718c21be9c5e46..6e43d84b17a15b934989d0b71c1ac795186f26b4:/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 f0bc4f2c..5ae763cc 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java @@ -45,8 +45,10 @@ import com.actionbarsherlock.view.MenuItem; import eu.alefzero.owncloud.R; import eu.alefzero.owncloud.authenticator.AccountAuthenticator; import eu.alefzero.owncloud.authenticator.AuthUtils; +import eu.alefzero.owncloud.datamodel.DataStorageManager; +import eu.alefzero.owncloud.datamodel.FileDataStorageManager; import eu.alefzero.owncloud.datamodel.OCFile; -import eu.alefzero.owncloud.ui.fragment.FileList; +import eu.alefzero.owncloud.ui.fragment.FileListFragment; import eu.alefzero.webdav.WebdavClient; /** @@ -59,6 +61,7 @@ import eu.alefzero.webdav.WebdavClient; public class FileDisplayActivity extends SherlockFragmentActivity implements OnNavigationListener { private ArrayAdapter mDirectories; + private DataStorageManager mStorageManager; private static final int DIALOG_CHOOSE_ACCOUNT = 0; @@ -92,12 +95,15 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements for (int i = mDirectories.getCount() - 2; i >= 0; --i) { path += "/" + mDirectories.getItem(i); } - OCFile parent = new OCFile(getContentResolver(), a, path + "/"); - path += "/" + s + "/"; + OCFile parent = mStorageManager.getFileByPath(path + "/"); + path += s + "/"; Thread thread = new Thread(new DirectoryCreator(path, a)); thread.start(); - OCFile.createNewFile(getContentResolver(), a, path, 0, 0, 0, - "DIR", parent.getFileId()).save(); + + OCFile new_file = new OCFile(path); + new_file.setMimetype("DIR"); + new_file.setParentId(parent.getParentId()); + mStorageManager.saveFile(new_file); dialog.dismiss(); } @@ -118,6 +124,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements R.layout.sherlock_spinner_dropdown_item); mDirectories.add("/"); setContentView(R.layout.files); + mStorageManager = new FileDataStorageManager(AuthUtils.getCurrentOwnCloudAccount(this), getContentResolver()); ActionBar action_bar = getSupportActionBar(); action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); action_bar.setDisplayShowTitleEnabled(false); @@ -137,9 +144,26 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements showDialog(0); break; } + case android.R.id.home: { + onBackPressed(); + break; + } + } return true; } + + @Override + public void onBackPressed(){ + popPath(); + if(mDirectories.getCount() == 0) { + Intent intent = new Intent(this, LandingActivity.class); + startActivity(intent); + return; + } + ((FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList)) + .onNavigateUp(); + } @Override protected Dialog onCreateDialog(int id) { @@ -196,17 +220,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements return true; } - @Override - public void onBackPressed() { - popPath(); - if (mDirectories.getCount() == 0) { - super.onBackPressed(); - return; - } - ((FileList) getSupportFragmentManager().findFragmentById(R.id.fileList)) - .onBackPressed(); - } - private class DirectoryCreator implements Runnable { private String mTargetPath; private Account mAccount; @@ -266,4 +279,4 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements } -} \ No newline at end of file +}