package cancer.findyourfate.com;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
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;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class signtraits extends AppCompatActivity {
	WebView web;
	int fsize=0;
	Button back;

	 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.signtraits);
            
            String userAgent = new WebView(signtraits.this).getSettings().getUserAgentString();
		     if (userAgent.contains("Mobile")) {
			fsize=15;
			} 
			else 
			{
	  		fsize=18;
			}





		ActionBar actionBar = getSupportActionBar();
		if (actionBar != null) {
			// Enable the home button and set display options
			actionBar.setDisplayHomeAsUpEnabled(true);
			actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);

			// Set the title of the ActionBar
			actionBar.setTitle(Html.fromHtml("<font color=\"#ffffff\" size=\"25px\"><b>"+"Cancer"+"</b></font>"));


			// Enable the home button for backward compatibility
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
				actionBar.setHomeButtonEnabled(true);
			}

			// Show the ActionBar
			actionBar.show();
		}
            back=(Button) findViewById(R.id.back);
            
            web=(WebView) findViewById(R.id.web);
            WebSettings webSettings = web.getSettings(); 
			webSettings.setDefaultFontSize(fsize);
		    webSettings.setBuiltInZoomControls(true);
		    
		     web.setBackgroundColor(0);
		     web.loadUrl("file:///android_asset/cancer.html"); 
		    	  
		    	  back.setOnClickListener(new View.OnClickListener() {
	    			   
						String open="list";
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
					 	signtraits.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(signtraits.this,signtraits.class);
              	 startActivity(in);
               	  return true;
               }
            if (id == R.id.card) {
           	 Intent in=new Intent(signtraits.this,card.class);
           	 startActivity(in);
            	  return true;
            }
            else  if(id==R.id.share)
            {
            	Intent emailIntent = new Intent(Intent.ACTION_SEND);
  		    	emailIntent.setType("text/plain");
  		    	emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Cancer - Findyourfate.com ");
  		      	emailIntent.putExtra(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);
           }

	  
}
