├── ic_launcher-web.png ├── Art ├── recorder_screen.png └── recording_play.png ├── res ├── drawable-hdpi │ ├── delete.png │ ├── ico_mic.png │ ├── share.png │ ├── sort_list.png │ ├── ic_launcher.png │ ├── ic_action_next.png │ ├── ic_action_play.png │ ├── ic_action_stop.png │ ├── ic_action_pause.png │ ├── ic_action_previous.png │ └── bg_gradient.xml ├── drawable-mdpi │ ├── ico_mic.png │ └── ic_launcher.png ├── drawable-xxhdpi │ ├── ico_mic.png │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── values │ ├── dimens.xml │ ├── color.xml │ ├── styles.xml │ ├── attrs.xml │ └── strings.xml ├── values-v11 │ └── styles.xml ├── values-w820dp │ └── dimens.xml ├── values-v14 │ └── styles.xml ├── menu │ └── main.xml └── layout │ ├── activity_main.xml │ ├── swipe_layout_recording_list_item.xml │ ├── record_audio_fragment.xml │ └── recording_list_fragment.xml ├── .gitattributes ├── .classpath ├── .settings └── org.eclipse.jdt.core.prefs ├── project.properties ├── proguard-project.txt ├── .project ├── src └── com │ └── serveroverload │ └── recorder │ ├── customview │ ├── SimpleSwipeListener.java │ ├── PlayerVisualizerView.java │ ├── RecorderVisualizerView.java │ └── SwipeLayout.java │ ├── util │ ├── Helper.java │ ├── RecordingsLoaderTask.java │ └── RecordingsListArrayAdapter.java │ └── ui │ ├── HomeActivity.java │ ├── RecordingListFragment.java │ └── RecordAudioFragment.java ├── .gitignore ├── README.md └── AndroidManifest.xml /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /Art/recorder_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/Art/recorder_screen.png -------------------------------------------------------------------------------- /Art/recording_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/Art/recording_play.png -------------------------------------------------------------------------------- /res/drawable-hdpi/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/delete.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ico_mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ico_mic.png -------------------------------------------------------------------------------- /res/drawable-hdpi/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/share.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ico_mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-mdpi/ico_mic.png -------------------------------------------------------------------------------- /res/drawable-hdpi/sort_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/sort_list.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ico_mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-xxhdpi/ico_mic.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_action_next.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_action_play.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_action_stop.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_action_pause.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/HEAD/res/drawable-hdpi/ic_action_previous.png -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ffffff 5 | #70000000 6 | #31244e 7 | #6b394c 8 | #9966FF 9 | 10 | -------------------------------------------------------------------------------- /res/drawable-hdpi/bg_gradient.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.7 12 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | android.library.reference.1=../FlappyCow-master (1)/FlappyCow-master/lib_projects/GooglePlayServices/google-play-services_lib 16 | android.library.reference.2=../../workspaceDroidNew/android-support-v7-appcompat 17 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Audio Recoder 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 15 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/customview/SimpleSwipeListener.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.customview; 2 | 3 | 4 | /** 5 | * The listener interface for receiving simpleSwipe events. 6 | * The class that is interested in processing a simpleSwipe 7 | * event implements this interface, and the object created 8 | * with that class is registered with a component using the 9 | * component's addSimpleSwipeListener method. When 10 | * the simpleSwipe event occurs, that object's appropriate 11 | * method is invoked. 12 | * 13 | * @see SimpleSwipeEvent 14 | */ 15 | public class SimpleSwipeListener implements SwipeLayout.SwipeListener { 16 | 17 | @Override 18 | public void onStartOpen(SwipeLayout layout) { 19 | } 20 | 21 | @Override 22 | public void onOpen(SwipeLayout layout) { 23 | } 24 | 25 | @Override 26 | public void onStartClose(SwipeLayout layout) { 27 | } 28 | 29 | @Override 30 | public void onClose(SwipeLayout layout) { 31 | } 32 | 33 | @Override 34 | public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) { 35 | } 36 | 37 | @Override 38 | public void onHandRelease(SwipeLayout layout, float xvel, float yvel) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Audio Recorder Pro 5 | Hello world! 6 | Settings 7 | Exit 8 | Tap on mic icon to start recording, taping on stop icon will save file on SD card. 9 | \nIf recording was not good you can delete it by pressing delete icon and try again or you can delete and compare with other saved file by tapping on list icon. 10 | \nIf you think recording is up to your expectations you can share it with your friends from browsing list 11 | Audio Recorder 12 | Recording Started 13 | Recording Failed 14 | Failed to create recordings folder 15 | Recording Saved at 16 | Deleted recording 17 | Failed to delete recording 18 | ca-app-pub-9404626930613325/4259844699 19 | ca-app-pub-9404626930613325/5736577892 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | */build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # ========================= 36 | # Operating System Files 37 | # ========================= 38 | 39 | # OSX 40 | # ========================= 41 | 42 | .DS_Store 43 | .AppleDouble 44 | .LSOverride 45 | 46 | # Thumbnails 47 | ._* 48 | 49 | # Files that might appear in the root of a volume 50 | .DocumentRevisions-V100 51 | .fseventsd 52 | .Spotlight-V100 53 | .TemporaryItems 54 | .Trashes 55 | .VolumeIcon.icns 56 | 57 | # Directories potentially created on remote AFP share 58 | .AppleDB 59 | .AppleDesktop 60 | Network Trash Folder 61 | Temporary Items 62 | .apdisk 63 | 64 | # Windows 65 | # ========================= 66 | 67 | # Windows image file caches 68 | Thumbs.db 69 | ehthumbs.db 70 | 71 | # Folder config file 72 | Desktop.ini 73 | 74 | # Recycle Bin used on file shares 75 | $RECYCLE.BIN/ 76 | 77 | # Windows Installer files 78 | *.cab 79 | *.msi 80 | *.msm 81 | *.msp 82 | 83 | # Windows shortcuts 84 | *.lnk 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Audio-Recorder-Visualization-Master 2 | Audio recorder with visualization for audio recorder & player. 3 | 4 | This project display visualizer for audio recording as well as on recording playback screen. 5 | 6 | There is a option to share or delete recordings with the help of swipe layout. 7 | 8 | ![Alt text](https://github.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/blob/master/Art/recorder_screen.png "recording screen") 9 | ![Alt text](https://github.com/hiteshsahu/Android-Audio-Recorder-Visualization-Master/blob/master/Art/recording_play.png "Playback screen") 10 | 11 | Feel free to play with controls on app or download it from playstore. 12 | 13 |
This project's main purpose was to demonstarte use of :-
14 | 15 |
1) Audio recorder & Media player ApI of Android.
16 | 17 |
2) Display Visalizer for both recording and playback screens.
18 | 19 |
3) Create simplay music player to support play,pause,next previous and play on tap.
20 | 21 |
4) Use adMob SDK to show ad banners.
22 | 23 | 24 | Dependency:- Appcomat v7 and Google plays libraries 25 | 26 | Copyright 2015 Hitesh Kumar Sahu 27 | 28 | Licensed under the Apache License, Version 2.0 (the "License"); 29 | you may not use this file except in compliance with the License. 30 | You may obtain a copy of the License at 31 | 32 | http://www.apache.org/licenses/LICENSE-2.0 33 | 34 | Unless required by applicable law or agreed to in writing, software 35 | distributed under the License is distributed on an "AS IS" BASIS, 36 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 37 | See the License for the specific language governing permissions and 38 | limitations under the License. 39 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/util/Helper.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.util; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | 6 | import android.content.Context; 7 | import android.os.Environment; 8 | import android.os.Vibrator; 9 | 10 | public class Helper { 11 | 12 | private static Helper helperInstance; 13 | 14 | private Helper() { 15 | 16 | } 17 | 18 | public static Helper getHelperInstance() { 19 | 20 | if (null == helperInstance) { 21 | helperInstance = new Helper(); 22 | } 23 | return helperInstance; 24 | 25 | } 26 | 27 | public static final String RECORDING_PATH = Environment 28 | .getExternalStorageDirectory() + "/Recordings"; 29 | public static final String LOAD_RECORDINGS = "Load Records"; 30 | 31 | public void makeHepticFeedback(Context context) { 32 | 33 | ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)) 34 | .vibrate(100); 35 | } 36 | 37 | public ArrayList getAllFileInDirectory(File directory) { 38 | 39 | final File[] files = directory.listFiles(); 40 | ArrayList listOfRecordings = new ArrayList(); 41 | 42 | if (files != null) { 43 | for (File file : files) { 44 | if (file != null) { 45 | if (file.isDirectory()) { // it is a folder... 46 | getAllFileInDirectory(file); 47 | } else { // it is a file... 48 | 49 | listOfRecordings.add(file.getAbsolutePath()); 50 | } 51 | } 52 | } 53 | } 54 | return listOfRecordings; 55 | } 56 | 57 | public ArrayList getAllRecordings() { 58 | return getAllFileInDirectory(new File(RECORDING_PATH)); 59 | 60 | } 61 | 62 | public boolean createRecordingFolder() { 63 | 64 | if (!new File(RECORDING_PATH).exists()) { 65 | 66 | return new File(RECORDING_PATH).mkdir(); 67 | } else { 68 | return true; 69 | } 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/ui/HomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.ui; 2 | 3 | import java.util.ArrayList; 4 | 5 | import android.media.MediaPlayer; 6 | import android.os.Bundle; 7 | import android.support.v4.app.FragmentActivity; 8 | import android.support.v4.app.FragmentManager; 9 | import android.support.v4.app.FragmentTransaction; 10 | 11 | import com.google.android.gms.ads.AdRequest; 12 | import com.google.android.gms.ads.AdView; 13 | import com.serveroverload.recorder.R; 14 | 15 | public class HomeActivity extends FragmentActivity { 16 | 17 | MediaPlayer mMediaPlayer; 18 | 19 | private ArrayList recordings = new ArrayList(); 20 | 21 | public int RecordingNumber; 22 | 23 | /** 24 | * @return the mMediaPlayer 25 | */ 26 | public MediaPlayer getmMediaPlayer() { 27 | return mMediaPlayer; 28 | } 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | 34 | setContentView(R.layout.activity_main); 35 | 36 | mMediaPlayer = new MediaPlayer(); 37 | 38 | FragmentManager fragmentManager = getSupportFragmentManager(); 39 | FragmentTransaction fragmentTransaction = fragmentManager 40 | .beginTransaction(); 41 | fragmentTransaction.replace(R.id.container, new RecordAudioFragment()); 42 | fragmentTransaction.addToBackStack("RecordAudioFragment"); 43 | fragmentTransaction.commit(); 44 | 45 | AdView mAdView = (AdView) findViewById(R.id.adView); 46 | AdRequest adRequest = new AdRequest.Builder().build(); 47 | mAdView.loadAd(adRequest); 48 | 49 | } 50 | 51 | @Override 52 | protected void onDestroy() { 53 | // TODO Auto-generated method stub 54 | super.onDestroy(); 55 | 56 | if (mMediaPlayer != null) { 57 | mMediaPlayer.stop(); 58 | mMediaPlayer = null; 59 | } 60 | 61 | } 62 | 63 | public ArrayList getRecordings() { 64 | return recordings; 65 | } 66 | 67 | public void setRecordings(ArrayList recordings) { 68 | this.recordings = recordings; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/customview/PlayerVisualizerView.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.customview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Rect; 8 | import android.media.audiofx.Visualizer.OnDataCaptureListener; 9 | import android.view.View; 10 | 11 | /** 12 | * code taken from official sample app see 13 | * ApiDemos>src>com>example>android>apis>media>AudioFxDemo.java A simple class 14 | * that draws waveform data received from a 15 | * {@link OnDataCaptureListener#onWaveFormDataCapture } 16 | */ 17 | public class PlayerVisualizerView extends View { 18 | private byte[] mBytes; 19 | private float[] mPoints; 20 | private Rect mRect = new Rect(); 21 | 22 | private Paint mForePaint = new Paint(); 23 | 24 | public PlayerVisualizerView(Context context) { 25 | super(context); 26 | init(); 27 | } 28 | 29 | private void init() { 30 | mBytes = null; 31 | 32 | mForePaint.setStrokeWidth(1f); 33 | mForePaint.setAntiAlias(true); 34 | mForePaint.setColor(Color.GREEN); 35 | } 36 | 37 | public void updateVisualizer(byte[] bytes) { 38 | mBytes = bytes; 39 | invalidate(); 40 | } 41 | 42 | @Override 43 | protected void onDraw(Canvas canvas) { 44 | super.onDraw(canvas); 45 | 46 | if (mBytes == null) { 47 | return; 48 | } 49 | 50 | if (mPoints == null || mPoints.length < mBytes.length * 4) { 51 | mPoints = new float[mBytes.length * 4]; 52 | } 53 | 54 | mRect.set(0, 0, getWidth(), getHeight()); 55 | 56 | for (int i = 0; i < mBytes.length - 1; i++) { 57 | mPoints[i * 4] = mRect.width() * i / (mBytes.length - 1); 58 | mPoints[i * 4 + 1] = mRect.height() / 2 59 | + ((byte) (mBytes[i] + 128)) * (mRect.height() / 2) / 128; 60 | mPoints[i * 4 + 2] = mRect.width() * (i + 1) / (mBytes.length - 1); 61 | mPoints[i * 4 + 3] = mRect.height() / 2 62 | + ((byte) (mBytes[i + 1] + 128)) * (mRect.height() / 2) 63 | / 128; 64 | } 65 | 66 | canvas.drawLines(mPoints, mForePaint); 67 | } 68 | } -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/util/RecordingsLoaderTask.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.util; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.serveroverload.recorder.R; 6 | import com.serveroverload.recorder.R.layout; 7 | import com.serveroverload.recorder.ui.HomeActivity; 8 | 9 | import android.content.Context; 10 | import android.os.AsyncTask; 11 | import android.support.v4.widget.SwipeRefreshLayout; 12 | import android.widget.ListView; 13 | 14 | /** 15 | * The Class ImageLoaderTask. 16 | */ 17 | public class RecordingsLoaderTask extends 18 | AsyncTask> { 19 | 20 | private Context context; 21 | private SwipeRefreshLayout swipeLayout; 22 | ListView recordingsListView; 23 | 24 | /** 25 | * Instantiates a new image loader task. 26 | * 27 | * @param contacts 28 | * the contacts 29 | * @param position 30 | * the position 31 | */ 32 | public RecordingsLoaderTask(SwipeRefreshLayout swipeLayout, 33 | ListView listView, Context context) { 34 | 35 | this.swipeLayout = swipeLayout; 36 | this.recordingsListView = listView; 37 | this.context = context; 38 | } 39 | 40 | /* 41 | * (non-Javadoc) 42 | * 43 | * @see android.os.AsyncTask#onPostExecute(java.lang.Object) 44 | */ 45 | @Override 46 | protected void onPostExecute(final ArrayList listOfRecordings) { 47 | 48 | if (null != recordingsListView) { 49 | 50 | RecordingsListArrayAdapter arrayAdapter2 = new RecordingsListArrayAdapter( 51 | context, R.layout.swipe_layout_recording_list_item, 52 | ((HomeActivity) context).getRecordings()); 53 | 54 | recordingsListView.setAdapter(arrayAdapter2); 55 | 56 | recordingsListView.setFastScrollEnabled(true); 57 | 58 | } 59 | 60 | if (null != swipeLayout) { 61 | swipeLayout.setRefreshing(false); 62 | } 63 | 64 | super.onPostExecute(listOfRecordings); 65 | } 66 | 67 | @Override 68 | protected ArrayList doInBackground(String... loadTask) { 69 | 70 | ((HomeActivity) context).setRecordings(Helper.getHelperInstance() 71 | .getAllRecordings()); 72 | 73 | return ((HomeActivity) context).getRecordings(); 74 | } 75 | } -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/customview/RecorderVisualizerView.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.customview; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import android.content.Context; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.util.AttributeSet; 11 | import android.view.View; 12 | 13 | public class RecorderVisualizerView extends View { 14 | private static final int LINE_WIDTH = 2; // width of visualizer lines 15 | private static final int LINE_SCALE = 100; // scales visualizer lines 16 | private List amplitudes; // amplitudes for line lengths 17 | private int width; // width of this View 18 | private int height; // height of this View 19 | private Paint linePaint; // specifies line drawing characteristics 20 | 21 | // constructor 22 | public RecorderVisualizerView(Context context, AttributeSet attrs) { 23 | super(context, attrs); // call superclass constructor 24 | linePaint = new Paint(); // create Paint for lines 25 | linePaint.setColor(Color.GREEN); // set color to green 26 | linePaint.setStrokeWidth(LINE_WIDTH); // set stroke width 27 | } 28 | 29 | // called when the dimensions of the View change 30 | @Override 31 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 32 | width = w; // new width of this View 33 | height = h; // new height of this View 34 | amplitudes = new ArrayList(width / LINE_WIDTH); 35 | } 36 | 37 | // clear all amplitudes to prepare for a new visualization 38 | public void clear() { 39 | amplitudes.clear(); 40 | } 41 | 42 | // add the given amplitude to the amplitudes ArrayList 43 | public void addAmplitude(float amplitude) { 44 | amplitudes.add(amplitude); // add newest to the amplitudes ArrayList 45 | 46 | // if the power lines completely fill the VisualizerView 47 | if (amplitudes.size() * LINE_WIDTH >= width) { 48 | amplitudes.remove(0); // remove oldest power value 49 | } 50 | } 51 | 52 | // draw the visualizer with scaled lines representing the amplitudes 53 | @Override 54 | public void onDraw(Canvas canvas) { 55 | int middle = height / 2; // get the middle of the View 56 | float curX = 0; // start curX at zero 57 | 58 | // for each item in the amplitudes ArrayList 59 | for (float power : amplitudes) { 60 | float scaledHeight = power / LINE_SCALE; // scale the power 61 | curX += LINE_WIDTH; // increase X by LINE_WIDTH 62 | 63 | // draw a line representing this item in the amplitudes ArrayList 64 | canvas.drawLine(curX, middle + scaledHeight / 2, curX, middle 65 | - scaledHeight / 2, linePaint); 66 | } 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /res/layout/swipe_layout_recording_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 19 | 20 | 25 | 26 | 31 | 32 | 42 | 43 | 44 | 48 | 49 | 54 | 55 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/com/serveroverload/recorder/util/RecordingsListArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.serveroverload.recorder.util; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.List; 6 | 7 | import com.serveroverload.recorder.R; 8 | import com.serveroverload.recorder.R.id; 9 | import com.serveroverload.recorder.R.layout; 10 | import com.serveroverload.recorder.customview.SwipeLayout; 11 | import com.serveroverload.recorder.ui.HomeActivity; 12 | 13 | import android.content.Context; 14 | import android.content.Intent; 15 | import android.media.MediaPlayer; 16 | import android.net.Uri; 17 | import android.view.LayoutInflater; 18 | import android.view.View; 19 | import android.view.View.OnClickListener; 20 | import android.view.ViewGroup; 21 | import android.widget.ArrayAdapter; 22 | import android.widget.TextView; 23 | import android.widget.Toast; 24 | 25 | public class RecordingsListArrayAdapter extends ArrayAdapter 26 | 27 | { 28 | public RecordingsListArrayAdapter(Context context, int resource, 29 | List listOfRecordings) { 30 | super(context, resource, listOfRecordings); 31 | 32 | this.context = context; 33 | this.listOfRecordings = listOfRecordings; 34 | } 35 | 36 | private final Context context; 37 | private final List listOfRecordings; 38 | private ViewHolder holder; 39 | 40 | private class ViewHolder { 41 | TextView recordingName; 42 | SwipeLayout currentSwipeLayout; 43 | } 44 | 45 | @Override 46 | public View getView(final int position, View convertView, ViewGroup parent) { 47 | 48 | if (convertView == null) { 49 | 50 | LayoutInflater inflater = (LayoutInflater) context 51 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 52 | 53 | convertView = inflater.inflate( 54 | R.layout.swipe_layout_recording_list_item, parent, false); 55 | 56 | holder = new ViewHolder(); 57 | 58 | holder.recordingName = (TextView) convertView 59 | .findViewById(R.id.textViewRecordingName); 60 | 61 | holder.recordingName.setSelected(true); 62 | 63 | holder.currentSwipeLayout = (SwipeLayout) convertView 64 | .findViewById(R.id.swipe_layout_1); 65 | 66 | holder.currentSwipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut); 67 | 68 | holder.currentSwipeLayout.setDragEdge(SwipeLayout.DragEdge.Left); 69 | 70 | convertView.setTag(holder); 71 | } else { 72 | holder = (ViewHolder) convertView.getTag(); 73 | } 74 | 75 | holder.recordingName.setText(((HomeActivity) context).getRecordings().get(position)); 76 | 77 | // Tapped in hidden menu 78 | holder.currentSwipeLayout.findViewById(R.id.share).setOnClickListener( 79 | new OnClickListener() { 80 | 81 | @Override 82 | public void onClick(View arg0) { 83 | Intent sharingIntent = new Intent( 84 | android.content.Intent.ACTION_SEND); 85 | sharingIntent.setType("text/plain"); 86 | File archivo = new File(((HomeActivity) context).getRecordings().get(position)); 87 | sharingIntent.putExtra(Intent.EXTRA_STREAM, 88 | Uri.fromFile(archivo)); 89 | context.startActivity(Intent.createChooser( 90 | sharingIntent, "Share via")); 91 | 92 | } 93 | }); 94 | 95 | holder.currentSwipeLayout.findViewById(R.id.delete_song) 96 | .setOnClickListener(new OnClickListener() { 97 | 98 | @Override 99 | public void onClick(View v) { 100 | 101 | Helper.getHelperInstance().makeHepticFeedback(context); 102 | 103 | if (new File(((HomeActivity) context).getRecordings().get(position)).delete()) { 104 | Toast.makeText(getContext(), "Deleted", 500).show(); 105 | 106 | ((HomeActivity) context).getRecordings().remove(position); 107 | 108 | notifyDataSetChanged(); 109 | 110 | ((HomeActivity) context).getmMediaPlayer().reset(); 111 | } 112 | 113 | } 114 | 115 | }); 116 | 117 | // convertView.setOnClickListener(new OnClickListener() { 118 | // 119 | // @Override 120 | // public void onClick(View v) { 121 | // MediaPlayer mMediaPlayer = ((HomeActivity) context) 122 | // .getmMediaPlayer(); 123 | // 124 | // try { 125 | // 126 | // mMediaPlayer.reset(); 127 | // mMediaPlayer.setDataSource(((HomeActivity) context).getRecordings().get(position)); 128 | // mMediaPlayer.prepare(); 129 | // mMediaPlayer.start(); 130 | // 131 | // } catch (IllegalArgumentException | SecurityException 132 | // | IllegalStateException | IOException e) { 133 | // // TODO Auto-generated catch block 134 | // e.printStackTrace(); 135 | // } 136 | // 137 | // } 138 | // }); 139 | 140 | return convertView; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /res/layout/record_audio_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 24 | 25 | 36 | 37 | 43 | 44 | 50 | 51 | 57 | 58 | 64 | 65 | 71 | 72 | 78 | 79 | 85 | 86 | 92 | 93 | 94 | 107 | 108 | 114 | 115 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /res/layout/recording_list_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | 23 | 32 | 33 | 40 | 41 | 42 | 51 | 52 | 57 | 58 |