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

Jacobo Aragunde Pérez jaragunde at igalia.com
Thu Sep 11 12:35:39 PDT 2014


 android/experimental/LibreOffice4Android/AndroidManifest.xml                               |    4 
 android/experimental/LibreOffice4Android/Makefile                                          |    5 
 android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java |   52 ++++------
 3 files changed, 27 insertions(+), 34 deletions(-)

New commits:
commit 085c6ebc14bd9670cd23a732b905d3c2379a9185
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Thu Sep 11 20:39:37 2014 +0200

    LibreOffice4Android: Fix NullPointerException
    
    The member fileNames was being correctly set in createUI() but it was
    being reset at openDirectory(). The only purpose of this member was
    sending the file name to open() method, but we can rewrite open() to
    accept File objects so fileNames became useless and was removed.
    
    Change-Id: I944be8ff13d221573a5a7accf0081c30872c62f0

diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index 63371f4..96e4251 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.prefs.Preferences;
 
 import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
 import android.os.Build;
 import android.graphics.Shader.TileMode;
 import android.graphics.BlurMaskFilter;
@@ -34,6 +35,7 @@ import android.app.Activity;
 import android.os.AsyncTask;
 import android.graphics.Bitmap;
 import android.graphics.Matrix;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
@@ -93,7 +95,6 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
 	
 	FileFilter fileFilter;
 	FilenameFilter filenameFilter;
-	private String[] fileNames;
 	private File[] filePaths;
 	
 	
@@ -173,17 +174,15 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
 	        // code to make a grid view
         	setContentView(R.layout.file_grid);
 	    	gv = (GridView)findViewById(R.id.file_explorer_grid_view);
-        	fileNames = currentDirectory.list( FileUtilities.getFilenameFilter( filterMode ) );
         	filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
 	        gv.setOnItemClickListener(new OnItemClickListener() {
 	            public void onItemClick(AdapterView<?> parent, View view,
 	                int position, long id) {
 	            	File file = filePaths[position];
 	            	if(!file.isDirectory()){
-	            		open(fileNames[position]);
+                        open(file);
 	            	}else{
-	            		file = new File( currentDirectory, file.getName() );
-	            		openDirectory( file );
+                        openDirectory( file );
 	            	}
 	            		
 	            }
@@ -194,7 +193,6 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
         	setContentView(R.layout.file_list);
         	lv = (ListView)findViewById( R.id.file_explorer_list_view);
         	lv.setClickable(true);
-        	fileNames = currentDirectory.list( FileUtilities.getFilenameFilter( filterMode ) );
         	filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
         	lv.setAdapter( new ListItemAdapter(getApplicationContext(), filePaths) );
         	actionBar.setSelectedNavigationItem( filterMode + 1 );
@@ -212,7 +210,6 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
             actionBar.setDisplayHomeAsUpEnabled( false );
         }
     	filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
-    	fileNames = new String[ filePaths.length ];
     	FileUtilities.sortFiles( filePaths, sortMode );
 /*
     	for( int i = 0; i < fileNames.length; i++){
@@ -230,7 +227,7 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
     	}
     }
     
-    public void open(String file){
+    public void open(File file) {
     	/*
     	Intent i = new Intent( this , WriterViewerActivity.class );
     	i.putExtra( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
@@ -239,7 +236,7 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
     	startActivity( i );
     	*/
     	Intent i = new Intent( this , DocumentLoader.class );
-    	i.putExtra("input",new File( currentDirectory , file).getAbsolutePath() );
+        i.putExtra("input", file.getAbsolutePath() );
     	i.putExtra( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
     	i.putExtra( FILTER_MODE_KEY  , filterMode );
     	i.putExtra( EXPLORER_VIEW_TYPE_KEY  , viewMode );
@@ -546,7 +543,7 @@ class ListItemAdapter implements ListAdapter{
 					if(filePaths[ pos ].isDirectory() ){
 						openDirectory( filePaths[ pos ] );
 					}else{
-						open( filePaths[ pos ].getName() );
+                        open( filePaths[ pos ] );
 					}
 				}
 			});
commit 3195c6db131699aae3cb84c051ebd3c437dafc6b
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Thu Sep 11 20:24:27 2014 +0200

    LibreOffice4Android: Remove dependency from actionbarsherlock
    
    Replace with the native Android action bar since API 11.
    
    Change-Id: Ia332b51cfea084072e8d0362702a359b8f09adea

diff --git a/android/experimental/LibreOffice4Android/AndroidManifest.xml b/android/experimental/LibreOffice4Android/AndroidManifest.xml
index ae54e9c..01ee311 100644
--- a/android/experimental/LibreOffice4Android/AndroidManifest.xml
+++ b/android/experimental/LibreOffice4Android/AndroidManifest.xml
@@ -5,7 +5,7 @@
           android:versionCode="1"
           android:versionName="1.0">
 
-    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>
+    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
     <application android:debuggable="true"
@@ -27,7 +27,7 @@
         <!-- File Explorer Activities taken from eclipse workspace -->
         <activity android:name=".ui.LibreOfficeUIActivity"
                   android:label="@string/app_name"
