Improve the camera preview in SendTransactionFragment, so that both the preview and the scan zone are squared.

This commit is contained in:
Severiano Jaramillo 2019-02-11 18:53:18 -06:00
parent 653bdbec69
commit 1e67fdf065
3 changed files with 34 additions and 26 deletions

View file

@ -351,6 +351,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
cameraPreview.setMaskColor(R.color.colorAccent)
cameraPreview.setResultHandler(this)
cameraPreview.startCamera()
cameraPreview.scrollY = holderCamera.width / 6
}
private fun stopCameraPreview() {

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="10dp" />
<solid android:color="#111" />
<corners android:radius="8dp" />
<stroke
android:width="1dp"
android:color="#888"/>
</shape>

View file

@ -136,8 +136,8 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilMemo" />
<View
android:id="@+id/viewCamera"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/holderCamera"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/spacing_same_topic"
@ -147,7 +147,21 @@
app:layout_constraintTop_toBottomOf="@+id/tvScan"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/cameraVerticalGuideline"/>
app:layout_constraintEnd_toStartOf="@id/cameraVerticalGuideline">
<me.dm7.barcodescanner.zxing.ZXingScannerView
android:id="@+id/cameraPreview"
android:layout_width="0dp"
android:layout_height="0dp"
app:squaredFinder="true"
app:borderColor="@color/colorSend"
app:layout_constraintDimensionRatio="h,3:4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabOpenCamera"
@ -161,16 +175,6 @@
app:layout_constraintStart_toEndOf="@id/cameraVerticalGuideline"
app:layout_constraintTop_toBottomOf="@+id/tvScan"/>
<me.dm7.barcodescanner.zxing.ZXingScannerView
android:id="@+id/cameraPreview"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="w,3:4"
app:layout_constraintTop_toTopOf="@+id/viewCamera"
app:layout_constraintBottom_toBottomOf="@id/viewCamera"
app:layout_constraintStart_toStartOf="@id/viewCamera"
app:layout_constraintEnd_toEndOf="@id/viewCamera" />
<View
android:id="@+id/vSend"
android:layout_width="120dp"
@ -178,8 +182,8 @@
android:layout_marginEnd="0dp"
android:background="@drawable/send_fab_background_disabled"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/viewCamera"
app:layout_constraintBottom_toBottomOf="@id/viewCamera"/>
app:layout_constraintTop_toTopOf="@id/holderCamera"
app:layout_constraintBottom_toBottomOf="@id/holderCamera"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSendTransaction"