implementation of #1193 - optimizing the uploader layout and taking user configured...
authorAndy Scherzinger <info@andy-scherzinger.de>
Mon, 9 Nov 2015 17:24:57 +0000 (18:24 +0100)
committerAndy Scherzinger <info@andy-scherzinger.de>
Mon, 9 Nov 2015 17:24:57 +0000 (18:24 +0100)
AndroidManifest.xml
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 805e9ce..b4c483a 100644 (file)
@@ -59,7 +59,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 79b077d..601ac60 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: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="@drawable/uploader_list_separator"
-                       android:dividerHeight="1dip">
+                       android:divider="#eee"
+                       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 f83608e..988c6e9 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="56dp"  >
-  
-    <ImageView 
-        android:layout_width="20dp"
-        android:layout_height="20dp"
-        android:layout_gravity="center_vertical|center"
-        android:layout_margin="4dp"
-        android:src="@drawable/ic_menu_archive" 
-        android:id="@+id/thumbnail" />
-    
-    <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="56dp"
+    android:background="@drawable/list_selector"
+    android:orientation="horizontal">
+
+    <LinearLayout
+        android:layout_width="56dp"
+        android:layout_height="56dp"
+        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="center_vertical"
+        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_marginLeft="4dp"
+            android:layout_marginRight="4dp"
+            android:ellipsize="middle"
+            android:singleLine="true"
+            android:text="TextView"
+            android:textColor="@color/textColor"
+            android:textSize="16dip" />
+
+        <TextView
+            android:id="@+id/last_mod"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="4dp"
+            android:layout_marginRight="4dp"
+            android:text="TextView"
+            android:textColor="@color/list_item_lastmod_and_filesize_text"
+            android:textSize="12dip" />
+
+    </LinearLayout>
+
 </LinearLayout>
index 320eea1..abe7282 100644 (file)
@@ -62,7 +62,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 0d1a801..99ca54e 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;
 
 
 /**
@@ -335,6 +336,8 @@ public class Uploader extends FileActivity
         Log_OC.d(TAG, "on item click");
         // 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>();
@@ -399,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);
 
@@ -420,19 +424,22 @@ public class Uploader extends FileActivity
         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);
@@ -445,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.sortFolder(files);
+        return files;
+    }
+
     private String generatePath(Stack<String> dirs) {
         String full_path = "";
 
index 07a3eed..975095b 100644 (file)
@@ -197,7 +197,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
                     ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
 \r
                     lastModV.setVisibility(View.VISIBLE);\r
-                    lastModV.setText(showRelativeTimestamp(file));\r
+                    lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file));\r
 \r
                     checkBoxV.setVisibility(View.GONE);\r
 \r
@@ -446,11 +446,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 a30595c..b6eaa89 100644 (file)
@@ -178,8 +178,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