The QR camera should stop and restart manually if the user need it
This commit is contained in:
parent
85b1015e9f
commit
d788ceab9a
2 changed files with 57 additions and 16 deletions
|
@ -8,7 +8,6 @@ import android.arch.lifecycle.Observer;
|
|||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -28,12 +27,10 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -41,7 +38,6 @@ import android.widget.Toast;
|
|||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.jaredrummler.materialspinner.MaterialSpinner;
|
||||
import com.vincent.filepicker.ToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.RoundingMode;
|
||||
|
@ -95,6 +91,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
View viewSend;
|
||||
@BindView(R.id.tvToError)
|
||||
TextView tvToError;
|
||||
@BindView(R.id.fabCloseCamera)
|
||||
FloatingActionButton btnCloseCamera;
|
||||
@BindView(R.id.spAsset)
|
||||
Spinner spAsset;
|
||||
@BindView(R.id.tvAssetError)
|
||||
|
@ -127,6 +125,11 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
@BindView(R.id.viewCamera)
|
||||
View viewCamera;
|
||||
|
||||
/*
|
||||
* Flag to control when the camera is visible and when is hide
|
||||
* */
|
||||
private boolean cameraVisible = true;
|
||||
|
||||
Button btnScanQrCode;
|
||||
|
||||
private long cryptoNetAccountId;
|
||||
|
@ -364,17 +367,41 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
mScannerView.stopCamera();
|
||||
|
||||
/*
|
||||
* Hide the camera
|
||||
* Hide the camera or show it
|
||||
* */
|
||||
if(cameraVisible){
|
||||
hideCamera();
|
||||
}
|
||||
else{
|
||||
showCamera();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show the camera and hide the black background
|
||||
* */
|
||||
private void showCamera(){
|
||||
|
||||
/*
|
||||
* Change visibilities of views
|
||||
* */
|
||||
viewCamera.setVisibility(View.GONE);
|
||||
mScannerView.setVisibility(View.VISIBLE);
|
||||
|
||||
/*
|
||||
* Change icon
|
||||
* */
|
||||
btnCloseCamera.setImageDrawable(getResources().getDrawable(R.drawable.ic_close));
|
||||
|
||||
/*
|
||||
* Reset variable
|
||||
* */
|
||||
cameraVisible = true;
|
||||
|
||||
/*
|
||||
* Star the camera again
|
||||
* */
|
||||
beginScanQrCode();
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,8 +409,22 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
|||
* Hide the camera and show the black background
|
||||
* */
|
||||
private void hideCamera(){
|
||||
|
||||
/*
|
||||
* Change visibilities of views
|
||||
* */
|
||||
viewCamera.setVisibility(View.VISIBLE);
|
||||
mScannerView.setVisibility(View.INVISIBLE);
|
||||
|
||||
/*
|
||||
* Change icon
|
||||
* */
|
||||
btnCloseCamera.setImageDrawable(getResources().getDrawable(R.drawable.ok));
|
||||
|
||||
/*
|
||||
* Reset variable
|
||||
* */
|
||||
cameraVisible = false;
|
||||
}
|
||||
|
||||
@OnTextChanged(value = R.id.etMemo,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white">
|
||||
|
@ -203,27 +204,26 @@
|
|||
|
||||
<me.dm7.barcodescanner.zxing.ZXingScannerView
|
||||
android:id="@+id/ivCamera"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="180dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="176dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:contentDescription="@string/camera_feed_to_scan_qr"
|
||||
android:src="#666"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvScan"
|
||||
android:contentDescription="@string/camera_feed_to_scan_qr" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvScan" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabCloseCamera"
|
||||
android:layout_width="30dp"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="30dp"
|
||||
app:fabSize="mini"
|
||||
android:layout_marginBottom="165dp"
|
||||
android:layout_marginStart="165dp"
|
||||
android:layout_marginBottom="165dp"
|
||||
app:backgroundTint="@color/send_strong_orange"
|
||||
app:srcCompat="@drawable/ic_close"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/ivCamera"
|
||||
app:layout_constraintStart_toStartOf="@+id/ivCamera" />
|
||||
app:layout_constraintStart_toStartOf="@+id/ivCamera"
|
||||
app:srcCompat="@drawable/ic_close" />
|
||||
|
||||
<View
|
||||
android:id="@+id/viewSend"
|
||||
|
|
Loading…
Reference in a new issue