Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
43103840
Kaydet (Commit)
43103840
authored
Haz 15, 2012
tarafından
Iain Billett
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added a list view to the Android UI.
üst
629001d4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
453 additions
and
47 deletions
+453
-47
file_list.xml
...-eclipse-workspace/LibreOfficeUI/res/layout/file_list.xml
+14
-0
file_list_item.xml
...pse-workspace/LibreOfficeUI/res/layout/file_list_item.xml
+43
-0
view_menu.xml
...12-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml
+4
-2
strings.xml
...12-eclipse-workspace/LibreOfficeUI/res/values/strings.xml
+2
-0
LibreOfficeUIActivity.java
...fficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+234
-45
ListItemAdapter.java
...LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java
+156
-0
No files found.
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_list.xml
0 → 100644
Dosyayı görüntüle @
43103840
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<ListView
android:id=
"@+id/file_explorer_list_view"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
></ListView>
</LinearLayout>
\ No newline at end of file
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_list_item.xml
0 → 100644
Dosyayı görüntüle @
43103840
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/file_list_item_icon"
android:layout_height=
"match_parent"
android:layout_width=
"32dp"
android:layout_margin=
"8dp"
android:layout_gravity=
"center"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:orientation=
"horizontal"
android:layout_weight=
"3"
>
<TextView
android:id=
"@+id/file_list_item_name"
android:layout_height=
"48dp"
android:layout_width=
"match_parent"
android:textSize=
"16dp"
android:textStyle=
"bold"
android:layout_weight=
"1"
android:gravity=
"center"
/>
<TextView
android:id=
"@+id/file_list_item_size"
android:layout_height=
"48dp"
android:layout_width=
"match_parent"
android:textSize=
"16dp"
android:textStyle=
"bold"
android:layout_weight=
"1"
android:gravity=
"center"
/>
<TextView
android:id=
"@+id/file_list_item_date"
android:layout_height=
"48dp"
android:layout_width=
"match_parent"
android:textSize=
"16dp"
android:textStyle=
"bold"
android:layout_weight=
"1"
android:gravity=
"center"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml
Dosyayı görüntüle @
43103840
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:id=
"@+id/menu_search"
<item
android:id=
"@+id/menu_search"
android:icon=
"@drawable/action_search"
android:icon=
"@drawable/action_search"
android:title=
"@string/menu_search"
android:showAsAction=
"always"
/>
android:showAsAction=
"ifRoom|withText"
/>
<item
android:id=
"@+id/menu_view_toggle"
android:title=
"@string/grid_view"
/>
</menu>
</menu>
\ No newline at end of file
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml
Dosyayı görüntüle @
43103840
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
<string
name=
"hello"
>
Hello World, LibreOfficeUIActivity!
</string>
<string
name=
"hello"
>
Hello World, LibreOfficeUIActivity!
</string>
<string
name=
"app_name"
>
LibreOfficeUI
</string>
<string
name=
"app_name"
>
LibreOfficeUI
</string>
<string
name=
"menu_search"
>
Search
</string>
<string
name=
"menu_search"
>
Search
</string>
<string
name=
"list_view"
>
List
</string>
<string
name=
"grid_view"
>
Grid
</string>
<string-array
name=
"file_view_modes"
>
<string-array
name=
"file_view_modes"
>
<item
>
EVERYTHING
</item>
<item
>
EVERYTHING
</item>
<item
>
DOCUMENTS
</item>
<item
>
DOCUMENTS
</item>
...
...
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java
Dosyayı görüntüle @
43103840
...
@@ -4,30 +4,35 @@ import java.io.File;
...
@@ -4,30 +4,35 @@ import java.io.File;
import
java.io.FileFilter
;
import
java.io.FileFilter
;
import
java.io.FilenameFilter
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
android.app.ActionBar
;
import
android.app.ActionBar
;
import
android.app.ActionBar.OnNavigationListener
;
import
android.app.ActionBar.OnNavigationListener
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.app.ListActivity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.database.DataSetObserver
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.view.View.OnClickListener
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.ArrayAdapter
;
import
android.widget.ArrayAdapter
;
import
android.widget.BaseAdapter
;
import
android.widget.GridView
;
import
android.widget.GridView
;
import
android.widget.ImageView
;
import
android.widget.ListAdapter
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.SpinnerAdapter
;
import
android.widget.SpinnerAdapter
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
public
class
LibreOfficeUIActivity
extends
Activity
implements
OnNavigationListener
{
public
class
LibreOfficeUIActivity
extends
Activity
implements
OnNavigationListener
{
private
String
tag
=
"file_manager"
;
private
String
tag
=
"file_manager"
;
...
@@ -36,21 +41,32 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
...
@@ -36,21 +41,32 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
private
String
filter
=
""
;
private
String
filter
=
""
;
private
String
[]
filters
=
{
"all"
,
".odt"
,
".ods"
,
".odp"
};
private
String
[]
filters
=
{
"all"
,
".odt"
,
".ods"
,
".odp"
};
private
int
filterMode
=
FileUtilities
.
ALL
;
private
int
filterMode
=
FileUtilities
.
ALL
;
private
int
viewType
=
0
;
FileFilter
fileFilter
;
FileFilter
fileFilter
;
FilenameFilter
filenameFilter
;
FilenameFilter
filenameFilter
;
private
String
[]
fileNames
;
private
String
[]
fileNames
;
private
File
[]
filePaths
;
private
File
[]
filePaths
;
private
ActionBar
actionBar
;
private
SharedPreferences
prefs
;
private
String
currentDirectoryKey
=
"CURRENT_DIRECTORY"
;
private
String
currentDirectoryKey
=
"CURRENT_DIRECTORY"
;
private
String
filterModeKey
=
"FILTER_MODE"
;
private
String
filterModeKey
=
"FILTER_MODE"
;
public
static
final
String
EXPLORER_VIEW_TYPE
=
"EXPLORER_VIEW_TYPE"
;
public
static
final
String
EXPLORER_PREFS
=
"EXPLORER_PREFS"
;
public
static
final
int
GRID_VIEW
=
0
;
public
static
final
int
LIST_VIEW
=
1
;
GridView
gv
;
GridView
gv
;
ListView
lv
;
@Override
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
file_grid
);
prefs
=
getSharedPreferences
(
EXPLORER_PREFS
,
MODE_PRIVATE
);
ActionBar
actionBar
=
getActionBar
();
viewType
=
prefs
.
getInt
(
EXPLORER_VIEW_TYPE
,
GRID_VIEW
);
actionBar
=
getActionBar
();
actionBar
.
setDisplayShowTitleEnabled
(
false
);
//This should show current directory if anything
actionBar
.
setDisplayShowTitleEnabled
(
false
);
//This should show current directory if anything
actionBar
.
setNavigationMode
(
ActionBar
.
NAVIGATION_MODE_LIST
);
actionBar
.
setNavigationMode
(
ActionBar
.
NAVIGATION_MODE_LIST
);
SpinnerAdapter
mSpinnerAdapter
=
ArrayAdapter
.
createFromResource
(
this
,
R
.
array
.
file_view_modes
,
SpinnerAdapter
mSpinnerAdapter
=
ArrayAdapter
.
createFromResource
(
this
,
R
.
array
.
file_view_modes
,
...
@@ -62,51 +78,68 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
...
@@ -62,51 +78,68 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
homeDirectory
.
mkdirs
();
homeDirectory
.
mkdirs
();
Intent
i
=
this
.
getIntent
();
Intent
i
=
this
.
getIntent
();
if
(
i
.
hasExtra
(
currentDirectoryKey
)
){
if
(
i
.
hasExtra
(
currentDirectoryKey
)
){
//This isn't what I think it is. It's not a full path
currentDirectory
=
new
File
(
i
.
getStringExtra
(
currentDirectoryKey
)
);
currentDirectory
=
new
File
(
i
.
getStringExtra
(
currentDirectoryKey
)
);
}
else
{
}
else
{
currentDirectory
=
homeDirectory
;
currentDirectory
=
homeDirectory
;
}
}
if
(
i
.
hasExtra
(
filterModeKey
)
){
if
(
i
.
hasExtra
(
filterModeKey
)
){
Log
.
d
(
filterModeKey
+
"_GRID_OC"
,
Integer
.
toString
(
i
.
getIntExtra
(
filterModeKey
,
FileUtilities
.
ALL
)
));
filterMode
=
i
.
getIntExtra
(
filterModeKey
,
FileUtilities
.
ALL
);
filterMode
=
i
.
getIntExtra
(
filterModeKey
,
FileUtilities
.
ALL
);
}
}
if
(
!
currentDirectory
.
equals
(
homeDirectory
)){
if
(
!
currentDirectory
.
equals
(
homeDirectory
)){
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
}
}
//fileFilter = FileUtilities.getFileFilter( filterMode );
//filenameFilter = FileUtilities.getFilenameFilter( filterMode );
createUI
();
//createDummyFileSystem();
}
//filePaths = currentDirectory.listFiles( fileFilter );
//order/filter filePaths here
public
void
createUI
(){
//fileNames = currentDirectory.list( filenameFilter );
if
(
viewType
==
GRID_VIEW
){
// code to make a grid view
// code to make a grid view
setContentView
(
R
.
layout
.
file_grid
);
gv
=
(
GridView
)
findViewById
(
R
.
id
.
file_explorer_grid_view
);
gv
=
(
GridView
)
findViewById
(
R
.
id
.
file_explorer_grid_view
);
//GridItemAdapter gridAdapter = new GridItemAdapter(getApplicationContext(), filePaths );
fileNames
=
currentDirectory
.
list
(
FileUtilities
.
getFilenameFilter
(
filterMode
)
);
//gv.setAdapter(gridAdapter);
filePaths
=
currentDirectory
.
listFiles
(
FileUtilities
.
getFileFilter
(
filterMode
)
);
gv
.
setOnItemClickListener
(
new
OnItemClickListener
()
{
gv
.
setOnItemClickListener
(
new
OnItemClickListener
()
{
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
int
position
,
long
id
)
{
File
file
=
filePaths
[
position
];
File
file
=
filePaths
[
position
];
if
(!
file
.
isDirectory
()){
if
(!
file
.
isDirectory
()){
open
(
fileNames
[
position
]);
open
(
fileNames
[
position
]);
}
else
{
}
else
{
/*fileNames = file.list();
file
=
new
File
(
currentDirectory
,
file
.
getName
()
);
filePaths = file.listFiles();
openDirectory
(
file
);
GridItemAdapter gridAdapter = new GridItemAdapter(getApplicationContext(), filePaths );
}
gv.setAdapter(gridAdapter);*/
file
=
new
File
(
currentDirectory
,
file
.
getName
()
);
}
openDirectory
(
file
);
});
}
gv
.
setAdapter
(
new
GridItemAdapter
(
getApplicationContext
(),
currentDirectory
,
filePaths
)
);
actionBar
.
setSelectedNavigationItem
(
filterMode
+
1
);
//This triggers the listener which modifies the view.
}
}
else
{
});
setContentView
(
R
.
layout
.
file_list
);
actionBar
.
setSelectedNavigationItem
(
filterMode
+
1
);
//This triggers the listener which modifies the view.
lv
=
(
ListView
)
findViewById
(
R
.
id
.
file_explorer_list_view
);
//openDirectory( currentDirectory );
lv
.
setClickable
(
true
);
fileNames
=
currentDirectory
.
list
(
FileUtilities
.
getFilenameFilter
(
filterMode
)
);
filePaths
=
currentDirectory
.
listFiles
(
FileUtilities
.
getFileFilter
(
filterMode
)
);
/*lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Log.d(tag, "click!");
File file = filePaths[position];
if(!file.isDirectory()){
open(fileNames[position]);
}else{
file = new File( currentDirectory, file.getName() );
openDirectory( file );
}
}
});*/
lv
.
setAdapter
(
new
ListItemAdapter
(
getApplicationContext
(),
filePaths
)
);
actionBar
.
setSelectedNavigationItem
(
filterMode
+
1
);
}
}
}
public
void
openDirectory
(
File
dir
){
public
void
openDirectory
(
File
dir
){
...
@@ -121,7 +154,11 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
...
@@ -121,7 +154,11 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
}
}
fileNames
=
currentDirectory
.
list
(
FileUtilities
.
getFilenameFilter
(
filterMode
)
);
fileNames
=
currentDirectory
.
list
(
FileUtilities
.
getFilenameFilter
(
filterMode
)
);
filePaths
=
currentDirectory
.
listFiles
(
FileUtilities
.
getFileFilter
(
filterMode
)
);
filePaths
=
currentDirectory
.
listFiles
(
FileUtilities
.
getFileFilter
(
filterMode
)
);
gv
.
setAdapter
(
new
GridItemAdapter
(
getApplicationContext
(),
currentDirectory
,
filePaths
)
);
if
(
viewType
==
GRID_VIEW
){
gv
.
setAdapter
(
new
GridItemAdapter
(
getApplicationContext
(),
currentDirectory
,
filePaths
)
);
}
else
{
lv
.
setAdapter
(
new
ListItemAdapter
(
getApplicationContext
(),
filePaths
)
);
}
}
}
public
void
open
(
String
file
){
public
void
open
(
String
file
){
...
@@ -136,24 +173,37 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
...
@@ -136,24 +173,37 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
MenuInflater
inflater
=
getMenuInflater
();
MenuInflater
inflater
=
getMenuInflater
();
inflater
.
inflate
(
R
.
menu
.
view_menu
,
menu
);
inflater
.
inflate
(
R
.
menu
.
view_menu
,
menu
);
MenuItem
item
=
(
MenuItem
)
menu
.
findItem
(
R
.
id
.
menu_view_toggle
);
if
(
viewType
==
GRID_VIEW
){
item
.
setTitle
(
R
.
string
.
grid_view
);
}
else
{
item
.
setTitle
(
R
.
string
.
list_view
);
}
return
true
;
return
true
;
}
}
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
switch
(
item
.
getItemId
())
{
case
android
.
R
.
id
.
home
:
case
android
.
R
.
id
.
home
:
// app icon in action bar clicked; go home
//Intent intent = new Intent(this, LibreOfficeUIActivity.class);
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//startActivity(intent);
if
(
!
currentDirectory
.
equals
(
homeDirectory
)
){
if
(
!
currentDirectory
.
equals
(
homeDirectory
)
){
openDirectory
(
currentDirectory
.
getParentFile
()
);
openDirectory
(
currentDirectory
.
getParentFile
()
);
}
}
break
;
return
true
;
case
R
.
id
.
menu_view_toggle
:
if
(
viewType
==
GRID_VIEW
){
viewType
=
LIST_VIEW
;
item
.
setTitle
(
R
.
string
.
grid_view
);
//Button points to next view.
}
else
{
viewType
=
GRID_VIEW
;
item
.
setTitle
(
R
.
string
.
list_view
);
//Button points to next view.
}
createUI
();
break
;
default
:
default
:
return
super
.
onOptionsItemSelected
(
item
);
return
super
.
onOptionsItemSelected
(
item
);
}
}
return
true
;
}
}
public
void
createDummyFileSystem
(){
public
void
createDummyFileSystem
(){
...
@@ -245,6 +295,145 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
...
@@ -245,6 +295,145 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
openDirectory
(
currentDirectory
);
// Uses filter mode
openDirectory
(
currentDirectory
);
// Uses filter mode
return
true
;
return
true
;
}
}
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
;
}
final
int
pos
=
position
;
listItem
.
setClickable
(
true
);
listItem
.
setOnClickListener
(
new
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
Log
.
d
(
"LIST"
,
"click!"
);
open
(
filePaths
[
pos
].
getName
()
);
}
});
// 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
);
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
);
}
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
;
}
}
}
}
...
...
android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/ListItemAdapter.java
0 → 100644
Dosyayı görüntüle @
43103840
package
org
.
libreoffice
.
ui
;
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 an inner class in LibreOfficeUI is impemented */
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
);
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
);
}
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment