package findyourfate.com.rahuketupeyarchi;

 
import org.w3c.dom.Text;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.DisplayMetrics;
import android.view.Gravity;
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 android.widget.TextView;

public class viewrahu2019 extends Activity {
WebView searhcweb;
Button resback,rasi2;
String rasi;
//TextView otherrasi;
//TextView daily,viewothersigns;
int ssize;int fsize=0;
final Context context = this;
public static final String MyPREFERENCES = "MyPrefs" ;
public static final String name = "fontsize";  
public static SharedPreferences sharedpreferences;
private static Typeface mTypeface;
 @Override
	public void onCreate(Bundle savedInstanceState) {
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
				.detectDiskReads().detectDiskWrites().detectNetwork()
				.penaltyLog().build());
		super.onCreate(savedInstanceState);
		setContentView(R.layout.resultrahu);

		rasi = getIntent().getStringExtra("rasi");
		

			

		//otherrasi = (TextView) findViewById(R.id.otherrasi);
			      rasi2= (Button) findViewById(R.id.rasi1);
		resback = (Button) findViewById(R.id.resultback);

		 DisplayMetrics metrics = new DisplayMetrics(); 
	        Activity activity = (Activity) context;
	        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
	         
	       
	        
	     
	   
	        
	       String userAgent = new WebView(viewrahu2019.this).getSettings().getUserAgentString();
	        if (userAgent.contains("Mobile")) {
	       
    if (metrics.densityDpi <= DisplayMetrics.DENSITY_LOW) {
    	//Toast.makeText(this, "low screen",Toast.LENGTH_LONG).show();
    	ssize=15;
    	 
    } else if (metrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) {
    	  //Toast.makeText(this, "high screen",Toast.LENGTH_LONG).show();
    	
    	ssize=20;
    	 
    }
    else if (metrics.densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
    	 // Toast.makeText(this, "medium screen",Toast.LENGTH_LONG).show();
    	ssize=20;
    	 
    }
    else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XHIGH) {
    	 // Toast.makeText(this, "xLarge screen",Toast.LENGTH_LONG).show();
    	ssize=23;
    	 
    }
    else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XXHIGH) {
    	// Toast.makeText(this, "xxLarge screen",Toast.LENGTH_LONG).show();
    	ssize=23;
    	 
    }
    else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XXXHIGH) {
    	 
    	ssize=25;
    	 
    }
    else {
    	 
    	ssize=17;
    	 
    }
	        }
	        else
	        {
	        	ssize=20;
	        }
	        
    
	        
	          
		         mTypeface = Typeface.createFromAsset(viewrahu2019.this.getAssets(), "arial.ttf"); 
		        // otherrasi .setTextSize(ssize); 
		      //otherrasi .setTypeface(mTypeface,Typeface.BOLD_ITALIC);
				
				//go.setTextSize(fsize);
				//go.setTypeface(mTypeface,Typeface.BOLD_ITALIC);
	 final	TextView  sign = new TextView(this);
	 sign.setGravity(Gravity.CENTER); 
	 

		/* final  ArrayAdapter<CharSequence> dataAdapter1 = ArrayAdapter.createFromResource(this,R.array.sign_array, android.R.layout.simple_spinner_item);
		 dataAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_item);
		 s1.setAdapter(dataAdapter1); 
	      
	     go.setOnClickListener(new OnClickListener()
		 { 
		 public void onClick(View v)
		 {
			// zodiacsign=s1.getSelectedItem().toString();
			 if (zodiacsign.equals("-- Choose Your Sign --"))
			 {
			 alt_bld.setTitle("Alert Message");
			 alt_bld.setMessage("Please Select Your Zodiac Sign ?")
			 .setCancelable(false)
						 .setPositiveButton("OK", new DialogInterface.OnClickListener() {
						 public void onClick(DialogInterface dialog, int id) {
						// s1.requestFocus(); 
						 }
						 });
			 AlertDialog alert = alt_bld.create();
			 alert.setTitle("Alert Message");
			 alert.setIcon(R.drawable.alert);
			 alert.show();
			 } 
			 else
			 {
					if (mInterstitialAd.isLoaded()) {
		 				 mInterstitialAd.show();
		 				mInterstitialAd.setAdListener(new AdListener() {
				            public void onAdClosed() {
				            	 Intent int_ep = new Intent(zodiacsign.this,findsign.class); 
				     				int_ep.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				     				int_ep.putExtra("sign", zodiacsign); 
				     				startActivity(int_ep); 
				               }
				              }); 
		 				 
		 		           }
					 else
					 {
		                	 Intent int_ep = new Intent(zodiacsign.this,findsign.class); 
		     				int_ep.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		     				int_ep.putExtra("sign", zodiacsign); 
		     				startActivity(int_ep);   
			   	    		 
					 } 
		                
				    
			 }  
				 
			 
			 
			   		 
		 } 
		 
		 }); */
	

	 
		 
       
	      
 searhcweb = (WebView) findViewById(R.id.content);  
	        
	        
	        searhcweb.getSettings().setSupportZoom(true);
	        searhcweb.getSettings().setBuiltInZoomControls(true);
	        searhcweb.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
	          
	      //settings.setDefaultFontSize(ssize);
	        searhcweb.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
	        searhcweb.setBackgroundColor(0);
	         if (rasi.equals("Mesha")) {
	 			 
	 			 
	        	 searhcweb.loadUrl("file:///android_asset/mesham19.html");
	 		} else if (rasi.equals("Vrishabha")) {
	 			 
	 			 
	 			searhcweb.loadUrl("file:///android_asset/rishabha19.html");
	 		} else if (rasi.equals("Mithuna")) {
	 			 
	 			searhcweb.loadUrl("file:///android_asset/mithuna19.html");
	 		} else if (rasi.equals("Karkata")) {
	 			 searhcweb.loadUrl("file:///android_asset/kataka19.html");
	 		} else if (rasi.equals("Simha")) {
	 			 searhcweb.loadUrl("file:///android_asset/simha19.html");
	 		} else if (rasi.equals("Kanya")) {
	 			 	searhcweb.loadUrl("file:///android_asset/kanya19.html");
	 		} else if (rasi.equals("Thula")) {
	 			 searhcweb.loadUrl("file:///android_asset/tula19.html");
	 		} else if (rasi.equals("Vrischika")) {
	 			 searhcweb.loadUrl("file:///android_asset/virschika19.html");
	 		} else if (rasi.equals("Dhanushya")) {
	 			 	searhcweb.loadUrl("file:///android_asset/dhanus19.html");
	 		} else if (rasi.equals("Makara")) {
	 			 	searhcweb.loadUrl("file:///android_asset/makara19.html");
	 		} else if (rasi.equals("Kumbha")) {
	 			 	searhcweb.loadUrl("file:///android_asset/kumbha19.html");
	 		} else if (rasi.equals("Meena")) {
	 			 	searhcweb.loadUrl("file:///android_asset/meena19.html");
	 		}
	         	 
		        /* if(alpha.equals("all"))
		         {
		        	 searhcweb.loadUrl("http://stanleyventures.in/colleges/recommandedviews.php?mode=all&year="+restoredText); 
		         }
		         else
		         {
		    searhcweb.loadUrl("http://stanleyventures.in/colleges/recommandedviews.php?mode=all&alpha="+alpha+"&year="+restoredText); 
		         }
	        */

	 
		resback.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				 viewrahu2019.this.finish();

			}
		});
		 
		rasi2.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent int_home = new Intent(viewrahu2019.this, rahu2019.class);
		           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		             startActivity(int_home); 

			}
		});
		/*otherrasi.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent int_home = new Intent(viewpalangal2017.this, palangal2017.class);
		           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		             startActivity(int_home); 

			}
		});*/

		
		 

		 
	}

	  
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main, menu);
		return super.onCreateOptionsMenu(menu);

	}

	 @SuppressLint("NewApi")
		@Override
	    public boolean onOptionsItemSelected(MenuItem item) {
		  if (item.getItemId() ==android.R.id.home) {
	  		  Intent int_home = new Intent(this, home.class);
		           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		             startActivity(int_home); 
	  	  }
		  else if (item.getItemId() ==R.id.icon_rasi) {
	  		  Intent int_home = new Intent(this, home.class);
		           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		             startActivity(int_home); 
	  	  }
		/*  else if (item.getItemId() ==R.id.rahu) {
	  		  Intent int_home = new Intent(this, rahucontent.class);
		           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		             startActivity(int_home); 
	  	  }
		  else if (item.getItemId() ==R.id.rahupalan) {
		  		final ProgressDialog progressDoalog = new ProgressDialog(viewpalangal2017.this);
		  		progressDoalog.setProgressDrawable(viewpalangal2017.this.getResources().getDrawable(R.drawable.progress));  
		     progressDoalog.setMessage("Please Wait....");
		    progressDoalog.setTitle("Loading...");
		    progressDoalog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		    progressDoalog.setCancelable(true); 
		    progressDoalog.show();
		    new Thread() {
		        public void run() {
		            try {
		            	 Intent int_home = new Intent(viewpalangal2017.this, home.class);
		  	           int_home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		  	             startActivity(int_home); 
		   	    		 
			  			 
		            } catch (Exception e) {
		            }
		            progressDoalog.dismiss();
		        }
		    }.start();
		  }*/
	      		else if (item.getItemId() ==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.";	


		/*LinearLayout layout = new LinearLayout(this); 
		TextView tvMessage = new TextView(this);  
		tvMessage.setBackgroundColor(Color.parseColor("#e9b44f")); 
		tvMessage.setText(desc); 
	  tvMessage.setPadding(5, 5, 5, 5);
		tvMessage.setTextSize(17); 
		layout.setOrientation(LinearLayout.VERTICAL);
		layout.addView(tvMessage); 
		alt_compat.setView(layout);  */

					alt_compat.setTitle("Guru Peyarchi");
					alt_compat.setMessage(desc); 
					alt_compat.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();

	  	    	}
	     		else if (item.getItemId() ==R.id.sani) {
	    	  	    
	    	  	    
	  			  AlertDialog.Builder alt_compat = new AlertDialog.Builder(this);
	  			  String desc="App to find out when Sani Peyarchi or Saturn transit takes place.";	
	  			  
	  			  
	  				/*LinearLayout layout = new LinearLayout(this); 
	  				TextView tvMessage = new TextView(this);  
	  				tvMessage.setBackgroundColor(Color.parseColor("#e9b44f")); 
	  				tvMessage.setText(desc); 
	  			    tvMessage.setPadding(5, 5, 5, 5);
	  				tvMessage.setTextSize(17); 
	  				layout.setOrientation(LinearLayout.VERTICAL);
	  				layout.addView(tvMessage); 
	  				alt_compat.setView(layout);  */
	  			  
	  			  				alt_compat.setTitle("Sani Peyarchi");
	  			  				alt_compat.setMessage(desc); 
	  							alt_compat.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.sanipeyarchi"));
	  			  						    	 startActivity(browserIntent);
	  			  						    
	  			  						   
	  			  }
	  			  						    });
	  			  						
	  			  						      
	  			  						         AlertDialog alert = alt_compat.create();   
	  			  						         alert.show();

	  			    	    	}
	  	    	else if (item.getItemId() ==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();
	  	    	}
	  	    	
	  	    	else if (item.getItemId() ==R.id.share) {
	  	    		
		    	Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
		    	emailIntent.setType("text/plain");
	    		emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Rahu-Ketu Peyarchi by findyourfate.com");
	    		emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi,I would like to suggest, this Rahu-Ketu Peyarchi App to you. Click this link to download app http://goo.gl/ypifK6"+"\n\n"+" Regards");
	      startActivity(Intent.createChooser(emailIntent,"Share using")); 
	  	    	}
	  	    	 else {
	  	     	} 
	  	    	return true;
		           
		    
	    }
	     
	 	
	}
		  