-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fix scoped storage issue #7
Conversation
This reverts commit 86c1653.
fetch upstream code
android-wave-recorder/src/main/java/com/github/squti/androidwaverecorder/WaveHeaderWriter.kt
Outdated
Show resolved
Hide resolved
android-wave-recorder/src/main/java/com/github/squti/androidwaverecorder/WaveHeaderWriter.kt
Outdated
Show resolved
Hide resolved
android-wave-recorder/src/main/java/com/github/squti/androidwaverecorder/WaveRecorder.kt
Outdated
Show resolved
Hide resolved
inputStream = File(filePath!!).inputStream() | ||
} else { | ||
val descriptor = | ||
context.contentResolver.openFileDescriptor(fileUri!!, "rw")?.fileDescriptor |
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.
fileUri!!
still with assertion
randomAccessFile.close() | ||
|
||
if (filePath == null) { | ||
val outputStream = context.contentResolver.openOutputStream(fileUri!!, "rw") |
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.
same on this line
outputStream?.write(header) | ||
outputStream?.close() | ||
} else { | ||
val randomAccessFile = RandomAccessFile(File(filePath!!), "rw") |
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.
same on this line
val outputStream: OutputStream | ||
// var length: Long | ||
if (filePath != null) { | ||
val file = File(filePath!!) |
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.
You can use filePath?.let { path -> ... } ?: run { ... }
instead of if else to avoid assertion
@@ -170,7 +202,11 @@ class WaveRecorder(private var filePath: String) { | |||
audioRecorder.stop() | |||
audioRecorder.release() | |||
audioSessionId = -1 | |||
WaveHeaderWriter(filePath, waveConfig).writeHeader() | |||
if (filePath != null) { | |||
WaveHeaderWriter(waveConfig, context).with(filePath!!).writeHeader() |
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.
same here
@@ -173,6 +186,17 @@ class MainActivity : AppCompatActivity() { | |||
private const val TAG = "MainActivity" | |||
} | |||
|
|||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
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.
This is not something to change right now. But in newer versions of Android onActivityResult is deprecated, and in future versions it may be deleted at all. There is a new API for that ActivityResultCallback .
Unfortunately I can't accept this PR. The reasons are below: |
@robertlevonyan @squti I have solved issue #6 using file descriptor and Uri. review it.