package com.example.carolina.times;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


// Carolina Souto
// Copyright (C) 2016 

//    This program is free software: you can redistribute it //    and/or modify it under the terms of the GNU General //Public License as published by
//    the Free Software Foundation, either version 3 of the //License, or
//    (at your option) any later version.

//   This program is distributed in the hope that it will be //useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  //See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General //Public License
//    along with this program.  If not, see //<http://www.gnu.org/licenses/>.

public class MainActivity extends ActionBarActivity {

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

        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setIcon(R.mipmap.ic_launcher);
    }

    public void Launch(View view){ //INICIAR MAIN ACTIVITY2
        Intent in  = new Intent(this, MainActivity2.class);
        startActivity(in);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }



    @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.autor) {
            String msn = "Nombre:\nCarolina Souto Venturini\nE-Mail:\ncarsouto@yahoo.com";
            MensajeEmergente("Autor.",msn, "OK");
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void MensajeEmergente(String titulo, String mensaje, String boton)
    {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle(titulo);
        alertDialog.setMessage(mensaje);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, boton,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }
}
