From a86a8ecc27abdc8a84b10270d48aeb2eda23f3bc Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 26 Mar 2012 20:43:11 -0400 Subject: [PATCH] run Eclipse code formatter --- AndroidManifest.xml | 26 ++- res/layout/main.xml | 27 +-- res/layout/row.xml | 33 +-- res/values/strings.xml | 5 +- .../iocipherexample/FileBrowser.java | 203 +++++++++--------- 5 files changed, 151 insertions(+), 143 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index dfbe3ff..6e7bbeb 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,19 +1,25 @@ - - - + package="info.guardianproject.iocipherexample" + android:versionCode="1" + android:versionName="1.0" > + + + + + + - - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/main.xml b/res/layout/main.xml index e297ffc..7ef1e39 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,17 +1,18 @@ - - - + android:orientation="vertical" > + + + + + + \ No newline at end of file diff --git a/res/layout/row.xml b/res/layout/row.xml index fc960f4..58f2daa 100644 --- a/res/layout/row.xml +++ b/res/layout/row.xml @@ -1,17 +1,18 @@ - - - - + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 21377bf..b793786 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,6 @@ - Hello World, FileBrowser! + IOCipherExample - + + \ No newline at end of file diff --git a/src/info/guardianproject/iocipherexample/FileBrowser.java b/src/info/guardianproject/iocipherexample/FileBrowser.java index 4215c19..4fe26f6 100644 --- a/src/info/guardianproject/iocipherexample/FileBrowser.java +++ b/src/info/guardianproject/iocipherexample/FileBrowser.java @@ -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; @@ -17,8 +16,6 @@ import android.widget.ListView; import android.widget.TextView; - - public class FileBrowser extends ListActivity { private List item = null; @@ -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(); //Declare as Array list - path = new ArrayList(); - - - - 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(); + path = new ArrayList(); + + 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); } - - - - } + + } } \ No newline at end of file