package virgo.findyourfate.com;

import com.google.android.gms.ads.AdRequest;

import com.google.android.gms.ads.AdView;

import android.annotation.SuppressLint;
import android.app.Activity; 
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle; 
import android.text.Html;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; 
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;

public class card extends Activity
{
	 String text;
	 Button back;
	 private AdView mAdview;
	 WebView contents;
	 int fsize=0;
	 
	 	@SuppressLint("SetJavaScriptEnabled")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
      
        setContentView(R.layout.card);
      	back=(Button) findViewById(R.id.back);
      	getActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\" size=\"25px\"><b>"+"Virgo"+"</b></font>"));
        String userAgent = new WebView(card.this).getSettings().getUserAgentString();
        
        if (userAgent.contains("Mobile")) {
    	fsize=15;
    	} 
    	else 
    	{
    		fsize=18;
    	}
         mAdview = (AdView) findViewById(R.id.adView);
    	mAdview.setAdListener(new ToastAdListener(this));
    	mAdview.loadAd(new AdRequest.Builder().build()); 
      contents=(WebView) findViewById(R.id.cards);
      WebSettings webSettings = contents.getSettings(); 
 	  webSettings.setDefaultFontSize(fsize);
	  webSettings.setBuiltInZoomControls(true);
	 contents.setClickable(true);
     contents.setFocusableInTouchMode(true); 
     contents.setBackgroundColor(0);
     contents.loadUrl("file:///android_asset/virgo-card.html"); 
     
       
     
    back.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			card.this.finish();
			 overridePendingTransition(R.anim.left_out, R.anim.right_in);
		}
	});
	}
	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
 		    MenuInflater inflater = getMenuInflater();
		    inflater.inflate(R.menu.mainone, menu);
		    return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
           // toggle nav drawer on selecting action bar app icon/title
            int id = item.getItemId();
            if (id == R.id.character) {
              	 Intent in=new Intent(card.this,signtraits.class);
              	 startActivity(in);
               	  return true;
               }
            if (id == R.id.card) {
           	 Intent in=new Intent(card.this,card.class);
           	 startActivity(in);
            	  return true;
            }
            else  if(id==R.id.share)
            {
          	Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
 		    	emailIntent.setType("text/plain");
 		    	emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Virgo - Findyourfate.com ");
 		      	emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi,I would like to suggest, this Virgo App to you. \n\n Click this Link to Download app \"http://goo.gl/0tIwFJ\"\n\n Regards");
 		    	startActivity(emailIntent);  
            }
            else if(id==R.id.exit)
            {
          	  AlertDialog.Builder builder = new AlertDialog.Builder(this);
 	   				builder.setTitle("Exit!");
 	   		 	    builder.setMessage("Are you sure want to exit from Virgo Apps?")
 	   			     .setCancelable(false)
 	   			     .setIcon(R.drawable.alert)
 	   			       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
 	   			          public void onClick(DialogInterface dialog, int id) {
 	   			            Intent intent = new Intent(Intent.ACTION_MAIN);
 	   			   		    intent.addCategory(Intent.CATEGORY_HOME);
 	   			   		    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 	   			   		    startActivity(intent);
 	   			              }
 	   			          })
 	   			          .setNegativeButton("No", new DialogInterface.OnClickListener() {
 	   			              public void onClick(DialogInterface dialog, int id) {
 	   			                 dialog.cancel();
 	   			               }
 	   			           });
 	   			    AlertDialog alert = builder.create();
 	   			    alert.show();
             }
           else
           {
         	  
           }
           return super.onOptionsItemSelected(item);
           }
	 
 
}