package org.pulpdust.da.sample;

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

public class SampleDaActivity extends FragmentActivity {
	final static String TAG = "SampleDA 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;
	EditText et;
	Button ok;
	Button nullpo;

	@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_sampleda);
		et = (EditText) findViewById(R.id.editText1);
		ok = (Button) findViewById(R.id.button1);
		nullpo = (Button) findViewById(R.id.button2);
 		if (getIntent().getStringExtra(DA_EX_TEXT) != null){
 			sbj = getIntent().getStringExtra(DA_EX_TEXT);
 		} else {
 			sbj = "";
 		}
 		et.setText(sbj);
		ok.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				Intent ret = new Intent();
				ret.putExtra(DA_EX_RETURN, et.getText().toString());
				setResult(RESULT_OK, ret);
				finish();
			}
			
		});
		nullpo.setOnClickListener(new OnClickListener(){
			
			@Override
			public void onClick(View v){
				Intent ret = new Intent();
				setResult(RESULT_OK, ret);
				finish();
			}
		});
    }

}
