Merge remote-tracking branch 'origin/master' into text_file_preview_pr_707_with_develop
authormasensio <masensio@solidgear.es>
Wed, 2 Sep 2015 11:21:17 +0000 (13:21 +0200)
committermasensio <masensio@solidgear.es>
Wed, 2 Sep 2015 11:23:42 +0000 (13:23 +0200)
Conflicts:
res/layout/file_preview.xml
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

1  2 
res/layout/file_preview.xml
src/com/owncloud/android/datamodel/OCFile.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

      android:layout_height="match_parent"
      android:background="@color/background_color"
      android:gravity="center"
 -    tools:context=".ui.fragment.FilePreviewFragment" >
 +    tools:context=".ui.fragment.FilePreviewFragment">
  
 -    <FrameLayout 
 +    <FrameLayout
          android:id="@+id/visual_area"
-         android:layout_width="match_parent"
-         android:layout_height="0dp"
-         android:layout_alignParentTop="true"
-         android:layout_above="@+id/media_controller">
-         <ImageView
-             android:id="@+id/image_preview"
-             android:layout_width="match_parent"
-             android:layout_height="match_parent"
-             android:layout_margin="16dp"
-             android:layout_gravity="center"
-             android:contentDescription="@string/preview_image_description"
-             android:src="@drawable/logo" />
-         <VideoView
-             android:id="@+id/video_preview"
-             android:layout_width="match_parent"
-             android:layout_height="match_parent"
-             android:layout_gravity="center"
-             android:visibility="gone" />
-     </FrameLayout>
-     <com.owncloud.android.media.MediaControlView
-         android:id="@id/media_controller"
-         android:layout_width="match_parent"
-         android:layout_height="wrap_content"
-         android:layout_alignParentBottom="true" />
+           android:layout_width="match_parent"
+           android:layout_height="0dp"
+           android:layout_alignParentTop="true"
+           android:layout_above="@+id/media_controller"
+         >
+     
+           <ImageView
+               android:id="@+id/image_preview"
+               android:layout_width="match_parent"
+               android:layout_height="match_parent"
+               android:layout_margin="16dp"
+               android:layout_gravity="center"
+               android:contentDescription="@string/preview_image_description"
+               android:src="@drawable/logo" />
+           
+               <VideoView  
+                   android:id="@+id/video_preview"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"  
+                       android:layout_gravity="center" 
+                       android:visibility="gone"
+                       />
+               
+       </FrameLayout>
+       
+       <com.owncloud.android.media.MediaControlView 
+           android:id="@id/media_controller"
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:layout_alignParentBottom="true"
+               android:layout_margin="16dp"
+           />
  
  </RelativeLayout>
@@@ -545,28 -540,16 +545,35 @@@ public class OCFile implements Parcelab
       */
      public boolean isImage() {
          return ((mMimeType != null && mMimeType.startsWith("image/")) ||
 -                FileStorageUtils.getMimeTypeFromName(mRemotePath).startsWith("image/"));
 +                getMimeTypeFromName().startsWith("image/"));
 +    }
 +
 +    /**
 +     * @return 'True' if the file is simple text (e.g. not application-dependent, like .doc or .docx)
 +     */
 +    public boolean isText() {
 +        return ((mMimeType != null && mMimeType.startsWith("text/")) ||
 +                getMimeTypeFromName().startsWith("text/"));
 +    }
 +
 +    public String getMimeTypeFromName() {
 +        String extension = "";
 +        int pos = mRemotePath.lastIndexOf('.');
 +        if (pos >= 0) {
 +            extension = mRemotePath.substring(pos + 1);
 +        }
 +        String result = MimeTypeMap.getSingleton().
 +                getMimeTypeFromExtension(extension.toLowerCase());
 +        return (result != null) ? result : "";
      }
  
+     /**
+      * @return 'True' if the file is hidden
+      */
+     public boolean isHidden() {
+         return getFileName().startsWith(".");
+     }
      public String getPermissions() {
          return mPermissions;
      }
@@@ -104,10 -106,7 +107,6 @@@ import com.owncloud.android.utils.UriUt
  
  import java.io.File;
  
- import java.io.IOException;
--
  /**
   * Displays, what files the user has available in his ownCloud.
   */
@@@ -200,10 -204,13 +205,13 @@@ public class FileDisplayActivity extend
                                                                  // according to the official
                                                                  // documentation
  
-         setSupportProgressBarIndeterminateVisibility(mSyncInProgress
-         /*|| mRefreshSharesInProgress*/);
+         // enable ActionBar app icon to behave as action to toggle nav drawer
+         //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+         getSupportActionBar().setHomeButtonEnabled(true);
+         mProgressBar.setIndeterminate(mSyncInProgress);
          // always AFTER setContentView(...) ; to work around bug in its implementation
 -        
 +
          setBackgroundText();
  
          Log_OC.v(TAG, "onCreate() end");
                      }
                      removeStickyBroadcast(intent);
                      Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
-                     setSupportProgressBarIndeterminateVisibility(mSyncInProgress
-                     /*|| mRefreshSharesInProgress*/);
+                     mProgressBar.setIndeterminate(mSyncInProgress);
+                     //mProgressBar.setVisibility((mSyncInProgress) ? View.VISIBLE : View.INVISIBLE);
+                     //setSupportProgressBarIndeterminateVisibility(mSyncInProgress
+                     /*|| mRefreshSharesInProgress*/ //);
  
                      setBackgroundText();
 -                        
 +
                  }
 -                
 +
                  if (synchResult != null) {
                      if (synchResult.getCode().equals(
                              RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
                      } else {
                          cleanSecondFragment();
                      }
 -                    
 -                    // Force the preview if the file is an image
 -                    if (uploadWasFine && PreviewImageFragment.canBePreviewed(getFile())) {
 -                        startImagePreview(getFile());
 -                    } // TODO what about other kind of previews?
 +
 +                    // Force the preview if the file is an image or text file
 +                    if (uploadWasFine) {
 +                        OCFile ocFile = getFile();
 +                        if (PreviewImageFragment.canBePreviewed(ocFile))
 +                            startImagePreview(getFile());
 +                        else if (PreviewTextFragment.canBePreviewed(ocFile))
 +                            startTextPreview(ocFile);
 +                        // TODO what about other kind of previews?
 +                    }
                  }
  
+                 mProgressBar.setIndeterminate(false);
              } finally {
                  if (intent != null) {
                      removeStickyBroadcast(intent);
                  getApplicationContext()
          );
          synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null);
-         setSupportProgressBarIndeterminateVisibility(true);
 +
+         mProgressBar.setIndeterminate(true);
  
          setBackgroundText();
      }
@@@ -52,8 -55,8 +55,9 @@@ import com.owncloud.android.ui.dialog.R
  import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
  import com.owncloud.android.ui.preview.PreviewImageFragment;
  import com.owncloud.android.ui.preview.PreviewMediaFragment;
+ import com.owncloud.android.utils.DialogMenuItem;
  import com.owncloud.android.utils.FileStorageUtils;
 +import com.owncloud.android.ui.preview.PreviewTextFragment;
  
  /**
   * A Fragment that lists all files and folders in a given path.