-                  android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
+                  android:theme="@android:style/Theme.Holo">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
diff --git a/android/experimental/LibreOffice4Android/Makefile b/android/experimental/LibreOffice4Android/Makefile
index f4b4c41..125cf74 100644
--- a/android/experimental/LibreOffice4Android/Makefile
+++ b/android/experimental/LibreOffice4Android/Makefile
@@ -18,11 +18,6 @@ native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py
 		> $@
 
 build-ant: android_version_setup copy-stuff link-so properties
-	echo sdk.dir=$(ANDROID_SDK_HOME) >../../abs-lib/local.properties
-# ActionBarSherlock uses the v4 support library, apparently one needs to copy
-# it like this for it to be found
-	mkdir -p ../../abs-lib/libs
-	cp $(ANDROID_SDK_HOME)/extras/android/support/v4/android-support-v4.jar ../../abs-lib/libs
 #
 # Copy jar files we need
 #
diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index 02cdc7d..63371f4 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -20,11 +20,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.prefs.Preferences;
 
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.app.SherlockActivity;
 import android.graphics.drawable.BitmapDrawable;
 import android.os.Build;
 import android.graphics.Shader.TileMode;
@@ -33,6 +28,7 @@ import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.Color;
 
+import android.app.ActionBar;
 import android.app.ActionBar.OnNavigationListener;
 import android.app.Activity;
 import android.os.AsyncTask;
@@ -47,6 +43,9 @@ import android.os.Environment;
 import android.preference.PreferenceManager;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.View.OnClickListener;
@@ -83,7 +82,7 @@ import java.nio.ByteBuffer;
 import java.nio.IntBuffer;
 import java.nio.ByteOrder;
 
-public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar.OnNavigationListener {
+public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavigationListener {
     private String tag = "file_manager";
 	private SharedPreferences prefs;
     private File homeDirectory;
@@ -142,7 +141,7 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
     }
     
     public void createUI(){
-        ActionBar actionBar = getSupportActionBar();
+        ActionBar actionBar = getActionBar();
         actionBar.setDisplayShowTitleEnabled(false);//This should show current directory if anything
         /*actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
         SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.file_view_modes,
@@ -150,21 +149,21 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
         actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);
         */
         //make the navigation spinner
-        Context context = getSupportActionBar().getThemedContext();
-        ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.file_view_modes, R.layout.sherlock_spinner_item);
-        list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
+        Context context = actionBar.getThemedContext();
+        ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.file_view_modes, android.R.layout.simple_spinner_item);
+        list.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 
-        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
-        getSupportActionBar().setListNavigationCallbacks(list, this);
+        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+        actionBar.setListNavigationCallbacks(list, this);
 
         //make striped actionbar
         BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped);
         bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
-        getSupportActionBar().setBackgroundDrawable(bg);
+        actionBar.setBackgroundDrawable(bg);
 
         BitmapDrawable bgSplit = (BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped_split_img);
         bgSplit.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
-        getSupportActionBar().setSplitBackgroundDrawable(bgSplit);
+        actionBar.setSplitBackgroundDrawable(bgSplit);
 
         if( !currentDirectory.equals( homeDirectory )){
             actionBar.setDisplayHomeAsUpEnabled(true);
@@ -206,10 +205,10 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
     public void openDirectory(File dir ){
     	currentDirectory = dir; 
         if( !currentDirectory.equals( homeDirectory )){
-            ActionBar actionBar = getSupportActionBar();
+            ActionBar actionBar = getActionBar();
             actionBar.setDisplayHomeAsUpEnabled(true);
         }else{
-            ActionBar actionBar = getSupportActionBar();
+            ActionBar actionBar = getActionBar();
             actionBar.setDisplayHomeAsUpEnabled( false );
         }
     	filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
@@ -249,7 +248,7 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
     
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        MenuInflater inflater = getSupportMenuInflater();
+        MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.view_menu, menu);
         
         MenuItem item = (MenuItem)menu.findItem(R.id.menu_view_toggle);
commit d9c2927ef2ea45777772cc52bd62f7ece2dda207
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Thu Sep 11 19:49:53 2014 +0200

    LibreOffice4Android: Disable thumbnails so the application can run
    
    Commented out the piece of code that invokes the creation of
    thumbnails, because it crashes after the call to native code.
    
    Once LibreOffice4Android is merged with the LOKit-based viewer, it
    will be the moment to fix the thumbnails properly.
    
    Change-Id: I6dd38c6f91008d41905d3c4a856899e9ec81bd6b

diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index c36c0b6..02cdc7d 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -215,6 +215,7 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
     	filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
     	fileNames = new String[ filePaths.length ];
     	FileUtilities.sortFiles( filePaths, sortMode );
+/*
     	for( int i = 0; i < fileNames.length; i++){
             fileNames[ i ] = filePaths[ i ].getName();
             if( !FileUtilities.hasThumbnail( filePaths[ i ] ) )
@@ -222,6 +223,7 @@ public class LibreOfficeUIActivity extends SherlockActivity implements ActionBar
                 new ThumbnailGenerator( filePaths[ i ] );
             }
     	}
+*/
     	if( viewMode == GRID_VIEW){
     		gv.setAdapter( new GridItemAdapter(getApplicationContext(), currentDirectory, filePaths ) );
     	}else{


More information about the Libreoffice-commits mailing list