package sunsigns2014.findyourfate.com;

import android.annotation.SuppressLint;


import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.Html;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;
import sunsigns2014.findyourfate.com.zodiacenglish2020.MyAdapter;


public class zodiacjapanese2020 extends Activity{
	final Context context = this;
	int ssize=0; 
	 String sign=null,fsign;
	String year="2015";
  
    String lang="Japanese";
 	TextView daily,topview; 

 	
 	
	  String[] Languages = { "言語を選択し", "2020 in English", "2020 in French", "2020 in Spanish", "2020 in Hindi","2020 in Dutch", "2020 in Arabic", "2020 in Malay", 
			  "2020 in German","2020 in Chinese","2020 in Japanese","2020 in Russian","2020 in Portuguese"};
 		 
	Integer[] images = { 0, R.drawable.us, R.drawable.france,R.drawable.spanish, R.drawable.india, R.drawable.dutch, R.drawable.arabia, R.drawable.malay, R.drawable.germany, R.drawable.china, R.drawable.japanse, R.drawable.russia, R.drawable.port};
	

 	
	@SuppressLint("NewApi") 
	@Override
	protected void onCreate(Bundle savedInstanceState) { 
		 StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() .penaltyLog().build()); 
		  super.onCreate(savedInstanceState);
		  setContentView(R.layout.adlayout);
		  
		   topview=(TextView) findViewById(R.id.daily);

		 	   
		   DisplayMetrics metrics = new DisplayMetrics(); 
	        Activity activity = (Activity) context;
	        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
	        
	 	 String userAgent = new WebView(zodiacjapanese2020.this).getSettings().getUserAgentString();
		  
