Commit afbcaf42 authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Clean up code a bit

parent 8496354f
......@@ -66,8 +66,6 @@ public class MainActivity extends AppCompatActivity {
});
Log.d("Debug2", "App launched");
m_gga = GoogleApiAvailability.getInstance();
int status = m_gga.isGooglePlayServicesAvailable(getApplicationContext());
if(status != ConnectionResult.SUCCESS) {
......@@ -78,8 +76,6 @@ public class MainActivity extends AppCompatActivity {
initializeListeners();
}
// From QRLudo
private void initializeListeners() {
......@@ -186,14 +182,10 @@ public class MainActivity extends AppCompatActivity {
public boolean DemoQR()
{
Log.d("Debug2", "Demo QR launch");
// The demo QR can cause a leaked memory warning. This may be fixed by binding a service to the photo activity.
requestPhotoPermission();
Log.d("Debug2", "Photo permission requested");
Intent PhotoIntent = new Intent( this, QRCaptureActivity.class);
Log.d("Debug2", "Photo intent created");
//startActivity(PhotoIntent);
startActivityForResult(PhotoIntent, 1);
Log.d("Debug2", "Photo activity launched");
return true;
}
......@@ -211,8 +203,6 @@ public class MainActivity extends AppCompatActivity {
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
}
private void requestRecordAudioPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String requiredPermission = Manifest.permission.RECORD_AUDIO;
......
......@@ -10,15 +10,10 @@ import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.example.qrquest.QR.handling.QRCodeBuilder;
import com.example.qrquest.QR.model.QRCode;
import com.example.qrquest.exceptions.UnhandledQRException;
import com.example.qrquest.exceptions.UnsupportedQRException;
import com.google.android.gms.vision.CameraSource;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.barcode.Barcode;
......@@ -41,7 +36,6 @@ public class QRCaptureActivity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("Debug2", "Creating QRCapture Activity");
setContentView(R.layout.photo_activity);
// Toolbar toolbar = findViewById(R.id.toolbar);
//setSupportActionBar(toolbar);
......@@ -49,7 +43,6 @@ public class QRCaptureActivity extends MainActivity {
setUpDetector();
startDetection();
Log.d("Debug2", "End of QRCapture activity creation");
}
@Override
......@@ -70,16 +63,6 @@ public class QRCaptureActivity extends MainActivity {
});
}
public void SetQRContent(String qr_result) // to display listening results
{
//end detection
m_cameraView.setVisibility(View.INVISIBLE);
Log.d("Debug", "QR content (from main activity): " + qr_result);
Toast.makeText(getApplicationContext(), qr_result, Toast.LENGTH_LONG).show();
}
private void initializeAttributes() {
m_cameraView = (SurfaceView) findViewById(R.id.camera_view);
m_cameraView.setVisibility(View.INVISIBLE);
......@@ -91,10 +74,6 @@ public class QRCaptureActivity extends MainActivity {
}
private void setUpDetector() {
/*
The barcode detector
*/
BarcodeDetector detector = new BarcodeDetector.Builder(getApplicationContext())
.setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE)
.build();
......@@ -106,7 +85,7 @@ public class QRCaptureActivity extends MainActivity {
m_cameraSource = new CameraSource
.Builder(this, detector)
.setRequestedPreviewSize(640, 480)
.setRequestedPreviewSize(720, 480) //640/480 old
.setAutoFocusEnabled(true)
.build();
......@@ -163,7 +142,7 @@ public class QRCaptureActivity extends MainActivity {
}
/**
* Method called when QRCodes have been detected by the camera
* Method automatically called when QRCodes have been detected by the camera
* @param detections
*/
@Override
......@@ -179,7 +158,8 @@ public class QRCaptureActivity extends MainActivity {
String rawValue = barcodes.valueAt(0).rawValue;
Log.d("Debug", "QR code raw value : " + rawValue);
stopDetection(rawValue);
//ignoring if the QRCode has already been recorded or ignored
//ignoring if the QRCode has already been recorded or ignored (from QRLudo, may be useful later)
/*
try {
QRCode detectedQR = QRCodeBuilder.build(rawValue);
// SetQRContent(rawValue);
......@@ -189,12 +169,11 @@ public class QRCaptureActivity extends MainActivity {
Log.d("Debug", "QR code non pris en charge");
} catch (UnsupportedQRException e) {
Log.d("Debug", "QR code non pris en charge");
}
}*/
}
}
};
detector.setProcessor(detector_processor);
}
......@@ -208,17 +187,13 @@ public class QRCaptureActivity extends MainActivity {
final AppCompatActivity activity = this;
activity.runOnUiThread(new Runnable() {
public void run() {
if(true/*m_ttsready*/) {
m_cameraView.setVisibility(View.INVISIBLE);
}else{
cameraState = CAMERA_INACTIVE_STATE;
}
m_cameraView.setVisibility(View.INVISIBLE);
}
});
Intent returnIntent= new Intent();
returnIntent.putExtra("QR_CONTENT",QRContent);
setResult(RESULT_OK, returnIntent);//Terminel'activité
setResult(RESULT_OK, returnIntent);
finish();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment