package scorpio.findyourfate.com;

import android.annotation.SuppressLint;
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 card extends AppCompatActivity
{
	 String text;
	 Button back;

	  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);
		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=\"21px\"><b>Scorpio</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();
		}    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/scorpio-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, "Scorpio - Findyourfate.com ");
	 		      	emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi,I would like to suggest, this Libra App to you. \n\n Click this Link to Download app \"http://goo.gl/BvjaNx\"\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 Scorpio 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);
	           }
}