package cancer.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.support.v7.app.AppCompatActivity;
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 AppCompatActivity
{
	  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);
             
        mAdview = (AdView) findViewById(R.id.adView);
     	mAdview.setAdListener(new ToastAdListener(this));
     	mAdview.loadAd(new AdRequest.Builder().build()); 
  
     	back=(Button) findViewById(R.id.back1);
        getSupportActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\" size=\"25px\"><b>"+"Cancer"+"</b></font>"));
	 
    String userAgent = new WebView(card.this).getSettings().getUserAgentString();
        
        if (userAgent.contains("Mobile")) {
    	fsize=15;
    	} 
    	else 
    	{
    		fsize=18;
    	}
       
          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/cancer-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);
		 // animation = (AnimationView) menu.findItem(R.id.character);
		    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, "Cancer - Findyourfate.com ");
  		      	emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi,I would like to suggest, this Cancer App to you. \n\n Click this Link to Download app \"http://goo.gl/3ky0O6\"\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 Cancer 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);
           }

 
}