package com.example.patrice.mysql01;

import android.app.Dialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import android.view.View.OnClickListener;

// https://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

public class MainActivity extends AppCompatActivity
{
    Button btnViewProducts;
    Button btnNewProduct;
    Button btnScanBarcode;
    Button btnGenerateBarcode;
    Button btnSSH;
    Button btnCamera;
    Button btnCamera02;
    Button btnCamera03;
    Button btnCamera04;
    Button btn_camera_recorder01;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnViewProducts = (Button) findViewById(R.id.btnViewProducts);
        btnNewProduct = (Button) findViewById(R.id.btnCreateProduct);
        btnScanBarcode = (Button) findViewById(R.id.btnScanBarcode);
        btnGenerateBarcode = (Button) findViewById(R.id.btnGenerateBarcode);
        btnSSH = (Button) findViewById(R.id.btnSSH);
        btnCamera = (Button) findViewById(R.id.btnCamera);
        btnCamera02 = (Button) findViewById(R.id.btnCamera02);
        btnCamera03 = (Button) findViewById(R.id.btnCamera03);
        btnCamera04 = (Button) findViewById(R.id.btnCamera04);
        btn_camera_recorder01 = (Button) findViewById(R.id.btn_camera_recorder01);

        btnViewProducts.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), AllProductsActivity.class);
                startActivity(i);
            }
        });

        btnNewProduct.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), NewProductActivity.class);
                startActivity(i);
            }
        });

        btnScanBarcode.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), ScanBarcodeActivity.class);
                startActivity(i);
            }
        });

        btnGenerateBarcode.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), GenerateBarcodeActivity.class);
                startActivity(i);
            }
        });

        btnSSH.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), SSH01.class);
                startActivity(i);
            }
        });

        btnCamera.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), camera_preview.class);
                startActivity(i);
            }
        });

        btnCamera02.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), camera_preview02.class);
                startActivity(i);
            }
        });

        btnCamera03.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), camera_preview03.class);
                startActivity(i);
            }
        });

        btnCamera04.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent i = new Intent(getApplicationContext(), camera_preview04.class);
                startActivity(i);
            }
        });

        btn_camera_recorder01.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                //Intent i = new Intent(getApplicationContext(), camera_recorder01.class);
                //Intent i = new Intent(getApplicationContext(), camera_recorder02.class);
                Intent i = new Intent(getApplicationContext(), OCR01.class);

                startActivity(i);
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        switch(item.getItemId())
        {
            case R.id.action_settings:
                //add the function to perform here
                return(true);
            case R.id.action_save:
                //add the function to perform here
                return(true);
            case R.id.action_delete:
                //add the function to perform here
                return(true);
            case R.id.action_bidule:
                //add the function to perform here
                return(true);

            case R.id.action_about:
                about();
                return true;


        }

        return(super.onOptionsItemSelected(item));
    }


    public void about()
    {

        //http://androidexample.com/Custom_Dialog_-_Android_Example/index.php?view=article_discription&aid=88

        final Dialog dialog = new Dialog(MainActivity.this);
        dialog.setContentView(R.layout.about_layout);
        dialog.setTitle("About:");
        dialog.show();


        Button dialogCloseButton = (Button) dialog.findViewById(R.id.close_button);
        dialogCloseButton.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                dialog.dismiss();
            }
        });

    }

}




/*****************************/
/*
<menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

<item
        android:id="@+id/action_save"
                android:icon="@android:drawable/ic_menu_save"
                android:title="@string/action_save"
                app:showAsAction="ifRoom" />

<item
        android:id="@+id/action_delete"
                android:icon="@android:drawable/ic_menu_delete"
                android:title="@string/action_delete"
                app:showAsAction="ifRoom" />

<item
        android:id="@+id/action_settings"
                android:title="@string/action_settings"
                app:showAsAction="never" />

</menu>
*/
/*********************************/