diff --git a/.gitignore b/.gitignore index 1fb1d115b..6f0a06cbe 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,4 @@ lint/generated/ lint/outputs/ lint/tmp/ lint/reports/ +/app/release/ diff --git a/capture/src/main/kotlin/com/alfresco/capture/SaveFragment.kt b/capture/src/main/kotlin/com/alfresco/capture/SaveFragment.kt index ed0ee746b..e199a5340 100644 --- a/capture/src/main/kotlin/com/alfresco/capture/SaveFragment.kt +++ b/capture/src/main/kotlin/com/alfresco/capture/SaveFragment.kt @@ -49,38 +49,40 @@ class SaveFragment : Fragment(), MavericksView { private fun onSuccessMediaLoad() { withState(viewModel) { if (it.capture != null) { - val mediaMetadataRetriever = MediaMetadataRetriever() - mediaMetadataRetriever.setDataSource(it.capture.uri.path) - val time: String? = - mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION) - val duration = time?.toLong() - - duration?.let { millis -> - val hour = TimeUnit.MILLISECONDS.toHours(millis) - val minutes = - TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes( - TimeUnit.MILLISECONDS.toHours(millis) - ) - val seconds = - TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds( - TimeUnit.MILLISECONDS.toMinutes(millis) - ) - val hms = if (hour > 0L) { - java.lang.String.format( - ENGLISH, - getString(R.string.format_video_duration_hour), hour, - minutes, seconds - ) - } else { - java.lang.String.format( - ENGLISH, - getString(R.string.format_video_duration_minute), - minutes, seconds - ) + if (it.capture.isVideo()) { + val mediaMetadataRetriever = MediaMetadataRetriever() + mediaMetadataRetriever.setDataSource(it.capture.uri.path) + val time: String? = + mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION) + val duration = time?.toLong() + + duration?.let { millis -> + val hour = TimeUnit.MILLISECONDS.toHours(millis) + val minutes = + TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes( + TimeUnit.MILLISECONDS.toHours(millis) + ) + val seconds = + TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds( + TimeUnit.MILLISECONDS.toMinutes(millis) + ) + val hms = if (hour > 0L) { + java.lang.String.format( + ENGLISH, + getString(R.string.format_video_duration_hour), hour, + minutes, seconds + ) + } else { + java.lang.String.format( + ENGLISH, + getString(R.string.format_video_duration_minute), + minutes, seconds + ) + } + + binding.videoDuration.isVisible = it.capture.isVideo() == true + binding.videoDuration.text = hms } - - binding.videoDuration.isVisible = it.capture.isVideo() == true - binding.videoDuration.text = hms } } binding.deletePhotoButton.isVisible = true diff --git a/capture/src/main/res/layout/fragment_save.xml b/capture/src/main/res/layout/fragment_save.xml index 32f75d204..6e2303704 100644 --- a/capture/src/main/res/layout/fragment_save.xml +++ b/capture/src/main/res/layout/fragment_save.xml @@ -39,11 +39,11 @@ diff --git a/capture/src/main/res/values/attrs.xml b/capture/src/main/res/values/attrs.xml index 3f0cf8ac5..d27a7e5c5 100644 --- a/capture/src/main/res/values/attrs.xml +++ b/capture/src/main/res/values/attrs.xml @@ -1,6 +1,7 @@ 24dp + 28dp 16dp 40dp 60dp