Skip to content

Commit fc62d4b

Browse files
committed
0 parents  commit fc62d4b

File tree

18 files changed

+256
-0
lines changed

18 files changed

+256
-0
lines changed

.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="src" path="gen"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="output" path="bin/classes"/>
8+
</classpath>

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
gen/
3+
libs/

.project

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>IOCipherExample</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

AndroidManifest.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="info.guardianproject.iocipherexample"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8"/>
7+
<application android:icon="@drawable/icon" android:label="@string/app_name">
8+
<activity android:name=".FileBrowser"
9+
android:label="@string/app_name">
10+
<intent-filter>
11+
<action android:name="android.intent.action.MAIN" />
12+
<category android:name="android.intent.category.LAUNCHER" />
13+
</intent-filter>
14+
</activity>
15+
16+
</application>
17+
18+
19+
</manifest>

project.properties

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-7

res/drawable-hdpi/folder.png

1015 Bytes
Loading

res/drawable-hdpi/icon.png

4.05 KB
Loading

res/drawable-hdpi/text.png

971 Bytes
Loading

res/drawable-ldpi/folder.png

1015 Bytes
Loading

res/drawable-ldpi/icon.png

1.68 KB
Loading

res/drawable-ldpi/text.png

971 Bytes
Loading

res/drawable-mdpi/folder.png

1015 Bytes
Loading

res/drawable-mdpi/icon.png

2.51 KB
Loading

res/drawable-mdpi/text.png

971 Bytes
Loading

res/layout/main.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="fill_parent"
5+
android:layout_height="fill_parent"
6+
>
7+
<TextView
8+
android:id = "@+id/info"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
/>
12+
<ListView
13+
android:id = "@android:id/list"
14+
android:layout_width = "fill_parent"
15+
android:layout_height = "fill_parent"
16+
android:drawSelectorOnTop = "false"/>
17+
</LinearLayout>

res/layout/row.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content">
6+
<ImageView
7+
android:id ="@+id/icon"
8+
android:layout_width = "wrap_content"
9+
android:layout_height = "wrap_content"
10+
android:paddingRight = "2px"
11+
/>
12+
<TextView
13+
android:id = "@+id/label"
14+
android:layout_width = "fill_parent"
15+
android:layout_height = "wrap_content"
16+
android:textStyle = "bold"/>
17+
</LinearLayout>

res/values/strings.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="hello">Hello World, FileBrowser!</string>
4+
<string name="app_name">IOCipherExample</string>
5+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package info.guardianproject.iocipherexample;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.List;
6+
7+
import android.app.AlertDialog;
8+
import android.app.ListActivity;
9+
import android.content.DialogInterface;
10+
import android.graphics.Color;
11+
import android.os.Bundle;
12+
import android.view.LayoutInflater;
13+
import android.view.View;
14+
import android.view.ViewGroup;
15+
import android.widget.ArrayAdapter;
16+
import android.widget.ImageView;
17+
import android.widget.ListView;
18+
import android.widget.TextView;
19+
20+
21+
22+
public class FileBrowser extends ListActivity {
23+
24+
private List<String> item = null;
25+
private List<String> path = null;
26+
private TextView fileInfo;
27+
private String[] items;
28+
private String root = "/";
29+
30+
/** Called when the activity is first created. */
31+
32+
@Override
33+
public void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.main);
36+
fileInfo = (TextView)findViewById(R.id.info);
37+
getFileList(root);
38+
}
39+
40+
//To make listview for the list of file
41+
public void getFileList(String dirPath){
42+
43+
item = new ArrayList<String>(); //Declare as Array list
44+
path = new ArrayList<String>();
45+
46+
47+
48+
File file = new File(dirPath); // get the file
49+
File[] files = file.listFiles(); //get the list array of file
50+
51+
if(!dirPath.equals(root)){
52+
item.add(root);
53+
path.add(root);// to get back to main list
54+
55+
item.add("..");
56+
path.add(file.getParent()); // back one level
57+
}
58+
59+
for (int i = 0; i < files.length; i++){
60+
61+
File fileItem = files[i];
62+
path.add(fileItem.getPath());
63+
if(fileItem.isDirectory()){
64+
item.add("["+fileItem.getName()+"]"); // input name directory to array list
65+
}
66+
else {
67+
item.add(fileItem.getName()); // input name file to array list
68+
}
69+
}
70+
fileInfo.setText("Info: "+dirPath+" [ " +files.length +" item ]");
71+
items = new String[item.size()]; //declare array with specific number off item
72+
item.toArray(items); //send data arraylist(item) to array(items
73+
setListAdapter(new IconicList()); //set the list with icon
74+
}
75+
76+
@Override
77+
protected void onListItemClick(ListView l, View v, int position, long id){
78+
File file = new File(path.get(position));
79+
if(file.isDirectory()){
80+
if(file.canRead()){
81+
getFileList(path.get(position));
82+
}
83+
else {
84+
new AlertDialog.Builder(this)
85+
.setIcon(R.drawable.icon).setTitle("["+file.getName()+"] folder can't be read")
86+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
87+
88+
//@Override
89+
public void onClick(DialogInterface dialog, int which) {
90+
// TODO Auto-generated method stub
91+
92+
}
93+
}).show();
94+
95+
}
96+
}
97+
else {
98+
new AlertDialog.Builder(this)
99+
.setIcon(R.drawable.icon)
100+
.setTitle("["+file.getName()+"]")
101+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
102+
103+
//@Override
104+
public void onClick(DialogInterface dialog, int which) {
105+
// TODO Auto-generated method stub
106+
107+
}
108+
}).show();
109+
}
110+
}
111+
112+
class IconicList extends ArrayAdapter {
113+
114+
115+
public IconicList() {
116+
super(FileBrowser.this, R.layout.row, items);
117+
118+
// TODO Auto-generated constructor stub
119+
}
120+
121+
public View getView(int position, View convertView, ViewGroup parent){
122+
LayoutInflater inflater = getLayoutInflater(); //to instantiate layout XML file into its corresponding View objects
123+
View row = inflater.inflate(R.layout.row, null); //to Quick access to the LayoutInflater instance that this Window retrieved from its Context.
124+
TextView label = (TextView)row.findViewById(R.id.label); //access the textview for the name file
125+
ImageView icon = (ImageView)row.findViewById(R.id.icon);//access the imageview for the icon list
126+
label.setText(items[position]);
127+
File f = new File(path.get(position)); //get the file according the position
128+
if(f.isDirectory()){ //decide are the file folder or file
129+
icon.setImageResource(R.drawable.folder);
130+
}
131+
else {
132+
icon.setImageResource(R.drawable.text);
133+
}
134+
return(row);
135+
}
136+
137+
138+
139+
}
140+
}

0 commit comments

Comments
 (0)