From c35347786f3d03193ff0669b1fb5281b9e9ccdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ramos?= Date: Sun, 7 Feb 2021 20:20:36 -0300 Subject: [PATCH] =?UTF-8?q?bot=C3=A3o=20voltar=20adicionado=20em=20ReceptF?= =?UTF-8?q?ileActivity.=20E=20j=C3=A1=20=C3=A9=20poss=C3=ADvel=20voltar=20?= =?UTF-8?q?da=20tela=20sem=20o=20modo=20escanear.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../main/java/com/cropdox/CameraActivity.java | 12 +--- .../java/com/cropdox/ReceptFileActivity.java | 67 +++++++++++++------ .../main/res/layout/activity_recept_file.xml | 22 ++++-- 4 files changed, 70 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f10ccea..dd8dbe1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.cropdox" minSdkVersion 17 targetSdkVersion 29 - versionCode 16 - versionName "13.0.6" + versionCode 17 + versionName "13.1" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/cropdox/CameraActivity.java b/app/src/main/java/com/cropdox/CameraActivity.java index d4b836d..1a785cf 100644 --- a/app/src/main/java/com/cropdox/CameraActivity.java +++ b/app/src/main/java/com/cropdox/CameraActivity.java @@ -21,7 +21,6 @@ import android.widget.Toast; import com.cropdox.model.FileInfo; -import com.cropdox.processamento.Utilidades; import com.cropdox.remote.APIUtils; import com.cropdox.remote.FileService; @@ -34,9 +33,7 @@ import org.opencv.android.Utils; import org.opencv.core.Core; import org.opencv.core.Mat; -import org.opencv.core.MatOfPoint; import org.opencv.core.Point; -import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.imgproc.Imgproc; @@ -47,9 +44,6 @@ import java.io.IOException; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; -import java.text.BreakIterator; -import java.util.ArrayList; -import java.util.List; import io.socket.client.IO; import io.socket.client.Socket; @@ -88,7 +82,7 @@ public class CameraActivity extends AppCompatActivity implements CameraBridgeVie private Socket mSocket; private boolean qr_ja_reconhecido; - private Emitter.Listener onNewMessage = new Emitter.Listener() { + /*private Emitter.Listener onNewMessage = new Emitter.Listener() { @Override public void call(final Object... args) { runOnUiThread(new Runnable() { @@ -98,7 +92,7 @@ public void run() { } }); } - }; + };*/ private LinearLayout camera_controles; @@ -115,7 +109,7 @@ public void run() { } public CameraActivity() { - mSocket.on("mensagem", onNewMessage); + //mSocket.on("mensagem", onNewMessage); mSocket.connect(); } diff --git a/app/src/main/java/com/cropdox/ReceptFileActivity.java b/app/src/main/java/com/cropdox/ReceptFileActivity.java index 79c40ea..d3ea196 100644 --- a/app/src/main/java/com/cropdox/ReceptFileActivity.java +++ b/app/src/main/java/com/cropdox/ReceptFileActivity.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.os.Environment; import android.util.Log; +import android.view.MotionEvent; import android.view.SurfaceView; import android.view.View; import android.widget.Button; @@ -54,7 +55,7 @@ import retrofit2.Callback; public class ReceptFileActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2, - View.OnClickListener { + View.OnClickListener, View.OnTouchListener { private ImageView imageView; private Button btn_enviar; private String currentPhotoPath; @@ -71,7 +72,7 @@ public class ReceptFileActivity extends AppCompatActivity implements CameraBridg private Socket mSocket; private boolean qr_ja_reconhecido; - +/* private Emitter.Listener onNewMessage = new Emitter.Listener() { @Override public void call(final Object... args) { @@ -82,10 +83,11 @@ public void run() { } }); } - }; + };*/ private LinearLayout camera_controles; private Bitmap bitmap; private Button botao_enviar; + private Button close_button; { try { @@ -100,7 +102,7 @@ public void run() { } public ReceptFileActivity() { - mSocket.on("mensagem", onNewMessage); + //mSocket.on("mensagem", onNewMessage); mSocket.connect(); } @@ -114,6 +116,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_recept_file); imageView = (ImageView) findViewById(R.id.imageView_img_recebida); botao_enviar = (Button) findViewById(R.id.botao_enviar); + close_button = (Button) findViewById(R.id.close_button); // Initialize Firebase Auth mAuth = FirebaseAuth.getInstance(); @@ -160,7 +163,10 @@ public void onManagerConnected(int status) { imageView.animate().rotation(imageView.getRotation() - 90).start(); botao_enviar.animate().rotation(botao_enviar.getRotation() - 90).start(); + close_button.animate().rotation(close_button.getRotation() - 90).start(); botao_enviar.setOnClickListener(this); + close_button.setOnClickListener(this); + close_button.setOnTouchListener(this); } @Override @@ -169,9 +175,23 @@ public void onClick(View v) { modo_QR = true; botoa_enviado_clicado = true; enviarImagem(); + }else if(v.getId() == R.id.close_button){ + finish(); } } + @Override + public boolean onTouch(View view, MotionEvent event) { + if(view.getId() == R.id.close_button) { + if (event.getAction() == MotionEvent.ACTION_UP) { + view.setBackgroundResource(android.R.drawable.ic_menu_close_clear_cancel); + //clicado = false; + } else if (event.getAction() == MotionEvent.ACTION_DOWN) { + view.setBackgroundResource(android.R.drawable.ic_media_previous); + } + } + return false; + } void handleSendImage(Intent intent) { Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); //MediaController mediaController = new MediaController(this.getApplication()); @@ -179,8 +199,6 @@ void handleSendImage(Intent intent) { //File photoUpload = new File(imageUri.getPath()); if (imageUri != null) { - //currentPhotoPath = photoUpload.getPath(); - InputStream stream = null; try { stream = this.getContentResolver().openInputStream(imageUri); @@ -203,8 +221,6 @@ void handleSendImage(Intent intent) { } } } - - try { this.saveImage(bitmap); @@ -243,23 +259,13 @@ public void onResponse(Call call, retrofit2.Response respons @Override public void onFailure(Call call, Throwable t) { Log.e(GENIAL_LOG, "Erro: " + t.getMessage()); - //Toast.makeText(CameraActivity.this, "Erro: " + t.getMessage(), Toast.LENGTH_SHORT).show(); + Toast.makeText(ReceptFileActivity.this, "Erro: " + t.getMessage(), Toast.LENGTH_SHORT).show(); } }); } }); } - @Override - protected void onResume() { - super.onResume(); - if(!OpenCVLoader.initDebug()){ - Toast.makeText(getApplicationContext(), "There's a problem, yo!", Toast.LENGTH_SHORT); - //OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_4_0, this, baseLoaderCallback); - }else{ - baseLoaderCallback.onManagerConnected(baseLoaderCallback.SUCCESS); - } - } @Override public void onCameraViewStarted(int width, int height) {} @@ -388,5 +394,28 @@ private void saveImage(Bitmap finalBitmap) throws IOException { } } + @Override + protected void onPause(){ + super.onPause(); + modo_QR = false; + botoa_enviado_clicado = false; + botao_enviar.setVisibility(View.VISIBLE); + if(cameraBridgeViewBase != null){ + cameraBridgeViewBase.disableView(); + } + } + + @Override + protected void onResume(){ + super.onResume(); + botao_enviar.setVisibility(View.VISIBLE); + if(!OpenCVLoader.initDebug()){ + Toast.makeText(getApplicationContext(), "There's a problem, yo!", Toast.LENGTH_SHORT); + //OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_4_0, this, baseLoaderCallback); + }else{ + baseLoaderCallback.onManagerConnected(baseLoaderCallback.SUCCESS); + } + } + } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_recept_file.xml b/app/src/main/res/layout/activity_recept_file.xml index 19a236c..9ac925b 100644 --- a/app/src/main/res/layout/activity_recept_file.xml +++ b/app/src/main/res/layout/activity_recept_file.xml @@ -17,24 +17,36 @@ android:layout_width="match_parent" android:layout_height="match_parent"> +