Skip to content

Commit

Permalink
run Eclipse code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
eighthave committed Mar 27, 2012
1 parent fc62d4b commit a86a8ec
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 143 deletions.
26 changes: 16 additions & 10 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.guardianproject.iocipherexample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".FileBrowser"
android:label="@string/app_name">
package="info.guardianproject.iocipherexample"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />

<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:name=".FileBrowser"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>


</manifest>
</manifest>
27 changes: 14 additions & 13 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id = "@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:id = "@android:id/list"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:drawSelectorOnTop = "false"/>
</LinearLayout>
android:orientation="vertical" >

<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false" />

</LinearLayout>
33 changes: 17 additions & 16 deletions res/layout/row.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id ="@+id/icon"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:paddingRight = "2px"
/>
<TextView
android:id = "@+id/label"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:textStyle = "bold"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="2px" />

<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold" />

</LinearLayout>
5 changes: 3 additions & 2 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, FileBrowser!</string>

<string name="app_name">IOCipherExample</string>
</resources>

</resources>
203 changes: 101 additions & 102 deletions src/info/guardianproject/iocipherexample/FileBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -17,8 +16,6 @@
import android.widget.ListView;
import android.widget.TextView;



public class FileBrowser extends ListActivity {

private List<String> item = null;
Expand All @@ -28,113 +25,115 @@ public class FileBrowser extends ListActivity {
private String root = "/";

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
fileInfo = (TextView)findViewById(R.id.info);
getFileList(root);
}

//To make listview for the list of file
public void getFileList(String dirPath){

item = new ArrayList<String>(); //Declare as Array list
path = new ArrayList<String>();



File file = new File(dirPath); // get the file
File[] files = file.listFiles(); //get the list array of file

if(!dirPath.equals(root)){
item.add(root);
path.add(root);// to get back to main list

item.add("..");
path.add(file.getParent()); // back one level
}

for (int i = 0; i < files.length; i++){

File fileItem = files[i];
path.add(fileItem.getPath());
if(fileItem.isDirectory()){
item.add("["+fileItem.getName()+"]"); // input name directory to array list
}
else {
item.add(fileItem.getName()); // input name file to array list
}
}
fileInfo.setText("Info: "+dirPath+" [ " +files.length +" item ]");
items = new String[item.size()]; //declare array with specific number off item
item.toArray(items); //send data arraylist(item) to array(items
setListAdapter(new IconicList()); //set the list with icon
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id){
File file = new File(path.get(position));
if(file.isDirectory()){
if(file.canRead()){
getFileList(path.get(position));
}
else {
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon).setTitle("["+file.getName()+"] folder can't be read")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {

//@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}
}).show();

}
}
else {
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("["+file.getName()+"]")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {

//@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}
}).show();
}
}

class IconicList extends ArrayAdapter {



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
fileInfo = (TextView) findViewById(R.id.info);
getFileList(root);
}

// To make listview for the list of file
public void getFileList(String dirPath) {

item = new ArrayList<String>();
path = new ArrayList<String>();

File file = new File(dirPath);
File[] files = file.listFiles();

if (!dirPath.equals(root)) {
item.add(root);
path.add(root);// to get back to main list

item.add("..");
path.add(file.getParent()); // back one level
}

for (int i = 0; i < files.length; i++) {

File fileItem = files[i];
path.add(fileItem.getPath());
if (fileItem.isDirectory()) {
// input name directory to array list
item.add("[" + fileItem.getName() + "]");
} else {
// input name file to array list
item.add(fileItem.getName());
}
}
fileInfo.setText("Info: " + dirPath + " [ " + files.length + " item ]");
// declare array with specific number of items
items = new String[item.size()];
// send data arraylist(item) to array(items)
item.toArray(items);
setListAdapter(new IconicList());
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
File file = new File(path.get(position));
if (file.isDirectory()) {
if (file.canRead()) {
getFileList(path.get(position));
} else {
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle(
"[" + file.getName() + "] folder can't be read")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {

// @Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub

}
}).show();

}
} else {
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getName() + "]")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {

// @Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub

}
}).show();
}
}

class IconicList extends ArrayAdapter {

public IconicList() {
super(FileBrowser.this, R.layout.row, items);

// TODO Auto-generated constructor stub
}
public View getView(int position, View convertView, ViewGroup parent){
LayoutInflater inflater = getLayoutInflater(); //to instantiate layout XML file into its corresponding View objects
View row = inflater.inflate(R.layout.row, null); //to Quick access to the LayoutInflater instance that this Window retrieved from its Context.
TextView label = (TextView)row.findViewById(R.id.label); //access the textview for the name file
ImageView icon = (ImageView)row.findViewById(R.id.icon);//access the imageview for the icon list

public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.row, null);
TextView label = (TextView) row.findViewById(R.id.label);
ImageView icon = (ImageView) row.findViewById(R.id.icon);
label.setText(items[position]);
File f = new File(path.get(position)); //get the file according the position
if(f.isDirectory()){ //decide are the file folder or file
File f = new File(path.get(position)); // get the file according the
// position
if (f.isDirectory()) {
icon.setImageResource(R.drawable.folder);
}
else {
} else {
icon.setImageResource(R.drawable.text);
}
return(row);
return (row);
}



}

}
}

0 comments on commit a86a8ec

Please sign in to comment.