[Libreoffice-commits] core.git: 2 commits - android/experimental

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 17 09:27:16 PST 2014


 android/experimental/LOAndroid3/AndroidManifest.xml.in                                 |    3 
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java         |   67 +++++--
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java |   88 +---------
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java       |   24 +-
 4 files changed, 81 insertions(+), 101 deletions(-)

New commits:
commit 3b490bda1e2cec48eff4a9c54291ecc12e70336a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 17 18:23:11 2014 +0100

    android doc browser: sync file type list with the intent filter
    
    Change-Id: I81746860198864bb5917a6c1e898b742b65d77e1

diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml.in b/android/experimental/LOAndroid3/AndroidManifest.xml.in
index 0c659d8..6b339e7 100644
--- a/android/experimental/LOAndroid3/AndroidManifest.xml.in
+++ b/android/experimental/LOAndroid3/AndroidManifest.xml.in
@@ -28,6 +28,8 @@
                 <action android:name="android.intent.action.PICK" />
                 <category android:name="android.intent.category.DEFAULT" />
 
+                <!-- Please keep this in sync with FileUtilities.java. -->
+
                 <!-- ODF -->
                 <data android:mimeType="application/vnd.oasis.opendocument.text" />
                 <data android:mimeType="application/vnd.oasis.opendocument.graphics" />
@@ -68,7 +70,6 @@
 
                 <!-- OTHER -->
                 <!-- Calc. <data android:mimeType="text/csv"/>-->
-                <!-- Calc. <data android:mimeType="text/spreadsheet"/> -->
                 <data android:mimeType="application/vnd.ms-works" />
                 <data android:mimeType="application/vnd.apple.keynote" />
                 <data android:mimeType="application/x-abiword" />
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
index bb3a365..baff933 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
@@ -40,33 +40,60 @@ public class FileUtilities {
 
     private static final Map<String,Integer> mExtnMap = new HashMap<String,Integer>();
     static {
-        mExtnMap.put(".odt",  DOC);
-        mExtnMap.put(".sxw",  DOC);
+        // Please keep this in sync with AndroidManifest.xml
+
+        // ODF
+        mExtnMap.put(".odt", DOC);
+        mExtnMap.put(".odg", DRAWING);
+        mExtnMap.put(".odp",  IMPRESS);
+        // mExtnMap.put(".ods",  CALC);
+        mExtnMap.put(".fodt", DOC);
+        mExtnMap.put(".fodg", DRAWING);
+        mExtnMap.put(".fodp",  IMPRESS);
+        // mExtnMap.put(".fods",  CALC);
+
+        // ODF templates
+        mExtnMap.put(".ott", DOC);
+        mExtnMap.put(".otg", DRAWING);
+        mExtnMap.put(".otp",  IMPRESS);
+        // mExtnMap.put(".ots",  CALC);
+
+        // MS
         mExtnMap.put(".rtf",  DOC);
         mExtnMap.put(".doc",  DOC);
-        mExtnMap.put(".docx", DOC);
-        mExtnMap.put(".html", DOC);
-        mExtnMap.put(".txt",  DOC);
-        mExtnMap.put(".wpd",  DOC);
-        mExtnMap.put(".wps",  DOC);
-        mExtnMap.put(".lwp",  DOC);
+        mExtnMap.put(".vsd", DRAWING);
+        mExtnMap.put(".vsdx", DRAWING);
+        mExtnMap.put(".pub", DRAWING);
+        mExtnMap.put(".ppt",  IMPRESS);
+        // mExtnMap.put(".pps",  IMPRESS);
+        // mExtnMap.put(".xls",  CALC);
 
-        mExtnMap.put(".ods",  CALC);
-        mExtnMap.put(".sxc",  CALC);
-        mExtnMap.put(".xls",  CALC);
-        mExtnMap.put(".xlsx", CALC);
+        // MS templates
+        mExtnMap.put(".dot",  DOC);
+        mExtnMap.put(".pot",  IMPRESS);
+        // mExtnMap.put(".xlt",  CALC);
 
-        mExtnMap.put(".odp",  IMPRESS);
-        mExtnMap.put(".sxi",  IMPRESS);
-        mExtnMap.put(".ppt",  IMPRESS);
+        // OOXML
+        mExtnMap.put(".docx", DOC);
         mExtnMap.put(".pptx", IMPRESS);
+        // mExtnMap.put(".ppsx", IMPRESS);
+        // mExtnMap.put(".xlsx", CALC);
+
+        // OOXML templates
+        mExtnMap.put(".dotx", DOC);
+        mExtnMap.put(".potx", IMPRESS);
+        // mExtnMap.put(".xltx", CALC);
 
-        mExtnMap.put(".odd",  DRAWING);
-        mExtnMap.put(".sxd",  DRAWING);
+        // Other
+        //mExtnMap.put(".csv",  CALC);
+        mExtnMap.put(".wps",  DOC);
+        mExtnMap.put(".key",  IMPRESS);
+        mExtnMap.put(".abw",  DOC);
+        mExtnMap.put(".pmd",  DRAWING);
+        mExtnMap.put(".emf",  DRAWING);
+        mExtnMap.put(".svm",  DRAWING);
+        mExtnMap.put(".wmf",  DRAWING);
         mExtnMap.put(".svg",  DRAWING);
-        mExtnMap.put(".vsd",  DRAWING);
-        mExtnMap.put(".wpg",  DRAWING);
-        // FIXME: we need to expand this ...
     }
 
     private static final String getExtension(String filename)
commit 87928d31b1ce6a75b4e72beaa218971de74ad890
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 17 18:04:42 2014 +0100

    android doc browser: let's list file extensions only at a single place
    
    There is still some duplication, as the file type -> resource mapping is
    there two times.
    
    Change-Id: I50cd58f1cc62e872fb925556dd151f6392eeeb87

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index 3d33614..d171494 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -241,70 +241,6 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         return true;
     }
 
