fix #47, add an Open With menu button for recordings
This commit is contained in:
parent
da60a8a1a0
commit
199c551e29
2 changed files with 22 additions and 3 deletions
|
@ -24,9 +24,11 @@ import kotlinx.android.synthetic.main.item_recording.view.*
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class RecordingsAdapter(activity: SimpleActivity, var recordings: ArrayList<Recording>, val refreshListener: RefreshRecordingsListener,
|
||||
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class RecordingsAdapter(
|
||||
activity: SimpleActivity, var recordings: ArrayList<Recording>, val refreshListener: RefreshRecordingsListener,
|
||||
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit
|
||||
) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
|
||||
var currRecordingId = 0
|
||||
|
||||
|
@ -39,6 +41,7 @@ class RecordingsAdapter(activity: SimpleActivity, var recordings: ArrayList<Reco
|
|||
override fun prepareActionMode(menu: Menu) {
|
||||
menu.apply {
|
||||
findItem(R.id.cab_rename).isVisible = isOneItemSelected()
|
||||
findItem(R.id.cab_open_with).isVisible = isOneItemSelected()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +54,7 @@ class RecordingsAdapter(activity: SimpleActivity, var recordings: ArrayList<Reco
|
|||
R.id.cab_rename -> renameRecording()
|
||||
R.id.cab_share -> shareRecordings()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
R.id.cab_open_with -> openRecordingWith()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,6 +101,17 @@ class RecordingsAdapter(activity: SimpleActivity, var recordings: ArrayList<Reco
|
|||
}
|
||||
}
|
||||
|
||||
private fun openRecordingWith() {
|
||||
val recording = getItemWithKey(selectedKeys.first()) ?: return
|
||||
val path = if (isQPlus()) {
|
||||
getAudioFileContentUri(recording.id.toLong()).toString()
|
||||
} else {
|
||||
recording.path
|
||||
}
|
||||
|
||||
activity.openPathIntent(path, false, BuildConfig.APPLICATION_ID, "audio/*")
|
||||
}
|
||||
|
||||
private fun shareRecordings() {
|
||||
val selectedItems = getSelectedItems()
|
||||
val paths = if (isQPlus()) {
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
android:icon="@drawable/ic_share_vector"
|
||||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/cab_open_with"
|
||||
android:title="@string/open_with"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@drawable/ic_delete_vector"
|
||||
|
|
Loading…
Reference in a new issue