summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2010-10-28 00:23:59 +0100
committerJoe Robinson <joe@lc8n.com>2010-10-28 00:23:59 +0100
commita94be1ada1fab129049e6a8864545c2d7e4e9dee (patch)
tree399da26854b6da6c224d6d7c1cb4917071e1ed44
parentfba62b1f4fbdb09e920591fd260fcfcd3adc52b8 (diff)
Added basic functionality for sound upload (.3gp format/AMR codec) and SMS of current location
-rw-r--r--AndroidManifest.xml20
-rw-r--r--bin/blauploader.apkbin59819 -> 64783 bytes
-rw-r--r--bin/classes.dexbin102616 -> 109268 bytes
-rw-r--r--bin/com/lc8n/blauploader/R$id.classbin397 -> 560 bytes
-rw-r--r--bin/com/lc8n/blauploader/R$layout.classbin431 -> 506 bytes
-rw-r--r--bin/com/lc8n/blauploader/R$string.classbin433 -> 433 bytes
-rw-r--r--gen/com/lc8n/blauploader/R.java7
-rw-r--r--res/layout/soundrecorder.xml18
-rw-r--r--res/layout/uploadlocation.xml36
-rw-r--r--src/com/lc8n/blauploader/SoundRecorder.java125
-rw-r--r--src/com/lc8n/blauploader/UploadLocation.java98
11 files changed, 304 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b78b9d8..3b467a6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -17,10 +17,30 @@
</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" />
</manifest> \ No newline at end of file
diff --git a/bin/blauploader.apk b/bin/blauploader.apk
index 24c75bf..ea9516b 100644
--- a/bin/blauploader.apk
+++ b/bin/blauploader.apk
Binary files differ
diff --git a/bin/classes.dex b/bin/classes.dex
index 0147dd7..ff9caf4 100644
--- a/bin/classes.dex
+++ b/bin/classes.dex
Binary files differ
diff --git a/bin/com/lc8n/blauploader/R$id.class b/bin/com/lc8n/blauploader/R$id.class
index bc1a3b5..0ec2db5 100644
--- a/bin/com/lc8n/blauploader/R$id.class
+++ b/bin/com/lc8n/blauploader/R$id.class
Binary files differ
diff --git a/bin/com/lc8n/blauploader/R$layout.class b/bin/com/lc8n/blauploader/R$layout.class
index 184a81e..dc584df 100644
--- a/bin/com/lc8n/blauploader/R$layout.class
+++ b/bin/com/lc8n/blauploader/R$layout.class
Binary files differ
diff --git a/bin/com/lc8n/blauploader/R$string.class b/bin/com/lc8n/blauploader/R$string.class
index e438feb..db984b9 100644
--- a/bin/com/lc8n/blauploader/R$string.class
+++ b/bin/com/lc8n/blauploader/R$string.class
Binary files differ
diff --git a/gen/com/lc8n/blauploader/R.java b/gen/com/lc8n/blauploader/R.java
index 4de5f2b..c0edd12 100644
--- a/gen/com/lc8n/blauploader/R.java
+++ b/gen/com/lc8n/blauploader/R.java
@@ -15,10 +15,17 @@ public final class R {
}
public static final class id {
public static final int ProgressBar01=0x7f050000;
+ public static final int Record=0x7f050001;
+ public static final int Stop=0x7f050002;
+ public static final int getlocation=0x7f050004;
+ public static final int location=0x7f050003;
+ public static final int uploadlocation=0x7f050005;
}
public static final class layout {
public static final int filerow=0x7f030000;
public static final int main=0x7f030001;
+ public static final int soundrecorder=0x7f030002;
+ public static final int uploadlocation=0x7f030003;
}
public static final class string {
public static final int app_name=0x7f040001;
diff --git a/res/layout/soundrecorder.xml b/res/layout/soundrecorder.xml
new file mode 100644
index 0000000..184bbae
--- /dev/null
+++ b/res/layout/soundrecorder.xml
@@ -0,0 +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>
diff --git a/res/layout/uploadlocation.xml b/res/layout/uploadlocation.xml
new file mode 100644
index 0000000..f924d43
--- /dev/null
+++ b/res/layout/uploadlocation.xml
@@ -0,0 +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>
diff --git a/src/com/lc8n/blauploader/SoundRecorder.java b/src/com/lc8n/blauploader/SoundRecorder.java
new file mode 100644
index 0000000..dba3873
--- /dev/null
+++ b/src/com/lc8n/blauploader/SoundRecorder.java
@@ -0,0 +1,125 @@
+package com.lc8n.blauploader;
+
+import java.io.File;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.ContentValues;
+import android.media.MediaRecorder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.MediaStore;
+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.MPEG_4);
+ 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()+".mp3";
+ 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();
+ }
+
+}
diff --git a/src/com/lc8n/blauploader/UploadLocation.java b/src/com/lc8n/blauploader/UploadLocation.java
new file mode 100644
index 0000000..8b211d6
--- /dev/null
+++ b/src/com/lc8n/blauploader/UploadLocation.java
@@ -0,0 +1,98 @@
+package com.lc8n.blauploader;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+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.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;
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.uploadlocation);
+
+
+
+ textLocation = (TextView) findViewById(R.id.location);
+
+ final Button getLoc = (Button) findViewById(R.id.getlocation);
+ getLoc.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
+ Criteria criteria = new Criteria();
+ criteria.setAccuracy(Criteria.ACCURACY_FINE);
+ criteria.setAltitudeRequired(true);
+ criteria.setBearingRequired(true);
+ String provider = lm.getBestProvider(criteria, true);
+
+ MyLocationListener 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) {
+
+ sendSms("07927278978","wjoe blauploaded his location: http://maps.google.com/maps?q="+lat+","+lon);
+
+ }
+ });
+ }
+
+ 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
+
+ }
+ }
+
+ private void sendSms(String number, String message)
+ {
+ SmsManager sms = SmsManager.getDefault();
+ PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, UploadLocation.class), 0);
+
+ sms.sendTextMessage(number, null, message, intent, null);
+ }
+
+}