package com.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.GestureDetector.OnGestureListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SearchWindow extends Activity{

	public static final int REQ_SEARCH_UPDATE=0;
	
	private EditText et_keywds;
	
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.setContentView(R.layout.searchbykeys);
		
		
		et_keywds=(EditText)findViewById(R.id.search_keywds);
		
		((Button)findViewById(R.id.search_in_search)).setOnClickListener(click_search);
		
		((Button)findViewById(R.id.close_search)).setOnClickListener(click_close);
		
	}
	
	public static void requestUpdate(Activity parent)
	{
		Intent search=new Intent(parent,SearchWindow.class);
		
		parent.startActivityForResult(search,REQ_SEARCH_UPDATE);
	}
	
	OnClickListener click_search=new OnClickListener()
	{
		public void onClick(View view)
		{
			//handle search commands
			Bundle b=new Bundle();
			b.putString("Keywords", et_keywds.getText().toString());
			
			setResult(RESULT_OK);
			finish();
		}
	};
	OnClickListener click_close=new OnClickListener()
	{
		public void onClick(View v)
		{
			setResult(Activity.RESULT_CANCELED);
			finish();
		}
	};

}
