1 package cz.cvut.fel.dce.qrscanner;
3 import android.content.Intent;
4 import android.support.v7.app.ActionBarActivity;
5 import android.os.Bundle;
6 import android.util.Log;
7 import android.view.Menu;
8 import android.view.MenuItem;
9 import android.view.View;
11 import cz.cvut.fel.dce.qrscanner.integration.IntentIntegrator;
12 import cz.cvut.fel.dce.qrscanner.integration.IntentResult;
15 * An {@link android.app.Activity} showing an immersive card with a Skoda Auto logo, waiting for
16 * user to tap the screen to start the QR code scanning.
18 public class MainActivity extends ActionBarActivity {
20 * An activity tag for debug, error and info messages.
22 public static final String TAG = "MainActivity";
25 protected void onCreate(Bundle savedInstanceState) {
26 super.onCreate(savedInstanceState);
27 setContentView(R.layout.activity_main);
32 public boolean onCreateOptionsMenu(Menu menu) {
33 // Inflate the menu; this adds items to the action bar if it is present.
34 getMenuInflater().inflate(R.menu.menu_main, menu);
39 public boolean onOptionsItemSelected(MenuItem item) {
40 int id = item.getItemId();
42 if (id == R.id.start_scan) {
46 return super.onOptionsItemSelected(item);
49 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
50 IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
51 if (scanResult != null) {
52 Log.i(TAG, scanResult.toString());
53 Intent preview = new Intent(this, PreviewActivity.class);
54 preview.putExtra(PreviewActivity.COMP_ID_INTENT_KEY, scanResult.getContents());
55 startActivity(preview);
60 * Start the scan code activity
62 private void startScan() {
63 IntentIntegrator integrator = new IntentIntegrator(this);
64 integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES);
67 /** Called when the user touches the screen */
68 public void findComponent(View view) {