[Libreoffice-commits] core.git: Branch 'distro/collabora/viewer2' - 13 commits - android/CustomTarget_lo_android.mk android/experimental

Siqi Liu me at siqi.fr
Fri Apr 24 01:10:41 PDT 2015


 android/CustomTarget_lo_android.mk                                                                          |    2 
 android/experimental/LOAndroid3/res/layout/file_list_item.xml                                               |   24 -
 android/experimental/LOAndroid3/res/menu/view_menu.xml                                                      |    4 
 android/experimental/LOAndroid3/res/values/strings.xml                                                      |    6 
 android/experimental/LOAndroid3/res/values/themes.xml                                                       |    6 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java                       |    2 
 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java |    3 
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java                              |  205 ++++------
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java                             |  124 +++---
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java                            |   34 -
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java                      |  166 ++++----
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java                            |  178 --------
 12 files changed, 292 insertions(+), 462 deletions(-)

New commits:
commit 14bf4870120857eca5ae4f6da15899418f6bc9a3
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 15:22:31 2015 +0200

    intent preference overrides default prefs.
    
    Change-Id: I315d283f6c000d971421a098264e9c594930283e

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 fd08574..938a259 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -501,6 +501,27 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         sortMode = prefs.getInt(SORT_MODE_KEY, FileUtilities.SORT_AZ);
         SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
         filterMode = Integer.valueOf(defaultPrefs.getString(FILTER_MODE_KEY , "-1"));
+
+        Intent i = this.getIntent();
+        if (i.hasExtra(CURRENT_DIRECTORY_KEY)) {
+            try {
+                currentDirectory = documentProvider.createFromUri(new URI(
+                        i.getStringExtra(CURRENT_DIRECTORY_KEY)));
+            } catch (URISyntaxException e) {
+                currentDirectory = documentProvider.getRootDirectory();
+            }
+            Log.d(LOGTAG, CURRENT_DIRECTORY_KEY);
+        }
+
+        if (i.hasExtra(FILTER_MODE_KEY)) {
+            filterMode = i.getIntExtra( FILTER_MODE_KEY, FileUtilities.ALL);
+            Log.d(LOGTAG, FILTER_MODE_KEY);
+        }
+
+        if (i.hasExtra(EXPLORER_VIEW_TYPE_KEY)) {
+            viewMode = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+            Log.d(LOGTAG, EXPLORER_VIEW_TYPE_KEY);
+        }
     }
 
     @Override
commit 1ef31fdf5eabd3c4b14d828021652d53da054c66
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 15:19:28 2015 +0200

    load default prefs once and use new sortmode/filter mode on refresh.
    
    Change-Id: I54c3e25e960ade172eeb0f4bf24104b3b06e2ee2

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 3c269bf..fd08574 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,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         DocumentProviderFactory.initialize(this);
         documentProviderFactory = DocumentProviderFactory.getInstance();
 
+        readPreferences();
         // init UI and populate with contents from the provider
         createUI();
         switchToDocumentProvider(documentProviderFactory.getDefaultProvider());
@@ -496,11 +497,10 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
 
     public void readPreferences(){
         prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
-        viewMode = prefs.getInt( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
-        sortMode = prefs.getInt( SORT_MODE_KEY, FileUtilities.SORT_AZ );
-        SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences( getBaseContext() );
-        filterMode = Integer.valueOf( defaultPrefs.getString( FILTER_MODE_KEY , "-1") );
-        sortMode = Integer.valueOf( defaultPrefs.getString( SORT_MODE_KEY , "-1") );
+        viewMode = prefs.getInt(EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+        sortMode = prefs.getInt(SORT_MODE_KEY, FileUtilities.SORT_AZ);
+        SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
+        filterMode = Integer.valueOf(defaultPrefs.getString(FILTER_MODE_KEY , "-1"));
     }
 
     @Override
@@ -547,25 +547,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
     protected void onResume() {
         super.onResume();
         Log.d(LOGTAG, "onResume");
-        readPreferences();// intent values take precedence over prefs?
-        Intent i = this.getIntent();
-        if( i.hasExtra( CURRENT_DIRECTORY_KEY ) ){
-            try {
-                currentDirectory = documentProvider.createFromUri(new URI(
-                        i.getStringExtra(CURRENT_DIRECTORY_KEY)));
-            } catch (URISyntaxException e) {
-                currentDirectory = documentProvider.getRootDirectory();
-            }
-            Log.d(LOGTAG, CURRENT_DIRECTORY_KEY);
-        }
-        if( i.hasExtra( FILTER_MODE_KEY ) ){
-            filterMode = i.getIntExtra( FILTER_MODE_KEY, FileUtilities.ALL);
-            Log.d(LOGTAG, FILTER_MODE_KEY);
-        }
-        if( i.hasExtra( EXPLORER_VIEW_TYPE_KEY ) ){
-            viewMode = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
-            Log.d(LOGTAG, EXPLORER_VIEW_TYPE_KEY);
-        }
+        Log.d(LOGTAG, "sortMode="+ sortMode + " filterMode=" + filterMode);
         createUI();
     }
 
commit 9acf5a678e20837db0ab20d145d0ba48c9e6c2fb
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 15:18:23 2015 +0200

    Use switch... and effectively sorts before listing.
    
    Change-Id: Ia7eb2c53dc8a69b3d65e56afc7a27f0548c63d07

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 9c58750..b8bb7e9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
@@ -10,11 +10,14 @@ package org.libreoffice.ui;
 
 import org.libreoffice.R;
 
+import org.libreoffice.storage.IFile;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.FilenameFilter;
 import java.util.Map;
-import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 import java.util.HashMap;
 import java.util.Comparator;
 import android.util.Log;
@@ -198,55 +201,52 @@ public class FileUtilities {
         };
     }
 
-    static void sortFiles(File[] files, int sortMode) {
-        // Should really change all this to a switch statement...
-        if (sortMode == SORT_AZ) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return lhs.getName().compareTo(rhs.getName());
-                }
-            });
-            return;
-        }
-        if (sortMode == SORT_ZA) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return rhs.getName().compareTo(lhs.getName());
-                }
-            });
-            return;
-        }
-        if (sortMode == SORT_OLDEST) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return Long.valueOf(lhs.lastModified()).compareTo(rhs.lastModified());
-                }
-            });
-            return;
-        }
-        if (sortMode == SORT_NEWEST) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return Long.valueOf(rhs.lastModified()).compareTo(lhs.lastModified());
-                }
-            });
-            return;
-        }
-        if (sortMode == SORT_LARGEST) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return Long.valueOf(rhs.length()).compareTo(lhs.length());
-                }
-            });
-            return;
-        }
-        if (sortMode == SORT_SMALLEST) {
-            Arrays.sort(files , new Comparator<File>() {
-                public int compare(File lhs, File rhs) {
-                    return Long.valueOf(lhs.length()).compareTo(rhs.length());
-                }
-            });
-            return;
+    static void sortFiles(List<IFile> files, int sortMode) {
+        switch (sortMode) {
+            case SORT_AZ:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return lhs.getName().compareTo(rhs.getName());
+                    }
+                });
+                break;
+            case SORT_ZA:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return rhs.getName().compareTo(lhs.getName());
+                    }
+                });
+                break;
+            case SORT_OLDEST:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return lhs.getLastModified().compareTo(rhs.getLastModified());
+                    }
+                });
+                break;
+            case SORT_NEWEST:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return rhs.getLastModified().compareTo(lhs.getLastModified());
+                    }
+                });
+                break;
+            case SORT_LARGEST:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return Long.valueOf(rhs.getSize()).compareTo(lhs.getSize());
+                    }
+                });
+                break;
+            case SORT_SMALLEST:
+                Collections.sort(files , new Comparator<IFile>() {
+                    public int compare(IFile lhs, IFile rhs) {
+                        return Long.valueOf(lhs.getSize()).compareTo(rhs.getSize());
+                    }
+                });
+                break;
+            default:
+                Log.e(LOGTAG, "uncatched sortMode: " + sortMode);
         }
         return;
     }
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 229c619..3c269bf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -177,6 +177,8 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         } else {
             getSupportActionBar().setDisplayHomeAsUpEnabled(false);
         }