	        if (userAgent.contains("Mobile")) {
	 	       
     if (metrics.densityDpi <= DisplayMetrics.DENSITY_LOW) {
     	//Toast.makeText(this, "low screen",Toast.LENGTH_LONG).show();
     	ssize=13;
     	 
     } else if (metrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) {
     	// Toast.makeText(this, "high screen",Toast.LENGTH_LONG).show();
     	ssize=14;
     	 
     }
     else if (metrics.densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
     	// Toast.makeText(this, "medium screen",Toast.LENGTH_LONG).show();
     	ssize=13;
     	 
     }
     else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XHIGH) {
     	 //Toast.makeText(this, "xLarge screen",Toast.LENGTH_LONG).show();
     	ssize=15;
     	 
     }
     else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XXHIGH) {
     	// Toast.makeText(this, "xxLarge screen",Toast.LENGTH_LONG).show();
     	ssize=18;
     	 
     }
     else if (metrics.densityDpi <= DisplayMetrics.DENSITY_XXXHIGH) {
     	 
     	ssize=21;
     	 
     }
     else {
     	 
     	ssize=14;
     	 
     }
	        }
	        else
	        {
	        	ssize=16;
	        }

	        
			
		   getActionBar().setDisplayHomeAsUpEnabled(true);
	    	   
	    	LinearLayout layouts = (LinearLayout) findViewById(R.id.layout);
	    	
		final ScrollView home_scroll = new ScrollView(this); 
		 home_scroll.setBackgroundColor(Color.BLACK);  
		 final LinearLayout layout=new  LinearLayout(this);
		 layout.setOrientation(LinearLayout.VERTICAL);
		 layout.setGravity(Gravity.TOP);
		 layout.setBackgroundColor(Color.WHITE);
		 final WebView content=new WebView(this);
		 
		 WebSettings webSettings = content.getSettings();
		 
		  webSettings.setDefaultFontSize(ssize); 
	
		  
		  daily = new TextView(this);
		 daily.setGravity(Gravity.CENTER);
		 
		 if(lang.equals("Japanese"))
			{
				topview.setText("毎日の星占い");
			}
				 
			 String sign =getIntent().getStringExtra("key");
	 	  if(sign.equals("白羊座"))
			 {
			 fsign="Aries";
			 content.loadUrl("file:///android_asset/aries-j.html");
		     		layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
			    }  
	 	  
	  	 else if(sign.equals("牡牛座"))
	 		 {
	 	 		 fsign="Taurus";
	 	 		 content.loadUrl("file:///android_asset/taurus-j.html"); 
	 	 		 layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
	 		 }
	  	 else if(sign.equals("双子"))
	 	 {
	 		 fsign="Gemini";
	 		 content.loadUrl("file:///android_asset/gemini-j.html");
    		layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
	 	 }
	 	  
	 	 else if(sign.equals("癌症"))
	 	 {
	 		 fsign="Cancer";
	 		content.loadUrl("file:///android_asset/cancer-j.html");
    		 
    		layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
	 	 }
	 	 else if(sign.equals("狮子座"))
	 	 {
	 		fsign="Leo";
	 		content.loadUrl("file:///android_asset/leo-j.html");
    		 
		layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
	 	 }
	 	  
	 	 	else if(sign.equals("乙女座"))
 			{
	 		    fsign="Virgo";
	 		   content.loadUrl("file:///android_asset/virgo-j.html");
			layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
 		    	}
	 		 else if(sign.equals("天秤座")) 
		 	 {
		 		 fsign="Libra";
		 		content.loadUrl("file:///android_asset/libra-j.html");
		 		 layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
		 	 }
	 	 	 else if(sign.equals("蠍座"))
		 	 {
		 		 fsign="Scorpio";
		 		content.loadUrl("file:///android_asset/scorp-j.html");
    		layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
		 	 }
	 		 else if(sign.equals("射手座"))
		 	 {
		 		 fsign="Sagittarius";
		 		content.loadUrl("file:///android_asset/sag-j.html");
		layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
		 	     }
	 	  
	 		 else if(sign.equals("山羊座"))
		 	 {
		 		 fsign="Capricorn";
		 		content.loadUrl("file:///android_asset/cap-j.html");
    		   layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
		 	 }
			 else if(sign.equals("アクエリアス"))
		 	 {
		 		 fsign="Aquarius";
		 		content.loadUrl("file:///android_asset/aquar-j.html");
		        layout.addView(content);
		    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
				    layout.addView(daily);
		 	 }
	  	 	 else if(sign.equals("魚座"))
		 	 {
		 		 fsign="Pisces";
		 		content.loadUrl("file:///android_asset/pisces-j.html");
     	    	layout.addView(content);
	    		daily.setText(Html.fromHtml("<p><b><u>"+"<font color=\"#f72901\" size=\""+3+"\" face=\"ms sans serif, verdana\">"+" 表示毎日の星占い"+"</font></u></b></p><br><br><br><br>"));
			    layout.addView(daily);
	 	  	 }  
	 	  
	      
	   daily.setOnClickListener(new View.OnClickListener() {
	 		@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent in=new Intent(zodiacjapanese2020.this,daily.class);
				in.putExtra("language", lang);
				startActivity(in);
 			}
		});
	   
	    topview.setPaintFlags(topview.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
		topview.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent in=new Intent(zodiacjapanese2020.this,daily.class);
					in.putExtra("language", lang);
					startActivity(in);
					
				}
			});
			   
		
	 	      home_scroll.addView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        // setContentView(layout);
	      layouts.removeAllViews();
		  layouts.addView(home_scroll);
         
         boolean hasActionBar = android.os.Build.VERSION.SDK_INT >= 11;

         if (hasActionBar) {
             ActionBar actionBar = getActionBar();
             actionBar.setDisplayHomeAsUpEnabled(true);
             actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME
            	        | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
             getActionBar().setTitle(sign+" 2020  年占い");   
             actionBar.show();
             
         } else {
             
         }
			
			};
			
		 
			@Override
			 public boolean onCreateOptionsMenu(Menu menu) {
				 MenuInflater inflater = getMenuInflater();
	     		    inflater.inflate(R.menu.custommenu, menu);
	     		    RelativeLayout layout = (RelativeLayout) menu.findItem(R.id.layout_item).getActionView();
	     		    View v = getLayoutInflater().inflate(R.layout.ab_bottom_layout, null);
	     		    
	     		    final Spinner sp = (Spinner) v.findViewById(R.id.bottomspinner);	 
	     	 	    
	     		     sp.setAdapter(new MyAdapter( zodiacjapanese2020.this, R.layout.spinnernew,
	     		    		Languages));
	     		   		 	  
	     		 	       final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
	     		 	        sp.setOnItemSelectedListener(new OnItemSelectedListener() {
	     		 	    	   public void onClick(View v) {
	     		 	    	    // TODO Auto-generated method stub
	     		 	    	   } 
	     		 	    	   @Override
	     		 	    	    public void onItemSelected(AdapterView<?> arg0, View view,
	     		 	    	            int position, long row_id) {
	     		 	    		   
	     		 	    	         switch(position){
	     		 	    	       
	     		 	    	                case 1:
	     		 	    	               
	     		 	    	            	Intent inn=new Intent( zodiacjapanese2020.this,main2020.class);
	     		 			            	inn.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(inn);
	     		 			            	break;
	     		 	    	                case 2:
	     		 	    	            	Intent in2=new Intent( zodiacjapanese2020.this,french2020.class);
	     		 			            	in2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(in2);
	     		 			            	break;
	     		 	    	               case 3:
	     			 	    	            	Intent in3=new Intent( zodiacjapanese2020.this,spain2020.class);
	     			 			            	in3.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     			 			            	startActivity(in3);
	     			 			            	break;
	     		 	    	              case 4:
	     			 	    	            	Intent in4=new Intent( zodiacjapanese2020.this,hindi2020.class);
	     			 			            	in4.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     			 			            	startActivity(in4);
	     			 			            	break;
	     		 	    	             case 5:
	     			 	    	            	Intent in5=new Intent( zodiacjapanese2020.this,dutch2020.class);
	     			 			            	in5.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     			 			            	startActivity(in5);
	     			 			            	break;
	     		 	    	            case 6:
	     		 	    	            	Intent in6=new Intent( zodiacjapanese2020.this,arabic2020.class);
	     		 			            	in6.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(in6);
	     		 			            	break;
	     		 	    	           case 7:
	     		 	    	            	Intent in7=new Intent( zodiacjapanese2020.this,malay2020.class);
	     		 			            	in7.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(in7);
	     		 			            	break;
	     		 	    	          case 8:
	     		 	    	            	Intent in8=new Intent( zodiacjapanese2020.this,german2020.class);
	     		 			            	in8.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(in8);
	     		 			            	break;
	     		 	    	         case 9:
	     		 	    	            	Intent in9=new Intent( zodiacjapanese2020.this,chinese2020.class);
	     		 			            	in9.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     		 			            	startActivity(in9);
	     		 			            	break;
	     		 	    	        case 10:
	     	 	    	            	Intent in10=new Intent( zodiacjapanese2020.this,japanese2020.class);
	     	 			            	in10.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     	 			            	startActivity(in10);
	     	 			            	break;
	     	 			            	
	     		 	    	       case 11:
	     	 	    	            	Intent in11=new Intent( zodiacjapanese2020.this,russian2020.class);
	     	 			            	in11.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     	 			            	startActivity(in11);
	     	 			            	break;
	     	 			            	
	     		 	    	      case 12:
	     	 	    	            	Intent in12=new Intent( zodiacjapanese2020.this,portuguese2020.class);
	     	 			            	in12.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	     	 			            	startActivity(in12);
	     	 			            	break;
	     		 			         }
	     		  	    	    }
	     	  	    	    @Override
	     		 	    	    public void onNothingSelected(AdapterView<?> arg0) {
	     		 	    	        // TODO Auto-generated method stub
	     		 	    	    }
	     	 	    	   });
	     		    
	     		    
	     		    layout.addView(v); 

	     		    return super.onCreateOptionsMenu(menu);
				  }
				      
				public boolean onOptionsItemSelected(MenuItem item) {
					 
			    if (item.getItemId()==android.R.id.home)
			    {
			  	Intent int_abt = new Intent(this,main2020.class);
			    int_abt.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			    startActivity(int_abt);
			    }
			   
			  	 	  
					 else if (item.getItemId() == R.id.exit)
					  {
						AlertDialog.Builder builder = new AlertDialog.Builder(this);
						 builder.setMessage("Are you sure  want to exit from Sun Signs 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.show();
					  }
					   
					   else
					  {
						  
					  }
				            return true;
				    }

	 
				public class MyAdapter extends ArrayAdapter {
	          		 
	        		public MyAdapter(Context context, int textViewResourceId,
	        		String[] objects) {
	        		super(context, textViewResourceId, objects);
	        		}
	        		 
	        		public View getCustomView(int position, View convertView,
	        		ViewGroup parent) {
	        		 
	        		// Inflating the layout for the custom Spinner
	        		LayoutInflater inflater = getLayoutInflater();
	        		View layout = inflater.inflate(R.layout.spinnernew, parent, false);
	        		 
	        	  	TextView tvLanguage = (TextView) layout
	        		.findViewById(R.id.spintext);
	        		 
	        	 	tvLanguage.setText(Languages[position]);
	        		 
	        	 	ImageView img = (ImageView) layout.findViewById(R.id.sspin);
	        		 
	        	 	img.setImageResource(images[position]);
	        		 
	        	 	if (position == 0) {
	        	 	img.setVisibility(View.GONE);
	        	 //	tvLanguage.setTextColor(Color.BLACK);
	         	  	}
	        		 
	        		return layout;
	        		}
	        		 
	        		// It gets a View that displays in the drop down popup the data at the specified position
	        		@Override
	        		public View getDropDownView(int position, View convertView,
	        		ViewGroup parent) {
	        		return getCustomView(position, convertView, parent);
	        		}
	        		 
	        		// It gets a View that displays the data at the specified position
	        		@Override
	        		public View getView(int position, View convertView, ViewGroup parent) {
	        		return getCustomView(position, convertView, parent);
	        		}
	        		}
	        }
