PageRenderTime 182ms CodeModel.GetById 81ms app.highlight 7ms RepoModel.GetById 63ms app.codeStats 0ms

/TheElements/src/sand/falling/opengl/network/networklogin.java

http://thelements.googlecode.com/
Java | 122 lines | 73 code | 23 blank | 26 comment | 8 complexity | 58485ac475b7af10ca3cec98284ab955 MD5 | raw file
  1package sand.falling.opengl.network;
  2
  3import sand.falling.opengl.R;
  4import android.app.Activity;
  5import android.content.Intent;
  6import android.os.Bundle;
  7import android.view.View;
  8import android.view.View.OnClickListener;
  9import android.widget.Button;
 10import android.widget.EditText;
 11import android.widget.Toast;
 12
 13/**
 14 * Application Name: Generic Login Screen for the Android Platform (back end)
 15 * Description: This is a generic login screen which catches the username and
 16 * password values Created on: November 23, 2007 Created by: Pogz Ortile
 17 * Contact: pogz(at)redhat(dot)polarhome(dot)com Notes: The string values for
 18 * username and password are assigned to sUserName and sPassword respectively
 19 * You are free to distribute, modify, and wreck for all I care. GPL ya!
 20 * */
 21
 22public class networklogin extends Activity
 23{
 24	/** Called when the activity is first created. */
 25
 26	static public Button launch;
 27	static public Button register;
 28	static public Button network_engage;
 29	static public EditText usernameEditText;
 30	static public EditText passwordEditText;
 31	static public String sUserName;
 32	static public String sPassword;
 33
 34	@Override
 35	public void onCreate(Bundle savedInstanceState)
 36	{
 37		super.onCreate(savedInstanceState);
 38
 39		// load up the layout
 40		setContentView(R.layout.login_layout);
 41
 42		// get the button resource in the xml file and assign it to a local
 43		// variable of type Button
 44		launch = (Button) findViewById(R.id.login_button2);
 45		register = (Button) findViewById(R.id.register_button);
 46		network_engage = (Button) findViewById(R.id.engage_test);
 47		// this gets the resources in the xml file and assigns it to a
 48		// local variable of type EditText
 49		usernameEditText = (EditText) findViewById(R.id.txt_username);
 50		passwordEditText = (EditText) findViewById(R.id.txt_password);
 51
 52		
 53
 54		// this is the action listener
 55		launch.setOnClickListener(new OnClickListener()
 56		{
 57
 58			public void onClick(View viewParam)
 59			{
 60				
 61				// the getText() gets the current value of the text box
 62				// the toString() converts the value to String data type
 63				// then assigns it to a variable of type String
 64				sUserName = usernameEditText.getText().toString();
 65				sPassword = passwordEditText.getText().toString();
 66
 67				if (usernameEditText == null || passwordEditText == null)
 68				{
 69					Toast.makeText(networklogin.this, "Couldn't find the 'txt_username' or 'txt_password'", Toast.LENGTH_SHORT).show();
 70				}
 71				else
 72				{
 73					// display the username and the password in string format
 74					Toast.makeText(networklogin.this, "username:" + sUserName + " password:" + sPassword, Toast.LENGTH_SHORT).show();
 75				}
 76			}
 77		}
 78
 79		); // end of launch.setOnclickListener
 80		register.setOnClickListener(new OnClickListener()
 81		{
 82
 83			public void onClick(View viewParam)
 84			{
 85				
 86				// the getText() gets the current value of the text box
 87				// the toString() converts the value to String data type
 88				// then assigns it to a variable of type String
 89				sUserName = usernameEditText.getText().toString();
 90				sPassword = passwordEditText.getText().toString();
 91
 92				// this just catches the error if the program cant locate the
 93				// GUI stuff
 94				if (usernameEditText == null || passwordEditText == null)
 95				{
 96					Toast.makeText(networklogin.this, "Couldn't find the 'txt_username' or 'txt_password'", Toast.LENGTH_SHORT).show();
 97				}
 98				else
 99				{
100					// display the username and the password in string format
101					Toast.makeText(networklogin.this, " Register Username:" + sUserName + " Password:" + sPassword, Toast.LENGTH_SHORT).show();
102				}
103			}
104		}
105
106		); // end of register.setOnClickStuff
107		network_engage.setOnClickListener(new OnClickListener()
108		{
109
110			public void onClick(View viewParam)
111			{
112				
113			//Start the main app activity
114				startActivity(new Intent(networklogin.this, networkengage.class));
115			
116			}
117		}
118
119		); // end of register.setOnClickStuff
120	}
121
122}