From b4c783fa9540cb66c8c4fb1b08d013316620e711 Mon Sep 17 00:00:00 2001 From: Fikri Milano Date: Wed, 8 Feb 2023 16:45:32 +0700 Subject: [PATCH 1/7] UI changes for Attachment widget (#1811) * Merge branch '1621-attachment-questionnaire-item-type' into 1796-new-ui-attachment-widget * Create independent file preview UI * Create independent photo preview UI * Update attachment widget UI * Create rounded background for file preview icon * Update attrs and styles * Update dimens * Update strings * Refactor Attachment widget logic - Update delete button to photoDeleteButton and fileDeleteButton same functionality but different xml file. - Add line divider visibility logic. - Add labelUploaded visibility logic. - Remove methods to display or hide delete button and instead moved the visibility logic to displayPreview method. - Rename variables. - Re-arrange code lines, looks neater. * Update tests - Remove duplicate assertation - Adjust tests from Attachment widget refactor * Set Snackbar gravity to top * Use padding left and right paddingHorizontal requires API 26, current project minimum is API 24. * Revert snackbar gravity top * Use color attribute for icon background preview * Use color attribute for divider outline Re-using item_border_color as it uses colorOnSurface. * Remove obsolete code after merging from master * Rename test class to QuestionnaireItemAttachmentViewHolderFactoryEspressoTest * Fix test build * Fix failed test --- ...ttachmentViewHolderFactoryEspressoTest.kt} | 72 ++------- ...ionnaireItemAttachmentViewHolderFactory.kt | 85 ++++++----- .../rounded_corner_preview_icon_bg_filled.xml | 8 + .../res/layout/attachment_file_preview.xml | 86 +++++++++++ .../res/layout/attachment_photo_preview.xml | 72 +++++++++ .../questionnaire_item_attachment_view.xml | 68 +++------ datacapture/src/main/res/values/attrs.xml | 18 ++- datacapture/src/main/res/values/dimens.xml | 11 +- datacapture/src/main/res/values/strings.xml | 3 +- datacapture/src/main/res/values/styles.xml | 139 ++++++++++++------ 10 files changed, 368 insertions(+), 194 deletions(-) rename datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/{QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest.kt => QuestionnaireItemAttachmentViewHolderFactoryEspressoTest.kt} (82%) create mode 100644 datacapture/src/main/res/drawable/rounded_corner_preview_icon_bg_filled.xml create mode 100644 datacapture/src/main/res/layout/attachment_file_preview.xml create mode 100644 datacapture/src/main/res/layout/attachment_photo_preview.xml diff --git a/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest.kt b/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentViewHolderFactoryEspressoTest.kt similarity index 82% rename from datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest.kt rename to datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentViewHolderFactoryEspressoTest.kt index 5bbb5995f9..529b65371e 100644 --- a/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest.kt +++ b/datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemAttachmentViewHolderFactoryEspressoTest.kt @@ -20,9 +20,8 @@ import android.util.Base64 import android.view.View import android.widget.Button import android.widget.FrameLayout -import android.widget.ImageView -import android.widget.LinearLayout import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry @@ -40,7 +39,7 @@ import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest { +class QuestionnaireItemAttachmentViewHolderFactoryEspressoTest { @Rule @JvmField @@ -219,17 +218,10 @@ class QuestionnaireItemAttachmentPickerViewHolderFactoryEspressoTest { runOnUI { viewHolder.bind(questionnaireItemView) } - assertThat(viewHolder.itemView.findViewById