Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Identity] Make error screen and Selfie screen scrollable #5247

Merged
merged 1 commit into from Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion identity/api/identity.api
Expand Up @@ -282,7 +282,8 @@ public final class com/stripe/android/identity/databinding/SelfieScanFragmentBin
public final field headerTitle Landroid/widget/TextView;
public final field kontinue Lcom/stripe/android/identity/ui/LoadingButton;
public final field message Landroid/widget/TextView;
public final field resultView Landroid/widget/LinearLayout;
public final field padding Landroid/view/View;
public final field resultView Landroid/widget/ScrollView;
public final field scanningView Lcom/google/android/material/card/MaterialCardView;
public static fun bind (Landroid/view/View;)Lcom/stripe/android/identity/databinding/SelfieScanFragmentBinding;
public synthetic fun getRoot ()Landroid/view/View;
Expand Down
5 changes: 2 additions & 3 deletions identity/res/layout/base_error_fragment.xml
Expand Up @@ -18,14 +18,13 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="180dp"
android:gravity="center">
android:orientation="vertical">

<ImageView
android:layout_gravity="center_horizontal"
android:layout_width="92dp"
android:layout_height="92dp"
android:layout_marginTop="180dp"
android:src="@drawable/ic_exclamation"
android:layout_marginBottom="26dp"
app:tint="@color/error_exclamation_color" />
Expand Down
40 changes: 23 additions & 17 deletions identity/res/layout/selfie_scan_fragment.xml
Expand Up @@ -71,32 +71,38 @@
</androidx.constraintlayout.widget.ConstraintLayout>


<LinearLayout
<ScrollView
android:id="@+id/result_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:visibility="gone"
android:orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/captured_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

<CheckBox
android:id="@+id/allow_image_collection"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/page_horizontal_margin"
android:layout_marginEnd="@dimen/page_horizontal_margin"
android:layout_marginTop="20dp" />
</LinearLayout>
android:orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/captured_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

<CheckBox
android:id="@+id/allow_image_collection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/page_horizontal_margin"
android:layout_marginEnd="@dimen/page_horizontal_margin"
android:layout_marginTop="20dp" />
</LinearLayout>
</ScrollView>

<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/padding"
android:layout_weight="1" />

<com.stripe.android.identity.ui.LoadingButton
Expand Down
Expand Up @@ -9,7 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import androidx.annotation.VisibleForTesting
import androidx.cardview.widget.CardView
Expand Down Expand Up @@ -53,7 +53,8 @@ internal class SelfieFragment(
private lateinit var messageView: TextView
private lateinit var flashMask: View
private lateinit var scanningView: CardView
private lateinit var resultView: LinearLayout
private lateinit var resultView: ScrollView
private lateinit var padding: View
private lateinit var capturedImages: RecyclerView
private lateinit var allowImageCollection: CheckBox

Expand All @@ -74,6 +75,7 @@ internal class SelfieFragment(
flashMask = binding.flashMask
scanningView = binding.scanningView
resultView = binding.resultView
padding = binding.padding
capturedImages = binding.capturedImages
allowImageCollection = binding.allowImageCollection
capturedImages.adapter = selfieResultAdapter
Expand Down Expand Up @@ -164,6 +166,7 @@ internal class SelfieFragment(
binding.message.text = requireContext().getText(R.string.selfie_capture_complete)
}
is IdentityScanState.Finished -> {
binding.message.text = requireContext().getText(R.string.selfie_capture_complete)
toggleResultViewWithResult(
(identityScanState.transitioner as FaceDetectorTransitioner)
.filteredFrames.map { it.first.cameraPreviewImage.image.mirrorHorizontally() }
Expand All @@ -177,6 +180,7 @@ internal class SelfieFragment(

override fun resetUI() {
scanningView.visibility = View.VISIBLE
padding.visibility = View.VISIBLE
resultView.visibility = View.GONE
continueButton.isEnabled = false
messageView.text = requireContext().getText(R.string.position_selfie)
Expand Down Expand Up @@ -258,6 +262,7 @@ internal class SelfieFragment(
private fun toggleResultViewWithResult(resultList: List<Bitmap>) {
scanningView.visibility = View.GONE
resultView.visibility = View.VISIBLE
padding.visibility = View.GONE
continueButton.isEnabled = true
selfieResultAdapter.submitList(resultList)
}
Expand Down
Expand Up @@ -158,6 +158,7 @@ internal class SelfieFragmentTest {
verify(mockIdentityViewModel).resetSelfieUploadedState()
assertThat(binding.scanningView.visibility).isEqualTo(View.VISIBLE)
assertThat(binding.resultView.visibility).isEqualTo(View.GONE)
assertThat(binding.padding.visibility).isEqualTo(View.VISIBLE)
assertThat(binding.kontinue.isEnabled).isEqualTo(false)
assertThat(binding.allowImageCollection.text.toString()).isEqualTo(CONSENT_TEXT)
}
Expand Down Expand Up @@ -197,6 +198,7 @@ internal class SelfieFragmentTest {

assertThat(binding.scanningView.visibility).isEqualTo(View.GONE)
assertThat(binding.resultView.visibility).isEqualTo(View.VISIBLE)
assertThat(binding.padding.visibility).isEqualTo(View.GONE)
assertThat(binding.kontinue.isEnabled).isEqualTo(true)
assertThat(fragment.selfieResultAdapter.itemCount).isEqualTo(FILTERED_FRAMES.size)
}
Expand Down