diff options
author | ninatai <ninatai@google.com> | 2015-05-11 13:21:51 -0700 |
---|---|---|
committer | ninatai <ninatai@google.com> | 2015-05-11 14:26:43 -0700 |
commit | 7967974283bbe9143c3660c84fb9f4b5396961bb (patch) | |
tree | a024fe1c08a8fac25408ca265746488d6cc44369 /LoopbackApp/app/src/main/java/org | |
parent | 17b7d005bf1f1fe864ce44576e212d3837eb46b8 (diff) | |
download | drrickorang-7967974283bbe9143c3660c84fb9f4b5396961bb.tar.gz |
Filename now saves the time of plot acquisition.
Add Toast to show where the file is saved.
Diffstat (limited to 'LoopbackApp/app/src/main/java/org')
-rw-r--r-- | LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java index 87dfd21..529a594 100644 --- a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java +++ b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java @@ -69,8 +69,10 @@ public class LoopbackActivity extends Activity { LoopbackAudioThread audioThread = null; NativeAudioThread nativeAudioThread = null; private WavePlotView mWavePlotView; + private String currentTime = "IncorrectTime"; // The time the plot is acquired + private String filePathWav; - SeekBar mBarMasterLevel; + SeekBar mBarMasterLevel; //drag the volumn TextView mTextInfo; TextView mTextViewCurrentLevel; TextView mTextViewEstimatedLatency; @@ -103,6 +105,7 @@ public class LoopbackActivity extends Activity { log("got message java rec complete!!"); refreshPlots(); refreshState(); + currentTime = (String) DateFormat.format("MMddkkmmss", System.currentTimeMillis()); showToast("Java Recording Completed"); stopAudioThread(); } @@ -126,10 +129,13 @@ public class LoopbackActivity extends Activity { log("got message native rec complete!!"); refreshPlots(); refreshState(); - if(msg.what == NativeAudioThread.FUN_PLUG_NATIVE_AUDIO_THREAD_MESSAGE_REC_COMPLETE_ERRORS) + if(msg.what == NativeAudioThread.FUN_PLUG_NATIVE_AUDIO_THREAD_MESSAGE_REC_COMPLETE_ERRORS) { + currentTime = (String) DateFormat.format("MMddkkmmss", System.currentTimeMillis()); showToast("Native Recording Completed with ERRORS"); - else + } else { + currentTime = (String) DateFormat.format("MMddkkmmss", System.currentTimeMillis()); showToast("Native Recording Completed"); + } stopAudioThread(); } break; @@ -325,7 +331,7 @@ public class LoopbackActivity extends Activity { public void onButtonSave(View view) { //create filename with date - String date = (String) DateFormat.format("MMddkkmmss", System.currentTimeMillis()); + String date = currentTime; // the time the plot is acquired String micSource = getApp().getMicSourceString( getApp().getMicSource()); String fileName = micSource+"_"+date; @@ -344,6 +350,7 @@ public class LoopbackActivity extends Activity { intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("audio/wav"); + // sometimes ".wav" will be added automatically, sometimes not intent.putExtra(Intent.EXTRA_TITLE, fileName + ".wav"); //suggested filename startActivityForResult(intent, SAVE_TO_WAVE_REQUEST); @@ -352,6 +359,10 @@ public class LoopbackActivity extends Activity { //save to a given uri... local file? Uri uri = Uri.parse("file://mnt/sdcard/"+fileName+".wav"); + File file = new File(getPath(uri)); + filePathWav = file.getAbsolutePath(); + + saveToWavefile(uri); Uri uri2 = Uri.parse("file://mnt/sdcard/"+fileName+".png"); @@ -368,6 +379,10 @@ public class LoopbackActivity extends Activity { Uri uri = null; if (resultData != null) { uri = resultData.getData(); + + File file = new File(getPath(uri)); + filePathWav = file.getAbsolutePath(); + saveToWavefile(uri); } } else if( requestCode == SAVE_TO_PNG_REQUEST && resultCode == Activity.RESULT_OK) { @@ -376,6 +391,7 @@ public class LoopbackActivity extends Activity { Uri uri = null; if (resultData != null) { uri = resultData.getData(); + saveScreenShot(uri); } @@ -387,6 +403,20 @@ public class LoopbackActivity extends Activity { } } + // method to get the file path from uri + public String getPath(Uri uri) + { + String[] p = {MediaStore.Images.Media.DATA}; + Cursor cursor1 = getContentResolver().query(uri, p, null, null, null); + if (cursor1 == null) + return null; + int ColumnIndex = cursor1.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + cursor1.moveToFirst(); + String path = cursor1.getString(ColumnIndex); + cursor1.close(); + return path; + } + /** Called when the user clicks the button */ public void onButtonZoomOutFull(View view) { @@ -535,7 +565,7 @@ public class LoopbackActivity extends Activity { boolean status = audioFileOutput.writeData(mWaveData); if (status) { - showToast("Finished exporting wave File"); + showToast("Finished exporting wave File " + filePathWav); // Toast.makeText(getApplicationContext(), "Finished exporting wave File", // Toast.LENGTH_SHORT).show(); } else { |