+
+        FileUtilities.sortFiles(filePaths, sortMode);
         // refresh view
         if (viewMode == GRID_VIEW) {
             gv.setAdapter(new GridItemAdapter(getApplicationContext(),
commit b4efa1b28a01fb42ceca5a185c140ae0f8bdcc32
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 15:17:54 2015 +0200

    Formatting for consistency
    
    Change-Id: Ifd153869c965ffa33640e23e9794defaa57dba0b

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 79ef341..229c619 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -131,7 +131,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
 
         LinearLayout content = (LinearLayout) findViewById(R.id.browser_main_content);
 
-        if( viewMode == GRID_VIEW){
+        if (viewMode == GRID_VIEW) {
             // code to make a grid view
             getLayoutInflater().inflate(R.layout.file_grid, content);
             gv = (GridView)findViewById(R.id.file_explorer_grid_view);
@@ -141,13 +141,13 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
                     open(position);
                 }
             });
-            actionBar.setSelectedNavigationItem( filterMode + 1 );//This triggers the listener which modifies the view.
+            actionBar.setSelectedNavigationItem(filterMode + 1);//This triggers the listener which modifies the view.
             registerForContextMenu(gv);
-        }else{
+        } else {
             getLayoutInflater().inflate(R.layout.file_list, content);
-            lv = (ListView)findViewById( R.id.file_explorer_list_view);
+            lv = (ListView)findViewById(R.id.file_explorer_list_view);
             lv.setClickable(true);
-            actionBar.setSelectedNavigationItem( filterMode + 1 );
+            actionBar.setSelectedNavigationItem(filterMode + 1);
             registerForContextMenu(lv);
         }
 
@@ -168,7 +168,6 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
                         .getProvider(position));
             }
         });
-
     }
 
     private void refreshView() {
@@ -393,33 +392,54 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         inflater.inflate(R.menu.view_menu, menu);
 
         MenuItem item = (MenuItem)menu.findItem(R.id.menu_view_toggle);
-        if( viewMode == GRID_VIEW){
+        if (viewMode == GRID_VIEW) {
             item.setTitle(R.string.list_view);
-            item.setIcon( R.drawable.light_view_as_list );
-        }else{
+            item.setIcon(R.drawable.light_view_as_list);
+        } else {
             item.setTitle(R.string.grid_view);
-            item.setIcon( R.drawable.light_view_as_grid );
+            item.setIcon(R.drawable.light_view_as_grid);
         }
+
+        item = (MenuItem)menu.findItem(R.id.menu_sort_size);
+        if (sortMode == FileUtilities.SORT_LARGEST) {
+            item.setTitle(R.string.sort_smallest);
+        } else {
+            item.setTitle(R.string.sort_largest);
+        }
+
+        item = (MenuItem)menu.findItem(R.id.menu_sort_az);
+        if (sortMode == FileUtilities.SORT_AZ) {
+            item.setTitle(R.string.sort_za);
+        } else {
+            item.setTitle(R.string.sort_az);
+        }
+
+        item = (MenuItem)menu.findItem(R.id.menu_sort_modified);
+        if (sortMode == FileUtilities.SORT_NEWEST) {
+            item.setTitle(R.string.sort_oldest);
+        } else {
+            item.setTitle(R.string.sort_newest);
+        }
+
         return true;
     }
 
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case android.R.id.home:
-                if( !currentDirectory.equals( homeDirectory ) ){
+                if (!currentDirectory.equals(homeDirectory)){
                     openParentDirectory();
                 }
                 break;
             case R.id.menu_view_toggle:
-                if( viewMode == GRID_VIEW){
+                if (viewMode == GRID_VIEW){
                     viewMode = LIST_VIEW;
-                    item.setTitle(R.string.grid_view);//Button points to next view.
-                    item.setIcon( R.drawable.light_view_as_grid );
-
-                }else{
+                    item.setTitle(R.string.grid_view); // Button points to next view.
+                    item.setIcon(R.drawable.light_view_as_grid);
+                } else {
                     viewMode = GRID_VIEW;
-                    item.setTitle(R.string.list_view);//Button points to next view.
-                    item.setIcon( R.drawable.light_view_as_list );
+                    item.setTitle(R.string.list_view); // Button points to next view.
+                    item.setIcon(R.drawable.light_view_as_list);
                 }
                 createUI();
                 break;
@@ -486,10 +506,10 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         // TODO Auto-generated method stub
         super.onSaveInstanceState(outState);
         outState.putString(CURRENT_DIRECTORY_KEY, currentDirectory.getUri().toString());
-        outState.putInt( FILTER_MODE_KEY , filterMode );
-        outState.putInt( EXPLORER_VIEW_TYPE_KEY , viewMode );
+        outState.putInt(FILTER_MODE_KEY , filterMode);
+        outState.putInt(EXPLORER_VIEW_TYPE_KEY , viewMode);
 
-        Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewMode) );
+        Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode) + Integer.toString(viewMode));
         //prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
         Log.d(LOGTAG, "savedInstanceSate");
     }
