summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/lc8n/blauploader/FileBrowser.java106
1 files changed, 93 insertions, 13 deletions
diff --git a/src/com/lc8n/blauploader/FileBrowser.java b/src/com/lc8n/blauploader/FileBrowser.java
index 279ed2c..890ee28 100644
--- a/src/com/lc8n/blauploader/FileBrowser.java
+++ b/src/com/lc8n/blauploader/FileBrowser.java
@@ -23,7 +23,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import android.app.ListActivity;
+import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -33,11 +33,13 @@ import android.telephony.SmsManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
+import android.view.View;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.TextView;
-public class FileBrowser extends ListActivity {
+public class FileBrowser extends Activity {
/** Called when the activity is first created. */
private List<String> directoryEntries = new ArrayList<String>();
@@ -45,31 +47,108 @@ public class FileBrowser extends ListActivity {
private float fileSize = 0;
private Handler pbHandle = null;
private ProgressDialog progressDialog;
+ private ListView fileList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
+ setContentView(R.layout.browser);
directoryEntries.clear();
File[] files = currentDirectory.listFiles();
- directoryEntries.add("Directory:"+currentDirectory.getAbsolutePath());
+ //directoryEntries.add("Directory:"+currentDirectory.getAbsolutePath());
directoryEntries.add("Up One Level");
if (files != null)
{
for (File file: files)
{
- directoryEntries.add(file.getPath());
+ directoryEntries.add(file.getAbsolutePath());
// System.out.println(file.getPath());
}
}
+
+ TextView header = (TextView)findViewById(R.id.directoryname);
+ header.setText(currentDirectory.getAbsolutePath());
ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries);
+ fileList = (ListView)findViewById(R.id.filelist);
- this.setListAdapter(directoryList);
+ fileList.setAdapter(directoryList);
+ fileList.setOnItemClickListener(new ListView.OnItemClickListener() {
+
+
+
+ public void onItemClick(AdapterView<?> l, View v, int position,
+ long id) {
+
+ String fileString = directoryEntries.get(position);
+
+
+ if(fileString.contains("Directory:"))
+ {
+ browseTo(currentDirectory);
+ }
+ else if (fileString.equals("Up One Level"))
+ {
+ System.out.println(currentDirectory.getParentFile().getPath());
+ if (currentDirectory.getParent() != null)
+ {
+ currentDirectory = currentDirectory.getParentFile();
+ browseTo(currentDirectory);
+ }
+ }
+ else
+ {
+
+
+ File chosenFile = new File(fileString);
+ if (chosenFile.isDirectory())
+ {
+ currentDirectory = chosenFile;
+ browseTo(currentDirectory);
+ }
+ else
+ {
+
+ //upload it
+ try {
+
+ fileSize = chosenFile.length();
+
+
+
+
+
+
+ FileUpload fu = new FileUpload(chosenFile,pbHandle);
+ Thread thread = new Thread(fu);
+
+ thread.start();
+
+ SmsManager sms = SmsManager.getDefault();
+ sms.sendTextMessage("07927278978", null, "New file blauploaded: http://www.blaupload.co.uk/"+chosenFile.getName(), null, null);
+
+
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
+
+ }
+
+ }
+
+ }
+
+
+
+ });
progressDialog = new ProgressDialog(this);
-
+
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Blauploading...");
@@ -116,25 +195,26 @@ public class FileBrowser extends ListActivity {
directoryEntries.clear();
File[] files = dir.listFiles();
- directoryEntries.add("Current Directory:"+currentDirectory.getAbsolutePath());
+ //directoryEntries.add("Current Directory:"+currentDirectory.getAbsolutePath());
directoryEntries.add("Up One Level");
-
+ TextView header = (TextView)findViewById(R.id.directoryname);
+ header.setText(currentDirectory.getAbsolutePath());
// System.out.println(files.length);
if(files != null)
{
for (File file: files)
{
- directoryEntries.add(file.getPath());
+ directoryEntries.add(file.getAbsolutePath());
System.out.println(file.getPath());
}
}
ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries);
- this.setListAdapter(directoryList);
+ fileList.setAdapter(directoryList);
}
- @Override
+ //Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String fileString = directoryEntries.get(position);