From bffa5e5ea8a852bae02f724d9758edd54776b885 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 1 Feb 2013 01:02:20 +0000 Subject: Gave FileBrowser a layout file and a header --- gen/com/lc8n/blauploader/R.java | 178 ++++++++++++++++++++++++------ res/layout/browser.xml | 17 +++ res/layout/filerow.xml | 3 +- src/com/lc8n/blauploader/FileBrowser.java | 106 +++++++++++++++--- 4 files changed, 257 insertions(+), 47 deletions(-) create mode 100644 res/layout/browser.xml diff --git a/gen/com/lc8n/blauploader/R.java b/gen/com/lc8n/blauploader/R.java index 47bafb7..f841ffc 100644 --- a/gen/com/lc8n/blauploader/R.java +++ b/gen/com/lc8n/blauploader/R.java @@ -9,50 +9,86 @@ package com.lc8n.blauploader; public final class R { public static final class attr { + /**

Must be a color value, in the form of "#rgb", "#argb", +"#rrggbb", or "#aarrggbb". +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + */ + public static final int exampleColor=0x7f010002; + /**

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". +Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), +in (inches), mm (millimeters). +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + */ + public static final int exampleDimension=0x7f010001; + /**

May be a reference to another resource, in the form "@[+][package:]type:name" +or to a theme attribute in the form "?[package:][type:]name". +

May be a color value, in the form of "#rgb", "#argb", +"#rrggbb", or "#aarrggbb". + */ + public static final int exampleDrawable=0x7f010003; + /**

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + */ + public static final int exampleString=0x7f010000; } public static final class drawable { public static final int icon=0x7f020000; public static final int marcus72=0x7f020001; } public static final class id { - public static final int ProgressBar01=0x7f070012; - public static final int Record=0x7f070010; - public static final int Stop=0x7f070011; - public static final int audio=0x7f070001; - public static final int browse=0x7f070000; - public static final int content=0x7f070004; - public static final int filename=0x7f070006; - public static final int getlocation=0x7f070014; - public static final int handle=0x7f070005; - public static final int imgquality=0x7f07000c; - public static final int locate=0x7f070002; - public static final int location=0x7f070013; - public static final int menuBrowse=0x7f070017; - public static final int menuExit=0x7f07001a; - public static final int menuLocate=0x7f070019; - public static final int menuRecord=0x7f070018; - public static final int menu_settings=0x7f070016; + public static final int ProgressBar01=0x7f070014; + public static final int Record=0x7f070012; + public static final int Stop=0x7f070013; + public static final int audio=0x7f070003; + public static final int browse=0x7f070002; + public static final int content=0x7f070008; + public static final int directoryname=0x7f070000; + public static final int filelist=0x7f070001; + public static final int filename=0x7f070005; + public static final int getlocation=0x7f070016; + public static final int handle=0x7f07000d; + public static final int imgquality=0x7f07000e; + public static final int locate=0x7f070004; + public static final int location=0x7f070015; + public static final int menuBrowse=0x7f070019; + public static final int menuExit=0x7f07001c; + public static final int menuLocate=0x7f07001b; + public static final int menuRecord=0x7f07001a; + public static final int menu_settings=0x7f070018; public static final int resize=0x7f07000b; public static final int rotateleft=0x7f070009; public static final int rotateright=0x7f07000a; - public static final int slidingDrawer1=0x7f070003; - public static final int tab1=0x7f07000d; - public static final int tab2=0x7f07000e; - public static final int tab3=0x7f07000f; - public static final int thumbnail=0x7f070008; - public static final int uploadfile=0x7f070007; - public static final int uploadlocation=0x7f070015; + public static final int slidingDrawer1=0x7f07000c; + public static final int tab1=0x7f07000f; + public static final int tab2=0x7f070010; + public static final int tab3=0x7f070011; + public static final int thumbnail=0x7f070007; + public static final int uploadfile=0x7f070006; + public static final int uploadlocation=0x7f070017; } public static final class layout { public static final int activity_main=0x7f030000; - public static final int filerow=0x7f030001; - public static final int home=0x7f030002; - public static final int imageshare=0x7f030003; - public static final int share=0x7f030004; - public static final int share2=0x7f030005; - public static final int soundrecorder=0x7f030006; - public static final int upload=0x7f030007; - public static final int uploadlocation=0x7f030008; + public static final int browser=0x7f030001; + public static final int filerow=0x7f030002; + public static final int home=0x7f030003; + public static final int sample_file_list_view=0x7f030004; + public static final int share=0x7f030005; + public static final int share2=0x7f030006; + public static final int soundrecorder=0x7f030007; + public static final int upload=0x7f030008; + public static final int uploadlocation=0x7f030009; } public static final class menu { public static final int activity_main=0x7f060000; @@ -73,4 +109,82 @@ public final class R { */ public static final int LightTheme=0x7f050000; } + public static final class styleable { + /** Attributes that can be used with a FileListView. +

Includes the following attributes:

+ + + + + + + + +
AttributeDescription
{@link #FileListView_exampleColor com.lc8n.blauploader:exampleColor}
{@link #FileListView_exampleDimension com.lc8n.blauploader:exampleDimension}
{@link #FileListView_exampleDrawable com.lc8n.blauploader:exampleDrawable}
{@link #FileListView_exampleString com.lc8n.blauploader:exampleString}
+ @see #FileListView_exampleColor + @see #FileListView_exampleDimension + @see #FileListView_exampleDrawable + @see #FileListView_exampleString + */ + public static final int[] FileListView = { + 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003 + }; + /** +

This symbol is the offset where the {@link com.lc8n.blauploader.R.attr#exampleColor} + attribute's value can be found in the {@link #FileListView} array. + + +

Must be a color value, in the form of "#rgb", "#argb", +"#rrggbb", or "#aarrggbb". +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + @attr name android:exampleColor + */ + public static final int FileListView_exampleColor = 2; + /** +

This symbol is the offset where the {@link com.lc8n.blauploader.R.attr#exampleDimension} + attribute's value can be found in the {@link #FileListView} array. + + +

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". +Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), +in (inches), mm (millimeters). +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + @attr name android:exampleDimension + */ + public static final int FileListView_exampleDimension = 1; + /** +

This symbol is the offset where the {@link com.lc8n.blauploader.R.attr#exampleDrawable} + attribute's value can be found in the {@link #FileListView} array. + + +

May be a reference to another resource, in the form "@[+][package:]type:name" +or to a theme attribute in the form "?[package:][type:]name". +

May be a color value, in the form of "#rgb", "#argb", +"#rrggbb", or "#aarrggbb". + @attr name android:exampleDrawable + */ + public static final int FileListView_exampleDrawable = 3; + /** +

This symbol is the offset where the {@link com.lc8n.blauploader.R.attr#exampleString} + attribute's value can be found in the {@link #FileListView} array. + + +

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. +

This may also be a reference to a resource (in the form +"@[package:]type:name") or +theme attribute (in the form +"?[package:][type:]name") +containing a value of this type. + @attr name android:exampleString + */ + public static final int FileListView_exampleString = 0; + }; } diff --git a/res/layout/browser.xml b/res/layout/browser.xml new file mode 100644 index 0000000..e4edd98 --- /dev/null +++ b/res/layout/browser.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/res/layout/filerow.xml b/res/layout/filerow.xml index 410c666..2780514 100644 --- a/res/layout/filerow.xml +++ b/res/layout/filerow.xml @@ -2,6 +2,5 @@ + android:layout_height="30sp"> 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 directoryEntries = new ArrayList(); @@ -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 directoryList = new ArrayAdapter(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 directoryList = new ArrayAdapter(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); -- cgit v1.2.3