Skip to content

Commit

Permalink
Mobileapps 830 (#30)
Browse files Browse the repository at this point in the history
* adjusted margins as per figma design
  • Loading branch information
aman-alfresco authored Sep 13, 2021
1 parent 480ca94 commit 1eb6dab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ lint/generated/
lint/outputs/
lint/tmp/
lint/reports/
/app/release/
64 changes: 33 additions & 31 deletions capture/src/main/kotlin/com/alfresco/capture/SaveFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions capture/src/main/res/layout/fragment_save.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

<ImageView
android:id="@+id/preview"
android:layout_width="240dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/capture_photo_preview_alt"
android:maxHeight="234dp"
android:maxHeight="280dp"
android:scaleType="fitXY" />

<TextView
Expand Down Expand Up @@ -74,6 +74,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/capture_layout_margin"
android:orientation="vertical">

<com.google.android.material.textfield.TextInputLayout
Expand Down Expand Up @@ -109,7 +110,7 @@
style="@style/Widget.Alfresco.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/capture_layout_margin"
android:layout_marginTop="@dimen/capture_layout_margin_button"
android:layout_marginBottom="@dimen/capture_layout_margin"
android:text="@string/capture_save_button" />
</LinearLayout>
Expand Down
1 change: 1 addition & 0 deletions capture/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="capture_layout_margin">24dp</dimen>
<dimen name="capture_layout_margin_button">28dp</dimen>
<dimen name="capture_layout_small_margin">16dp</dimen>
<dimen name="capture_button_size">40dp</dimen>
<dimen name="capture_view_size">60dp</dimen>
Expand Down

0 comments on commit 1eb6dab

Please sign in to comment.