diff --git a/README.md b/README.md index 6d53a19..852f8d7 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,5 @@ The app offers a few ways to calculate the audio level to display: Future Features? * Make meter fit a variety of screen sizes. -* Allow a log of the readings \ No newline at end of file +* Allow a log of the readings. +* Fancier display. \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f8f5207..cb609ef 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="1" + android:versionName="1.0"> adapterView) { levelType.setSelection(levelTypeAdapter.getPosition(levM)); levelMethodChanged((MicLevelReader.LevelMethod)levelType.getSelectedItem()); + checkMicrophoneAccess(); } + private boolean checkMicrophoneAccess() { + if (ContextCompat.checkSelfPermission(this,Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.RECORD_AUDIO}, + REQUEST_RECORD_AUDIO); + return false; + } + return true; + } + + private static final int REQUEST_RECORD_AUDIO = 121; + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + switch (requestCode) { + case REQUEST_RECORD_AUDIO: { + // If request is cancelled, the result arrays are empty. + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + + Toast.makeText(this, "Yay!", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(this, "This application will not function without access to the microphone", Toast.LENGTH_LONG).show(); + } + } + } + } + private void levelMethodChanged(MicLevelReader.LevelMethod levelMethod) { mMicLevelReader.setLevelMethod(levelMethod); mMeterView.setmMeterMax(mMicLevelReader.getMaxLevel()); @@ -174,9 +211,13 @@ public void handleMessage(Message msg) { }; - public void startit() { - mRecorderThread = new Thread(mMicLevelReader, "AudioListener Thread"); - mRecorderThread.start(); + public boolean startit() { + if (checkMicrophoneAccess()) { + mRecorderThread = new Thread(mMicLevelReader, "AudioListener Thread"); + mRecorderThread.start(); + return true; + } + return false; } diff --git a/app/src/main/res/drawable/audiometer.png b/app/src/main/res/drawable/audiometer.png index 6aef0e5..20e3af9 100644 Binary files a/app/src/main/res/drawable/audiometer.png and b/app/src/main/res/drawable/audiometer.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bc..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c133a0c..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfa42f0..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72c..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index aee44e1..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