Эх сурвалжийг харах

Fixes the text preview issue

Jorge Antonio Diaz-Benito Soriano 9 жил өмнө
parent
commit
ae0e116ffc

+ 0 - 8
src/com/owncloud/android/datamodel/OCFile.java

@@ -548,14 +548,6 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
                 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('.');

+ 9 - 1
src/com/owncloud/android/ui/preview/PreviewTextFragment.java

@@ -29,6 +29,8 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.lang.ref.WeakReference;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Scanner;
 
 public class PreviewTextFragment extends FileFragment {
@@ -389,7 +391,13 @@ public class PreviewTextFragment extends FileFragment {
      * @return 'True' if the file can be handled by the fragment.
      */
     public static boolean canBePreviewed(OCFile file) {
-        return (file != null && file.isDown() && file.isText());
+        final List<String> supportedTypes = new LinkedList<String>();
+        supportedTypes.add("text/plain");
+        supportedTypes.add("text/html");
+        supportedTypes.add("text/css");
+        supportedTypes.add("text/csv");
+
+        return (file != null && file.isDown() && supportedTypes.contains(file.getMimetype()));
     }
 
     /**