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)
.travis.yml
AndroidManifest.xml
CHANGELOG.md
res/layout/uploader_layout.xml
res/layout/uploader_list_item_layout.xml
res/values/strings.xml
src/com/owncloud/android/ui/activity/Uploader.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/utils/DisplayUtils.java

index 0db9b1e..1d64863 100644 (file)
@@ -8,6 +8,6 @@ before_install:
   - rm pom.xml
 script:
   - ./setup_env.sh ant
-  - ant clean
-  - ant debug
+  - ant clean -Djava.source=7 -Djava.target=7
+  - ant debug -Djava.source=7 -Djava.target=7
   
index 17945c8..ad5dcfd 100644 (file)
@@ -18,6 +18,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
 <manifest package="com.owncloud.android"
+    android:versionCode="10800000"
     android:versionName="ownCloud beta" xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-sdk
@@ -57,7 +58,9 @@
             </intent-filter>
         </activity>
         <activity android:name=".ui.activity.UploadFilesActivity" />
-        <activity android:name=".ui.activity.Uploader" >
+        <activity android:name=".ui.activity.Uploader"
+            android:label="@string/uploader_top_message"
+            android:theme="@style/Theme.ownCloud">
             <intent-filter>
                 <action android:name="android.intent.action.SEND" />
 
index 3be88b4..22f32de 100644 (file)
@@ -1,3 +1,7 @@
+# 2015-11-10
+- update master
+- PR [#1277] (https://github.com/owncloud/android/pull/1277) "Optimized uploader layout and user configured sorting" merged
+
 # 2015-11-05
 - update master
 - fix #1244
index 1c2b6cc..51122ec 100644 (file)
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-       android:layout_height="wrap_content" android:orientation="vertical"
-       android:layout_width="wrap_content" android:background="#fefefe"
+       android:layout_height="wrap_content"
+       android:orientation="vertical"
+       android:layout_width="wrap_content"
+       android:background="@color/white"
        android:gravity="center">
 
-       <TextView android:layout_width="fill_parent"
-               android:text="@string/uploader_top_message"
-               android:layout_height="wrap_content"
-               android:id="@+id/drawer_username"
-               android:textColor="@android:color/black"
-               android:gravity="center_horizontal">
-       </TextView>
-
-       <FrameLayout android:layout_height="fill_parent"
+       <FrameLayout
+               android:layout_height="fill_parent"
                android:layout_width="fill_parent"
-               android:id="@+id/frameLayout1"
-               android:layout_below="@+id/drawer_username"
-               android:layout_above="@+id/linearLayout1">
+               android:id="@+id/upload_list"
+               android:layout_above="@+id/upload_actions">
 
-               <ListView android:id="@android:id/list"
+               <ListView
+                       android:id="@android:id/list"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:divider="@color/list_divider_background"
-                       android:dividerHeight="1dip">
+                       android:dividerHeight="1dp">
                </ListView>
 
        </FrameLayout>
 
        <LinearLayout
-           android:id="@+id/linearLayout1"
+           android:id="@+id/upload_actions"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
index b66df44..9f6f5ba 100644 (file)
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
-<LinearLayout
-       xmlns:android="http://schemas.android.com/apk/res/android"
-       android:layout_width="fill_parent"
-       android:background="#fefefe"
-       android:orientation="horizontal"
-       android:layout_height="72dp"
-    android:padding="@dimen/standard_padding">
-  
-    <ImageView 
-        android:layout_width="@dimen/file_icon_size"
-        android:layout_height="@dimen/file_icon_size"
-        android:layout_gravity="center_vertical|center"
-        android:src="@drawable/ic_menu_archive" 
-        android:id="@+id/thumbnail"
-        android:layout_marginRight="@dimen/standard_padding"/>
-    
-    <TextView 
-        android:text="TextView" 
-        android:layout_width="fill_parent" 
-        android:id="@+id/filename"
-        android:layout_height="wrap_content" 
-        android:textColor="@android:color/black"
-               android:layout_gravity="center_vertical"
-        android:textSize="20dip"/>
-    
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="72dp"
+    android:background="@drawable/list_selector"
+    android:orientation="horizontal">
+
+    <LinearLayout
+        android:layout_width="60dp"
+        android:layout_height="72dp"
+        android:orientation="horizontal">
+
+        <ImageView
+            android:id="@+id/thumbnail"
+            android:layout_width="@dimen/file_icon_size"
+            android:layout_height="@dimen/file_icon_size"
+            android:layout_gravity="center_vertical"
+            android:layout_marginLeft="12dp"
+            android:src="@drawable/ic_menu_archive" />
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:gravity="top"
+        android:paddingTop="@dimen/standard_padding"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/filename"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginRight="4dp"
+            android:ellipsize="middle"
+            android:singleLine="true"
+            android:text="TextView"
+            android:textColor="@color/textColor"
+            android:textSize="16sp" />
+
+        <TextView
+            android:id="@+id/last_mod"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginRight="4dp"
+            android:text="TextView"
+            android:textColor="@color/list_item_lastmod_and_filesize_text"
+            android:textSize="14sp" />
+
+    </LinearLayout>
+
 </LinearLayout>
index a65d277..4e8f180 100644 (file)
@@ -61,7 +61,7 @@
     <string name="setup_btn_connect">Connect</string>
     <string name="uploader_btn_upload_text">Upload</string>
     <string name="uploader_btn_new_folder_text">New folder</string>
-    <string name="uploader_top_message">Choose upload folder:</string>
+    <string name="uploader_top_message">Choose upload folder</string>
     <string name="uploader_wrn_no_account_title">No account found</string>
     <string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.</string>
     <string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
index 37363e4..cd80a94 100644 (file)
@@ -84,6 +84,7 @@ import com.owncloud.android.ui.dialog.LoadingDialog;
 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 @@ public class Uploader extends FileActivity
     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>();
@@ -398,16 +402,17 @@ public class Uploader extends FileActivity
         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);
 
@@ -417,20 +422,24 @@ public class Uploader extends FileActivity
 
         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);
@@ -443,6 +452,18 @@ public class Uploader extends FileActivity
         }
     }
 
+    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 = "";
 
index 4804754..c46b296 100644 (file)
@@ -207,7 +207,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
 \r
 \r
                     lastModV.setVisibility(View.VISIBLE);\r
-                    lastModV.setText(showRelativeTimestamp(file));\r
+                    lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file));\r
 \r
 \r
                     fileSizeSeparatorV.setVisibility(View.VISIBLE);\r
@@ -486,11 +486,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
         notifyDataSetChanged();\r
 \r
     }\r
-    \r
-    private CharSequence showRelativeTimestamp(OCFile file){\r
-        return DisplayUtils.getRelativeDateTimeString(mContext, file.getModificationTimestamp(),\r
-                DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0);\r
-    }\r
 \r
     public void setGridMode(boolean gridMode) {\r
         mGridMode = gridMode;\r
index 25cc55a..e3c94f2 100644 (file)
@@ -198,8 +198,13 @@ public class DisplayUtils {
         return fileExtension;\r
     }\r
 \r
+    public static CharSequence getRelativeTimestamp(Context context, OCFile file) {\r
+        return getRelativeDateTimeString(context, file.getModificationTimestamp(),\r
+                DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0);\r
+    }\r
+\r
     @SuppressWarnings("deprecation")\r
-    public static CharSequence getRelativeDateTimeString (\r
+    private static CharSequence getRelativeDateTimeString (\r
             Context c, long time, long minResolution, long transitionResolution, int flags\r
             ){\r
         \r