Intermediate commit: Work on new FileDetailFragment layout, simplified
authorLennart Rosam <lennart@familie-rosam.de>
Fri, 18 May 2012 06:09:31 +0000 (08:09 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Fri, 18 May 2012 06:09:31 +0000 (08:09 +0200)
it's code a bit and renamed a color. Layout is WIP

res/drawable/icon_list_selector.xml
res/drawable/list_selector.xml
res/layout/file_details_fragment.xml
res/layout/files.xml
res/values/colors.xml
res/values/strings.xml
src/eu/alefzero/owncloud/DisplayUtils.java
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java

index d9f8d68..f7c8392 100644 (file)
@@ -17,7 +17,7 @@
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
 
-    <item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/>
+    <item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
 
     <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
     <item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>
index d9f8d68..f7c8392 100644 (file)
@@ -17,7 +17,7 @@
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
 
-    <item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/>
+    <item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
 
     <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
     <item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>
index f4cd33f..99c09bc 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- 
+<!--
   ownCloud Android client application
 
   Copyright (C) 2012  Bartek Przybylski
 
   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:layout_height="fill_parent"
-    android:background="#F7F7F7"
+    android:background="@color/owncloud_white"
     android:orientation="vertical" >
 
-    <LinearLayout
-        android:id="@+id/linearLayout1"
+    <ScrollView
+        android:id="@+id/fdScrollView"
         android:layout_width="fill_parent"
-        android:layout_height="wrap_content" >
-
-        <LinearLayout
-            android:id="@+id/linearLayout2"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent" >
-
-            <ImageView
-                android:id="@+id/imageView1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/icon" >
-            </ImageView>
-        </LinearLayout>
+        android:layout_height="fill_parent" >
 
         <LinearLayout
-            android:id="@+id/linearLayout3"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
             android:orientation="vertical" >
 
-            <TextView
-                android:id="@+id/textView1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView2"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
-
-            <TextView
-                android:id="@+id/textView3"
+            <ImageView
+                android:id="@+id/fdIcon"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
+                android:layout_alignParentLeft="true"
+                android:layout_marginLeft="16dp"
+                android:src="@drawable/file" />
 
             <TextView
-                android:id="@+id/textView4"
+                android:id="@+id/fdFilename"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
+                android:layout_alignBottom="@+id/fdIcon"
+                android:layout_centerHorizontal="true"
+                android:text="file.name"
+                android:textAppearance="?android:attr/textAppearanceLarge" />
 
-            <TextView
-                android:id="@+id/textView5"
+            <LinearLayout
                 android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="TextView" >
-            </TextView>
+                android:layout_height="wrap_content" >
+
+                <TextView
+                    android:id="@+id/fdType"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_above="@+id/fdCreatedLabel"
+                    android:layout_alignLeft="@+id/fdFilename"
+                    android:text="JPG Image"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <TextView
+                    android:id="@+id/fdSize"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_above="@+id/fdSizeLabel"
+                    android:layout_alignLeft="@+id/fdFilename"
+                    android:text="389 KB"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <TextView
+                    android:id="@+id/fdCreated"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_above="@+id/fdModifiedLabel"
+                    android:layout_alignLeft="@+id/fdFilename"
+                    android:text="2012/05/18 12:23 PM"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <TextView
+                    android:id="@+id/fdModified"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignBaseline="@+id/fdModifiedLabel"
+                    android:layout_alignBottom="@+id/fdModifiedLabel"
+                    android:layout_alignLeft="@+id/fdCreated"
+                    android:text="2012/05/19 02:56 PM"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <ImageView
+                    android:id="@+id/fdPreview"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_below="@+id/fdModified"
+                    android:layout_centerHorizontal="true"
+                    android:layout_marginTop="16dp"
+                    android:src="@drawable/owncloud_logo" />
+
+                <LinearLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentTop="true" >
+
+                    <TextView
+                        android:id="@+id/fdTypeLabel"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@+id/fdIcon"
+                        android:layout_below="@+id/fdIcon"
+                        android:layout_marginTop="24dp"
+                        android:text="@string/filedetails_type"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdSizeLabel"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@+id/fdIcon"
+                        android:layout_below="@+id/fdTypeLabel"
+                        android:layout_marginTop="12dp"
+                        android:text="@string/filedetails_size"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdCreatedLabel"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@+id/fdIcon"
+                        android:layout_below="@+id/fdSizeLabel"
+                        android:layout_marginTop="12dp"
+                        android:text="@string/filedetails_created"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                    <TextView
+                        android:id="@+id/fdModifiedLabel"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignLeft="@+id/fdIcon"
+                        android:layout_below="@+id/fdCreatedLabel"
+                        android:layout_marginTop="12dp"
+                        android:text="@string/filedetails_modified"
+                        android:textAppearance="?android:attr/textAppearanceMedium" />
+                </LinearLayout>
+            </LinearLayout>
         </LinearLayout>
-    </LinearLayout>
-
-    <LinearLayout
-        android:id="@+id/linearLayout4"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent" >
-
-        <ImageView
-            android:id="@+id/imageView2"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:src="@drawable/action_item_btn" />
-
-        <VideoView
-            android:id="@+id/videoView1"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent" />
-
-        <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" >
-        </ListView>
-    </LinearLayout>
+    </ScrollView>
+
+    <Button
+        android:id="@+id/fdDownloadBtn"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/fdScrollView"
+        android:layout_centerHorizontal="true"
+        android:text="@string/filedetails_download" />
 
 </LinearLayout>
\ No newline at end of file
index e1be03b..3ff6012 100644 (file)
@@ -19,6 +19,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
     android:layout_width="fill_parent"\r
     android:layout_height="fill_parent"\r
+    android:background="@color/owncloud_white"\r
     android:orientation="vertical" >\r
 \r
     <fragment\r
index 521105b..26a029b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="filelist_icon_backgorund">#DDDDDD</color>
-    <color name="filelist_backgorund">#F7F7F7</color>
+    <color name="owncloud_white">#F7F7F7</color>
     
 </resources>
\ No newline at end of file
index a75f227..afec754 100644 (file)
     <string name="uploader_info_uploading">Uploading</string>
     <string name="uploader_btn_create_dir_text">Create dir for upload</string>
     <string name="filedetails_select_file">Tap on a file to display additional information.</string>
+    <string name="filedetails_size">Size:</string>
+    <string name="filedetails_type">Type:</string>
+    <string name="filedetails_created">Created:</string>
+    <string name="filedetails_modified">Modified:</string>
+    <string name="filedetails_download">Download</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
index 40bcb5e..08afd65 100644 (file)
@@ -35,7 +35,7 @@ public class DisplayUtils {
             attachedsuff++;\r
         }\r
         result = ((int) (result * 100)) / 100.;\r
-        return result + suffixes[attachedsuff];\r
+        return result + " " + suffixes[attachedsuff];\r
     }\r
 \r
     public static String HtmlDecode(String s) {\r
index 137cd29..e4b33f1 100644 (file)
@@ -29,10 +29,10 @@ import android.view.LayoutInflater;
 import android.view.View;\r
 import android.view.View.OnClickListener;\r
 import android.view.ViewGroup;\r
+import android.widget.Button;\r
 import android.widget.ImageView;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
-import android.widget.VideoView;\r
 \r
 import com.actionbarsherlock.app.SherlockFragment;\r
 \r
@@ -122,28 +122,20 @@ public class FileDetailFragment extends SherlockFragment implements
             setFiletype(DisplayUtils.convertMIMEtoPrettyPrint(mFile\r
                     .getMimetype()));\r
             setFilesize(mFile.getFileLength());\r
-\r
-            // set file preview if available and possible\r
-            VideoView videoView = (VideoView) getView()\r
-                    .findViewById(R.id.videoView1);\r
-            videoView.setVisibility(View.INVISIBLE);\r
-            if (mFile.getStoragePath() == null) {\r
-                ImageView imageView = (ImageView) getView().findViewById(\r
-                        R.id.imageView2);\r
-                imageView.setImageResource(R.drawable.download);\r
-                imageView.setOnClickListener(this);\r
-            } else {\r
+            \r
+            // Update preview\r
+            if (mFile.getStoragePath() != null) {\r
                 if (mFile.getMimetype().startsWith("image/")) {\r
-                    ImageView imageView = (ImageView) getView()\r
-                            .findViewById(R.id.imageView2);\r
+                    ImageView preview = (ImageView) getView().findViewById(\r
+                            R.id.fdPreview);\r
                     Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath());\r
-                    imageView.setImageBitmap(bmp);\r
-                } else if (mFile.getMimetype().startsWith("video/")) {\r
-                    videoView.setVisibility(View.VISIBLE);\r
-                    videoView.setVideoPath(mFile.getStoragePath());\r
-                    videoView.start();\r
+                    preview.setImageBitmap(bmp);\r
                 }\r
             }\r
+            \r
+            // Make download button effective\r
+            Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn);\r
+            downloadButton.setOnClickListener(this);\r
         }\r
     }\r
 \r