-    public void createDummyFileSystem(){
-        boolean mExternalStorageAvailable = false;
-        boolean mExternalStorageWriteable = false;
-        String state = Environment.getExternalStorageState();
-
-        if (Environment.MEDIA_MOUNTED.equals(state)) {
-            mExternalStorageAvailable = mExternalStorageWriteable = true;
-        } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
-            mExternalStorageAvailable = true;
-            mExternalStorageWriteable = false;
-        } else {
-            mExternalStorageAvailable = mExternalStorageWriteable = false;
-        }
-        if( mExternalStorageAvailable && mExternalStorageWriteable ){//can also check if its writeable
-            Log.d(tag, Boolean.toString( currentDirectory.mkdir() ) );
-            try {
-                File[] removeList = currentDirectory.listFiles();
-                for(File item : removeList){
-                    if(item.isDirectory())
-                        continue;//Log.d(tag, item.getPath());
-                    item.delete();
-                }
-                new File( currentDirectory , "d0.odp" ).createNewFile();
-                new File( currentDirectory , "d1.odt" ).createNewFile();
-                new File( currentDirectory , "d2.odt" ).createNewFile();
-                new File( currentDirectory , "d3.odp" ).createNewFile();
-                new File( currentDirectory , "d4.ods" ).createNewFile();
-                new File( currentDirectory , "d5.odt" ).createNewFile();
-                new File( currentDirectory , "d6.odp" ).createNewFile();
-                new File( currentDirectory , "d7.odt" ).createNewFile();
-                new File( currentDirectory , "d8.odt" ).createNewFile();
-                new File( currentDirectory , "d9.odp" ).createNewFile();
-                new File( currentDirectory , "d10.odp" ).createNewFile();
-                new File( currentDirectory , "d11.odt" ).createNewFile();
-                new File( currentDirectory , "d12.odt" ).createNewFile();
-                new File( currentDirectory , "d13.odp" ).createNewFile();
-                new File( currentDirectory , "d14.ods" ).createNewFile();
-                new File( currentDirectory , "d15.odt" ).createNewFile();
-                File templatesDirectory = new File( currentDirectory , "Templates" );
-                templatesDirectory.mkdir();
-                new File( templatesDirectory , "template1.odt" ).createNewFile();
-                new File( templatesDirectory , "template2.odt" ).createNewFile();
-                new File( templatesDirectory , "template3.ods" ).createNewFile();
-                new File( templatesDirectory , "template4.odp" ).createNewFile();
-                File regularDirectory = new File( currentDirectory , "Folder" );
-                regularDirectory.mkdir();
-                new File( regularDirectory , "yetAnotherDoc.odt" ).createNewFile();
-                new File( regularDirectory , "some really long file name.ods" ).createNewFile();
-                File anotherRegularDirectory = new File( regularDirectory , "AnotherFolder" );
-                anotherRegularDirectory.mkdir();
-                new File( anotherRegularDirectory , "yetAnotherDoc2.odt" ).createNewFile();
-                //Should put a folder in at some stage.
-
-            } catch (IOException e) {
-                Log.d(tag, "file io failure");
-                e.printStackTrace();
-            }
-            //Log.d(tag, fileStore.toString());
-        }
-        else{
-            Log.d(tag, "No External Storage");
-        }
-    }
-
     @SuppressWarnings("unused")//see android:onClick properties in view_menu.xml
     public void sortFiles(MenuItem item){
         switch ( item.getItemId() ) {
@@ -527,14 +463,22 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
             // set image based on selected text
             ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon);
-            if( filePaths[position].getName().endsWith(".odt") ){
-                imageView.setImageResource(R.drawable.writer);
-            }
-            if( filePaths[position].getName().endsWith(".ods") ){
-                imageView.setImageResource(R.drawable.calc);
-            }
-            if( filePaths[position].getName().endsWith(".odp") ){
-                imageView.setImageResource(R.drawable.impress);
+            switch (FileUtilities.getType(filePaths[position].getName()))
+            {
+                case FileUtilities.DOC:
+                    imageView.setImageResource(R.drawable.writer);
+                    break;
+                /*case FileUtilities.CALC:
+                    imageView.setImageResource(R.drawable.calc);
+                    break;*/
+                case FileUtilities.DRAWING:
+                    imageView.setImageResource(R.drawable.draw);
+                    break;
+                case FileUtilities.IMPRESS:
+                    imageView.setImageResource(R.drawable.impress);
+                    break;
+                default:
+                    break;
             }
             if( filePaths[position].isDirectory() ){
                 //Eventually have thumbnails of each sub file on a black circle
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java
index 79e3c04..9386bf9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java
@@ -112,14 +112,22 @@ public class ListItemAdapter implements ListAdapter{
 
         // set image based on selected text
         ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon);
-        if( filePaths[position].getName().endsWith(".odt") ){
-            imageView.setImageResource(R.drawable.writer);
-        }
-        if( filePaths[position].getName().endsWith(".ods") ){
-            imageView.setImageResource(R.drawable.calc);
-        }
-        if( filePaths[position].getName().endsWith(".odp") ){
-            imageView.setImageResource(R.drawable.impress);
+        switch (FileUtilities.getType(filePaths[position].getName()))
+        {
+            case FileUtilities.DOC:
+                imageView.setImageResource(R.drawable.writer);
+                break;
+            /*case FileUtilities.CALC:
+                imageView.setImageResource(R.drawable.calc);
+                break;*/
+            case FileUtilities.DRAWING:
+                imageView.setImageResource(R.drawable.draw);
+                break;
+            case FileUtilities.IMPRESS:
+                imageView.setImageResource(R.drawable.impress);
+                break;
+            default:
+                break;
         }
         if( filePaths[position].isDirectory() ){
             //Eventually have thumbnails of each sub file on a black circle


More information about the Libreoffice-commits mailing list