Started working on the "Where is my device?" feature
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / activity / FileDisplayActivity.java
index 6c3f2a8..5ae763c 100644 (file)
@@ -45,8 +45,10 @@ import com.actionbarsherlock.view.MenuItem;
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
 import eu.alefzero.owncloud.authenticator.AuthUtils;\r
+import eu.alefzero.owncloud.datamodel.DataStorageManager;\r
+import eu.alefzero.owncloud.datamodel.FileDataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
-import eu.alefzero.owncloud.ui.fragment.FileList;\r
+import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
@@ -59,6 +61,7 @@ import eu.alefzero.webdav.WebdavClient;
 public class FileDisplayActivity extends SherlockFragmentActivity implements\r
                OnNavigationListener {\r
        private ArrayAdapter<String> mDirectories;\r
+       private DataStorageManager mStorageManager;\r
 \r
        private static final int DIALOG_CHOOSE_ACCOUNT = 0;\r
 \r
@@ -78,6 +81,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                final Account a = AuthUtils.getCurrentOwnCloudAccount(this);\r
                builder.setView(dirName);\r
                builder.setTitle(R.string.uploader_info_dirname);\r
+               dirName.setTextColor(R.color.setup_text_typed);\r
 \r
                builder.setPositiveButton(R.string.common_ok, new OnClickListener() {\r
                        public void onClick(DialogInterface dialog, int which) {\r
@@ -91,12 +95,15 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                                for (int i = mDirectories.getCount() - 2; i >= 0; --i) {\r
                                        path += "/" + mDirectories.getItem(i);\r
                                }\r
-                               OCFile parent = new OCFile(getContentResolver(), a, path + "/");\r
-                               path += "/" + s + "/";\r
+                               OCFile parent = mStorageManager.getFileByPath(path + "/");\r
+                               path += s + "/";\r
                                Thread thread = new Thread(new DirectoryCreator(path, a));\r
                                thread.start();\r
-                               OCFile.createNewFile(getContentResolver(), a, path, 0, 0, 0,\r
-                                               "DIR", parent.getFileId()).save();\r
+                               \r
+                               OCFile new_file = new OCFile(path);\r
+                               new_file.setMimetype("DIR");\r
+                               new_file.setParentId(parent.getParentId());\r
+                               mStorageManager.saveFile(new_file);\r
 \r
                                dialog.dismiss();\r
                        }\r
@@ -117,6 +124,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                                R.layout.sherlock_spinner_dropdown_item);\r
                mDirectories.add("/");\r
                setContentView(R.layout.files);\r
+               mStorageManager = new FileDataStorageManager(AuthUtils.getCurrentOwnCloudAccount(this), getContentResolver());\r
                ActionBar action_bar = getSupportActionBar();\r
                action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);\r
                action_bar.setDisplayShowTitleEnabled(false);\r
@@ -136,9 +144,26 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                        showDialog(0);\r
                        break;\r
                }\r
+               case android.R.id.home: {\r
+                       onBackPressed();\r
+                       break;\r
+               }\r
+                       \r
                }\r
                return true;\r
        }\r
+       \r
+       @Override\r
+       public void onBackPressed(){\r
+               popPath();\r
+               if(mDirectories.getCount() == 0) {\r
+                       Intent intent = new Intent(this, LandingActivity.class);\r
+                       startActivity(intent);\r
+                       return;\r
+               }\r
+               ((FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList))\r
+                               .onNavigateUp();\r
+       }\r
 \r
        @Override\r
        protected Dialog onCreateDialog(int id) {\r
@@ -195,17 +220,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                return true;\r
        }\r
 \r
-       @Override\r
-       public void onBackPressed() {\r
-               popPath();\r
-               if (mDirectories.getCount() == 0) {\r
-                       super.onBackPressed();\r
-                       return;\r
-               }\r
-               ((FileList) getSupportFragmentManager().findFragmentById(R.id.fileList))\r
-                               .onBackPressed();\r
-       }\r
-\r
        private class DirectoryCreator implements Runnable {\r
                private String mTargetPath;\r
                private Account mAccount;\r
@@ -265,4 +279,4 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
 \r
                \r
        }\r
-}
\ No newline at end of file
+}