@@ -498,7 +518,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
     protected void onRestoreInstanceState(Bundle savedInstanceState) {
         // TODO Auto-generated method stub
         super.onRestoreInstanceState(savedInstanceState);
-        if( savedInstanceState.isEmpty() ){
+        if (savedInstanceState.isEmpty()){
             return;
         }
         try {
@@ -507,11 +527,11 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         } 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 );
+        filterMode = savedInstanceState.getInt(FILTER_MODE_KEY , FileUtilities.ALL) ;
+        viewMode = savedInstanceState.getInt(EXPLORER_VIEW_TYPE_KEY , GRID_VIEW);
+        //openDirectory(currentDirectory);
         Log.d(LOGTAG, "onRestoreInstanceState");
-        Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewMode) );
+        Log.d(LOGTAG, currentDirectory.toString() + Integer.toString(filterMode) + Integer.toString(viewMode));
     }
 
     @Override
@@ -567,11 +587,11 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
 
     public boolean onNavigationItemSelected(int itemPosition, long itemId) {
         filterMode = itemPosition -1; //bit of a hack, I know. -1 is ALL 0 Docs etc
-        openDirectory( currentDirectory );// Uses filter mode
+        openDirectory(currentDirectory);// Uses filter mode
         return true;
     }
 
-    private int dpToPx( int dp ){
+    private int dpToPx(int dp){
         final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
         return (int) (dp * scale + 0.5f);
     }
@@ -645,23 +665,23 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
             //TODO Give size in KB , MB as appropriate.
             String size = "0B";
             long length = filePaths.get(position).getSize();
-            if( length < KB ){
-                size = Long.toString( length ) + "B";
+            if (length < KB){
+                size = Long.toString(length) + "B";
             }
-            if( length >= KB && length < MB){
-                size = Long.toString( length/KB ) + "KB";
+            if (length >= KB && length < MB){
+                size = Long.toString(length/KB) + "KB";
             }
-            if( length >= MB){
-                size = Long.toString( length/MB ) + "MB";
+            if (length >= MB){
+                size = Long.toString(length/MB) + "MB";
             }
-            fileSize.setText( size );
+            fileSize.setText(size);
             //fileSize.setClickable(true);
 
             TextView fileDate = (TextView) listItem.findViewById(R.id.file_list_item_date);
             SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy hh:ss");
             Date date = filePaths.get(position).getLastModified();
             //TODO format date
-            fileDate.setText( df.format( date ) );
+            fileDate.setText(df.format(date));
 
             // set image based on selected text
             ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon);
commit 580ef90e510fd50870c17a225bf5aac1a96f188d
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 15:16:24 2015 +0200

    Set correct title for sort mode after changes.
    
    Change-Id: I4f75f5ee68de6ed6f3b07d93b3681aa2307cb2dc

diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index ffce3d8..66934e0 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -17,6 +17,12 @@
     <string name="menu_search">Search</string>
     <string name="list_view">List</string>
     <string name="grid_view">Grid</string>
+    <string name="sort_smallest">Smallest first</string>
+    <string name="sort_largest">Largest first</string>
+    <string name="sort_az">A-Z</string>
+    <string name="sort_za">Z-A</string>
+    <string name="sort_oldest">Oldest first</string>
+    <string name="sort_newest">Newest first</string>
     <string name="menu_sort_size">Sort By Size</string>
     <string name="menu_sort_az">Sort A-Z</string>
     <string name="menu_sort_modified">Sort by Date</string>
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 e41846b..79ef341 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -437,28 +437,33 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
         return true;
     }
 
-    @SuppressWarnings("unused")//see android:onClick properties in view_menu.xml
     public void sortFiles(MenuItem item){
-        switch ( item.getItemId() ) {
+        switch (item.getItemId()) {
             case R.id.menu_sort_az:
-                if( sortMode == FileUtilities.SORT_AZ ){
+                if (sortMode == FileUtilities.SORT_AZ){
                     sortMode = FileUtilities.SORT_ZA;
-                }else{
+                    item.setTitle(R.string.sort_az);
+                } else {
                     sortMode = FileUtilities.SORT_AZ;
+                    item.setTitle(R.string.sort_za);
                 }
                 break;
             case R.id.menu_sort_modified:
-                if( sortMode == FileUtilities.SORT_NEWEST ){
+                if (sortMode == FileUtilities.SORT_NEWEST){
                     sortMode = FileUtilities.SORT_OLDEST;
-                }else{
+                    item.setTitle(R.string.sort_newest);
+                } else {
                     sortMode = FileUtilities.SORT_NEWEST;
+                    item.setTitle(R.string.sort_oldest);
                 }
                 break;
             case R.id.menu_sort_size:
-                if( sortMode == FileUtilities.SORT_LARGEST ){
+                if (sortMode == FileUtilities.SORT_LARGEST){
                     sortMode = FileUtilities.SORT_SMALLEST;
-                }else{
+                    item.setTitle(R.string.sort_largest);
+                } else {
                     sortMode = FileUtilities.SORT_LARGEST;
+                    item.setTitle(R.string.sort_smallest);
                 }
                 break;
             default:
commit 286132bcbdfe8799c58b28deffe55e8646ecf0e7
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 13:48:39 2015 +0200

    Remove unimplemented search functionality
    
    Change-Id: I955bec2c94c386ee18fff8e8f5d90a7a90edf9d2

diff --git a/android/experimental/LOAndroid3/res/menu/view_menu.xml b/android/experimental/LOAndroid3/res/menu/view_menu.xml
index 81a3aa5..37a39b1 100644
--- a/android/experimental/LOAndroid3/res/menu/view_menu.xml
+++ b/android/experimental/LOAndroid3/res/menu/view_menu.xml
@@ -2,10 +2,6 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <item android:id="@+id/menu_search"
-          android:icon="@drawable/action_search"
-          app:showAsAction="always" />
-
     <item android:id="@+id/menu_view_toggle"
           android:title="@string/grid_view"/>
     <item android:id="@+id/menu_sort_size"
commit b49efc24bcc9c686077e9de7b44e909a6e443842
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 13:46:49 2015 +0200

    formatting for consistancy and remove unused file.
    
    TODO(siqi): try to refactor the ListItemAdapter to a separate file later.
    
    Change-Id: I01b82d1fea65cda353d5bb08da42e2faf1c8cf13

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 9650fa5..9c58750 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
@@ -22,7 +22,7 @@ import android.webkit.MimeTypeMap;
 
 public class FileUtilities {
 
-    private String LOGTAG = FileUtilities.class.getSimpleName();
+    private static String LOGTAG = FileUtilities.class.getSimpleName();
 
     static final int ALL = -1;
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
index c689ba1..1c2b25f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
@@ -27,7 +27,7 @@ import java.io.File;
 import java.util.Stack;
 
 public class FolderIconView extends View{
-    private String TAG = "FolderIconView";
+    private String LOGTAG = "FolderIconView";
 
     private Paint mPaintBlack;
     private Paint mPaintGray;
@@ -69,7 +69,7 @@ public class FolderIconView extends View{
     @Override
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
-        Log.d(TAG, "onDraw");
+        Log.d(LOGTAG, "onDraw");
         //float width = (float)canvas.getWidth();
         //float height = (float)canvas.getHeight();
         float width = (float) this.getWidth();
@@ -83,7 +83,7 @@ public class FolderIconView extends View{
         float DZx = 0.2f*outerRadius;
         float DZy = 0.2f*outerRadius;
         //Bitmap blankPage = BitmapFactory.decodeResource(getResources(), R.drawable.page);
-        Log.i(TAG, Float.toString(width) + "x" + Float.toString(height));
+        Log.i(LOGTAG, Float.toString(width) + "x" + Float.toString(height));
         canvas.drawCircle(centerX, centerY, outerRadius, mPaintGray);
         canvas.drawCircle(centerX, centerY, innerRadius, mPaintBlack);
         //Either get thumbs from directory or use generic page images
@@ -107,7 +107,7 @@ public class FolderIconView extends View{
         /*while(thumbs.size() < 4) {// padd out with blanks?
             thumbs.push(blankPage);
         }*/
-        Log.i(TAG, Integer.toString(thumbs.size()));
+        Log.i(LOGTAG, Integer.toString(thumbs.size()));
         //should handle empty folders better
         //  options:
         //      don't show?
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 fd4d7b2..c50d3a3 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/GridItemAdapter.java
@@ -37,28 +37,14 @@ public class GridItemAdapter extends BaseAdapter {
     Context mContext;
     List<IFile> filePaths;
     IFile currentDirectory;
-    String TAG = "GridItemAdapter";
-
-    public GridItemAdapter(Context mContext, List<IFile> filePaths) {
-        this.mContext = mContext;
-        this.filePaths = filePaths;
-        for (IFile fn : filePaths) {
-            Log.d(TAG, fn.getName());
-        }
-    }
-
-    public GridItemAdapter(Context mContext, IFile currentDirectory) {
-        this.mContext = mContext;
-        this.currentDirectory = currentDirectory;
-        filePaths = currentDirectory.listFiles();
-    }
+    String LOGTAG = "GridItemAdapter";
 
     public GridItemAdapter(Context mContext, IFile currentDirectory,
-            List<IFile> filteredFiles)
-    {
+            List<IFile> filteredFiles) {
         this.mContext = mContext;
         this.currentDirectory = currentDirectory;
         filePaths = filteredFiles;
+        Log.d(LOGTAG, "currentDirectory.getName(): " + currentDirectory.getName());
     }
 
     public int getCount() {
@@ -66,7 +52,7 @@ public class GridItemAdapter extends BaseAdapter {
     }
 
     public Object getItem(int position) {
-        return null;//filePaths[ position ];
+        return null; //filePaths[ position ];
     }
 
     public long getItemId(int position) {
@@ -74,8 +60,7 @@ public class GridItemAdapter extends BaseAdapter {
         return 0;
     }
 
-    public View getView(int position, View convertView, ViewGroup parent)
-    {
+    public View getView(int position, View convertView, ViewGroup parent) {
         LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
 
@@ -97,13 +82,10 @@ public class GridItemAdapter extends BaseAdapter {
         // set image based on selected text
         ImageView imageView = (ImageView) gridView
             .findViewById(R.id.grid_item_image);
-        if (filePaths.get(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);
-        }
-        else
-        {
+        } else {
             /*
             File thumbnailFile = new File( filePaths[position].getParent() , "."
                     + filePaths[position].getName().split("[.]")[0] + ".png");
@@ -141,7 +123,7 @@ public class GridItemAdapter extends BaseAdapter {
         return gridView;
     }
 
-    public void update(){
+    public void update() {
         this.notifyDataSetChanged();
     }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java
deleted file mode 100644
index 2f91b4f..0000000
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- 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.ui;
-
-import org.libreoffice.R;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import android.content.Context;
-import android.database.DataSetObserver;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.View.OnClickListener;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.TextView;
-
-/*Currently this is class is not used but instead is implemented as an inner class in LibreOfficeUI.
- * This is because I can't get the onItemClickListener to fire on the listview so I need to set an
- * onClick listener in the adapter. ( I've tried turning off the focusability etc of the listitem
- * contents but no dice...) */
-public class ListItemAdapter implements ListAdapter{
-    private Context mContext;
-    private File[] filePaths;
-    private final long KB = 1024;
-    private final long MB = 1048576;
-
-    public ListItemAdapter(Context mContext, File[] filePaths) {
-        this.mContext = mContext;
-        this.filePaths = filePaths;
-    }
-
-    public int getCount() {
-        // TODO Auto-generated method stub
-        return filePaths.length;
-    }
-
-    public Object getItem(int arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public long getItemId(int arg0) {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    public int getItemViewType(int arg0) {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    public View getView(int position, View convertView, ViewGroup parent) {
-        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-
-        View listItem;
-
-        if (convertView == null) {
-            listItem = new View(mContext);
-            listItem = inflater.inflate(R.layout.file_list_item, null);
-        } else {
-            listItem = (View) convertView;
-        }
-
-        listItem.setClickable(true);
-        listItem.setOnClickListener(new OnClickListener() {
-
-            public void onClick(View v) {
-                Log.d("LIST", "click!");
-            }
-        });
-
-
-
-        // set value into textview
-        TextView filename = (TextView) listItem.findViewById(R.id.file_list_item_name);
-        filename.setText( filePaths[ 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();
-        if( length < KB ){
-            size = Long.toString( length ) + "B";
-        }
-        if( length >= KB && length < MB){
-            size = Long.toString( length/KB ) + "KB";
-        }
-        if( length >= MB){
-            size = Long.toString( length/MB ) + "MB";
-        }
-        fileSize.setText( size );
-        //fileSize.setClickable(true);
-
-        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() );
-        //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()))
-        {
-            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
-            //For now just a folder icon
-            imageView.setImageResource(R.drawable.folder);
-        }
-        //imageView.setClickable(true);
-        return listItem;
-    }
-
-    public int getViewTypeCount() {
-        // TODO Auto-generated method stub
-        return 1;
-    }
-
-    public boolean hasStableIds() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean isEmpty() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public void registerDataSetObserver(DataSetObserver arg0) {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void unregisterDataSetObserver(DataSetObserver arg0) {
-        // TODO Auto-generated method stub
-
-    }
-
-    public boolean areAllItemsEnabled() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean isEnabled(int position) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 51d4980d4c2262268d58082a7fe0a468b0bc67fc
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 13:44:29 2015 +0200

    Do NOT browse files from "Documents" folder. Browse from root instead.
    
    This is more likely what users expect. Previously we assumed that all
    the documents are stored in root_folder/Documents and there is no way
    to navigate up to other folders.
    
    Change-Id: Idf0ce2476d3abe638b2e8b0f35b6da577032742b

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 92d93d6..820a915 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
@@ -28,8 +28,7 @@ public class LocalDocumentsDirectoryProvider extends LocalDocumentsProvider {
     @Override
     public IFile getRootDirectory() {
         File documentsDirectory = new File(
-                Environment.getExternalStorageDirectory(), "Documents");
-        documentsDirectory.mkdirs();
+                Environment.getExternalStorageDirectory(), "");
         return new LocalFile(documentsDirectory);
     }
 
commit 6fedb679c3879484688636fe51790bfcf137b941
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 13:43:49 2015 +0200

    refactor xml styling for listview texts
    
    Change-Id: Id52d33807c34b0fa12bc563ed479f5519103c8fe

diff --git a/android/experimental/LOAndroid3/res/layout/file_list_item.xml b/android/experimental/LOAndroid3/res/layout/file_list_item.xml
index 91d84fd..17590fc 100644
--- a/android/experimental/LOAndroid3/res/layout/file_list_item.xml
+++ b/android/experimental/LOAndroid3/res/layout/file_list_item.xml
@@ -21,27 +21,21 @@
         android:orientation="horizontal">
         <TextView
             android:id="@+id/file_list_item_name"
-            android:layout_height="48dp"
+            style="@style/ListItemText"
+            android:layout_height="match_parent"
             android:layout_width="0dp"
-            android:textSize="15dp"
-            android:textStyle="bold"
-            android:layout_weight="2"
-            android:gravity="center"/>
+            android:layout_weight="2" />
         <TextView
             android:id="@+id/file_list_item_size"
-            android:layout_height="48dp"
+            style="@style/ListItemText"
+            android:layout_height="match_parent"
             android:layout_width="0dp"
-            android:textSize="15dp"
-            android:textStyle="bold"
-            android:layout_weight="1"
-            android:gravity="center"/>
+            android:layout_weight="1" />
         <TextView
             android:id="@+id/file_list_item_date"
-            android:layout_height="48dp"
+            style="@style/ListItemText"
+            android:layout_height="match_parent"
             android:layout_width="0dp"
-            android:textSize="15dp"
-            android:textStyle="bold"
-            android:layout_weight="2"
-            android:gravity="center"/>
+            android:layout_weight="2" />
     </LinearLayout>
 </LinearLayout>
diff --git a/android/experimental/LOAndroid3/res/values/themes.xml b/android/experimental/LOAndroid3/res/values/themes.xml
index 478aeb7e..2b9e9f1 100644
--- a/android/experimental/LOAndroid3/res/values/themes.xml
+++ b/android/experimental/LOAndroid3/res/values/themes.xml
@@ -9,4 +9,10 @@
 
     <style name="BrowserTheme" parent="Theme.AppCompat.Light.NoActionBar">
     </style>
+
+    <style name="ListItemText">
+        <item name="android:gravity">center</item>
+        <item name="android:textColor">@android:color/black</item>
+        <item name="android:textSize">15sp</item>
+    </style>
 </resources>
commit 462c40944c89de9cb42593bb600a3c0f239a831b
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 12:53:51 2015 +0200

    formatting for consistancy across Java code
    
    Change-Id: I7bde4c9c024dfe7a18c92a36069433f044fc89bc

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
index b0211b1..c689ba1 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java
@@ -35,7 +35,7 @@ public class FolderIconView extends View{
 
     private File dir;
 
-    public FolderIconView(Context context ) {
+    public FolderIconView(Context context) {
         super(context);
         initialisePaints();
     }
@@ -48,86 +48,86 @@ public class FolderIconView extends View{
         initialisePaints();
     }
 
-    private void initialisePaints(){
+    private void initialisePaints() {
         mPaintBlack = new Paint();
-        mPaintBlack.setColor( Color.DKGRAY );//Can also use parseColor( String "#aarrggbb")
-        mPaintBlack.setAntiAlias( true );
+        mPaintBlack.setColor(Color.DKGRAY);//Can also use parseColor(String "#aarrggbb")
+        mPaintBlack.setAntiAlias(true);
 
         mPaintGray = new Paint();
-        mPaintGray.setColor( Color.GRAY );//Can also use parseColor( String "#aarrggbb")
-        mPaintGray.setAntiAlias( true );
+        mPaintGray.setColor(Color.GRAY);//Can also use parseColor(String "#aarrggbb")
+        mPaintGray.setAntiAlias(true);
 
         mPaintShadow = new Paint();
-        mPaintShadow.setColor( Color.parseColor( "#88888888") );
-        mPaintShadow.setAntiAlias( true );
+        mPaintShadow.setColor(Color.parseColor("#88888888"));
+        mPaintShadow.setAntiAlias(true);
     }
 
-    public void setDir( File dir ){
+    public void setDir(File dir) {
         this.dir = dir;
     }
 
     @Override
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
-        Log.d( TAG, "onDraw");
+        Log.d(TAG, "onDraw");
         //float width = (float)canvas.getWidth();
         //float height = (float)canvas.getHeight();
-        float width = (float)this.getWidth();
-        float height = (float)this.getHeight();
+        float width = (float) this.getWidth();
+        float height = (float) this.getHeight();
         float centerX = width*0.5f;// centered on horz axis
         float centerY = height*0.5f;
-        float outerRadius = 0.8f*0.5f* width;
-        float innerRadius = 0.7f*0.5f* width;
+        float outerRadius = 0.8f*0.5f*width;
+        float innerRadius = 0.7f*0.5f*width;
         float thumbHeight = outerRadius*1.25f;
         float thumbWidth = thumbHeight*(float)(1/Math.sqrt(2));
         float DZx = 0.2f*outerRadius;
         float DZy = 0.2f*outerRadius;
-        //Bitmap blankPage = BitmapFactory.decodeResource( getResources() , R.drawable.page );
-        Log.i( TAG , Float.toString( width ) + " X " + Float.toString( height ) );
-        canvas.drawCircle( centerX , centerY , outerRadius , mPaintGray );
-        canvas.drawCircle( centerX , centerY , innerRadius , mPaintBlack );
+        //Bitmap blankPage = BitmapFactory.decodeResource(getResources(), R.drawable.page);
+        Log.i(TAG, Float.toString(width) + "x" + Float.toString(height));
+        canvas.drawCircle(centerX, centerY, outerRadius, mPaintGray);
+        canvas.drawCircle(centerX, centerY, innerRadius, mPaintBlack);
         //Either get thumbs from directory or use generic page images
         //For now just get the first 4 thumbs -> add some checks later
-        if( dir == null )
+        if (dir == null)
             return;//TODO
         File[] contents = dir.listFiles();//TODO consider filtering thumbs to match grid.
-        if( contents == null )
+        if (contents == null)
             // dir is not a directory,
             // or user does not have permissions to read it
             return;
         Stack<Bitmap> thumbs = new Stack<Bitmap>();
         BitmapFactory factory = new BitmapFactory();
-        for( File file : contents ){
-            if( !FileUtilities.isThumbnail(file) )
+        for (File file : contents) {
+            if (!FileUtilities.isThumbnail(file))
                 continue;
-            thumbs.push( factory.decodeFile( file.getAbsolutePath() ) );//TODO switch to push for semantics
-            if( thumbs.size() > 3 )
+            thumbs.push(factory.decodeFile(file.getAbsolutePath()));//TODO switch to push for semantics
+            if (thumbs.size() > 3)
                 break;
         }
-        /*while( thumbs.size() < 4 ){// padd out with blanks?
-            thumbs.push( blankPage );
+        /*while(thumbs.size() < 4) {// padd out with blanks?
+            thumbs.push(blankPage);
         }*/
-        Log.i( TAG, Integer.toString( thumbs.size() ) );
+        Log.i(TAG, Integer.toString(thumbs.size()));
         //should handle empty folders better
         //  options:
         //      don't show?
         //      show generic LO icons for writer etc
         //      Show a generic blank page icon
-        if( thumbs.isEmpty() )
+        if (thumbs.isEmpty())
             return;
         /*float left = centerX ;//+ 0.25f*outerRadius;
         float top = centerY - 0.5f*outerRadius;
         float right = left + thumbs.get(0).getWidth()*0.4f;
         float bottom = top + thumbs.get(0).getHeight()*0.4f;
-        RectF dest = new RectF( left, top , right , bottom );
+        RectF dest = new RectF(left, top, right, bottom);
         RectF shadowBox = new RectF(dest);
-        shadowBox.inset( -1 , -1 );
+        shadowBox.inset(-1, -1);
         int size = thumbs.size();
-        for( int i = 1 ; i <= size ; i++ ){
-            canvas.drawRect( shadowBox , mPaintShadow);
-            canvas.drawBitmap( thumbs.pop() , null , dest , null);
-            dest.offset( -outerRadius*0.2f , outerRadius*0.1f );
-            shadowBox.offset( -outerRadius*0.2f , outerRadius*0.1f );
+        for (int i = 1; i <= size; i++) {
+            canvas.drawRect(shadowBox, mPaintShadow);
+            canvas.drawBitmap(thumbs.pop(), null, dest, null);
+            dest.offset(-outerRadius*0.2f, outerRadius*0.1f);
+            shadowBox.offset(-outerRadius*0.2f, outerRadius*0.1f);
         }*/
         float left;
         float top;
@@ -136,7 +136,7 @@ public class FolderIconView extends View{
         RectF dest;
         RectF shadowBox;
         int size;
-        switch( thumbs.size() ){
+        switch(thumbs.size()) {
             case 0:
                 break;
             case 1:
@@ -144,26 +144,26 @@ public class FolderIconView extends View{
                 top = centerY - 0.5f*thumbHeight;
                 right = left + thumbWidth;
                 bottom = top + thumbHeight;
-                dest = new RectF( left, top , right , bottom );
+                dest = new RectF(left, top, right, bottom);
                 shadowBox = new RectF(dest);
-                shadowBox.inset( -1 , -1 );
-                canvas.drawRect( shadowBox , mPaintShadow);
-                canvas.drawBitmap( thumbs.pop() , null , dest , null);
+                shadowBox.inset(-1, -1);
+                canvas.drawRect(shadowBox, mPaintShadow);
+                canvas.drawBitmap(thumbs.pop(), null, dest, null);
                 break;
             case 2:
                 left = centerX - 0.5f*thumbWidth + 0.5f*DZx;
                 top = centerY - 0.5f*thumbHeight - 0.5f*DZy;
                 right = left + thumbWidth;
                 bottom = top + thumbHeight;
-                dest = new RectF( left, top , right , bottom );
+                dest = new RectF(left, top, right, bottom);
                 shadowBox = new RectF(dest);
-                shadowBox.inset( -1 , -1 );
+                shadowBox.inset(-1, -1);
                 size = thumbs.size();
-                for( int i = 1 ; i <= size ; i++ ){
-                    canvas.drawRect( shadowBox , mPaintShadow);
-                    canvas.drawBitmap( thumbs.pop() , null , dest , null);
-                    dest.offset( -DZx , DZy );
-                    shadowBox.offset( -DZx , DZy );
+                for (int i = 1; i <= size; i++) {
+                    canvas.drawRect(shadowBox, mPaintShadow);
+                    canvas.drawBitmap(thumbs.pop(), null, dest, null);
+                    dest.offset(-DZx, DZy);
+                    shadowBox.offset(-DZx, DZy);
                 }
                 break;
             case 3:
@@ -171,15 +171,15 @@ public class FolderIconView extends View{
                 top = centerY - 0.5f*thumbHeight - DZy;
                 right = left + thumbWidth;
                 bottom = top + thumbHeight;
-                dest = new RectF( left, top , right , bottom );
+                dest = new RectF(left, top, right, bottom);
                 shadowBox = new RectF(dest);
-                shadowBox.inset( -1 , -1 );
+                shadowBox.inset(-1, -1);
                 size = thumbs.size();
-                for( int i = 1 ; i <= size ; i++ ){
-                    canvas.drawRect( shadowBox , mPaintShadow);
-                    canvas.drawBitmap( thumbs.pop() , null , dest , null);
-                    dest.offset( -DZx , DZy );
-                    shadowBox.offset( -DZx , DZy );
+                for (int i = 1; i <= size; i++) {
+                    canvas.drawRect(shadowBox, mPaintShadow);
+                    canvas.drawBitmap(thumbs.pop(), null, dest, null);
+                    dest.offset(-DZx, DZy);
+                    shadowBox.offset(-DZx, DZy);
                 }
                 break;
             case 4:
@@ -187,15 +187,15 @@ public class FolderIconView extends View{
                 top = centerY - 0.5f*thumbHeight - 1.5f*DZy;
                 right = left + thumbWidth;
                 bottom = top + thumbHeight;
-                dest = new RectF( left, top , right , bottom );
+                dest = new RectF(left, top, right, bottom);
                 shadowBox = new RectF(dest);
-                shadowBox.inset( -1 , -1 );
+                shadowBox.inset(-1, -1);
                 size = thumbs.size();
-                for( int i = 1 ; i <= size ; i++ ){
-                    canvas.drawRect( shadowBox , mPaintShadow);
-                    canvas.drawBitmap( thumbs.pop() , null , dest , null);
-                    dest.offset( -DZx , DZy );
-                    shadowBox.offset( -DZx , DZy );
+                for (int i = 1; i <= size; i++) {
+                    canvas.drawRect(shadowBox, mPaintShadow);
+                    canvas.drawBitmap(thumbs.pop(), null, dest, null);
+                    dest.offset(-DZx, DZy);
+                    shadowBox.offset(-DZx, DZy);
                 }
                 break;
             default:
commit c0f965c0f37a9987b1dcc82dad90c0559acb228b
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 12:49:01 2015 +0200

    use LOGTAG instead
    
    Change-Id: Ie89afb3526ff670581094107c59a4a20597d9225

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 559bd95..9650fa5 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
@@ -21,6 +21,9 @@ import android.util.Log;
 import android.webkit.MimeTypeMap;
 
 public class FileUtilities {
+
+    private String LOGTAG = FileUtilities.class.getSimpleName();
+
     static final int ALL = -1;
 
     // These have to be in sync with the file_view_modes resource.
@@ -135,7 +138,7 @@ public class FileUtilities {
 
     static int getType(String filename) {
         int type = lookupExtension (filename);
-        Log.d("debug", "extn : " + filename + " -> " + type);
+        Log.d(LOGTAG, "extn : " + filename + " -> " + type);
         return type;
     }
 
@@ -152,7 +155,7 @@ public class FileUtilities {
 
     // Filter by mode, and/or in future by filename/wildcard
     static private boolean doAccept(String filename, int byMode, String byFilename) {
-        Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename);
+        Log.d(LOGTAG, "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename);
         if (filename == null)
             return false;
 
commit e3516e381b5224d58fa3b0a3f66dd45bbb13b3c9
Author: Siqi Liu <me at siqi.fr>
Date:   Thu Apr 23 12:47:00 2015 +0200

    formatting for consistancy across Java code
    
    Change-Id: I4d53376ea1b5ffa158cbb3412353c3cf5ba860d5

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 61ec014..ccbc978 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -127,11 +127,13 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
             if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
                 if (copyFileToTemp() && mTempFile != null) {
                     mInputFile = mTempFile.getPath();
+                    Log.d(LOGTAG, "SCHEME_CONTENT: getPath(): " + getIntent().getData().getPath());
                 } else {
                     // TODO: can't open the file
                 }
             } else if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_FILE)) {
                 mInputFile = getIntent().getData().getPath();
+                Log.d(LOGTAG, "SCHEME_FILE: getPath(): " + getIntent().getData().getPath());
             }
         } else {
             mInputFile = DEFAULT_DOC_PATH;
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 118eded..559bd95 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FileUtilities.java
@@ -42,7 +42,7 @@ public class FileUtilities {
     /** Smallest Files First */
     static final int SORT_SMALLEST = 5;
 
-    private static final Map<String,Integer> mExtnMap = new HashMap<String,Integer>();
+    private static final Map<String, Integer> mExtnMap = new HashMap<String, Integer>();
     private static final Map<String, String> extensionToMimeTypeMap = new HashMap<String, String>();
     static {
         // Please keep this in sync with AndroidManifest.xml
@@ -117,8 +117,7 @@ public class FileUtilities {
         extensionToMimeTypeMap.put("oth", "application/vnd.oasis.opendocument.text-web");
     }
 
-    private static final String getExtension(String filename)
-    {
+    private static final String getExtension(String filename) {
         if (filename == null)
             return "";
         int nExt = filename.lastIndexOf('.');
@@ -127,26 +126,23 @@ public class FileUtilities {
         return filename.substring(nExt);
     }
 
-    private static final int lookupExtension(String filename)
-    {
-        String extn = getExtension (filename);
+    private static final int lookupExtension(String filename) {
+        String extn = getExtension(filename);
         if (!mExtnMap.containsKey(extn))
             return UNKNOWN;
-        return mExtnMap.get (extn);
+        return mExtnMap.get(extn);
     }
 
-    static int getType(String filename)
-    {
+    static int getType(String filename) {
         int type = lookupExtension (filename);
-        android.util.Log.d("debug", "extn : " + filename + " -> " + type);
+        Log.d("debug", "extn : " + filename + " -> " + type);
         return type;
     }
 
-    static String getMimeType(String filename)
-    {
+    static String getMimeType(String filename) {
         String extension = MimeTypeMap.getFileExtensionFromUrl(filename);
         String mime = extensionToMimeTypeMap.get(extension);
-        if(mime == null) {
+        if (mime == null) {
             //fallback to Android's MimeTypeMap
             mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
                     extension);
@@ -155,100 +151,96 @@ public class FileUtilities {
     }
 
     // Filter by mode, and/or in future by filename/wildcard
-    static private boolean doAccept(String filename, int byMode, String byFilename)
-    {
-    android.util.Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename);
-    if (filename == null)
-        return false;
-
-    if (byMode == ALL && byFilename == "") {
-        if( filename.startsWith(".")) {//ignore hidden files
+    static private boolean doAccept(String filename, int byMode, String byFilename) {
+        Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename);
+        if (filename == null)
             return false;
+
+        if (byMode == ALL && byFilename == "") {
+            if (filename.startsWith(".")) {//ignore hidden files
+                return false;
+            }
+            return true;
+        }
+        // check extension
+        if (byMode != ALL) {
+            if (mExtnMap.get (getExtension (filename)) != byMode)
+                return false;
+        }
+        if (byFilename != "") {
+            // FIXME return false on a non-match
         }
         return true;
     }
-    // check extension
-    if (byMode != ALL) {
-        if (mExtnMap.get (getExtension (filename)) != byMode)
-            return false;
-    }
-    if (byFilename != "") {
-        // FIXME return false on a non-match
-    }
-    return true;
-    }
 
-    static FileFilter getFileFilter(final int mode)
-    {
-    return new FileFilter() {
-        public boolean accept(File pathname) {
-        if (pathname.isDirectory())
-            return true;
-        if( lookupExtension(pathname.getName()) == UNKNOWN)
-            return false;
-        return doAccept(pathname.getName(), mode, "");
-        }
-    };
+    static FileFilter getFileFilter(final int mode) {
+        return new FileFilter() {
+            public boolean accept(File pathname) {
+                if (pathname.isDirectory())
+                    return true;
+                if (lookupExtension(pathname.getName()) == UNKNOWN)
+                    return false;
+                return doAccept(pathname.getName(), mode, "");
+            }
+        };
     }
 
-    static FilenameFilter getFilenameFilter(final int mode)
-    {
+    static FilenameFilter getFilenameFilter(final int mode) {
         return new FilenameFilter() {
             public boolean accept(File dir, String filename) {
-                if( new File( dir , filename ).isDirectory() )
+                if (new File(dir , filename).isDirectory())
                     return true;
                 return doAccept(filename, mode, "");
             }
         };
     }
 
-    static void sortFiles(File[] files , int sortMode)
-    {
+    static void sortFiles(File[] files, int sortMode) {
         // Should really change all this to a switch statement...
-        if( sortMode == SORT_AZ ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_AZ) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return lhs.getName().compareTo( rhs.getName() );
+                    return lhs.getName().compareTo(rhs.getName());
                 }
             });
             return;
         }
-        if( sortMode == SORT_ZA ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_ZA) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return rhs.getName().compareTo( lhs.getName() );
+                    return rhs.getName().compareTo(lhs.getName());
                 }
             });
             return;
         }
-        if( sortMode == SORT_OLDEST ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_OLDEST) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return Long.valueOf( lhs.lastModified() ).compareTo( rhs.lastModified() );
+                    return Long.valueOf(lhs.lastModified()).compareTo(rhs.lastModified());
                 }
             });
             return;
         }
-        if( sortMode == SORT_NEWEST ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_NEWEST) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return Long.valueOf( rhs.lastModified() ).compareTo( lhs.lastModified() );
+                    return Long.valueOf(rhs.lastModified()).compareTo(lhs.lastModified());
                 }
             });
             return;
         }
-        if( sortMode == SORT_LARGEST ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_LARGEST) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return Long.valueOf( rhs.length() ).compareTo( lhs.length() );
+                    return Long.valueOf(rhs.length()).compareTo(lhs.length());
                 }
             });
             return;
         }
-        if( sortMode == SORT_SMALLEST ){
-            Arrays.sort( files , new Comparator<File>() {
+        if (sortMode == SORT_SMALLEST) {
+            Arrays.sort(files , new Comparator<File>() {
                 public int compare(File lhs, File rhs) {
-                    return Long.valueOf( lhs.length() ).compareTo( rhs.length() );
+                    return Long.valueOf(lhs.length()).compareTo(rhs.length());
                 }
             });
             return;
@@ -256,33 +248,31 @@ public class FileUtilities {
         return;
     }
 
-    static boolean isHidden( File file ){
-        if( file.getName().startsWith(".") )
+    static boolean isHidden(File file) {
+        if (file.getName().startsWith("."))
             return true;
         return false;
     }
 
-    static boolean isThumbnail( File file ){
-        if( isHidden(file) && file.getName().endsWith(".png") )
+    static boolean isThumbnail(File file) {
+        if (isHidden(file) && file.getName().endsWith(".png"))
             return true;
         return false;
     }
 
-    static boolean hasThumbnail(File file)
-    {
+    static boolean hasThumbnail(File file) {
         String filename = file.getName();
-        if( lookupExtension( filename ) == DOC ) // only do this for docs for now
+        if (lookupExtension(filename) == DOC) // only do this for docs for now
         {
             // Will need another method to check if Thumb is up-to-date - or extend this one?
-            if( new File( file.getParent() , getThumbnailName( file ) ).isFile() )
+            if (new File(file.getParent() , getThumbnailName(file)).isFile())
                 return true;
             return false; // If it's a document with no thumb
         }
         return true;
     }
 
-    static String getThumbnailName( File file )
-    {
+    static String getThumbnailName(File file) {
         return "." + file.getName().split("[.]")[0] + ".png" ;
     }
 }
commit 585dfa62b369627d76f71bf5895731aa7d4a372e
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Apr 20 15:33:22 2015 +0200

    viewer: Revert "Copy only *-debug.apk"
    
    In 'product' builds, this fails, as there is no *-debug.apk.
    
    This reverts commit 1895fd2195ab11026e07271dbba71c0e963c0a3b.

diff --git a/android/CustomTarget_lo_android.mk b/android/CustomTarget_lo_android.mk
index 24225c0..07c7d11 100644
--- a/android/CustomTarget_lo_android.mk
+++ b/android/CustomTarget_lo_android.mk
@@ -20,7 +20,7 @@ $(loandroid3_DIR)/done : $(call gb_Postprocess_get_target,AllModulesButInstsetNa
 # still looks for the .apk, and we want fresh daily builds to be uploaded.
 # Us "foo" instead of the old INPATH
 	mkdir -p $(BUILDDIR)/instsetoo_native/foo/bin; \
-	cp $(SRCDIR)/android/experimental/LOAndroid3/bin/*-debug.apk $(BUILDDIR)/instsetoo_native/foo/bin
+	cp $(SRCDIR)/android/experimental/LOAndroid3/bin/*.apk $(BUILDDIR)/instsetoo_native/foo/bin
 
 $(call gb_CustomTarget_get_clean_target,android/loandroid3) :
 	$(call gb_Output_announce,$(subst $(WORKDIR)/Clean/,,$@),$(false),MAK,2)


More information about the Libreoffice-commits mailing list