[Libreoffice-commits] .: 2 commits - android/experimental
Iain Billett
iainb at kemper.freedesktop.org
Tue Jun 19 09:03:05 PDT 2012
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_sort_by_size.png |binary
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_grid.png |binary
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_list.png |binary
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml | 9
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml | 3
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/FileUtilities.java | 73 +++
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java | 193 +++++++---
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java | 5
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java | 23 -
9 files changed, 231 insertions(+), 75 deletions(-)
New commits:
commit 5e380fbdcdebf762a07b0ec502a4d3c40190838d
Author: Iain Billett <Iain at Iains-MacBook-Pro.local>
Date: Tue Jun 19 16:20:34 2012 +0100
Added file sorting - alphabetical, by size, by last modified.
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_sort_by_size.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_sort_by_size.png
new file mode 100644
index 0000000..3b34aaf
Binary files /dev/null and b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_sort_by_size.png differ
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_grid.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_grid.png
new file mode 100644
index 0000000..ae138ed
Binary files /dev/null and b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_grid.png differ
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_list.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_list.png
new file mode 100644
index 0000000..c5f6c97
Binary files /dev/null and b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/light_view_as_list.png differ
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml
index 14eabb3..a780f55 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml
@@ -5,4 +5,13 @@
android:showAsAction="always" />
<item android:id="@+id/menu_view_toggle"
android:title="@string/grid_view"/>
+ <item android:id="@+id/menu_sort_size"
+ android:title="@string/menu_sort_size"
+ android:onClick="sortFiles"/>
+ <item android:id="@+id/menu_sort_az"
+ android:title="@string/menu_sort_az"
+ android:onClick="sortFiles"/>
+ <item android:id="@+id/menu_sort_modified"
+ android:title="@string/menu_sort_modified"
+ android:onClick="sortFiles"/>
</menu>
\ No newline at end of file
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml
index 7306683..3ff73f7 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml
@@ -6,6 +6,9 @@
<string name="menu_search">Search</string>
<string name="list_view">List</string>
<string name="grid_view">Grid</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>
<string-array name="file_view_modes">
<item >EVERYTHING</item>
<item >DOCUMENTS</item>
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/FileUtilities.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/FileUtilities.java
index 3b6bbf3..2e21dbe 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/FileUtilities.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/FileUtilities.java
@@ -3,6 +3,8 @@ package org.libreoffice.ui;
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.Comparator;
public class FileUtilities {
@@ -11,6 +13,17 @@ public class FileUtilities {
static final int CALC = 1;
static final int IMPRESS = 2;
+ static final int SORT_AZ = 0;
+ static final int SORT_ZA = 1;
+ /** Oldest Files First*/
+ static final int SORT_OLDEST = 2;
+ /** Newest Files First*/
+ static final int SORT_NEWEST = 3;
+ /** Largest Files First */
+ static final int SORT_LARGEST = 4;
+ /** Smallest Files First */
+ static final int SORT_SMALLEST = 5;
+
private static String[] fileExtensions = {".odt",".ods",".odp"};
static boolean isDoc(String filename){
@@ -34,7 +47,7 @@ public class FileUtilities {
return false;
}
- static FileFilter getFileFilter(int mode){
+ static FileFilter getFileFilter(int mode ){
if( mode != ALL){
final String ext = fileExtensions[ mode ];
return new FileFilter() {
@@ -84,5 +97,63 @@ 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;
+ }
+ return;
+ }
}
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index 704df20..743ae20 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -36,21 +36,24 @@ import android.widget.TextView;
public class LibreOfficeUIActivity extends Activity implements OnNavigationListener {
private String tag = "file_manager";
- private File homeDirectory;//make final?
+ private SharedPreferences prefs;
+ private File homeDirectory;
private File currentDirectory;
private int filterMode = FileUtilities.ALL;
- private int viewType = 0;
+ private int viewMode;
+ private int sortMode;
+
FileFilter fileFilter;
FilenameFilter filenameFilter;
private String[] fileNames;
private File[] filePaths;
- //private ActionBar actionBar;
- private SharedPreferences prefs;
+
private static final String CURRENT_DIRECTORY_KEY = "CURRENT_DIRECTORY";
private static final String FILTER_MODE_KEY = "FILTER_MODE";
public static final String EXPLORER_VIEW_TYPE_KEY = "EXPLORER_VIEW_TYPE";
public static final String EXPLORER_PREFS_KEY = "EXPLORER_PREFS";
+ public static final String SORT_MODE_KEY = "SORT_MODE";
public static final int GRID_VIEW = 0;
public static final int LIST_VIEW = 1;
@@ -69,7 +72,8 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
currentDirectory = homeDirectory;
//Load default settings
prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
- viewType = prefs.getInt( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+ viewMode = prefs.getInt( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+ sortMode = prefs.getInt( SORT_MODE_KEY, FileUtilities.SORT_AZ );
}
@@ -84,7 +88,7 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
actionBar.setDisplayHomeAsUpEnabled(true);
}
- if( viewType == GRID_VIEW){
+ if( viewMode == GRID_VIEW){
// code to make a grid view
setContentView(R.layout.file_grid);
gv = (GridView)findViewById(R.id.file_explorer_grid_view);
@@ -139,9 +143,13 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled( false );
}
- fileNames = currentDirectory.list( FileUtilities.getFilenameFilter( filterMode ) );
filePaths = currentDirectory.listFiles( FileUtilities.getFileFilter( filterMode ) );
- if( viewType == GRID_VIEW){
+ fileNames = new String[ filePaths.length ];
+ FileUtilities.sortFiles( filePaths, sortMode );
+ for( int i = 0; i < fileNames.length; i++){
+ fileNames[ i ] = filePaths[ i ].getName();
+ }
+ if( viewMode == GRID_VIEW){
gv.setAdapter( new GridItemAdapter(getApplicationContext(), currentDirectory, filePaths ) );
}else{
lv.setAdapter( new ListItemAdapter(getApplicationContext(), filePaths) );
@@ -152,7 +160,7 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
Intent i = new Intent( this , WriterViewerActivity.class );
i.putExtra( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
i.putExtra( FILTER_MODE_KEY , filterMode );
- i.putExtra( EXPLORER_VIEW_TYPE_KEY , viewType );
+ i.putExtra( EXPLORER_VIEW_TYPE_KEY , viewMode );
startActivity( i );
}
@@ -162,10 +170,12 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
inflater.inflate(R.menu.view_menu, menu);
MenuItem item = (MenuItem)menu.findItem(R.id.menu_view_toggle);
- if( viewType == GRID_VIEW){
+ if( viewMode == GRID_VIEW){
item.setTitle(R.string.list_view);
+ item.setIcon( R.drawable.light_view_as_list );
}else{
item.setTitle(R.string.grid_view);
+ item.setIcon( R.drawable.light_view_as_grid );
}
return true;
}
@@ -178,12 +188,15 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
}
break;
case R.id.menu_view_toggle:
- if( viewType == GRID_VIEW){
- viewType = LIST_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{
- viewType = GRID_VIEW;
+ viewMode = GRID_VIEW;
item.setTitle(R.string.list_view);//Button points to next view.
+ item.setIcon( R.drawable.light_view_as_list );
}
createUI();
break;
@@ -257,15 +270,46 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
}
}
+ @SuppressWarnings("unused")//see android:onClick properties in view_menu.xml
+ public void sortFiles(MenuItem item){
+ switch ( item.getItemId() ) {
+ case R.id.menu_sort_az:
+ if( sortMode == FileUtilities.SORT_AZ ){
+ sortMode = FileUtilities.SORT_ZA;
+ }else{
+ sortMode = FileUtilities.SORT_AZ;
+ }
+ break;
+ case R.id.menu_sort_modified:
+ if( sortMode == FileUtilities.SORT_NEWEST ){
+ sortMode = FileUtilities.SORT_OLDEST;
+ }else{
+ sortMode = FileUtilities.SORT_NEWEST;
+ }
+ break;
+ case R.id.menu_sort_size:
+ if( sortMode == FileUtilities.SORT_LARGEST ){
+ sortMode = FileUtilities.SORT_SMALLEST;
+ }else{
+ sortMode = FileUtilities.SORT_LARGEST;
+ }
+ break;
+ default:
+ break;
+ }
+ this.onResume();
+ return;
+ }
+
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
outState.putString( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
outState.putInt( FILTER_MODE_KEY , filterMode );
- outState.putInt( EXPLORER_VIEW_TYPE_KEY , viewType );
+ outState.putInt( EXPLORER_VIEW_TYPE_KEY , viewMode );
- Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewType) );
+ Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewMode) );
//prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
Log.d(tag, "savedInstanceSate");
}
@@ -279,10 +323,10 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
}
currentDirectory = new File( savedInstanceState.getString( CURRENT_DIRECTORY_KEY ) );
filterMode = savedInstanceState.getInt( FILTER_MODE_KEY , FileUtilities.ALL ) ;
- viewType = savedInstanceState.getInt( EXPLORER_VIEW_TYPE_KEY , GRID_VIEW );
+ viewMode = savedInstanceState.getInt( EXPLORER_VIEW_TYPE_KEY , GRID_VIEW );
//openDirectory( currentDirectory );
Log.d(tag, "onRestoreInstanceState");
- Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewType) );
+ Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewMode) );
}
@Override
@@ -307,7 +351,7 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
Log.d(tag, FILTER_MODE_KEY);
}
if( i.hasExtra( EXPLORER_VIEW_TYPE_KEY ) ){
- viewType = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+ viewMode = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
Log.d(tag, EXPLORER_VIEW_TYPE_KEY);
}
createUI();
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java
index 1fd2d62..1e66e3a 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java
@@ -15,7 +15,10 @@ import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
-/*Currently this is class is not used but instead an inner class in LibreOfficeUI is impemented */
+/*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;
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
index d217421..fe2f113 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
@@ -1,20 +1,12 @@
package org.libreoffice.ui;
-import java.io.File;
-
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.os.Environment;
-import android.util.Log;
import android.view.MenuItem;
public class WriterViewerActivity extends Activity{
- private String currentDirectoryKey = "CURRENT_DIRECTORY";
- private String filterModeKey = "FILTER_MODE";
- File dir;
- private int filterMode;
private Bundle extras;
@Override
commit b059deda1de7513dde886f3259d925df0472c4c3
Author: Iain Billett <Iain at Iains-MacBook-Pro.local>
Date: Mon Jun 18 21:15:00 2012 +0100
Re-organised the Android UI code to make better use of Android lifecycle events. A little code streamlining, also.
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index 330ffc5..704df20 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -44,13 +44,13 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
FilenameFilter filenameFilter;
private String[] fileNames;
private File[] filePaths;
- private ActionBar actionBar;
+ //private ActionBar actionBar;
private SharedPreferences prefs;
- private static final String currentDirectoryKey = "CURRENT_DIRECTORY";
- private static final String filterModeKey = "FILTER_MODE";
- public static final String EXPLORER_VIEW_TYPE = "EXPLORER_VIEW_TYPE";
- public static final String EXPLORER_PREFS = "EXPLORER_PREFS";
+ private static final String CURRENT_DIRECTORY_KEY = "CURRENT_DIRECTORY";
+ private static final String FILTER_MODE_KEY = "FILTER_MODE";
+ public static final String EXPLORER_VIEW_TYPE_KEY = "EXPLORER_VIEW_TYPE";
+ public static final String EXPLORER_PREFS_KEY = "EXPLORER_PREFS";
public static final int GRID_VIEW = 0;
public static final int LIST_VIEW = 1;
@@ -60,46 +60,30 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
@Override
public void onCreate(Bundle savedInstanceState) {
+
super.onCreate(savedInstanceState);
- prefs = getSharedPreferences(EXPLORER_PREFS, MODE_PRIVATE);
- viewType = prefs.getInt( EXPLORER_VIEW_TYPE, GRID_VIEW);
-
- actionBar = getActionBar();
+ Log.d(tag, "onCreate");
+ //Set the "home" - top level - directory.
+ homeDirectory = new File(Environment.getExternalStorageDirectory(),"LibreOffice");
+ homeDirectory.mkdirs();
+ currentDirectory = homeDirectory;
+ //Load default settings
+ prefs = getSharedPreferences(EXPLORER_PREFS_KEY, MODE_PRIVATE);
+ viewType = prefs.getInt( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+
+ }
+
+ public void createUI(){
+ 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,
android.R.layout.simple_spinner_dropdown_item);
actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);
-
-
- homeDirectory = new File(Environment.getExternalStorageDirectory(),"LibreOffice");
- homeDirectory.mkdirs();
- currentDirectory = homeDirectory;
- Intent i = this.getIntent();
- if( i.hasExtra( currentDirectoryKey ) ){
- currentDirectory = new File( i.getStringExtra( currentDirectoryKey ) );
- }else{
- if( savedInstanceState != null){
- if( savedInstanceState.getString( currentDirectoryKey ) != null ){
- currentDirectory = new File(
- savedInstanceState.getString( currentDirectoryKey ) );
- }
- }
- }
-
- if( i.hasExtra( filterModeKey ) ){
- filterMode = i.getIntExtra( filterModeKey, FileUtilities.ALL);
- }
if( !currentDirectory.equals( homeDirectory )){
actionBar.setDisplayHomeAsUpEnabled(true);
}
-
- //createDummyFileSystem();
- createUI();
-
- }
-
- public void createUI(){
+
if( viewType == GRID_VIEW){
// code to make a grid view
setContentView(R.layout.file_grid);
@@ -148,7 +132,6 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
public void openDirectory(File dir ){
currentDirectory = dir;
- Log.d(tag, dir.toString() + " " + homeDirectory.toString());
if( !currentDirectory.equals( homeDirectory )){
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
@@ -166,10 +149,10 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
}
public void open(String file){
- //Should add file to the intent as an extra
Intent i = new Intent( this , WriterViewerActivity.class );
- i.putExtra( currentDirectoryKey , currentDirectory.getAbsolutePath() );
- i.putExtra( filterModeKey , filterMode );
+ i.putExtra( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
+ i.putExtra( FILTER_MODE_KEY , filterMode );
+ i.putExtra( EXPLORER_VIEW_TYPE_KEY , viewType );
startActivity( i );
}
@@ -278,21 +261,79 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
- outState.putString( currentDirectoryKey , currentDirectory.getAbsolutePath() );
- prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
+ outState.putString( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
+ outState.putInt( FILTER_MODE_KEY , filterMode );
+ outState.putInt( EXPLORER_VIEW_TYPE_KEY , viewType );
+
+ Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewType) );
+ //prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
+ Log.d(tag, "savedInstanceSate");
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onRestoreInstanceState(savedInstanceState);
- //currentDirectory = new File( savedInstanceState.getString( currentDirectoryKey ) );
+ if( savedInstanceState.isEmpty() ){
+ return;
+ }
+ currentDirectory = new File( savedInstanceState.getString( CURRENT_DIRECTORY_KEY ) );
+ filterMode = savedInstanceState.getInt( FILTER_MODE_KEY , FileUtilities.ALL ) ;
+ viewType = savedInstanceState.getInt( EXPLORER_VIEW_TYPE_KEY , GRID_VIEW );
+ //openDirectory( currentDirectory );
+ Log.d(tag, "onRestoreInstanceState");
+ Log.d(tag, currentDirectory.toString() + Integer.toString(filterMode ) + Integer.toString(viewType) );
}
@Override
protected void onPause() {
-
+ //prefs.edit().putInt(EXPLORER_VIEW_TYPE, viewType).commit();
super.onPause();
+ Log.d(tag, "onPause");
+ }
+
+ @Override
+ protected void onResume() {
+ // TODO Auto-generated method stub
+ super.onResume();
+ Log.d(tag, "onResume");
+ Intent i = this.getIntent();
+ if( i.hasExtra( CURRENT_DIRECTORY_KEY ) ){
+ currentDirectory = new File( i.getStringExtra( CURRENT_DIRECTORY_KEY ) );
+ Log.d(tag, CURRENT_DIRECTORY_KEY);
+ }
+ if( i.hasExtra( FILTER_MODE_KEY ) ){
+ filterMode = i.getIntExtra( FILTER_MODE_KEY, FileUtilities.ALL);
+ Log.d(tag, FILTER_MODE_KEY);
+ }
+ if( i.hasExtra( EXPLORER_VIEW_TYPE_KEY ) ){
+ viewType = i.getIntExtra( EXPLORER_VIEW_TYPE_KEY, GRID_VIEW);
+ Log.d(tag, EXPLORER_VIEW_TYPE_KEY);
+ }
+ createUI();
+ openDirectory( currentDirectory );
+ }
+
+ @Override
+ protected void onStart() {
+ // TODO Auto-generated method stub
+ super.onStart();
+ Log.d(tag, "onStart");
+ }
+
+ @Override
+ protected void onStop() {
+ // TODO Auto-generated method stub
+ super.onStop();
+ Log.d(tag, "onStop");
+ }
+
+ @Override
+ protected void onDestroy() {
+ // TODO Auto-generated method stub
+ super.onDestroy();
+
+ Log.d(tag, "onDestroy");
}
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
index 75f3b1a..d217421 100644
--- a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
+++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java
@@ -15,19 +15,13 @@ public class WriterViewerActivity extends Activity{
private String filterModeKey = "FILTER_MODE";
File dir;
private int filterMode;
+ private Bundle extras;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
- Intent i = this.getIntent();
- if( i.hasExtra( currentDirectoryKey ) ){
- Log.d(currentDirectoryKey, i.getStringExtra( currentDirectoryKey ) );
- dir = new File( i.getStringExtra( currentDirectoryKey ) );
- }
- if( i.hasExtra( filterModeKey ) ){
- //Log.d("FILTER_OC_WRITER", Integer.toString(i.getIntExtra( filterModeKey , FileUtilities.ALL )));
- filterMode = i.getIntExtra( filterModeKey , FileUtilities.ALL );
- }
+ extras = getIntent().getExtras();
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
@@ -39,8 +33,7 @@ public class WriterViewerActivity extends Activity{
case android.R.id.home:
// app icon in action bar clicked; go home
Intent intent = new Intent(this, LibreOfficeUIActivity.class);
- intent.putExtra(currentDirectoryKey, dir.getAbsolutePath() );
- intent.putExtra( filterModeKey , filterMode );
+ intent.putExtras( extras );
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
More information about the Libreoffice-commits
mailing list