diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-17 18:04:42 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-17 18:26:33 +0100 |
commit | 87928d31b1ce6a75b4e72beaa218971de74ad890 (patch) | |
tree | c7640abd0c510974f3146fc4fd06fc49dcdddc45 /android | |
parent | f425517f2f0c22462ed463ef37ba76fe5c05df12 (diff) |
android doc browser: let's list file extensions only at a single place
There is still some duplication, as the file type -> resource mapping is
there two times.
Change-Id: I50cd58f1cc62e872fb925556dd151f6392eeeb87
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 88 | ||||
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java | 24 |
2 files changed, 32 insertions, 80 deletions
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 3d33614ab673..d17149404eef 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -241,70 +241,6 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga return true; } - public void createDummyFileSystem(){ - boolean mExternalStorageAvailable = false; - boolean mExternalStorageWriteable = false; - String state = Environment.getExternalStorageState(); - - if (Environment.MEDIA_MOUNTED.equals(state)) { - mExternalStorageAvailable = mExternalStorageWriteable = true; - } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { - mExternalStorageAvailable = true; - mExternalStorageWriteable = false; - } else { - mExternalStorageAvailable = mExternalStorageWriteable = false; - } - if( mExternalStorageAvailable && mExternalStorageWriteable ){//can also check if its writeable - Log.d(tag, Boolean.toString( currentDirectory.mkdir() ) ); - try { - File[] removeList = currentDirectory.listFiles(); - for(File item : removeList){ - if(item.isDirectory()) - continue;//Log.d(tag, item.getPath()); - item.delete(); - } - new File( currentDirectory , "d0.odp" ).createNewFile(); - new File( currentDirectory , "d1.odt" ).createNewFile(); - new File( currentDirectory , "d2.odt" ).createNewFile(); - new File( currentDirectory , "d3.odp" ).createNewFile(); - new File( currentDirectory , "d4.ods" ).createNewFile(); - new File( currentDirectory , "d5.odt" ).createNewFile(); - new File( currentDirectory , "d6.odp" ).createNewFile(); - new File( currentDirectory , "d7.odt" ).createNewFile(); - new File( currentDirectory , "d8.odt" ).createNewFile(); - new File( currentDirectory , "d9.odp" ).createNewFile(); - new File( currentDirectory , "d10.odp" ).createNewFile(); - new File( currentDirectory , "d11.odt" ).createNewFile(); - new File( currentDirectory , "d12.odt" ).createNewFile(); - new File( currentDirectory , "d13.odp" ).createNewFile(); - new File( currentDirectory , "d14.ods" ).createNewFile(); - new File( currentDirectory , "d15.odt" ).createNewFile(); - File templatesDirectory = new File( currentDirectory , "Templates" ); - templatesDirectory.mkdir(); - new File( templatesDirectory , "template1.odt" ).createNewFile(); - new File( templatesDirectory , "template2.odt" ).createNewFile(); - new File( templatesDirectory , "template3.ods" ).createNewFile(); - new File( templatesDirectory , "template4.odp" ).createNewFile(); - File regularDirectory = new File( currentDirectory , "Folder" ); - regularDirectory.mkdir(); - new File( regularDirectory , "yetAnotherDoc.odt" ).createNewFile(); - new File( regularDirectory , "some really long file name.ods" ).createNewFile(); - File anotherRegularDirectory = new File( regularDirectory , "AnotherFolder" ); - anotherRegularDirectory.mkdir(); - new File( anotherRegularDirectory , "yetAnotherDoc2.odt" ).createNewFile(); - //Should put a folder in at some stage. - - } catch (IOException e) { - Log.d(tag, "file io failure"); - e.printStackTrace(); - } - //Log.d(tag, fileStore.toString()); - } - else{ - Log.d(tag, "No External Storage"); - } - } - @SuppressWarnings("unused")//see android:onClick properties in view_menu.xml public void sortFiles(MenuItem item){ switch ( item.getItemId() ) { @@ -527,14 +463,22 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga // set image based on selected text ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon); - if( filePaths[position].getName().endsWith(".odt") ){ - imageView.setImageResource(R.drawable.writer); - } - if( filePaths[position].getName().endsWith(".ods") ){ - imageView.setImageResource(R.drawable.calc); - } - if( filePaths[position].getName().endsWith(".odp") ){ - imageView.setImageResource(R.drawable.impress); + switch (FileUtilities.getType(filePaths[position].getName())) + { + case FileUtilities.DOC: + imageView.setImageResource(R.drawable.writer); + break; + /*case FileUtilities.CALC: + imageView.setImageResource(R.drawable.calc); + break;*/ + case FileUtilities.DRAWING: + imageView.setImageResource(R.drawable.draw); + break; + case FileUtilities.IMPRESS: + imageView.setImageResource(R.drawable.impress); + break; + default: + break; } if( filePaths[position].isDirectory() ){ //Eventually have thumbnails of each sub file on a black circle diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java index 79e3c04c69f7..9386bf91bff4 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/ListItemAdapter.java @@ -112,14 +112,22 @@ public class ListItemAdapter implements ListAdapter{ // set image based on selected text ImageView imageView = (ImageView) listItem.findViewById(R.id.file_list_item_icon); - if( filePaths[position].getName().endsWith(".odt") ){ - imageView.setImageResource(R.drawable.writer); - } - if( filePaths[position].getName().endsWith(".ods") ){ - imageView.setImageResource(R.drawable.calc); - } - if( filePaths[position].getName().endsWith(".odp") ){ - imageView.setImageResource(R.drawable.impress); + switch (FileUtilities.getType(filePaths[position].getName())) + { + case FileUtilities.DOC: + imageView.setImageResource(R.drawable.writer); + break; + /*case FileUtilities.CALC: + imageView.setImageResource(R.drawable.calc); + break;*/ + case FileUtilities.DRAWING: + imageView.setImageResource(R.drawable.draw); + break; + case FileUtilities.IMPRESS: + imageView.setImageResource(R.drawable.impress); + break; + default: + break; } if( filePaths[position].isDirectory() ){ //Eventually have thumbnails of each sub file on a black circle |