@@ -172,19 +164,19 @@ public class FileDetailFragment extends SherlockFragment implements
     }\r
 \r
     private void setFilename(String filename) {\r
-        TextView tv = (TextView) getView().findViewById(R.id.textView1);\r
+        TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
         if (tv != null)\r
             tv.setText(filename);\r
     }\r
 \r
     private void setFiletype(String mimetype) {\r
-        TextView tv = (TextView) getView().findViewById(R.id.textView2);\r
+        TextView tv = (TextView) getView().findViewById(R.id.fdType);\r
         if (tv != null)\r
             tv.setText(mimetype);\r
     }\r
 \r
     private void setFilesize(long filesize) {\r
-        TextView tv = (TextView) getView().findViewById(R.id.textView3);\r
+        TextView tv = (TextView) getView().findViewById(R.id.fdSize);\r
         if (tv != null)\r
             tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
     }\r
@@ -211,8 +203,7 @@ public class FileDetailFragment extends SherlockFragment implements
         Intent i = new Intent(getActivity(), FileDownloader.class);\r
         i.putExtra(FileDownloader.EXTRA_ACCOUNT,\r
                 mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));\r
-        i.putExtra(FileDownloader.EXTRA_FILE_PATH,\r
-                mIntent.getStringExtra(FileDownloader.EXTRA_FILE_PATH));\r
+        i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());\r
         getActivity().startService(i);\r
     }\r
 \r