package findyourfate.com.porutham; 
 
  
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle; 
import android.widget.ImageView;  
import android.widget.TextView;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

public class stamil extends Activity {  
	
	ImageView image; 
 	static final Uri APP_URI = Uri.parse("android-app://findyourfate.com.porutham/https/findyourfate.com/indianastro/10porutham.htm");
    static final Uri WEB_URL = Uri.parse("https://www.findyourfate.com/indianastro/10porutham.htm");
    static final Uri EMPTY_WEB_URL = Uri.parse("");
    //private GoogleApiClient mClient;
 
    @Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.APP_INDEX_API).build();
		setContentView(R.layout.tamil_home); 
	  	
		Typeface fontface = Typeface.createFromAsset(getAssets(),
                "fonts/Bamini.ttf");


		ActionBar actionBar = getActionBar(); // or getSupportActionBar() for AppCompatActivity

		if (actionBar != null) {
			// Set the title directly in the ActionBar
			actionBar.setTitle("10 பொருத்தம்");
		}








        	//TextView button4 = (TextView) findViewById(R.id.button4);
		 	//button4.setTypeface(fontface, Typeface.BOLD);
		 	
			 // Other initializations
			TextView button4 = (TextView) findViewById(R.id.button4);
			button4.setTypeface(fontface, Typeface.BOLD);



    // Ensure TamilUtil is correctly implemented
    //String tamilString = TamilUtil.convertToTamil(TamilUtil.BAMINI, getResources().getString(R.string.Text2));
    button4.setText("ஆண் நட்சத்திரம்");
		 	 
		 	//button4.setOnClickListener(v -> startActivity(new Intent(getApplicationContext(), tamilsingle.class))); 
         
		 	button4.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {            
                Intent nextScreen = new Intent(getApplicationContext(), tamilsingle.class);
                startActivity(nextScreen); 
            }
           });
         	
			TextView link = (TextView) findViewById(R.id.link);  
				link.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {
            	Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
                myWebLink.setData(Uri.parse("https://www.findyourfate.com/")); 
                startActivity(myWebLink); 
            }
           });           
        	TextView button3 = (TextView) findViewById(R.id.button3); 
        	button3.setTypeface(fontface, Typeface.BOLD);
        	 //String tamilString1 = TamilUtil.convertToTamil(TamilUtil.BAMINI, (getResources().getString(
	                    //R.string.Text1)));
		 	 button3.setText("ஆண் மற்றும் பெண் நட்சத்திரம்");
		 	 
         		button3.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {
                Intent nextScreen = new Intent(getApplicationContext(), MainActivityTamil.class);
             startActivity(nextScreen); 
            }
            });       
        	TextView butont2 = (TextView) findViewById(R.id.button2);      
			butont2.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {
                Intent nextScreen = new Intent(getApplicationContext(), MainActivityTamil.class);
                startActivity(nextScreen); 
            }
            });           
			TextView button1 = (TextView) findViewById(R.id.button1);
             button1.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {          
                Intent nextScreen = new Intent(getApplicationContext(), tamilsingle.class); 
                startActivity(nextScreen); 
            }
            });       
         	TextView button5 = (TextView) findViewById(R.id.button5); 
         	button5.setTypeface(fontface, Typeface.BOLD);
         	
         	 //String tamilString2 = TamilUtil.convertToTamil(TamilUtil.BAMINI, (getResources().getString(
	                    //R.string.Text4)));
		 	 button5.setText("பொருத்தம்");
		 	 
            button5.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {          
                Intent nextScreen = new Intent(getApplicationContext(), tamilcontent.class);
                startActivity(nextScreen); 
            }
            });
             
            TextView buttonn = (TextView) findViewById(R.id.buttonn); 
            buttonn.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {          
                Intent nextScreen = new Intent(getApplicationContext(), tamilcontent.class);
                startActivity(nextScreen); 
            }
            });
            TextView eng = (TextView) findViewById(R.id.english); 
            eng.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View arg0) {          
                Intent nextScreen = new Intent(getApplicationContext(), index.class);
                startActivity(nextScreen); 
            }
            });
         	} 
	
	@Override
	public void onStart() {
	    super.onStart();
	   // mClient.connect();
	    final String title = "10 Porutham";
        //AppIndex.AppIndexApi.view(mClient, this, APP_URI, title, WEB_URL, null);
 	}

	@Override
	public void onStop() {
	    super.onStop();
	   // AppIndex.AppIndexApi.viewEnd(mClient, this, APP_URI);
	   // mClient.disconnect();
 	}
	 @Override
     public void onBackPressed() {
         AlertDialog.Builder builder = new AlertDialog.Builder(this);
         builder.setMessage("Are you sure you want to leave this App.")
                .setCancelable(false)
                .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.setIcon(R.drawable.alert);
         alert.show();
    }  
	 public boolean onCreateOptionsMenu(Menu menu) {
		 MenuInflater menuInflater = getMenuInflater();
         menuInflater.inflate(R.menu.activity_main, menu);
        MenuItem item = menu.findItem(R.id.cfont); 
    	item.setVisible(false);
        return true;
    }
	public boolean onOptionsItemSelected(MenuItem item) {
		int itemId = item.getItemId();

		if (itemId == android.R.id.home) {
			Intent int_abt = new Intent(this, index.class);
			int_abt.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(int_abt);
			return true;
		}
		else if (itemId == R.id.claculator) {
			Intent icon_calc = new Intent(this, poruthamcalculator.class);
			icon_calc.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(icon_calc);
			return true;
		}
		else if (itemId == R.id.Nakshatra) {
			Intent icon_find = new Intent(this, findnakshatra.class);
			icon_find.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(icon_find);
			return true;
		}
		else if (itemId == R.id.guru) {
			AlertDialog.Builder alt_compat = new AlertDialog.Builder(this);
			String desc = "App to find out when Guru Peyarchi or Jupiter transit takes place.";
			alt_compat.setTitle("Guru Peyarchi");
			alt_compat.setMessage(desc)
					.setCancelable(false)
					.setPositiveButton("Later", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.cancel();
						}
					})
					.setNegativeButton("Never/Already", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.cancel();
						}
					})
					.setNeutralButton("Open", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							Intent browserIntent = new Intent(Intent.ACTION_VIEW,
									Uri.parse("market://details?id=findyourfate.com.gurupeyarchi"));
							startActivity(browserIntent);
						}
					});
			AlertDialog alert = alt_compat.create();
			alert.show();
			return true;
		}
		else if (itemId == R.id.icon_exit) {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Are you sure you want to leave this App.")
					.setCancelable(false)
					.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 alert1 = builder.create();
			alert1.setTitle("Close App.");
			alert1.setIcon(R.drawable.alert);
			alert1.show();
			return true;
		}
		else if (itemId == R.id.share) {
			Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
			emailIntent.setType("text/plain");
			emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "10 Porutham by findyourfate.com");
			emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
					"Hi, I would like to suggest this 10 Porutham App to you. Click this link to download the app http://goo.gl/38FZui"
							+ "\n\n" + " Regards");
			startActivity(Intent.createChooser(emailIntent, "Share using"));
			return true;
		}
		else {
			return super.onOptionsItemSelected(item);
		}
	}

}