package athary.audio.ency;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Toast;

public class MenuActivity extends Activity {
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.songs_layout);    

    }
    
	@Override
	protected void onResume() {
		 super.onResume();
		 showinfo();
	}

	private void showinfo(){
		
	   	final ArrayAdapter<String> dataArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1);
		  
	   	dataArrayAdapter.add("قائمة الدروس");
	   	dataArrayAdapter.add("التصانيف الفقهية");
	   	dataArrayAdapter.add("البحث في الفهارس");
	   	dataArrayAdapter.add("الفهارس المفضلة");
	   	dataArrayAdapter.add("خيارات المستخدم");
	   	dataArrayAdapter.add("حول البرنامج");

	 
	AlertDialog.Builder builder = new AlertDialog.Builder(this);

	builder.setTitle("");
	builder.setAdapter(dataArrayAdapter, new DialogInterface.OnClickListener() {

	  public void onClick(DialogInterface dialog, int item) {
			       
	       switch (item) {
		case 0:
			Intent i = new Intent(getApplicationContext(), DroosActivity.class);
			startActivity(i);	
			break;
		case 1:
			Intent ii = new Intent(getApplicationContext(), athary.audio.ency.Class_Activity.class);
			ii.putExtra("title", "التصانيف الفقهية");
			startActivity(ii);	
			break;
		case 2:
			Intent iii = new Intent(getApplicationContext(), athary.audio.ency.Search_Activity.class);
			iii.putExtra("SEARCHFEILD", 1);
			iii.putExtra("SEARCHCRITERIA", "");
			startActivity(iii);	
			break;
		case 3:
			Intent iiii = new Intent(getApplicationContext(), athary.audio.ency.Favorite_Activity.class);
			startActivity(iiii);	
			break;
		case 4:
			Intent iiiiii = new Intent(getApplicationContext(), athary.audio.ency.Settings_Activity.class);
			startActivity(iiiiii);	
			break;
		case 5:
			final Dialog dig = new Dialog(MenuActivity.this);
			dig.setContentView(R.layout.custom_popup);
			dig.setTitle("الموسوعة الصوتية");
			Button btn_send = (Button)dig.findViewById(R.id.btn_send);
			Button btn_cancel = (Button)dig.findViewById(R.id.btn_cancel);

			btn_send.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {

					Intent i = new Intent(Intent.ACTION_SEND);
					i.setType("message/rfc822");
					i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"mohammed.athary@gmail.com"});
					i.putExtra(Intent.EXTRA_SUBJECT, "الموسوعة الصوتية: ملاحظات");
					i.putExtra(Intent.EXTRA_TEXT   , "اكتب ملاحظاتك هنا");
					try {
					    startActivity(Intent.createChooser(i, "إرسال ملاحظات..."));
					} catch (android.content.ActivityNotFoundException ex) {
					    Toast.makeText(MenuActivity.this, "لا يوجد لديك برنامج بريد إلكتروني!", Toast.LENGTH_SHORT).show();
					}					}
			});
			
			btn_cancel.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					dig.dismiss();						
				}
			});
			
			dig.show();


			break;

		}

	  }

	});

	AlertDialog alert = builder.create();

	alert.show();
		}
}