|
|
|
|
@ -31,8 +31,8 @@ import java.util.* |
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
enum class FileType(var value: String) { |
|
|
|
|
IMAGE("image/gif"), |
|
|
|
|
VIDEO("video/*") |
|
|
|
|
IMAGE_GIF("image/gif"), |
|
|
|
|
VIDEO_MP4("video/mp4") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class ReplayExportService : Service() { |
|
|
|
|
@ -92,7 +92,7 @@ class ReplayExportService : Service() { |
|
|
|
|
animator.configure(width.toFloat(), height.toFloat(), context) |
|
|
|
|
|
|
|
|
|
val formattedDate = Date().dateTimeFileFormatted |
|
|
|
|
val fileName = "hand_${formattedDate}.gif" |
|
|
|
|
val fileName = "hand_${formattedDate}" |
|
|
|
|
|
|
|
|
|
// Add a specific media item. |
|
|
|
|
val resolver = applicationContext.contentResolver |
|
|
|
|
@ -102,6 +102,7 @@ class ReplayExportService : Service() { |
|
|
|
|
|
|
|
|
|
val gifDetails = ContentValues().apply { |
|
|
|
|
put(MediaStore.Images.Media.DISPLAY_NAME, fileName) |
|
|
|
|
put(MediaStore.Images.Media.MIME_TYPE, FileType.IMAGE_GIF.value) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val uri = resolver.insert(imageCollection, gifDetails) |
|
|
|
|
@ -135,7 +136,7 @@ class ReplayExportService : Service() { |
|
|
|
|
writer.finishWrite(os) |
|
|
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
notifyUser(uri, FileType.IMAGE) |
|
|
|
|
notifyUser(uri, FileType.IMAGE_GIF) |
|
|
|
|
} else { |
|
|
|
|
Timber.w("Resolver insert ended without uri...") |
|
|
|
|
} |
|
|
|
|
@ -206,6 +207,7 @@ class ReplayExportService : Service() { |
|
|
|
|
val fileDetails = ContentValues().apply { |
|
|
|
|
Timber.d("set file details = $fileName") |
|
|
|
|
put(MediaStore.Video.Media.DISPLAY_NAME, fileName) |
|
|
|
|
put(MediaStore.Images.Media.MIME_TYPE, FileType.VIDEO_MP4.value) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// copy video to nice path |
|
|
|
|
@ -219,7 +221,7 @@ class ReplayExportService : Service() { |
|
|
|
|
|
|
|
|
|
file.delete() // delete temp file |
|
|
|
|
|
|
|
|
|
notifyUser(uri, FileType.VIDEO) |
|
|
|
|
notifyUser(uri, FileType.VIDEO_MP4) |
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
Timber.w("Resolver insert ended without uri...") |
|
|
|
|
|