package com.example.distmeasapp;

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

public class Help extends Activity {

	private static final int M_CAMERA = 0;
	private static final int M_SHORTMEAS = 1;
	private static final int M_LONGMEAS = 2;
	private static final int M_HELP = 3;
	private static final int M_EXIT = 4;
	int key[] = {0,0,0,0};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help);

    	final Transparent popup1;
    	popup1 = (Transparent) findViewById(R.id.popup_window1);
    	popup1.setVisibility(View.GONE);
        final Transparent popup2 = (Transparent) findViewById(R.id.popup_window2);
    	popup2.setVisibility(View.GONE);
        final Transparent popup3 = (Transparent) findViewById(R.id.popup_window3);
    	popup3.setVisibility(View.GONE);
        final Transparent popup4 = (Transparent) findViewById(R.id.popup_window4);
    	popup4.setVisibility(View.GONE);
 
    	final Button btn1=(Button)findViewById(R.id.handle1);
    	btn1.setOnClickListener(new View.OnClickListener() {
 
		@Override
		public void onClick(View arg0) {
			if(key[3]==0){key[3]=1; popup1.setVisibility(View.VISIBLE);}
			else if(key[3]==1){key[3]=0; popup1.setVisibility(View.GONE);}
		}});

    	final Button btn2=(Button)findViewById(R.id.handle2);
    	btn2.setOnClickListener(new View.OnClickListener() {
 
		@Override
		public void onClick(View arg0) {
			if(key[1]==0){key[1]=1; popup2.setVisibility(View.VISIBLE);}
			else if(key[1]==1){key[1]=0; popup2.setVisibility(View.GONE);}
		}});

    	final Button btn3=(Button)findViewById(R.id.handle3);
    	btn3.setOnClickListener(new View.OnClickListener() {
 
		@Override
		public void onClick(View arg0) {
			if(key[2]==0){key[2]=1; popup3.setVisibility(View.VISIBLE);}
			else if(key[2]==1){key[2]=0; popup3.setVisibility(View.GONE);}
		}});

    	final Button btn4=(Button)findViewById(R.id.handle4);
    	btn4.setOnClickListener(new View.OnClickListener() {
 
		@Override
		public void onClick(View arg0) {
			if(key[3]==0){key[3]=1; popup4.setVisibility(View.VISIBLE);}
			else if(key[3]==1){key[3]=0; popup4.setVisibility(View.GONE);}
		}});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.add(0, M_CAMERA,0, R.string.menu0);
		menu.add(0, M_SHORTMEAS,0, R.string.menu1);
		menu.add(0, M_LONGMEAS,0, R.string.menu2);
		menu.add(0, M_HELP,0, R.string.menu3);
		menu.add(0, M_EXIT,0, R.string.menu4);
		return true;
	}

	@Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
    	switch(item.getItemId()) {
        case M_CAMERA:
        	startActivity(new Intent(this, CameraMeas.class));
        	return true;
        case M_SHORTMEAS:
        	startActivity(new Intent(this, ShortMeas.class));
        	return true;
        case M_LONGMEAS:
        	startActivity(new Intent(this, LongMeas.class));
        	return true;
        case M_HELP:
        	startActivity(new Intent(this, Help.class));
        	return true;
        case M_EXIT:
        	finish();
        	return true;
        default:
            return super.onOptionsItemSelected(item);
	    }
    }
}
