package gemini.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 androidx.appcompat.app.ActionBar;
import androidx.appcompat.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;
	 WebView contents;

	 int fsize=0;
	 
	@SuppressLint("SetJavaScriptEnabled")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.card);



		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>"+"Gemini"+"</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);
        back=(Button) findViewById(R.id.back1);
        
	   WebSettings webSettings = contents.getSettings(); 
	   webSettings.setDefaultFontSize(fsize);
	   webSettings.setBuiltInZoomControls(true);
	   contents.setClickable(true);
       contents.setFocusableInTouchMode(true); 
       contents.setBackgroundColor(0);
       contents.loadUrl("file:///android_asset/geminicard.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.card) {
           	 Intent in=new Intent(card.this,card.class);
           	 startActivity(in);
            	  return true;
            }
            else if (id == R.id.character) {
            	 Intent in=new Intent(card.this,signtraits.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, "Gemini - Findyourfate.com ");
 		      	emailIntent.putExtra(Intent.EXTRA_TEXT, "Hi,I would like to suggest, this Gemini App to you. \n\n Click this Link to Download app \" http://goo.gl/83xLVo \"\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 Gemini 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);
           }
      
     }
 	
    
 