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

Jacobo Aragunde Pérez jaragunde at igalia.com
Mon Jan 19 01:48:23 PST 2015


 android/experimental/LOAndroid3/res/layout/file_grid.xml                                                    |   19 +
 android/experimental/LOAndroid3/res/layout/file_list.xml                                                    |   20 +
 android/experimental/LOAndroid3/res/layout/item_in_drawer.xml                                               |   17 +
 android/experimental/LOAndroid3/res/values/strings.xml                                                      |    4 
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java               |  100 +++++++++
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java                     |   44 ++++
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IFile.java                                 |  102 +++++++++
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java |   40 +++
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java          |   40 +++
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java                       |   96 +++++++++
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java                            |   31 +--
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java                      |  103 +++++++---
 12 files changed, 569 insertions(+), 47 deletions(-)

New commits:
commit 61682ae51129310b62290be77c8349754845aedb
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Wed Jan 14 12:51:56 2015 +0000

    Android: i18n-ized document provider names.
    
    The factory will need access to the Context to be able to transform
    the resources into Strings, and the only way to receive it is from
    the Activity. Implemented initialize(Context) for that reason.
    
    Change-Id: If6e81a9c4ad73180851e43968ac97aa1e74231e7

diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index 2d03388..7cd7423 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -30,4 +30,8 @@
     <string name="share">Share</string>
     <string name="share_via">Share via</string>
 
+    <!-- Document provider names -->
+    <string name="local_documents">Local documents</string>
+    <string name="local_file_system">Local file system</string>
+
 </resources>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
index 2ec0dc9..9aa1973 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
@@ -12,6 +12,8 @@ package org.libreoffice.storage;
 import org.libreoffice.storage.local.LocalDocumentsDirectoryProvider;
 import org.libreoffice.storage.local.LocalDocumentsProvider;
 
+import android.content.Context;
+
 /**
  * Keeps the instances of the available IDocumentProviders in the system.
  * Instances are maintained in a sorted list and providers have to be
@@ -31,22 +33,39 @@ public final class DocumentProviderFactory {
     private IDocumentProvider[] providers = {
             new LocalDocumentsDirectoryProvider(), new LocalDocumentsProvider() };
 
-    private String[] providerNames = {
-            "Local documents", "Local file system" };
+    private String[] providerNames;
 
     private DocumentProviderFactory() {
         // private to prevent external instances of the factory
     }
 
     /**
-     * Retrieve the unique instance of the factory.
+     * Initializes the factory with some context. If this method is called for
+     * twice or more times those calls will have no effect.
      *
-     * @return the unique factory object.
+     * @param context
+     *            Application context for the factory.
      */
