import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import cz.cvut.fel.dce.qrscanner.integration.IntentIntegrator;
import cz.cvut.fel.dce.qrscanner.integration.IntentResult;
-
+/**
+ * An {@link android.app.Activity} showing an immersive card with a Skoda Auto logo, waiting for
+ * user to tap the screen to start the QR code scanning.
+ */
public class MainActivity extends ActionBarActivity {
+ /**
+ * An activity tag for debug, error and info messages.
+ */
public static final String TAG = "MainActivity";
@Override
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
- //noinspection SimplifiableIfStatement
if (id == R.id.start_scan) {
startScan();
}
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
Log.i(TAG, scanResult.toString());
+ Intent preview = new Intent(this, PreviewActivity.class);
+ preview.putExtra(PreviewActivity.COMP_ID_INTENT_KEY, scanResult.getContents());
+ startActivity(preview);
}
- // else continue with any other code you need in the method
-
}
+ /**
+ * Start the scan code activity
+ */
private void startScan() {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES);
}
+
+ /** Called when the user touches the screen */
+ public void findComponent(View view) {
+ startScan();
+ }
}