package com.ramos.munoz.tesis;

import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;

public class LauncherActivity extends Activity {

    private AccountManager am;
    private SharedPreferences prefs;
    private String user;
    private String usuario;
    private String pass;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.launcher_activity);
	inicializarComponentes();
	if (!verificarLogin()) {
	    Intent login = new Intent(this, LoginActivity.class);
	    startActivity(login);
	}
	finish();
    }

    private void inicializarComponentes() {

    }

    private Boolean verificarLogin() {
	AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
	Account[] list = manager.getAccounts();
	for (Account account : list) {
	    if (account.type.equalsIgnoreCase(Constantes.ACCOUNT_TYPE)) {
		user = account.name;

		Intent intent = new Intent(this, MapaActivity.class);
		startActivity(intent);
		return true;
	    }
	}
	return false;
    }

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