Merge branch 'beta' of github.com:owncloud/android into beta
authortobiasKaminsky <tobias@kaminsky.me>
Fri, 13 Nov 2015 16:52:18 +0000 (17:52 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Fri, 13 Nov 2015 16:52:18 +0000 (17:52 +0100)
1  2 
src/com/owncloud/android/ui/activity/Uploader.java

@@@ -84,6 -84,7 +84,7 @@@ import com.owncloud.android.ui.dialog.L
  import com.owncloud.android.utils.CopyTmpFileAsyncTask;
  import com.owncloud.android.utils.DisplayUtils;
  import com.owncloud.android.utils.ErrorMessageAdapter;
+ import com.owncloud.android.utils.FileStorageUtils;
  
  
  /**
@@@ -333,7 -334,10 +334,10 @@@ public class Uploader extends FileActiv
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          // click on folder in the list
          Log_OC.d(TAG, "on item click");
-         Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile, false);
+         // TODO Enable when "On Device" is recovered ?
+         Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile , false);
+         tmpfiles = sortFileList(tmpfiles);
          if (tmpfiles.size() <= 0) return;
          // filter on dirtype
          Vector<OCFile> files = new Vector<OCFile>();
          setContentView(R.layout.uploader_layout);
          
          ListView mListView = (ListView) findViewById(android.R.id.list);
+         ActionBar actionBar = getSupportActionBar();
  
          String current_dir = mParents.peek();
          if(current_dir.equals("")){
-             getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder));
+             actionBar.setTitle(getString(R.string.uploader_top_message));
          }
          else{
-             getSupportActionBar().setTitle(current_dir);
+             actionBar.setTitle(current_dir);
          }
          boolean notRoot = (mParents.size() > 1);
-         ActionBar actionBar = getSupportActionBar();
          actionBar.setDisplayHomeAsUpEnabled(notRoot);
          actionBar.setHomeButtonEnabled(notRoot);
  
  
          mFile = getStorageManager().getFileByPath(full_path);
          if (mFile != null) {
+             // TODO Enable when "On Device" is recovered ?
              Vector<OCFile> files = getStorageManager().getFolderContent(mFile, false);
+             files = sortFileList(files);
              List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
              for (OCFile f : files) {
-                 HashMap<String, Object> h = new HashMap<String, Object>();
                  if (f.isFolder()) {
+                     HashMap<String, Object> h = new HashMap<String, Object>();
                      h.put("dirname", f.getFileName());
+                     h.put("last_mod", DisplayUtils.getRelativeTimestamp(this, f));
                      data.add(h);
                  }
              }
              SimpleAdapter sa = new SimpleAdapter(this,
                                                  data,
                                                  R.layout.uploader_list_item_layout,
-                                                 new String[] {"dirname"},
-                                                 new int[] {R.id.filename});
+                                                 new String[] {"dirname", "last_mod"},
+                                                 new int[] {R.id.filename, R.id.last_mod});
              
              mListView.setAdapter(sa);
              Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
          }
      }
  
+     private Vector<OCFile> sortFileList(Vector<OCFile> files) {
+         SharedPreferences sharedPreferences = PreferenceManager
+                 .getDefaultSharedPreferences(this);
+         // Read sorting order, default to sort by name ascending
+         FileStorageUtils.mSortOrder = sharedPreferences.getInt("sortOrder", 0);
+         FileStorageUtils.mSortAscending = sharedPreferences.getBoolean("sortAscending", true);
+         files = FileStorageUtils.sortOcFolder(files);
+         return files;
+     }
      private String generatePath(Stack<String> dirs) {
          String full_path = "";
  
      private void onCreateFolderOperationFinish(CreateFolderOperation operation,
                                                 RemoteOperationResult result) {
          if (result.isSuccess()) {
 +            dismissLoadingDialog();
 +            String remotePath = operation.getRemotePath().substring(0, operation.getRemotePath().length() -1);
 +            String newFolder = remotePath.substring(remotePath.lastIndexOf("/") + 1);
 +            mParents.push(newFolder);
              populateDirectoryList();
          } else {
              try {