-
Notifications
You must be signed in to change notification settings - Fork 771
IDE-295 Refactor SoundRecorder files to Kotlin #5124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Frajhamster
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
2dd02ff to
9a538e5
Compare
|
Rebased PR. |
| } | ||
|
|
||
| @Throws(IOException::class, RuntimeException::class) | ||
| fun start() { |
Check warning
Code scanning / detekt
Restrict the number of throw statements in methods. Warning
| recorder.start() | ||
| isRecording = true | ||
| } catch (e: IllegalStateException) { | ||
| throw e |
Check warning
Code scanning / detekt
Do not rethrow a caught exception of the same type. Warning
| isRecording = true | ||
| } catch (e: IllegalStateException) { | ||
| throw e | ||
| } catch (e: RuntimeException) { |
Check warning
Code scanning / detekt
The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning
| } catch (e: IllegalStateException) { | ||
| throw e | ||
| } catch (e: RuntimeException) { | ||
| throw e |
Check warning
Code scanning / detekt
Do not rethrow a caught exception of the same type. Warning
| } catch (_: RuntimeException) { | ||
| Log.d( | ||
| TAG, ("Note that a RuntimeException is intentionally " | ||
| + "thrown to the application, if no valid audio/video data " |
Check warning
Code scanning / detekt
Checks if condition chaining is wrapped right Warning
| + "is called immediately after start(). The failure lets the application " | ||
| + "take action accordingly to clean up the output file " | ||
| + "(delete the output file, for instance), since the output file " | ||
| + "is not properly constructed when this happens.") |
Check warning
Code scanning / detekt
Checks if condition chaining is wrapped right Warning
| } catch (e: IllegalStateException) { | ||
| Log.e(TAG, "Error recording sound (Other recorder running?).", e) | ||
| ToastUtil.showError(this, R.string.soundrecorder_error) | ||
| } catch (e: RuntimeException) { |
Check warning
Code scanning / detekt
The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning
|
|
||
| @Test | ||
| fun testMaxAmplitudeDelegatesToMediaRecorder() { | ||
| val expectedAmplitude = 12345 |
Check warning
Code scanning / detekt
Report missing or invalid underscores in base 10 numbers. Numeric literals should be underscore separated to increase readability. Warning test
| // Create a file (not directory) at the path where we need a directory | ||
| // Then try to create a subdirectory inside it - mkdirs() will fail | ||
| val blockingFile = File(tempFolder.root, "blocker") | ||
| blockingFile.createNewFile() // Create a FILE named "blocker" |
Check warning
Code scanning / detekt
Reports multiple space usages Warning test
| // "blocker" is a file, not a directory | ||
| val invalidPath = File(File(blockingFile, "subdir"), "test.m4a").absolutePath | ||
| val invalidRecorder = SoundRecorder(invalidPath, mockRecorder) | ||
| invalidRecorder.start() // Should throw IOException: "Path to file could not be created." |
Check warning
Code scanning / detekt
Reports multiple space usages Warning test
|



Refactored the files
org.catrobat.catroid.soundrecorder.RecordButton,org.catrobat.catroid.soundrecorder.SoundRecorder, andorg.catrobat.catroid.soundrecorder.SoundRecorderActivityfrom Java to Kotlin. Created a Unit-Test for SoundRecorder in addition to existing Integration-Tests. Added Dependency for MockK and used it to fix the test inorg.catrobat.catroid.test.formulaeditor.SensorHandlerTest.https://catrobat.atlassian.net/browse/IDE-295
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.