diff options
46 files changed, 1413 insertions, 956 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 58d6c60..ea526c3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,56 +1,65 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.lc8n.blauploader" - android:versionCode="1" - android:versionName="1.0"> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - - <activity android:name=".HomeScreen" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter></activity> - - <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> - <intent-filter> - <action android:name="android.intent.action.SEND" /> - <category android:name="android.intent.category.DEFAULT" /> - <data android:mimeType="text/plain" /> - </intent-filter> - - </activity> - - - - <activity android:name=".SoundRecorder" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter></activity> - - - <activity android:name=".UploadLocation" - 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> - <uses-sdk android:minSdkVersion="7" /> - <uses-permission android:name="android.permission.INTERNET"></uses-permission> - <uses-permission android:name="android.permission.RECORD_AUDIO" /> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> - <uses-permission android:name="android.permission.SEND_SMS" /> - - +<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.lc8n.blauploader"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+
+ <activity android:name=".HomeScreen"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter></activity>
+
+ <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>
+
+ <activity android:name=".FileShare"
+ android:label="Blaupload File">
+ <intent-filter>
+ <action android:name="android.intent.action.SEND" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="image/*" />
+ </intent-filter>
+
+ </activity>
+
+
+
+ <activity android:name=".SoundRecorder"
+ android:label="@string/app_name">
+ <!-- intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter> -->
+ </activity>
+
+
+ <activity android:name=".UploadLocation"
+ 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>
+ <uses-sdk android:minSdkVersion="7" />
+ <uses-permission android:name="android.permission.INTERNET"></uses-permission>
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.SEND_SMS" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+
+
</manifest>
\ No newline at end of file @@ -1,5 +1,5 @@ -One day, this might be a readme file. - -Right now, it's not a readme file. - -Sorry. +One day, this might be a readme file.
+
+Right now, it's not a readme file.
+
+Sorry.
diff --git a/bin/com/lc8n/blauploader/FileBrowser.class b/bin/com/lc8n/blauploader/FileBrowser.class Binary files differindex e4ba7f8..db356c6 100644 --- a/bin/com/lc8n/blauploader/FileBrowser.class +++ b/bin/com/lc8n/blauploader/FileBrowser.class diff --git a/bin/com/lc8n/blauploader/FileShare$1.class b/bin/com/lc8n/blauploader/FileShare$1.class Binary files differnew file mode 100644 index 0000000..b03e124 --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare$1.class diff --git a/bin/com/lc8n/blauploader/FileShare$2.class b/bin/com/lc8n/blauploader/FileShare$2.class Binary files differnew file mode 100644 index 0000000..91d4a68 --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare$2.class diff --git a/bin/com/lc8n/blauploader/FileShare$3.class b/bin/com/lc8n/blauploader/FileShare$3.class Binary files differnew file mode 100644 index 0000000..a3d2d3c --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare$3.class diff --git a/bin/com/lc8n/blauploader/FileShare$4.class b/bin/com/lc8n/blauploader/FileShare$4.class Binary files differnew file mode 100644 index 0000000..3e774df --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare$4.class diff --git a/bin/com/lc8n/blauploader/FileShare$5.class b/bin/com/lc8n/blauploader/FileShare$5.class Binary files differnew file mode 100644 index 0000000..90755fc --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare$5.class diff --git a/bin/com/lc8n/blauploader/FileShare.class b/bin/com/lc8n/blauploader/FileShare.class Binary files differnew file mode 100644 index 0000000..2370629 --- /dev/null +++ b/bin/com/lc8n/blauploader/FileShare.class diff --git a/bin/com/lc8n/blauploader/FileUpload.class b/bin/com/lc8n/blauploader/FileUpload.class Binary files differindex fa10fff..2854498 100644 --- a/bin/com/lc8n/blauploader/FileUpload.class +++ b/bin/com/lc8n/blauploader/FileUpload.class diff --git a/bin/com/lc8n/blauploader/HomeScreen$1.class b/bin/com/lc8n/blauploader/HomeScreen$1.class Binary files differindex 3d386ac..274682b 100644 --- a/bin/com/lc8n/blauploader/HomeScreen$1.class +++ b/bin/com/lc8n/blauploader/HomeScreen$1.class diff --git a/bin/com/lc8n/blauploader/HomeScreen$2.class b/bin/com/lc8n/blauploader/HomeScreen$2.class Binary files differindex d7fa6f9..bfbc125 100644 --- a/bin/com/lc8n/blauploader/HomeScreen$2.class +++ b/bin/com/lc8n/blauploader/HomeScreen$2.class diff --git a/bin/com/lc8n/blauploader/HomeScreen$3.class b/bin/com/lc8n/blauploader/HomeScreen$3.class Binary files differindex 2118eae..47719f9 100644 --- a/bin/com/lc8n/blauploader/HomeScreen$3.class +++ b/bin/com/lc8n/blauploader/HomeScreen$3.class diff --git a/bin/com/lc8n/blauploader/HomeScreen.class b/bin/com/lc8n/blauploader/HomeScreen.class Binary files differindex 3c29b11..1899b6d 100644 --- a/bin/com/lc8n/blauploader/HomeScreen.class +++ b/bin/com/lc8n/blauploader/HomeScreen.class diff --git a/bin/com/lc8n/blauploader/R$drawable.class b/bin/com/lc8n/blauploader/R$drawable.class Binary files differindex a29ff28..0dea56c 100644 --- a/bin/com/lc8n/blauploader/R$drawable.class +++ b/bin/com/lc8n/blauploader/R$drawable.class diff --git a/bin/com/lc8n/blauploader/R$id.class b/bin/com/lc8n/blauploader/R$id.class Binary files differindex be7fa1b..84999bb 100644 --- a/bin/com/lc8n/blauploader/R$id.class +++ b/bin/com/lc8n/blauploader/R$id.class diff --git a/bin/com/lc8n/blauploader/R$layout.class b/bin/com/lc8n/blauploader/R$layout.class Binary files differindex 696fcb7..ae76dce 100644 --- a/bin/com/lc8n/blauploader/R$layout.class +++ b/bin/com/lc8n/blauploader/R$layout.class diff --git a/bin/com/lc8n/blauploader/R$menu.class b/bin/com/lc8n/blauploader/R$menu.class Binary files differindex 56e1859..12ba949 100644 --- a/bin/com/lc8n/blauploader/R$menu.class +++ b/bin/com/lc8n/blauploader/R$menu.class diff --git a/bin/com/lc8n/blauploader/R$string.class b/bin/com/lc8n/blauploader/R$string.class Binary files differindex 527b01a..2e6d248 100644 --- a/bin/com/lc8n/blauploader/R$string.class +++ b/bin/com/lc8n/blauploader/R$string.class diff --git a/bin/com/lc8n/blauploader/SoundRecorder.class b/bin/com/lc8n/blauploader/SoundRecorder.class Binary files differindex 74aaca6..41f0b58 100644 --- a/bin/com/lc8n/blauploader/SoundRecorder.class +++ b/bin/com/lc8n/blauploader/SoundRecorder.class diff --git a/bin/com/lc8n/blauploader/UploadLocation$1.class b/bin/com/lc8n/blauploader/UploadLocation$1.class Binary files differindex 7885eb5..e5e5dc3 100644 --- a/bin/com/lc8n/blauploader/UploadLocation$1.class +++ b/bin/com/lc8n/blauploader/UploadLocation$1.class diff --git a/bin/com/lc8n/blauploader/UploadLocation$2.class b/bin/com/lc8n/blauploader/UploadLocation$2.class Binary files differindex 13f8942..62ea06c 100644 --- a/bin/com/lc8n/blauploader/UploadLocation$2.class +++ b/bin/com/lc8n/blauploader/UploadLocation$2.class diff --git a/bin/com/lc8n/blauploader/UploadLocation$MyLocationListener.class b/bin/com/lc8n/blauploader/UploadLocation$MyLocationListener.class Binary files differindex e7b2a3c..997a177 100644 --- a/bin/com/lc8n/blauploader/UploadLocation$MyLocationListener.class +++ b/bin/com/lc8n/blauploader/UploadLocation$MyLocationListener.class diff --git a/bin/com/lc8n/blauploader/UploadLocation.class b/bin/com/lc8n/blauploader/UploadLocation.class Binary files differindex 04af09b..aaa8c0e 100644 --- a/bin/com/lc8n/blauploader/UploadLocation.class +++ b/bin/com/lc8n/blauploader/UploadLocation.class diff --git a/bin/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.class b/bin/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.class Binary files differindex 6449876..d755cd7 100644 --- a/bin/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.class +++ b/bin/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.class diff --git a/default.properties b/default.properties index 9d135cb..0b9250e 100644 --- a/default.properties +++ b/default.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-7 +target=android-8 diff --git a/gen/com/lc8n/blauploader/R.java b/gen/com/lc8n/blauploader/R.java index ea04b00..64da886 100644 --- a/gen/com/lc8n/blauploader/R.java +++ b/gen/com/lc8n/blauploader/R.java @@ -12,34 +12,39 @@ public final class R { } 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=0x7f060005; - public static final int Record=0x7f060003; - public static final int Stop=0x7f060004; + public static final int ProgressBar01=0x7f060007; + public static final int Record=0x7f060005; + public static final int Stop=0x7f060006; public static final int audio=0x7f060001; public static final int browse=0x7f060000; - public static final int getlocation=0x7f060007; + public static final int filename=0x7f060003; + public static final int getlocation=0x7f060009; public static final int locate=0x7f060002; - public static final int location=0x7f060006; - public static final int menuBrowse=0x7f060009; - public static final int menuExit=0x7f06000c; - public static final int menuLocate=0x7f06000b; - public static final int menuRecord=0x7f06000a; - public static final int uploadlocation=0x7f060008; + public static final int location=0x7f060008; + public static final int menuBrowse=0x7f06000b; + public static final int menuExit=0x7f06000e; + public static final int menuLocate=0x7f06000d; + public static final int menuRecord=0x7f06000c; + public static final int uploadfile=0x7f060004; + public static final int uploadlocation=0x7f06000a; } public static final class layout { public static final int filerow=0x7f030000; public static final int home=0x7f030001; - public static final int soundrecorder=0x7f030002; - public static final int upload=0x7f030003; - public static final int uploadlocation=0x7f030004; + public static final int share=0x7f030002; + public static final int soundrecorder=0x7f030003; + public static final int upload=0x7f030004; + public static final int uploadlocation=0x7f030005; } public static final class menu { public static final int menu=0x7f050000; } public static final class string { public static final int app_name=0x7f040001; + public static final int cancel=0x7f040002; public static final int hello=0x7f040000; } } diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png Binary files differindex 8074c4c..adaeefb 100644 --- a/res/drawable-hdpi/icon.png +++ b/res/drawable-hdpi/icon.png diff --git a/res/drawable-hdpi/marcus72.png b/res/drawable-hdpi/marcus72.png Binary files differnew file mode 100644 index 0000000..b93712d --- /dev/null +++ b/res/drawable-hdpi/marcus72.png diff --git a/res/drawable-ldpi/icon.png b/res/drawable-ldpi/icon.png Binary files differindex 1095584..4744bb9 100644 --- a/res/drawable-ldpi/icon.png +++ b/res/drawable-ldpi/icon.png diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png Binary files differindex a07c69f..a8a7390 100644 --- a/res/drawable-mdpi/icon.png +++ b/res/drawable-mdpi/icon.png diff --git a/res/layout/filerow.xml b/res/layout/filerow.xml index 7f12ffa..410c666 100644 --- a/res/layout/filerow.xml +++ b/res/layout/filerow.xml @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="utf-8"?> -<TextView - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="30sp" - android:typeface="monospace"> -</TextView> +<?xml version="1.0" encoding="utf-8"?>
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="30sp"
+ android:typeface="monospace">
+</TextView>
diff --git a/res/layout/home.xml b/res/layout/home.xml index c17cf47..a68954f 100644 --- a/res/layout/home.xml +++ b/res/layout/home.xml @@ -1,29 +1,29 @@ -<?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"> - <Button - android:id="@+id/browse" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:layout_weight="1" - android:text="Upload File" - /> - <Button - android:id="@+id/audio" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:layout_weight="1" - android:text="Record Audio" - /> - <Button - android:id="@+id/locate" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:layout_weight="1" - android:text="Find Location" - /> - -</LinearLayout> +<?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">
+ <Button
+ android:id="@+id/browse"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_weight="1"
+ android:text="Upload File"
+ />
+ <Button
+ android:id="@+id/audio"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_weight="1"
+ android:text="Record Audio"
+ />
+ <Button
+ android:id="@+id/locate"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_weight="1"
+ android:text="Find Location"
+ />
+
+</LinearLayout>
diff --git a/res/layout/share.xml b/res/layout/share.xml new file mode 100644 index 0000000..6a70ea3 --- /dev/null +++ b/res/layout/share.xml @@ -0,0 +1,30 @@ +<?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:text="Enter Filename" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> + <EditText + android:id="@+id/filename" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:focusable="true" + /> + <TextView + android:text=" " + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> + <Button + android:id="@+id/uploadfile" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:text="Upload" + /> + +</LinearLayout> diff --git a/res/layout/soundrecorder.xml b/res/layout/soundrecorder.xml index 184bbae..f707e88 100644 --- a/res/layout/soundrecorder.xml +++ b/res/layout/soundrecorder.xml @@ -1,18 +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"> - <Button - android:id="@+id/Record" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:text="Record" -/> - <Button - android:id="@+id/Stop" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:text="Stop" -/> -</LinearLayout> +<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/Record"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:text="Record"
+/>
+ <Button
+ android:id="@+id/Stop"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:text="Stop"
+/>
+</LinearLayout>
diff --git a/res/layout/upload.xml b/res/layout/upload.xml index 13a38b7..d56345d 100644 --- a/res/layout/upload.xml +++ b/res/layout/upload.xml @@ -1,19 +1,19 @@ -<?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" - > -<ListView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" - /> - <ProgressBar -android:id="@+id/ProgressBar01" -android:indeterminateOnly="false" -android:progressDrawable="@android:drawable/progress_horizontal" -android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal" -android:minHeight="20dip" -android:maxHeight="20dip" android:layout_width="fill_parent"/> -</LinearLayout> +<?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"
+ >
+<ListView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+ <ProgressBar
+android:id="@+id/ProgressBar01"
+android:indeterminateOnly="false"
+android:progressDrawable="@android:drawable/progress_horizontal"
+android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
+android:minHeight="20dip"
+android:maxHeight="20dip" android:layout_width="fill_parent"/>
+</LinearLayout>
diff --git a/res/layout/uploadlocation.xml b/res/layout/uploadlocation.xml index f924d43..69251e4 100644 --- a/res/layout/uploadlocation.xml +++ b/res/layout/uploadlocation.xml @@ -1,36 +1,36 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - <TextView - android:text="Current Location" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - /> - <TextView - android:id="@+id/location" - android:text="" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - /> - <LinearLayout - android:orientation="horizontal" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - > - <Button - android:id="@+id/getlocation" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:text="Get Location" -/> - <Button - android:id="@+id/uploadlocation" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:text="Upload" -/> -</LinearLayout> -</LinearLayout> +<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <TextView
+ android:text="Current Location"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ />
+ <TextView
+ android:id="@+id/location"
+ android:text=""
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ >
+ <Button
+ android:id="@+id/getlocation"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="Get Location"
+/>
+ <Button
+ android:id="@+id/uploadlocation"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="Upload"
+/>
+</LinearLayout>
+</LinearLayout>
diff --git a/res/menu/menu.xml b/res/menu/menu.xml index ffc9eca..1d60246 100644 --- a/res/menu/menu.xml +++ b/res/menu/menu.xml @@ -1,16 +1,16 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu - xmlns:android="http://schemas.android.com/apk/res/android"> -<item android:id="@+id/menuBrowse" - android:icon="@android:drawable/ic_menu_upload" - android:title="Upload Files"></item> -<item android:id="@+id/menuRecord" - android:icon="@android:drawable/ic_btn_speak_now" - android:title="Record Audio"></item> -<item android:id="@+id/menuLocate" - android:icon="@android:drawable/ic_menu_compass" - android:title="Send Location"></item> -<item android:id="@+id/menuExit" - android:icon="@android:drawable/ic_menu_close_clear_cancel" - android:title="Exit"></item> -</menu> +<?xml version="1.0" encoding="utf-8"?>
+<menu
+ xmlns:android="http://schemas.android.com/apk/res/android">
+<item android:id="@+id/menuBrowse"
+ android:icon="@android:drawable/ic_menu_upload"
+ android:title="Upload Files"></item>
+<item android:id="@+id/menuRecord"
+ android:icon="@android:drawable/ic_btn_speak_now"
+ android:title="Record Audio"></item>
+<item android:id="@+id/menuLocate"
+ android:icon="@android:drawable/ic_menu_compass"
+ android:title="Send Location"></item>
+<item android:id="@+id/menuExit"
+ android:icon="@android:drawable/ic_menu_close_clear_cancel"
+ android:title="Exit"></item>
+</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml index 4f00040..9e611cf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,6 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hello">Hello World, fileBrowser!</string> - <string name="app_name">blauploader</string> -</resources> +<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, fileBrowser!</string>
+ <string name="app_name">blauploader</string>
+ <string name="cancel">Cancel</string>
+</resources>
diff --git a/src/com/lc8n/blauploader/FileBrowser.java b/src/com/lc8n/blauploader/FileBrowser.java index 18d2214..279ed2c 100644 --- a/src/com/lc8n/blauploader/FileBrowser.java +++ b/src/com/lc8n/blauploader/FileBrowser.java @@ -1,239 +1,239 @@ -/* - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Copyright 2010 Joe Robinson <joe@lc8n.com> -*/ - -package com.lc8n.blauploader; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import android.app.ListActivity; -import android.app.ProgressDialog; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.telephony.SmsManager; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -public class FileBrowser extends ListActivity { - /** Called when the activity is first created. */ - - private List<String> directoryEntries = new ArrayList<String>(); - private File currentDirectory = new File("/"); - private float fileSize = 0; - private Handler pbHandle = null; - private ProgressDialog progressDialog; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - - directoryEntries.clear(); - - File[] files = currentDirectory.listFiles(); - directoryEntries.add("Directory:"+currentDirectory.getAbsolutePath()); - directoryEntries.add("Up One Level"); - if (files != null) - { - for (File file: files) - { - directoryEntries.add(file.getPath()); -// System.out.println(file.getPath()); - } - } - ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries); - - this.setListAdapter(directoryList); - - progressDialog = new ProgressDialog(this); - - - progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); - progressDialog.setMessage("Blauploading..."); - progressDialog.setCancelable(true); - progressDialog.setProgress(0); - - -// -// - - - - pbHandle = new Handler(){ - - @Override - public void handleMessage(Message msg) { - - /* get the value from the Message */ - - long progress = msg.getData().getLong("progress_update"); - System.out.println(progress+"/"+fileSize); - if(progress>(fileSize-10240)) - { - progressDialog.dismiss(); - } - float percent = (progress/fileSize)*100; - Integer intProgress = Math.round(percent); - if(intProgress==100) - { - progressDialog.dismiss(); - } - else - { - progressDialog.show(); - progressDialog.setProgress(intProgress); - } - } - }; - - } - - public void browseTo(File dir) - { - directoryEntries.clear(); - - File[] files = dir.listFiles(); - directoryEntries.add("Current Directory:"+currentDirectory.getAbsolutePath()); - directoryEntries.add("Up One Level"); - -// System.out.println(files.length); - if(files != null) - { - for (File file: files) - { - directoryEntries.add(file.getPath()); - System.out.println(file.getPath()); - } - } - ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries); - - this.setListAdapter(directoryList); - } - - - @Override - protected void onListItemClick(ListView 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, "wjoe 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(); - } - - } - - } - - - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.menu, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - case R.id.menuBrowse: -// Intent browse = new Intent(this, FileBrowser.class); -// startActivityForResult(browse, 0);; - return true; - case R.id.menuRecord: - Intent record = new Intent(this, SoundRecorder.class); - startActivityForResult(record, 0); - return true; - case R.id.menuLocate: - Intent locate = new Intent(this, UploadLocation.class); - startActivityForResult(locate, 0);; - return true; - case R.id.menuExit: - this.finish(); - break; - default: - return super.onOptionsItemSelected(item); - - } - return true; - - } - - - +/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Copyright 2010 Joe Robinson <joe@lc8n.com>
+*/
+
+package com.lc8n.blauploader;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import android.app.ListActivity;
+import android.app.ProgressDialog;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.telephony.SmsManager;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class FileBrowser extends ListActivity {
+ /** Called when the activity is first created. */
+
+ private List<String> directoryEntries = new ArrayList<String>();
+ private File currentDirectory = new File("/");
+ private float fileSize = 0;
+ private Handler pbHandle = null;
+ private ProgressDialog progressDialog;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+ directoryEntries.clear();
+
+ File[] files = currentDirectory.listFiles();
+ directoryEntries.add("Directory:"+currentDirectory.getAbsolutePath());
+ directoryEntries.add("Up One Level");
+ if (files != null)
+ {
+ for (File file: files)
+ {
+ directoryEntries.add(file.getPath());
+// System.out.println(file.getPath());
+ }
+ }
+ ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries);
+
+ this.setListAdapter(directoryList);
+
+ progressDialog = new ProgressDialog(this);
+
+
+ progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ progressDialog.setMessage("Blauploading...");
+ progressDialog.setCancelable(true);
+ progressDialog.setProgress(0);
+
+
+//
+//
+
+
+
+ pbHandle = new Handler(){
+
+ @Override
+ public void handleMessage(Message msg) {
+
+ /* get the value from the Message */
+
+ long progress = msg.getData().getLong("progress_update");
+ System.out.println(progress+"/"+fileSize);
+ if(progress>(fileSize-10240))
+ {
+ progressDialog.dismiss();
+ }
+ float percent = (progress/fileSize)*100;
+ Integer intProgress = Math.round(percent);
+ if(intProgress==100)
+ {
+ progressDialog.dismiss();
+ }
+ else
+ {
+ progressDialog.show();
+ progressDialog.setProgress(intProgress);
+ }
+ }
+ };
+
+ }
+
+ public void browseTo(File dir)
+ {
+ directoryEntries.clear();
+
+ File[] files = dir.listFiles();
+ directoryEntries.add("Current Directory:"+currentDirectory.getAbsolutePath());
+ directoryEntries.add("Up One Level");
+
+// System.out.println(files.length);
+ if(files != null)
+ {
+ for (File file: files)
+ {
+ directoryEntries.add(file.getPath());
+ System.out.println(file.getPath());
+ }
+ }
+ ArrayAdapter<String> directoryList = new ArrayAdapter<String>(this, R.layout.filerow, this.directoryEntries);
+
+ this.setListAdapter(directoryList);
+ }
+
+
+ @Override
+ protected void onListItemClick(ListView 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();
+ }
+
+ }
+
+ }
+
+
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.menuBrowse:
+// Intent browse = new Intent(this, FileBrowser.class);
+// startActivityForResult(browse, 0);;
+ return true;
+ case R.id.menuRecord:
+ Intent record = new Intent(this, SoundRecorder.class);
+ startActivityForResult(record, 0);
+ return true;
+ case R.id.menuLocate:
+ Intent locate = new Intent(this, UploadLocation.class);
+ startActivityForResult(locate, 0);;
+ return true;
+ case R.id.menuExit:
+ this.finish();
+ break;
+ default:
+ return super.onOptionsItemSelected(item);
+
+ }
+ return true;
+
+ }
+
+
+
}
\ No newline at end of file diff --git a/src/com/lc8n/blauploader/FileShare.java b/src/com/lc8n/blauploader/FileShare.java new file mode 100644 index 0000000..6b474a5 --- /dev/null +++ b/src/com/lc8n/blauploader/FileShare.java @@ -0,0 +1,298 @@ +package com.lc8n.blauploader;
+
+import java.io.File;
+import java.io.InputStream;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.MediaStore;
+import android.telephony.SmsManager;
+import android.util.Log;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class FileShare extends Activity {
+ private EditText text;
+ private float fileSize;
+ private Handler pbHandle = null;
+ private ProgressDialog progressDialog;
+ private ProgressDialog preparing;
+ private InputStream is;
+ private String fileName;
+ private Thread thread;
+ private AlertDialog alert;
+ private File file;
+
+
+ public void onCreate(Bundle savedInstanceState)
+ {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.share);
+
+ File blaDirectory = new File("/sdcard/blaupload/");
+ blaDirectory.mkdirs();
+
+ Intent intent = getIntent();
+ Bundle extras = intent.getExtras();
+ String action = intent.getAction();
+
+ text = (EditText) findViewById(R.id.filename);
+ text.requestFocus();
+ ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
+ .showSoftInput(text, 0);
+// text.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+//
+// public void onFocusChange(View v, boolean hasFocus) {
+// // TODO Auto-generated method stub
+// if (hasFocus)
+// {
+//
+// }
+// }
+// });
+// progressBar = (ProgressBar) findViewById(R.id.uploadprogress);
+
+ alert = new AlertDialog.Builder(this).create();
+ alert.setTitle("FTP Response");
+ alert.setButton("OK", new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ alert.dismiss();
+
+ }
+ });
+ progressDialog = new ProgressDialog(this);
+
+
+ progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ progressDialog.setMessage("Blauploading...");
+ progressDialog.setCancelable(true);
+ progressDialog.setProgress(0);
+
+ progressDialog.setButton(getText(R.string.cancel), new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ // Cancel the upload!
+ progressDialog.dismiss();
+ thread.stop();
+
+
+ }
+ });
+
+ preparing = new ProgressDialog(this);
+ preparing.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ preparing.setMessage("Preparing to Blaupload...");
+ preparing.setCancelable(true);
+ preparing.setButton(getText(R.string.cancel), new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ // Cancel the upload!
+ progressDialog.dismiss();
+ thread.interrupt();
+
+
+ }
+ });
+
+
+
+
+
+ pbHandle = new Handler(){
+
+ @Override
+ public void handleMessage(Message msg) {
+
+ /* get the value from the Message */
+
+ long progress = msg.getData().getLong("progress_update");
+ System.out.println(progress+"/"+fileSize);
+
+ float percent = (progress/fileSize)*100.0f;
+ System.out.println(percent);
+ Integer intProgress = Math.round(percent);
+ System.out.println(intProgress);
+ int kB = Math.round(progress / 1024);
+ if(intProgress==100 || progress>(fileSize-1024)) {
+ progressDialog.dismiss();
+ }
+ else {
+ preparing.dismiss();
+ progressDialog.show();
+ progressDialog.setProgress(kB);
+ }
+
+ int code = msg.getData().getInt("response");
+
+ switch (code) {
+ case 0:
+ break;
+ case 600:
+ alert.setMessage("File Already Exists! Please Rename");
+ alert.show();
+ progressDialog.dismiss();
+ thread.interrupt();
+ break;
+ case 226:
+ progressDialog.dismiss();
+ SmsManager sms = SmsManager.getDefault();
+ sms.sendTextMessage("07927278978", null, "New image blauploaded: http://www.blaupload.co.uk/"+fileName,null, null);
+ break;
+ case 800:
+ alert.setMessage("Unable To Connect To Server!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ case 801:
+ alert.setMessage("Unable To Log In!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ case 804:
+ alert.setMessage("Unable To Get File List!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ case 805:
+ alert.setMessage("Unable To Get Upload File!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ case 806:
+ alert.setMessage("FTP Server Did Not Respond!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ case 807:
+ alert.setMessage("Unable To Log Out!");
+ alert.show();
+ progressDialog.dismiss();
+ break;
+ default:
+ alert.setMessage("Response Code: "+code);
+ alert.show();
+ progressDialog.dismiss();
+ break;
+
+
+ }
+ }
+ };
+
+
+
+ final Button button = (Button) findViewById(R.id.uploadfile);
+ button.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+
+
+
+ fileName = text.getText().toString();
+ String path = file.getParent();
+ System.out.println(path);
+ System.out.println(fileName);
+
+
+ File newName = new File(path+"/"+fileName);
+ System.out.println(newName.getAbsolutePath());
+ file.renameTo(newName);
+ file = newName;
+ System.out.println("a"+file.getAbsolutePath());
+ FileUpload uploader = new FileUpload(file, pbHandle);
+ thread = new Thread(uploader);
+ thread.start();
+ progressDialog.setMax(Math.round(fileSize/1024));
+ preparing.show();
+
+
+
+
+
+// Toast toast = Toast.makeText(getApplicationContext(), "Upload Complete!", 10);
+// toast.show();
+ }
+ });
+
+
+
+
+ // if this is from the share menu
+ if (Intent.ACTION_SEND.equals(action))
+ {
+ if (extras.containsKey(Intent.EXTRA_STREAM))
+ {
+ try
+ {
+ // Get resource path from intent callee
+ Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
+
+ // Query gallery for camera picture via
+ // Android ContentResolver interface
+ ContentResolver cr = getContentResolver();
+ is = cr.openInputStream(uri);
+
+ String[] projection = { MediaStore.MediaColumns.DISPLAY_NAME, MediaStore.MediaColumns.MIME_TYPE, MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.DATA };
+ Cursor cur = cr.query(uri, projection, null, null, null);
+ cur.moveToFirst();
+
+ fileName = cur.getString(3);
+ fileSize = cur.getLong(2);
+ System.out.println(cur.getString(3));
+ cur.close();
+ String[] fileParts = fileName.split("/");
+ for (int i = 0; i < fileParts.length; i++) {
+ System.out.println(fileParts[i]);
+ }
+ text.setText(fileParts[fileParts.length-1]);
+ text.setSelection(fileParts[fileParts.length-1].indexOf("."));
+ file = new File(fileName);
+
+// text.setSelection(0, filename.indexOf("."));
+// text.requestFocus();
+
+ InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ // only will trigger it if no physical keyboard is open
+ mgr.showSoftInput(text, InputMethodManager.SHOW_FORCED);
+
+
+ // Get binary bytes for encode
+// byte[] data = getBytesFromFile(is);
+// cr.
+//
+// // base 64 encode for text transmission (HTTP)
+// byte[] encoded_data = Base64.encodeBase64(data);
+// String data_string = new String(encoded_data); // convert to string
+//
+// SendRequest(data_string);
+
+ return;
+ } catch (Exception e)
+ {
+ Log.e(this.getClass().getName(), e.toString());
+ }
+
+ } else if (extras.containsKey(Intent.EXTRA_TEXT))
+ {
+ return;
+ }
+ }
+
+ }
+
+
+}
diff --git a/src/com/lc8n/blauploader/FileUpload.java b/src/com/lc8n/blauploader/FileUpload.java index b81ec2d..18f7af8 100644 --- a/src/com/lc8n/blauploader/FileUpload.java +++ b/src/com/lc8n/blauploader/FileUpload.java @@ -1,76 +1,183 @@ -/* - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Copyright 2010 Joe Robinson <joe@lc8n.com> -*/ - -package com.lc8n.blauploader; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.SocketException; - -import org.apache.commons.net.ftp.FTP; -import org.apache.commons.net.ftp.FTPClient; - -import android.os.Handler; - -public class FileUpload implements Runnable{ - - private File file; - private Handler pbHandle; - public FileUpload(File file, Handler pbHandle) - { - this.file = file; - this.pbHandle = pbHandle; - } - - public void uploadFile(File file, Handler pbHandle) throws SocketException, IOException - { - - - FileInputStream fis = new FileInputStream(file); - BufferedInputStream bis = new BufferedInputStream(fis); - ProgressInputStream pis = new ProgressInputStream(bis,pbHandle); - String fileName = file.getName(); - FTPClient ftpClient = new FTPClient(); - - ftpClient.connect("tghost.co.uk"); - ftpClient.login("blaupload", "lemons"); - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - ftpClient.enterLocalPassiveMode(); - ftpClient.changeWorkingDirectory("/"); - ftpClient.storeFile(fileName, pis); - bis.close(); - pis.close(); - ftpClient.logout(); - ftpClient.disconnect(); - - } - public void run() { - try { - uploadFile(file, pbHandle); - } catch (Exception e) { - - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - -} +/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Copyright 2010 Joe Robinson <joe@lc8n.com>
+*/
+
+package com.lc8n.blauploader;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.SocketException;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+
+public class FileUpload implements Runnable{
+
+ private File file = null;
+ private Handler pbHandle;
+ private InputStream is;
+ private String fileName;
+ private FTPClient ftpClient;
+
+ public FileUpload(File file, Handler pbHandle)
+ {
+ this.file = file;
+ this.pbHandle = pbHandle;
+ }
+
+ public FileUpload(InputStream is, Handler pbHandle, String fileName)
+ {
+ this.is = is;
+ this.pbHandle = pbHandle;
+ this.fileName = fileName;
+
+
+ }
+
+ public void uploadFile(File file, Handler pbHandle)
+ {
+
+
+ int code = 0;
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ code = 700;
+ }
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ ProgressInputStream pis = new ProgressInputStream(bis,pbHandle);
+ String fileName = file.getName();
+ ftpClient = new FTPClient();
+
+ try {
+ ftpClient.connect("tghost.co.uk");
+ } catch (Exception e) {
+ code = 800;
+ e.printStackTrace();
+ }
+ try {
+ ftpClient.login("blaupload", "lemons");
+ } catch (IOException e) {
+ code = 801;
+ e.printStackTrace();
+ }
+ try {
+ ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+ } catch (IOException e) {
+ code = 802;
+ }
+ ftpClient.enterLocalPassiveMode();
+ try {
+ ftpClient.changeWorkingDirectory("blaupload");
+ } catch (IOException e) {
+ code = 803;
+ }
+ String[] curFiles = null;
+ try {
+ curFiles = ftpClient.listNames();
+ } catch (IOException e) {
+ code = 804;
+ }
+ boolean exists = false;
+ for (int i = 0; i < curFiles.length; i++) {
+ if (curFiles[i].equals(fileName))
+ {
+ exists = true;
+ code = 600;
+ }
+ }
+ if (!exists) {
+ try {
+ ftpClient.storeFile(fileName, pis);
+ } catch (IOException e) {
+ code = 805;
+ }
+ try {
+ code = ftpClient.getReply();
+ } catch (IOException e) {
+ code = 806;
+ }
+ }
+ try {
+ bis.close();
+ pis.close();
+ } catch (IOException e) {
+ code = 999;
+ }
+
+ try {
+ ftpClient.logout();
+ ftpClient.disconnect();
+ } catch (IOException e) {
+ code = 807;
+ }
+
+
+ Bundle data = new Bundle();
+ data.putInt("response", code);
+ Message message = Message.obtain();
+ message.setData(data);
+ pbHandle.sendMessage(message);
+
+ }
+
+
+ public void run() {
+ try {
+
+// if(file == null && is != null) {
+// file = new File("/sdcard/blaupload/"+fileName);
+// OutputStream out = new FileOutputStream(file);
+//
+// int read=0;
+// byte[] bytes = new byte[1024];
+//
+// while((read = is.read(bytes))!= -1){
+// out.write(bytes, 0, read);
+// }
+//
+// is.close();
+// out.flush();
+// out.close();
+// }
+
+ uploadFile(file, pbHandle);
+ } catch (Exception e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ public void interrupt() throws IOException {
+ ftpClient.abort();
+ file = null;
+ }
+
+}
diff --git a/src/com/lc8n/blauploader/HomeScreen.java b/src/com/lc8n/blauploader/HomeScreen.java index 98de7f8..37343f3 100644 --- a/src/com/lc8n/blauploader/HomeScreen.java +++ b/src/com/lc8n/blauploader/HomeScreen.java @@ -1,49 +1,57 @@ -package com.lc8n.blauploader; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -public class HomeScreen extends Activity{ - - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.home); - - final Button browse = (Button) findViewById(R.id.browse); - browse.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - Intent myIntent = new Intent(v.getContext(), FileBrowser.class); - startActivityForResult(myIntent, 0); - - - } - }); - - final Button audio = (Button) findViewById(R.id.audio); - audio.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - Intent myIntent = new Intent(v.getContext(), SoundRecorder.class); - startActivityForResult(myIntent, 0); - - } - }); - - final Button locate = (Button) findViewById(R.id.locate); - locate .setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - Intent myIntent = new Intent(v.getContext(), UploadLocation.class); - startActivityForResult(myIntent, 0); - - } - }); - - - } -} +package com.lc8n.blauploader;
+
+import java.io.File;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+
+public class HomeScreen extends Activity{
+
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.home);
+
+ File blaDirectory = new File("/sdcard/blaupload/");
+ blaDirectory.mkdirs();
+
+
+
+
+ final Button browse = (Button) findViewById(R.id.browse);
+ browse.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ Intent myIntent = new Intent(v.getContext(), FileBrowser.class);
+ startActivityForResult(myIntent, 0);
+
+
+ }
+ });
+
+ final Button audio = (Button) findViewById(R.id.audio);
+ audio.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ Intent myIntent = new Intent(v.getContext(), SoundRecorder.class);
+ startActivityForResult(myIntent, 0);
+
+ }
+ });
+
+ final Button locate = (Button) findViewById(R.id.locate);
+ locate .setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ Intent myIntent = new Intent(v.getContext(), UploadLocation.class);
+ startActivityForResult(myIntent, 0);
+
+ }
+ });
+
+
+ }
+}
diff --git a/src/com/lc8n/blauploader/ProgressInputStream.java b/src/com/lc8n/blauploader/ProgressInputStream.java index bda5980..9404633 100644 --- a/src/com/lc8n/blauploader/ProgressInputStream.java +++ b/src/com/lc8n/blauploader/ProgressInputStream.java @@ -1,97 +1,97 @@ -/* - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Copyright 2010 Joe Robinson <joe@lc8n.com> -*/ - -package com.lc8n.blauploader; - -import java.io.IOException; -import java.io.InputStream; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; - -public class ProgressInputStream extends InputStream { - - /* Key to retrieve progress value from message bundle passed to handler */ - public static final String PROGRESS_UPDATE = "progress_update"; - - private static final int TEN_KILOBYTES = 1024 * 10; - - private InputStream inputStream; - private Handler handler; - - private long progress; - private long lastUpdate; - - private boolean closed; - - public ProgressInputStream(InputStream inputStream, Handler handler) { - this.inputStream = inputStream; - this.handler = handler; - - this.progress = 0; - this.lastUpdate = 0; - - this.closed = false; - } - - @Override - public int read() throws IOException { - int count = inputStream.read(); - return incrementCounterAndUpdateDisplay(count); - } - - @Override - public int read(byte[] b, int off, int len) throws IOException { - int count = inputStream.read(b, off, len); - return incrementCounterAndUpdateDisplay(count); - } - - @Override - public void close() throws IOException { - super.close(); - if (closed) - throw new IOException("already closed"); - closed = true; - } - - private int incrementCounterAndUpdateDisplay(int count) { - if (count > 0) - progress += count; - lastUpdate = maybeUpdateDisplay(progress, lastUpdate); - return count; - } - - private long maybeUpdateDisplay(long progress, long lastUpdate) { - if (progress - lastUpdate > TEN_KILOBYTES) { - lastUpdate = progress; - sendLong(PROGRESS_UPDATE, progress); - } - return lastUpdate; - } - - public void sendLong(String key, long value) { - Bundle data = new Bundle(); - data.putLong(key, value); - - Message message = Message.obtain(); - message.setData(data); - handler.sendMessage(message); - } +/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Copyright 2010 Joe Robinson <joe@lc8n.com>
+*/
+
+package com.lc8n.blauploader;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+
+public class ProgressInputStream extends InputStream {
+
+ /* Key to retrieve progress value from message bundle passed to handler */
+ public static final String PROGRESS_UPDATE = "progress_update";
+
+ private static final int TEN_KILOBYTES = 1024 * 10;
+
+ private InputStream inputStream;
+ private Handler handler;
+
+ private long progress;
+ private long lastUpdate;
+
+ private boolean closed;
+
+ public ProgressInputStream(InputStream inputStream, Handler handler) {
+ this.inputStream = inputStream;
+ this.handler = handler;
+
+ this.progress = 0;
+ this.lastUpdate = 0;
+
+ this.closed = false;
+ }
+
+ @Override
+ public int read() throws IOException {
+ int count = inputStream.read();
+ return incrementCounterAndUpdateDisplay(count);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int count = inputStream.read(b, off, len);
+ return incrementCounterAndUpdateDisplay(count);
+ }
+
+ @Override
+ public void close() throws IOException {
+ super.close();
+ if (closed)
+ throw new IOException("already closed");
+ closed = true;
+ }
+
+ private int incrementCounterAndUpdateDisplay(int count) {
+ if (count > 0)
+ progress += count;
+ lastUpdate = maybeUpdateDisplay(progress, lastUpdate);
+ return count;
+ }
+
+ private long maybeUpdateDisplay(long progress, long lastUpdate) {
+ if (progress - lastUpdate > TEN_KILOBYTES) {
+ lastUpdate = progress;
+ sendLong(PROGRESS_UPDATE, progress);
+ }
+ return lastUpdate;
+ }
+
+ public void sendLong(String key, long value) {
+ Bundle data = new Bundle();
+ data.putLong(key, value);
+
+ Message message = Message.obtain();
+ message.setData(data);
+ handler.sendMessage(message);
+ }
}
\ No newline at end of file diff --git a/src/com/lc8n/blauploader/SoundRecorder.java b/src/com/lc8n/blauploader/SoundRecorder.java index 8e6e7bd..e31fc9f 100644 --- a/src/com/lc8n/blauploader/SoundRecorder.java +++ b/src/com/lc8n/blauploader/SoundRecorder.java @@ -1,163 +1,163 @@ -package com.lc8n.blauploader; - -import java.io.File; - -import android.app.Activity; -import android.app.ProgressDialog; -import android.content.ContentValues; -import android.content.Intent; -import android.media.MediaRecorder; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.provider.MediaStore; -import android.telephony.SmsManager; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; -import android.widget.Toast; - -public class SoundRecorder extends Activity{ - - private MediaRecorder mediaRecorder; - private String fileName; - private ProgressDialog progressDialog; - private long fileSize; - private Handler pbHandle = null; - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.soundrecorder); - - final Button recordButton = (Button) findViewById(R.id.Record); - recordButton.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - recordAudio(); - Toast toast = Toast.makeText(getApplicationContext(), "Recording!", 10); - toast.show(); - } - }); - - final Button stopButton = (Button) findViewById(R.id.Stop); - stopButton.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - stopAudio(); - Toast toast = Toast.makeText(getApplicationContext(), "Stopping!", 10); - toast.show(); - } - }); - - progressDialog = new ProgressDialog(this); - - - progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); - progressDialog.setMessage("Blauploading..."); - progressDialog.setCancelable(true); - progressDialog.setProgress(0); - - pbHandle = new Handler(){ - - @Override - public void handleMessage(Message msg) { - - /* get the value from the Message */ - - long progress = msg.getData().getLong("progress_update"); - System.out.println(progress+"/"+fileSize); - if(progress>(fileSize-10240)) - { - progressDialog.dismiss(); - } - float percent = (progress/fileSize)*100; - Integer intProgress = Math.round(percent); - if(intProgress==100) - { - progressDialog.dismiss(); - } - else - { - progressDialog.show(); - progressDialog.setProgress(intProgress); - } - } - }; - - } - - public void recordAudio() - { - mediaRecorder = new MediaRecorder(); - mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); - mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); - mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); - ContentValues contentValues = new ContentValues(3); - contentValues.put(MediaStore.MediaColumns.TITLE, "Blauploaded from Android"); - contentValues.put(MediaStore.MediaColumns.DATE_ADDED, System.currentTimeMillis()); -// contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mediaRecorder.) - - fileName = "/sdcard/blasound"+System.currentTimeMillis()+".3gp"; - mediaRecorder.setOutputFile(fileName); - try { - mediaRecorder.prepare(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - mediaRecorder.start(); - } - - public void stopAudio() - { - mediaRecorder.stop(); - mediaRecorder.release(); - File recordedSound = new File(fileName); - fileSize = recordedSound.length(); - - - FileUpload fu = new FileUpload(recordedSound,pbHandle); - Thread thread = new Thread(fu); - - thread.start(); - - SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage("07927278978", null, "wjoe blauploaded a recording: http://www.blaupload.co.uk/"+recordedSound.getName(), null, null); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.menu, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - case R.id.menuBrowse: - Intent browse = new Intent(this, FileBrowser.class); - startActivityForResult(browse, 0); - return true; - case R.id.menuRecord: -// Intent record = new Intent(this, SoundRecorder.class); -// startActivityForResult(record, 0); - return true; - case R.id.menuLocate: - Intent locate = new Intent(this, UploadLocation.class); - startActivityForResult(locate, 0); - return true; - case R.id.menuExit: - this.finish(); - break; - default: - return super.onOptionsItemSelected(item); - - } - return true; - - } - -} +package com.lc8n.blauploader;
+
+import java.io.File;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.media.MediaRecorder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.MediaStore;
+import android.telephony.SmsManager;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+
+public class SoundRecorder extends Activity{
+
+ private MediaRecorder mediaRecorder;
+ private String fileName;
+ private ProgressDialog progressDialog;
+ private long fileSize;
+ private Handler pbHandle = null;
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.soundrecorder);
+
+ final Button recordButton = (Button) findViewById(R.id.Record);
+ recordButton.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ recordAudio();
+ Toast toast = Toast.makeText(getApplicationContext(), "Recording!", 10);
+ toast.show();
+ }
+ });
+
+ final Button stopButton = (Button) findViewById(R.id.Stop);
+ stopButton.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ stopAudio();
+ Toast toast = Toast.makeText(getApplicationContext(), "Stopping!", 10);
+ toast.show();
+ }
+ });
+
+ progressDialog = new ProgressDialog(this);
+
+
+ progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ progressDialog.setMessage("Blauploading...");
+ progressDialog.setCancelable(true);
+ progressDialog.setProgress(0);
+
+ pbHandle = new Handler(){
+
+ @Override
+ public void handleMessage(Message msg) {
+
+ /* get the value from the Message */
+
+ long progress = msg.getData().getLong("progress_update");
+ System.out.println(progress+"/"+fileSize);
+ if(progress>(fileSize-10240))
+ {
+ progressDialog.dismiss();
+ }
+ float percent = (progress/fileSize)*100;
+ Integer intProgress = Math.round(percent);
+ if(intProgress==100)
+ {
+ progressDialog.dismiss();
+ }
+ else
+ {
+ progressDialog.show();
+ progressDialog.setProgress(intProgress);
+ }
+ }
+ };
+
+ }
+
+ public void recordAudio()
+ {
+ mediaRecorder = new MediaRecorder();
+ mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+ mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+ ContentValues contentValues = new ContentValues(3);
+ contentValues.put(MediaStore.MediaColumns.TITLE, "Blauploaded from Android");
+ contentValues.put(MediaStore.MediaColumns.DATE_ADDED, System.currentTimeMillis());
+// contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mediaRecorder.)
+
+ fileName = "/sdcard/blasound"+System.currentTimeMillis()+".3gp";
+ mediaRecorder.setOutputFile(fileName);
+ try {
+ mediaRecorder.prepare();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ mediaRecorder.start();
+ }
+
+ public void stopAudio()
+ {
+ mediaRecorder.stop();
+ mediaRecorder.release();
+ File recordedSound = new File(fileName);
+ fileSize = recordedSound.length();
+
+
+ FileUpload fu = new FileUpload(recordedSound,pbHandle);
+ Thread thread = new Thread(fu);
+
+ thread.start();
+
+ SmsManager sms = SmsManager.getDefault();
+ sms.sendTextMessage("07927278978", null, "New sound recording blauploaded: http://www.blaupload.co.uk/"+recordedSound.getName(), null, null);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.menuBrowse:
+ Intent browse = new Intent(this, FileBrowser.class);
+ startActivityForResult(browse, 0);
+ return true;
+ case R.id.menuRecord:
+// Intent record = new Intent(this, SoundRecorder.class);
+// startActivityForResult(record, 0);
+ return true;
+ case R.id.menuLocate:
+ Intent locate = new Intent(this, UploadLocation.class);
+ startActivityForResult(locate, 0);
+ return true;
+ case R.id.menuExit:
+ this.finish();
+ break;
+ default:
+ return super.onOptionsItemSelected(item);
+
+ }
+ return true;
+
+ }
+
+}
diff --git a/src/com/lc8n/blauploader/UploadLocation.java b/src/com/lc8n/blauploader/UploadLocation.java index 99f1a08..3db3974 100644 --- a/src/com/lc8n/blauploader/UploadLocation.java +++ b/src/com/lc8n/blauploader/UploadLocation.java @@ -1,130 +1,129 @@ -package com.lc8n.blauploader; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.location.Criteria; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.telephony.SmsManager; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -public class UploadLocation extends Activity { - - private TextView textLocation; - private double lat = 0; - private double lon = 0; - private MyLocationListener ll; - private LocationManager lm; - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.uploadlocation); - - - - textLocation = (TextView) findViewById(R.id.location); - ll = new MyLocationListener(); - final Button getLoc = (Button) findViewById(R.id.getlocation); - getLoc.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); - Criteria criteria = new Criteria(); - criteria.setAccuracy(Criteria.ACCURACY_FINE); - criteria.setAltitudeRequired(false); - criteria.setBearingRequired(false); - String provider = lm.getBestProvider(criteria, true); - - ll = new MyLocationListener(); - lm.requestLocationUpdates(provider, 10000, 0, ll); - - } - }); - - final Button uploadLoc = (Button) findViewById(R.id.uploadlocation); - uploadLoc.setOnClickListener(new View.OnClickListener() { - - public void onClick(View v) { - - SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage("07927278978", null, "wjoe blauploaded his location: http://maps.google.com/maps?q="+lat+","+lon, null, null); - lm.removeUpdates(ll); - } - }); - } - - private class MyLocationListener implements LocationListener - { - - public void onLocationChanged(Location loc) { - if (loc != null) { - - - lat = (loc.getLatitude()); - lon = (loc.getLongitude()); - textLocation.setText(lat+", "+lon); - - - - } - } - - public void onProviderDisabled(String provider) { - // TODO Auto-generated method stub - - } - - public void onProviderEnabled(String provider) { - // TODO Auto-generated method stub - - } - - public void onStatusChanged(String provider, int status, Bundle extras) { - // TODO Auto-generated method stub - - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.menu, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - case R.id.menuBrowse: - Intent browse = new Intent(this, FileBrowser.class); - startActivityForResult(browse, 0);; - return true; - case R.id.menuRecord: - Intent record = new Intent(this, SoundRecorder.class); - startActivityForResult(record, 0); - return true; - case R.id.menuLocate: -// Intent locate = new Intent(this, UploadLocation.class); -// startActivityForResult(locate, 0);; - return true; - case R.id.menuExit: - this.finish(); - break; - default: - return super.onOptionsItemSelected(item); - - } - return true; - - } - - -} +package com.lc8n.blauploader;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.location.Criteria;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.telephony.SmsManager;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class UploadLocation extends Activity {
+
+ private TextView textLocation;
+ private double lat = 0;
+ private double lon = 0;
+ private MyLocationListener ll;
+ private LocationManager lm;
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.uploadlocation);
+
+
+
+ textLocation = (TextView) findViewById(R.id.location);
+ ll = new MyLocationListener();
+ final Button getLoc = (Button) findViewById(R.id.getlocation);
+ getLoc.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
+ Criteria criteria = new Criteria();
+ criteria.setAltitudeRequired(false);
+ criteria.setBearingRequired(false);
+ String provider = lm.getBestProvider(criteria, true);
+
+ ll = new MyLocationListener();
+ lm.requestLocationUpdates(provider, 10000, 0, ll);
+
+ }
+ });
+
+ final Button uploadLoc = (Button) findViewById(R.id.uploadlocation);
+ uploadLoc.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+
+ SmsManager sms = SmsManager.getDefault();
+ sms.sendTextMessage("07927278978", null, "Current location: http://maps.google.com/maps?q="+lat+","+lon, null, null);
+ lm.removeUpdates(ll);
+ }
+ });
+ }
+
+ private class MyLocationListener implements LocationListener
+ {
+
+ public void onLocationChanged(Location loc) {
+ if (loc != null) {
+
+
+ lat = (loc.getLatitude());
+ lon = (loc.getLongitude());
+ textLocation.setText(lat+", "+lon);
+
+
+
+ }
+ }
+
+ public void onProviderDisabled(String provider) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onProviderEnabled(String provider) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ // TODO Auto-generated method stub
+
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.menuBrowse:
+ Intent browse = new Intent(this, FileBrowser.class);
+ startActivityForResult(browse, 0);;
+ return true;
+ case R.id.menuRecord:
+ Intent record = new Intent(this, SoundRecorder.class);
+ startActivityForResult(record, 0);
+ return true;
+ case R.id.menuLocate:
+// Intent locate = new Intent(this, UploadLocation.class);
+// startActivityForResult(locate, 0);;
+ return true;
+ case R.id.menuExit:
+ this.finish();
+ break;
+ default:
+ return super.onOptionsItemSelected(item);
+
+ }
+ return true;
+
+ }
+
+
+}
|