-    public static DocumentProviderFactory getInstance() {
+    public static void initialize(Context context) {
         if (instance == null) {
+            // initialize instance
             instance = new DocumentProviderFactory();
+
+            // initialize document providers list
+            instance.providerNames = new String[instance.providers.length];
+            for (int i = 0; i < instance.providers.length; i++) {
+                instance.providerNames[i] = context.getString(instance
+                        .getProvider(i).getNameResource());
+            }
         }
+    }
+
+    /**
+     * Retrieve the unique instance of the factory.
+     *
+     * @return the unique factory object or null if it is not yet initialized.
+     */
+    public static DocumentProviderFactory getInstance() {
         return instance;
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java
index bf50523..191a143 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java
@@ -33,4 +33,12 @@ public interface IDocumentProvider {
      * @return IFile object pointing to the content represented by uri.
      */
     IFile createFromUri(URI uri);
+
+    /**
+     * Get internationalized name for this provider. This name is intended to be
+     * shown in the UI.
+     *
+     * @return string resource pointing to the provider name.
+     */
+    int getNameResource();
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
index 62bbd59..92d93d6 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
@@ -12,6 +12,7 @@ package org.libreoffice.storage.local;
 import java.io.File;
 
 import org.libreoffice.storage.IFile;
+import org.libreoffice.R;
 
 import android.os.Environment;
 
@@ -31,4 +32,9 @@ public class LocalDocumentsDirectoryProvider extends LocalDocumentsProvider {
         documentsDirectory.mkdirs();
         return new LocalFile(documentsDirectory);
     }
+
+    @Override
+    public int getNameResource() {
+        return R.string.local_documents;
+    }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
index 8e21182..cc96ef0 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
@@ -14,6 +14,8 @@ import java.net.URI;
 import org.libreoffice.storage.IDocumentProvider;
 import org.libreoffice.storage.IFile;
 
+import org.libreoffice.R;
+
 import android.os.Environment;
 
 /**
@@ -30,4 +32,9 @@ public class LocalDocumentsProvider implements IDocumentProvider {
     public IFile createFromUri(URI uri) {
         return new LocalFile(uri);
     }
+
+    @Override
+    public int getNameResource() {
+        return R.string.local_file_system;
+    }
 }
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 1ee88bf..c1d0dcb 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -107,6 +107,8 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         super.onCreate(savedInstanceState);
         Log.d(tag, "onCreate - tweaked - meeks !");
 
+        // initialize document provider factory
+        DocumentProviderFactory.initialize(this);
         documentProviderFactory = DocumentProviderFactory.getInstance();
 
         //Set the "home" - top level - directory.
commit 9f3716cb7d99ceb5c3c390e650c13188f6515e61
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Thu Jan 15 16:30:08 2015 +0000

    Android: reimplement DocumentProviderFactory as a singleton
    
    The factory will require some objects that are not available from a
    static context.
    
    Change-Id: Idf852f5b9ab3023644b1a9577951a94c4f21c4e9

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
index 57b0437..2ec0dc9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
@@ -16,22 +16,47 @@ import org.libreoffice.storage.local.LocalDocumentsProvider;
  * Keeps the instances of the available IDocumentProviders in the system.
  * Instances are maintained in a sorted list and providers have to be
  * accessed from their position.
+ *
+ * The factory follows the Singleton pattern, there is only one instance of it
+ * in the application and it must be retrieved with
+ * DocumentProviderFactory.getInstance().
  */
-public class DocumentProviderFactory {
+public final class DocumentProviderFactory {
+
+    /**
+     * Private factory instance for the Singleton pattern.
+     */
+    private static DocumentProviderFactory instance = null;
 
-    private static IDocumentProvider[] providers = {
+    private IDocumentProvider[] providers = {
             new LocalDocumentsDirectoryProvider(), new LocalDocumentsProvider() };
 
-    private static String[] providerNames = {
+    private String[] providerNames = {
             "Local documents", "Local file system" };
 
+    private DocumentProviderFactory() {
+        // private to prevent external instances of the factory
+    }
+
+    /**
+     * Retrieve the unique instance of the factory.
+     *
+     * @return the unique factory object.
+     */
+    public static DocumentProviderFactory getInstance() {
+        if (instance == null) {
+            instance = new DocumentProviderFactory();
+        }
+        return instance;
+    }
+
     /**
      * Retrieve the provider associated to a certain position.
      *
      * @param position
      * @return document provider in that position.
      */
-    public static IDocumentProvider getProvider(int position) {
+    public IDocumentProvider getProvider(int position) {
         return providers[position];
     }
 
@@ -41,7 +66,7 @@ public class DocumentProviderFactory {
      *
      * @return Array with the names of the available providers.
      */
-    public static String[] getNames() {
+    public String[] getNames() {
         return providerNames;
     }
 
@@ -50,7 +75,7 @@ public class DocumentProviderFactory {
      *
      * @return default provider.
      */
-    public static IDocumentProvider getDefaultProvider() {
+    public IDocumentProvider getDefaultProvider() {
         return providers[0];
     }
 }
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 041eda8..1ee88bf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -78,6 +78,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     FileFilter fileFilter;
     FilenameFilter filenameFilter;
     private List<IFile> filePaths;
+    private DocumentProviderFactory documentProviderFactory;
     private IDocumentProvider documentProvider;
     private IFile homeDirectory;
     private IFile currentDirectory;
@@ -105,8 +106,11 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
         super.onCreate(savedInstanceState);
         Log.d(tag, "onCreate - tweaked - meeks !");
+
+        documentProviderFactory = DocumentProviderFactory.getInstance();
+
         //Set the "home" - top level - directory.
-        documentProvider = DocumentProviderFactory.getDefaultProvider();
+        documentProvider = documentProviderFactory.getDefaultProvider();
         homeDirectory = documentProvider.getRootDirectory();
         currentDirectory = homeDirectory;
         //Load default settings
@@ -177,13 +181,13 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
         // Set the adapter for the list view
         drawerList.setAdapter(new ArrayAdapter<String>(this,
-                R.layout.item_in_drawer, DocumentProviderFactory.getNames()));
+                R.layout.item_in_drawer, documentProviderFactory.getNames()));
         // Set the list's click listener
         drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView parent, View view,
                     int position, long id) {
-                documentProvider = DocumentProviderFactory.getProvider(position);
+                documentProvider = documentProviderFactory.getProvider(position);
                 homeDirectory = documentProvider.getRootDirectory();
                 currentDirectory = homeDirectory;
                 createUI();
commit e0517616fac5b9b64ad82257534db95f39df568d
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Wed Jan 14 09:43:18 2015 +0000

    Android: prevent browsing further than the root directory.
    
    We must ensure that two LocalFile objects pointing to the same File
    are equal so the check to decide if the application button means "up"
    works.
    
    Change-Id: Ib83b34a210eec9a3f038c27d27a4e9b305c98ef9

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java
index 797d909..8e8115a 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java
@@ -83,4 +83,14 @@ public class LocalFile implements IFile {
     public File getDocument() {
         return file;
     }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object)
+            return true;
+        if (!(object instanceof LocalFile))
+            return false;
+        LocalFile file = (LocalFile) object;
+        return file.getUri().equals(getUri());
+    }
 }
commit 233138918dfcc5d3c19c5c018be94dcfcf61a11c
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Tue Jan 13 19:15:21 2015 +0000

    Android: add UI selector for the available IDocumentProviders.
    
    Implemented a DrawerLayout in the main activity where the providers
    are listed. Also added the class DocumentProviderFactory which keeps
    the instances of the providers.
    
    Change-Id: I821958e93b9ea1008921db321e825648a8766405

diff --git a/android/experimental/LOAndroid3/res/layout/file_grid.xml b/android/experimental/LOAndroid3/res/layout/file_grid.xml
index 6b41977..ec7fdd0 100644
--- a/android/experimental/LOAndroid3/res/layout/file_grid.xml
+++ b/android/experimental/LOAndroid3/res/layout/file_grid.xml
@@ -5,11 +5,13 @@
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
  -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.v4.widget.DrawerLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical" >
+    android:layout_height="match_parent">
 
+    <!-- The main content view -->
     <GridView
         android:id="@+id/file_explorer_grid_view"
         android:layout_width="fill_parent"
@@ -22,5 +24,14 @@
         android:gravity="center">
     </GridView>
 
+    <!-- The navigation drawer -->
+    <ListView android:id="@+id/left_drawer"
+        android:layout_width="240dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        android:choiceMode="singleChoice"
+        android:divider="@android:color/transparent"
+        android:dividerHeight="0dp"
+        android:background="#111"/>
 
-</LinearLayout>
+</android.support.v4.widget.DrawerLayout>
diff --git a/android/experimental/LOAndroid3/res/layout/file_list.xml b/android/experimental/LOAndroid3/res/layout/file_list.xml
index 48dfb1e..dd5346f 100644
--- a/android/experimental/LOAndroid3/res/layout/file_list.xml
+++ b/android/experimental/LOAndroid3/res/layout/file_list.xml
@@ -6,15 +6,27 @@
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
  -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.v4.widget.DrawerLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical" >
+    android:layout_height="match_parent">
 
+    <!-- The main content view -->
     <ListView
         android:id="@+id/file_explorer_list_view"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
     </ListView>
 
-</LinearLayout>
+    <!-- The navigation drawer -->
+    <ListView android:id="@+id/left_drawer"
+        android:layout_width="240dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        android:choiceMode="singleChoice"
+        android:divider="@android:color/transparent"
+        android:dividerHeight="0dp"
+        android:background="#111"/>
+
+</android.support.v4.widget.DrawerLayout>
diff --git a/android/experimental/LOAndroid3/res/layout/item_in_drawer.xml b/android/experimental/LOAndroid3/res/layout/item_in_drawer.xml
new file mode 100644
index 0000000..da73063
--- /dev/null
+++ b/android/experimental/LOAndroid3/res/layout/item_in_drawer.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ This file is part of the LibreOffice project.
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ -->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/text1"
+    android:layout_width="match_parent"
+    android:layout_height="48dp"
+    android:textAppearance="?android:attr/textAppearanceMedium"
+    android:textColor="@android:color/white"
+    android:gravity="center_vertical"
+    android:paddingLeft="48dp"
+/>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
new file mode 100644
index 0000000..57b0437
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderFactory.java
@@ -0,0 +1,56 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage;
+
+import org.libreoffice.storage.local.LocalDocumentsDirectoryProvider;
+import org.libreoffice.storage.local.LocalDocumentsProvider;
+
+/**
+ * Keeps the instances of the available IDocumentProviders in the system.
+ * Instances are maintained in a sorted list and providers have to be
+ * accessed from their position.
+ */
+public class DocumentProviderFactory {
+
+    private static IDocumentProvider[] providers = {
+            new LocalDocumentsDirectoryProvider(), new LocalDocumentsProvider() };
+
+    private static String[] providerNames = {
+            "Local documents", "Local file system" };
+
+    /**
+     * Retrieve the provider associated to a certain position.
+     *
+     * @param position
+     * @return document provider in that position.
+     */
+    public static IDocumentProvider getProvider(int position) {
+        return providers[position];
+    }
+
+    /**
+     * Returns a sorted list of the names of the providers. Order is meaningful
+     * to retrieve the actual provider object with getProvider().
+     *
+     * @return Array with the names of the available providers.
+     */
+    public static String[] getNames() {
+        return providerNames;
+    }
+
+    /**
+     * Returns the default provider.
+     *
+     * @return default provider.
+     */
+    public static IDocumentProvider getDefaultProvider() {
+        return providers[0];
+    }
+}
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 8bb64f3..041eda8 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -12,6 +12,7 @@ package org.libreoffice.ui;
 import org.libreoffice.R;
 import org.libreoffice.LOAbout;
 import org.libreoffice.android.Bootstrap;
+import org.libreoffice.storage.DocumentProviderFactory;
 import org.libreoffice.storage.IDocumentProvider;
 import org.libreoffice.storage.IFile;
 import org.libreoffice.storage.local.LocalDocumentsProvider;
@@ -40,6 +41,7 @@ import android.database.DataSetObserver;
 import android.os.Bundle;
 import android.os.Environment;
 import android.preference.PreferenceManager;
+import android.support.v4.widget.DrawerLayout;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
@@ -76,7 +78,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     FileFilter fileFilter;
     FilenameFilter filenameFilter;
     private List<IFile> filePaths;
-    private IDocumentProvider documentProvider = new LocalDocumentsProvider();
+    private IDocumentProvider documentProvider;
     private IFile homeDirectory;
     private IFile currentDirectory;
 
@@ -89,6 +91,8 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     public static final int GRID_VIEW = 0;
     public static final int LIST_VIEW = 1;
 
+    private DrawerLayout drawerLayout;
+    private ListView drawerList;
     GridView gv;
     ListView lv;
 
@@ -102,6 +106,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         super.onCreate(savedInstanceState);
         Log.d(tag, "onCreate - tweaked - meeks !");
         //Set the "home" - top level - directory.
+        documentProvider = DocumentProviderFactory.getDefaultProvider();
         homeDirectory = documentProvider.getRootDirectory();
         currentDirectory = homeDirectory;
         //Load default settings
@@ -165,6 +170,26 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
             registerForContextMenu(lv);
         }
 
+        // setup the drawer
+
+        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+        drawerList = (ListView) findViewById(R.id.left_drawer);
+
+        // Set the adapter for the list view
+        drawerList.setAdapter(new ArrayAdapter<String>(this,
+                R.layout.item_in_drawer, DocumentProviderFactory.getNames()));
+        // Set the list's click listener
+        drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView parent, View view,
+                    int position, long id) {
+                documentProvider = DocumentProviderFactory.getProvider(position);
+                homeDirectory = documentProvider.getRootDirectory();
+                currentDirectory = homeDirectory;
+                createUI();
+            }
+        });
+
     }
 
     @Override
commit 280f1c03a71bc72e8d1222de4118424561bf8ac7
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Tue Jan 13 17:34:02 2015 +0000

    Android: implement LocalDocumentsDirectoryProvider.
    
    A convenience Document Provider to browse the /sdcard/Documents
    directory.
    
    Change-Id: Ib412d9b54dfb0e54ac014cf80ce94f067b2f4924

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
new file mode 100644
index 0000000..62bbd59
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
@@ -0,0 +1,34 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage.local;
+
+import java.io.File;
+
+import org.libreoffice.storage.IFile;
+
+import android.os.Environment;
+
+/**
+ * A convenience IDocumentProvider to browse the /sdcard/Documents directory.
+ *
+ * Extends LocalDocumentsProvider to overwrite getRootDirectory and set it to
+ * /sdcard/Documents. Most documents will probably be stored there so there is
+ * no need for the user to browse the filesystem from the root every time.
+ */
+public class LocalDocumentsDirectoryProvider extends LocalDocumentsProvider {
+
+    @Override
+    public IFile getRootDirectory() {
+        File documentsDirectory = new File(
+                Environment.getExternalStorageDirectory(), "Documents");
+        documentsDirectory.mkdirs();
+        return new LocalFile(documentsDirectory);
+    }
+}
commit 2ac02d6083094c9b831851c8cc5be5fc41a4a818
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Mon Jan 12 12:08:52 2015 +0000

    Android: Abstract file management from LibreOfficeUIActivity.
    
    This is the first step towards implementing support for different
    cloud providers.
    
    The use of File objects is replaced with the interface IFile, which
    has similar operations. A LocalFile implementation is provided to
    deal with local contents in the same way it was being done before.
    
    Some system-wide storage operations are abstracted in the interface
    IDocumentProvider. A LocalDocumentsProvider implementation is
    provided.
    
    Known issues in this patch:
    
    * Dummy filesystem code has been removed. This should be provided as
      an implementation of IDocumentProvider in case we need it, but that
      will probably not happen.
    
    * Sorting is not implemented in LocalDocumentsProvider yet. It seemed
      not to be working anyway.
    
    * Code to get directory thumbnails has been commented out. This code
      will probably belong to the IDocumentProvider/IFile implementations.
      We might want to have a different approach instead of reading
      hidden thumbnail files, something similar to what the native
      Start Center does.
    
    Change-Id: Ib0882c69a0b24e28d2346bbe0154db01d1102b06

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java
new file mode 100644
index 0000000..bf50523
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IDocumentProvider.java
@@ -0,0 +1,36 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage;
+
+import java.net.URI;
+
+/**
+ * Represents a Document Provider, an object able to provide documents from a
+ * certain source (e.g. local documents, DropBox, Google Docs).
+ */
+public interface IDocumentProvider {
+
+    /**
+     * Provides the content root element for the Document Provider.
+     *
+     * @return Content root element.
+     */
+    IFile getRootDirectory();
+
+    /**
+     * Transforms some URI into the IFile object that represents that content.
+     *
+     * @param uri
+     *            URI pointing to some content object that has been previously
+     *            retrieved with IFile.getUri().
+     * @return IFile object pointing to the content represented by uri.
+     */
+    IFile createFromUri(URI uri);
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IFile.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IFile.java
new file mode 100644
index 0000000..5b71c09
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/IFile.java
@@ -0,0 +1,102 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * An abstraction of the File class, intended to be implemented by different
+ * Document Providers.
+ *
+ * It represents a file or a directory in the context of a certain Document
+ * Provider. It wraps the file-related operations and provides access to the
+ * final document as a local File, downloading it if necessary.
+ */
+public interface IFile {
+
+    /**
+     * Provides a URI that represents this IFile object.
+     *
+     * @return URI that represents this IFile object in the context of the
+     *         Document Provider that created it. The URI can be transformed
+     *         back into an IFile object with IDocumentProvider.createFromUri().
+     */
+    URI getUri();
+
+    /**
+     * Returns the name of the file or directory represented by this file.
+     *
+     * @return This file's name.
+     */
+    String getName();
+
+    /**
+     * Indicates if this file represents a directory in the context of the
+     * Document Provider which originated it.
+     *
+     * @return true if this file is a directory, false otherwise.
+     */
+    boolean isDirectory();
+
+    /**
+     * Returns the file size in bytes.
+     *
+     * @return file size in bytes, 0 if the file does not exist.
+     */
+    long getSize();
+
+    /**
+     * Returns the time when this file was last modified, measured in
+     * milliseconds since January 1st, 1970, midnight.
+     *
+     * @return time when this file was last modified, or 0 if the file does not
+     *         exist.
+     */
+    Date getLastModified();
+
+    /**
+     * Returns a list containing the files in the directory represented by this
+     * file.
+     *
+     * @return list of files contained by this directory, or an empty list if
+     *         this is not a directory.
+     */
+    List<IFile> listFiles();
+
+    /**
+     * Gets the list of files contained in the directory represented by this
+     * file, and filters it through some FilenameFilter.
+     *
+     * @param filter
+     *            the filter to match names against.
+     * @return filtered list of files contained by this directory, or an empty
+     *         list if this is not a directory.
+     */
+    List<IFile> listFiles(FileFilter filter);
+
+    /**
+     * Returns the pparent of this file.
+     *
+     * @return this file's parent or null if it does not have it.
+     */
+    IFile getParent();
+
+    /**
+     * Returns the document wrapped by this IFile as a local file. The result
+     * for a directory is not defined.
+     *
+     * @return local file containing the document wrapped by this object.
+     */
+    File getDocument();
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
new file mode 100644
index 0000000..8e21182
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsProvider.java
@@ -0,0 +1,33 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage.local;
+
+import java.net.URI;
+
+import org.libreoffice.storage.IDocumentProvider;
+import org.libreoffice.storage.IFile;
+
+import android.os.Environment;
+
+/**
+ * Implementation of IDocumentProvider for the local file system.
+ */
+public class LocalDocumentsProvider implements IDocumentProvider {
+
+    @Override
+    public IFile getRootDirectory() {
+        return new LocalFile(Environment.getExternalStorageDirectory());
+    }
+
+    @Override
+    public IFile createFromUri(URI uri) {
+        return new LocalFile(uri);
+    }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java
new file mode 100644
index 0000000..797d909
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalFile.java
@@ -0,0 +1,86 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.storage.local;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.libreoffice.storage.IFile;
+
+/**
+ * Implementation of IFile for the local file system.
+ */
+public class LocalFile implements IFile {
+
+    private File file;
+
+    public LocalFile(File file) {
+        this.file = file;
+    }
+
+    public LocalFile(URI uri) {
+        this.file = new File(uri);
+    }
+
+    public URI getUri() {
+        return file.toURI();
+    }
+
+    public String getName() {
+        return file.getName();
+    }
+
+    @Override
+    public boolean isDirectory() {
+        return file.isDirectory();
+    }
+
+    @Override
+    public long getSize() {
+        return file.length();
+    }
+
+    @Override
+    public Date getLastModified() {
+        return new Date(file.lastModified());
+    }
+
+    @Override
+    public List<IFile> listFiles() {
+        List<IFile> children = new ArrayList<IFile>();
+        for (File child : file.listFiles()) {
+            children.add(new LocalFile(child));
+        }
+        return children;
+    }
+
+    @Override
+    public List<IFile> listFiles(FileFilter filter) {
+        List<IFile> children = new ArrayList<IFile>();
+        for (File child : file.listFiles(filter)) {
+            children.add(new LocalFile(child));
+        }
+        return children;
+    }
+
+    @Override
+    public IFile getParent() {
+        return new LocalFile(file.getParentFile());
+    }
+
+    @Override
+    public File getDocument() {
+        return file;
+    }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java
index d0470e7..64eebc1 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java
@@ -10,11 +10,13 @@
 package org.libreoffice.ui;
 
 import org.libreoffice.R;
+import org.libreoffice.storage.IFile;
 
 
 import java.io.File;
 import java.nio.ByteBuffer;
 import java.nio.IntBuffer;
+import java.util.List;
 
 import android.content.Context;
 import android.util.Log;
@@ -33,25 +35,26 @@ import android.graphics.Color;
 
 public class GridItemAdapter extends BaseAdapter {
     Context mContext;
-    File[] filePaths;
-    File currentDirectory;
+    List<IFile> filePaths;
+    IFile currentDirectory;
     String TAG = "GridItemAdapter";
 
-    public GridItemAdapter(Context mContext, File[] filePaths) {
+    public GridItemAdapter(Context mContext, List<IFile> filePaths) {
         this.mContext = mContext;
         this.filePaths = filePaths;
-        for(File fn : filePaths){
+        for (IFile fn : filePaths) {
             Log.d(TAG, fn.getName());
         }
     }
 
-    public GridItemAdapter(Context mContext, File currentDirectory) {
+    public GridItemAdapter(Context mContext, IFile currentDirectory) {
         this.mContext = mContext;
         this.currentDirectory = currentDirectory;
         filePaths = currentDirectory.listFiles();
     }
 
-    public GridItemAdapter(Context mContext, File currentDirectory, File[] filteredFiles)
+    public GridItemAdapter(Context mContext, IFile currentDirectory,
+            List<IFile> filteredFiles)
     {
         this.mContext = mContext;
         this.currentDirectory = currentDirectory;
@@ -59,7 +62,7 @@ public class GridItemAdapter extends BaseAdapter {
     }
 
     public int getCount() {
-        return filePaths.length;
+        return filePaths.size();
     }
 
     public Object getItem(int position) {
@@ -90,11 +93,11 @@ public class GridItemAdapter extends BaseAdapter {
         // set value into textview
         TextView textView = (TextView) gridView
             .findViewById(R.id.grid_item_label);
-        textView.setText(filePaths[position].getName());
+        textView.setText(filePaths.get(position).getName());
         // set image based on selected text
         ImageView imageView = (ImageView) gridView
             .findViewById(R.id.grid_item_image);
-        if( filePaths[position].isDirectory() ) // Is a folder
+        if (filePaths.get(position).isDirectory()) // Is a folder
         {
             // Default view is a generic folder icon.
             imageView.setImageResource(R.drawable.folder);
@@ -102,13 +105,14 @@ public class GridItemAdapter extends BaseAdapter {
             gridView =  inflater.inflate(R.layout.file_explorer_folder_icon, null);
             org.libreoffice.ui.FolderIconView icon =
                 (org.libreoffice.ui.FolderIconView)gridView.findViewById(R.id.folder_icon);
-            icon.setDir( filePaths[position]);
+            // icon.setDir( filePaths[position]);
             textView = (TextView) gridView.findViewById(R.id.grid_item_label);
-            textView.setText(filePaths[position].getName());
+            textView.setText(filePaths.get(position).getName());
             return gridView;
         }
         else
         {
+            /*
             File thumbnailFile = new File( filePaths[position].getParent() , "."
                     + filePaths[position].getName().split("[.]")[0] + ".png");
             BitmapFactory factory = new BitmapFactory();
@@ -118,13 +122,16 @@ public class GridItemAdapter extends BaseAdapter {
             }else{
                 Log.i( "GRID" , thumbnailFile.getAbsolutePath() );
             }
-            switch (FileUtilities.getType(filePaths[position].getName()))
+            */
+            switch (FileUtilities.getType(filePaths.get(position).getName()))
             {
                 case FileUtilities.DOC:
+                    /*
                     if( thumb != null){
                         imageView.setImageBitmap( thumb );
                         break;
                     }
+                    */
                     imageView.setImageResource(R.drawable.writer);
                     break;
                 /*case FileUtilities.CALC:
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 0c9668d..8bb64f3 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -12,12 +12,17 @@ package org.libreoffice.ui;
 import org.libreoffice.R;
 import org.libreoffice.LOAbout;
 import org.libreoffice.android.Bootstrap;
+import org.libreoffice.storage.IDocumentProvider;
+import org.libreoffice.storage.IFile;
+import org.libreoffice.storage.local.LocalDocumentsProvider;
 
 import java.io.File;
 import java.io.FileFilter;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 import java.util.prefs.Preferences;
 
 import android.graphics.drawable.BitmapDrawable;
@@ -58,17 +63,22 @@ import android.widget.ListView;
 import android.widget.SpinnerAdapter;
 import android.widget.TextView;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNavigationListener {
     private String tag = "file_manager";
     private SharedPreferences prefs;
-    private File homeDirectory;
-    private File currentDirectory;
     private int filterMode = FileUtilities.ALL;
     private int viewMode;
     private int sortMode;
 
     FileFilter fileFilter;
-    private File[] filePaths;
+    FilenameFilter filenameFilter;
+    private List<IFile> filePaths;
+    private IDocumentProvider documentProvider = new LocalDocumentsProvider();
+    private IFile homeDirectory;
+    private IFile currentDirectory;
 
     private static final String CURRENT_DIRECTORY_KEY = "CURRENT_DIRECTORY";
     private static final String FILTER_MODE_KEY = "FILTER_MODE";
@@ -92,7 +102,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         super.onCreate(savedInstanceState);
         Log.d(tag, "onCreate - tweaked - meeks !");
         //Set the "home" - top level - directory.
-        homeDirectory  = Environment.getExternalStorageDirectory();
+        homeDirectory = documentProvider.getRootDirectory();
         currentDirectory = homeDirectory;
         //Load default settings
 
@@ -135,7 +145,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
             // code to make a grid view
             setContentView(R.layout.file_grid);
             gv = (GridView)findViewById(R.id.file_explorer_grid_view);
-            filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
+            filePaths = currentDirectory.listFiles(FileUtilities.getFileFilter(filterMode));
             gv.setOnItemClickListener(new OnItemClickListener() {
                 public void onItemClick(AdapterView<?> parent, View view,
                     int position, long id) {
@@ -149,7 +159,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
             setContentView(R.layout.file_list);
             lv = (ListView)findViewById( R.id.file_explorer_list_view);
             lv.setClickable(true);
-            filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
+            filePaths = currentDirectory.listFiles(FileUtilities.getFileFilter(filterMode));
             lv.setAdapter( new ListItemAdapter(getApplicationContext(), filePaths) );
             actionBar.setSelectedNavigationItem( filterMode + 1 );
             registerForContextMenu(lv);
@@ -181,7 +191,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         }
     }
 
-    public void openDirectory(File dir ){
+    public void openDirectory(IFile dir) {
         currentDirectory = dir;
         if( !currentDirectory.equals( homeDirectory )){
             ActionBar actionBar = getActionBar();
@@ -190,8 +200,8 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
             ActionBar actionBar = getActionBar();
             actionBar.setDisplayHomeAsUpEnabled( false );
         }
-        filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
-        FileUtilities.sortFiles( filePaths, sortMode );
+        filePaths = currentDirectory.listFiles(FileUtilities.getFileFilter(filterMode));
+        // FileUtilities.sortFiles( filePaths, sortMode );
         /*
            for( int i = 0; i < fileNames.length; i++){
            fileNames[ i ] = filePaths[ i ].getName();
@@ -208,7 +218,8 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         }
     }
 
-    public void open(File file) {
+    public void open(IFile document) {
+        File file = document.getDocument();
         Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
         i.setComponent(new ComponentName(
                     "org.libreoffice",
@@ -217,7 +228,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     }
 
     private void open(int position) {
-        File file = filePaths[position];
+        IFile file = filePaths.get(position);
         if (!file.isDirectory()) {
             open(file);
         } else {
@@ -226,7 +237,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     }
 
     private void share(int position) {
-        File file = filePaths[position];
+        File file = filePaths.get(position).getDocument();
         Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
         Uri uri = Uri.fromFile(file);
         String extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString());
@@ -259,7 +270,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         switch (item.getItemId()) {
             case android.R.id.home:
                 if( !currentDirectory.equals( homeDirectory ) ){
-                    openDirectory( currentDirectory.getParentFile() );
+                    openDirectory(currentDirectory.getParent());
                 }
                 break;
             case R.id.menu_view_toggle:
@@ -336,7 +347,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
     protected void onSaveInstanceState(Bundle outState) {
         // TODO Auto-generated method stub
         super.onSaveInstanceState(outState);
-        outState.putString( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
+        outState.putString(CURRENT_DIRECTORY_KEY, currentDirectory.getUri().toString());
         outState.putInt( FILTER_MODE_KEY , filterMode );
         outState.putInt( EXPLORER_VIEW_TYPE_KEY , viewMode );
 
@@ -352,7 +363,12 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         if( savedInstanceState.isEmpty() ){
             return;
         }
-        currentDirectory = new File( savedInstanceState.getString( CURRENT_DIRECTORY_KEY ) );
+        try {
+            currentDirectory = documentProvider.createFromUri(new URI(
+                    savedInstanceState.getString(CURRENT_DIRECTORY_KEY)));
+        } catch (URISyntaxException e) {
+            currentDirectory = documentProvider.getRootDirectory();
+        }
         filterMode = savedInstanceState.getInt( FILTER_MODE_KEY , FileUtilities.ALL ) ;
         viewMode = savedInstanceState.getInt( EXPLORER_VIEW_TYPE_KEY , GRID_VIEW );
         //openDirectory( currentDirectory );
@@ -374,7 +390,12 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
         readPreferences();// intent values take precedence over prefs?
         Intent i = this.getIntent();
         if( i.hasExtra( CURRENT_DIRECTORY_KEY ) ){
-            currentDirectory = new File( i.getStringExtra( CURRENT_DIRECTORY_KEY ) );
+            try {
+                currentDirectory = documentProvider.createFromUri(new URI(
+                        i.getStringExtra(CURRENT_DIRECTORY_KEY)));
+            } catch (URISyntaxException e) {
+                currentDirectory = documentProvider.getRootDirectory();
+            }
             Log.d(tag, CURRENT_DIRECTORY_KEY);
         }
         if( i.hasExtra( FILTER_MODE_KEY ) ){
@@ -423,18 +444,17 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
     class ListItemAdapter implements ListAdapter{
         private Context mContext;
-        private File[] filePaths;
+        private List<IFile> filePaths;
         private final long KB = 1024;
         private final long MB = 1048576;
 
-        public ListItemAdapter(Context mContext, File[] filePaths) {
+        public ListItemAdapter(Context mContext, List<IFile> filePaths) {
             this.mContext = mContext;
             this.filePaths = filePaths;
         }
 
         public int getCount() {
-            // TODO Auto-generated method stub
-            return filePaths.length;
+            return filePaths.size();
         }
 
         public Object getItem(int arg0) {
@@ -487,13 +507,13 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
             // set value into textview
             TextView filename = (TextView) listItem.findViewById(R.id.file_list_item_name);
-            filename.setText( filePaths[ position ].getName() );
+            filename.setText(filePaths.get(position).getName());
             //filename.setClickable(true);
 
             TextView fileSize = (TextView) listItem.findViewById(R.id.file_list_item_size);
             //TODO Give size in KB , MB as appropriate.
             String size = "0B";
-            long length = filePaths[ position ].length();
+            long length = filePaths.get(position).getSize();
             if( length < KB ){
                 size = Long.toString( length ) + "B";
             }
@@ -508,13 +528,13 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
             TextView fileDate = (TextView) listItem.findViewById(R.id.file_list_item_date);
             SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy hh:ss");
-            Date date = new Date( filePaths[ position ].lastModified() );
+            Date date = filePaths.get(position).getLastModified();
             //TODO format date
             fileDate.setText( df.format( date ) );
 
             // set image based on selected text
             ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon);
-            switch (FileUtilities.getType(filePaths[position].getName()))
+            switch (FileUtilities.getType(filePaths.get(position).getName()))
             {
                 case FileUtilities.DOC:
                     imageView.setImageResource(R.drawable.writer);
@@ -531,7 +551,7 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
                 default:
                     break;
             }
-            if( filePaths[position].isDirectory() ){
+            if (filePaths.get(position).isDirectory()) {
                 //Eventually have thumbnails of each sub file on a black circle
                 //For now just a folder icon
                 imageView.setImageResource(R.drawable.folder);
commit 4bb76ebfb81cd2f5da89dd9f35b035f687424b15
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Fri Dec 5 12:45:14 2014 +0000

    Android: remove unnecessary openDirectory call from onResume.
    
    The call to createUI already performs all the actions done by
    openDirectory, there is no need to call it again.
    
    Change-Id: I7f900a23a4f85b627b7132dd6eb54b6e98e7edb6

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 61f8450..0c9668d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -369,7 +369,6 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
 
     @Override
     protected void onResume() {
-        // TODO Auto-generated method stub
         super.onResume();
         Log.d(tag, "onResume");
         readPreferences();// intent values take precedence over prefs?
@@ -387,7 +386,6 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
             Log.d(tag, EXPLORER_VIEW_TYPE_KEY);
         }
         createUI();
-        openDirectory( currentDirectory );
     }
 
     @Override


More information about the Libreoffice-commits mailing list