package org.pulpdust.da.kakomun;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class KakomunDaActivity extends FragmentActivity {
	final static String TAG = "KakomunDA Main";
	final static String DA_EX_TEXT = "org.pulpdust.da.extra.TEXT";
	final static String DA_EX_THEME = "org.pulpdust.da.extra.THEME";
	final static String DA_EX_RETURN = "org.pulpdust.da.extra.RETURN";
	String sbj;
	Button kaku;
	Button dai;
	Button maru;
	Button kou;
	Button yama;
	Button niyama;
	Button kagi;
	Button nikagi;
	Button sumi;
	Button niin;
	Button hoshi;
	Button futou;
	Button inyou;
	Button tomoe;
	Button nami;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		int cs = getIntent().getIntExtra(DA_EX_THEME, 0);
		if (cs >= 1){
			setTheme(R.style.AppTheme_Dark);
		} else {
			setTheme(R.style.AppTheme);
		}
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_kakomunda);
		kaku = (Button) findViewById(R.id.button1);
		dai = (Button) findViewById(R.id.button2);
		maru = (Button) findViewById(R.id.button3);
		kou = (Button) findViewById(R.id.button4);
		yama = (Button) findViewById(R.id.button5);
		niyama = (Button) findViewById(R.id.button6);
		kagi = (Button) findViewById(R.id.button7);
		nikagi = (Button) findViewById(R.id.button8);
		sumi = (Button) findViewById(R.id.button9);
		niin = (Button) findViewById(R.id.button10);
		hoshi = (Button) findViewById(R.id.button11);
		futou = (Button) findViewById(R.id.button12);
		inyou = (Button) findViewById(R.id.button13);
		tomoe = (Button) findViewById(R.id.button14);
		nami = (Button) findViewById(R.id.button15);
 		if (getIntent().getStringExtra(DA_EX_TEXT) != null){
 			sbj = getIntent().getStringExtra(DA_EX_TEXT);
 		} else {
 			sbj = "";
 		}
		kaku.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.kaku_h, sbj, R.string.kaku_t);
			}
 			
 		});
 		dai.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.dai_h, sbj, R.string.dai_t);
			}
 			
 		});
 		maru.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.maru_h, sbj, R.string.maru_t);
			}
 			
 		});
 		kou.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.kou_h, sbj, R.string.kou_t);
			}
 			
 		});
 		yama.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.yama_h, sbj, R.string.yama_t);
			}
 			
 		});
 		niyama.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.niyama_h, sbj, R.string.niyama_t);
			}
 			
 		});
 		kagi.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.kagi_h, sbj, R.string.kagi_t);
			}
 			
 		});
 		nikagi.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.nikagi_h, sbj, R.string.nikagi_t);
			}
 			
 		});
 		sumi.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.sumi_h, sbj, R.string.sumi_t);
			}
 			
 		});
 		niin.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.niin_h, sbj, R.string.niin_t);
			}
 			
 		});
 		hoshi.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.hoshi_h, sbj, R.string.hoshi_t);
			}
 			
 		});
 		futou.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.futou_h, sbj, R.string.futou_t);
			}
 			
 		});
 		inyou.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.inyou_h, sbj, R.string.inyou_t);
			}
 			
 		});
 		tomoe.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.tomoe_h, sbj, R.string.tomoe_t);
			}
 			
 		});
 		nami.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				sendResult(R.string.nami_h, sbj, R.string.nami_t);
			}
 			
 		});


	}
	
	void sendResult(int left, String obj, int right){
		String retstr;
		retstr = getString(left) + obj + getString(right);
		Intent ret = new Intent();
		ret.putExtra(DA_EX_RETURN, retstr);
		setResult(RESULT_OK, ret);
		finish();
	}

}
