Hide creation info when the uses ownCloud version is affected by oc-764
authorLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 21:50:59 +0000 (23:50 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 21:50:59 +0000 (23:50 +0200)
res/layout/file_details_fragment.xml
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java

index 76065e3..e940642 100644 (file)
@@ -91,6 +91,7 @@
                         android:layout_below="@+id/fdSizeLabel"
                         android:layout_marginTop="12dp"
                         android:text="@string/filedetails_created"
+                        android:visibility="gone"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
                     
                     <TextView
                         android:layout_height="wrap_content"
                         android:layout_below="@+id/fdSize"
                         android:layout_marginTop="12dp"
+                        android:visibility="gone"
                         android:text="2012/05/18 12:23 PM"
                         android:textAppearance="?android:attr/textAppearanceMedium" />
 
index 78c636b..7b6142b 100644 (file)
@@ -17,6 +17,8 @@
  */\r
 package eu.alefzero.owncloud.ui.fragment;\r
 \r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
 import android.content.BroadcastReceiver;\r
 import android.content.Context;\r
 import android.content.Intent;\r
@@ -40,7 +42,9 @@ import com.actionbarsherlock.app.SherlockFragment;
 import eu.alefzero.owncloud.DisplayUtils;\r
 import eu.alefzero.owncloud.FileDownloader;\r
 import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
+import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 \r
 /**\r
  * This Fragment is used to display the details about a file.\r
@@ -178,7 +182,10 @@ public class FileDetailFragment extends SherlockFragment implements
             setFiletype(DisplayUtils.convertMIMEtoPrettyPrint(mFile\r
                     .getMimetype()));\r
             setFilesize(mFile.getFileLength());\r
-            setTimeCreated(mFile.getCreationTimestamp());\r
+            if(ocVersionSupportsTimeCreated()){\r
+                setTimeCreated(mFile.getCreationTimestamp());\r
+            }\r
+           \r
             setTimeModified(mFile.getModificationTimestamp());\r
             \r
             // Update preview\r
@@ -245,8 +252,11 @@ public class FileDetailFragment extends SherlockFragment implements
      */\r
     private void setTimeCreated(long milliseconds){\r
         TextView tv = (TextView) getView().findViewById(R.id.fdCreated);\r
+        TextView tvLabel = (TextView) getView().findViewById(R.id.fdCreatedLabel);\r
         if(tv != null){\r
             tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds));\r
+            tv.setVisibility(View.VISIBLE);\r
+            tvLabel.setVisibility(View.VISIBLE);\r
         }\r
     }\r
     \r
@@ -260,6 +270,28 @@ public class FileDetailFragment extends SherlockFragment implements
             tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds));\r
         }\r
     }\r
+    \r
+    /**\r
+     * In ownCloud 3.0.3 and 4.0.0 there is a bug that SabreDAV does not return\r
+     * the time time that the file was created. There is a chance that this will\r
+     * be fixed in future versions. Use this method to check if this version of\r
+     * ownCloud has this fix.\r
+     * @return True, if ownCloud the ownCloud version is > 3.0.4 and 4.0.1\r
+     */\r
+    private boolean ocVersionSupportsTimeCreated(){\r
+        if(mIntent != null){\r
+            Account ocAccount = mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);\r
+            if(ocAccount != null){\r
+                AccountManager accManager = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE);\r
+                OwnCloudVersion ocVersion = new OwnCloudVersion(accManager\r
+                        .getUserData(ocAccount, AccountAuthenticator.KEY_OC_VERSION));\r
+                if(ocVersion.compareTo(new OwnCloudVersion(0x030004)) >= 0 || ocVersion.compareTo(new OwnCloudVersion(0x040001)) >= 0){\r
+                    return true;\r
+                }\r
+            }\r
+        }\r
+        return false;\r
+    }\r
 \r
     /**\r
      * Once the file download has finished -> update view\r