Android Open Source - TheNewBoston Text Play






From Project

Back to project page TheNewBoston.

License

The source code is released under:

Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECI...

If you think the Android project TheNewBoston listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.homelysoft.thenewboston;
//from w w  w  . j  a  va 2s.  c  o  m
import java.util.Random;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class TextPlay extends Activity implements View.OnClickListener {

  Button checkCommand;
  ToggleButton passwordToggle;
  EditText commandInput;
  TextView display;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text_play);

    bridgeXML();

    setOnClickListeners();
  }

  private void bridgeXML() {
    checkCommand = (Button) findViewById(R.id.b_run_command);
    passwordToggle = (ToggleButton) findViewById(R.id.tb_password);
    commandInput = (EditText) findViewById(R.id.et_command);
    display = (TextView) findViewById(R.id.tv_command_display);
  }

  private void setOnClickListeners() {
    checkCommand.setOnClickListener(this);
    passwordToggle.setOnClickListener(this);
  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
    case R.id.b_run_command:
      String input = commandInput.getText().toString();
      display.setText(input);
      if (input.contentEquals("left")) {
        display.setGravity(Gravity.LEFT);
      } else if (input.contentEquals("center")) {
        display.setGravity(Gravity.CENTER);
      } else if (input.contentEquals("right")) {
        display.setGravity(Gravity.RIGHT);
      } else if (input.contentEquals("blue")) {
        display.setTextColor(Color.BLUE);
      } else if (input.contentEquals("WTF")) {
        Random crazy = new Random();
        display.setText("WTF!!!");
        display.setTextSize(crazy.nextInt(100));
        display.setTextColor(Color.rgb(crazy.nextInt(255),
            crazy.nextInt(255), crazy.nextInt(255)));
        switch (crazy.nextInt(3)) {
        case 0:
          display.setGravity(Gravity.LEFT);
          break;
        case 1:
          display.setGravity(Gravity.CENTER);
          break;
        case 2:
          display.setGravity(Gravity.RIGHT);
          break;

        }
      } else {
        display.setText(getResources().getString(
            R.string.command_display_default));
        display.setTextColor(Color.BLACK);
      }
      break;
    case R.id.tb_password:
      if (passwordToggle.isChecked()) {
        commandInput.setInputType(InputType.TYPE_CLASS_TEXT
            | InputType.TYPE_TEXT_VARIATION_PASSWORD);
      } else {
        commandInput.setInputType(InputType.TYPE_CLASS_TEXT);
      }
      break;
    }
  }

}




Java Source Code List

com.homelysoft.thenewboston.AboutUs.java
com.homelysoft.thenewboston.Accelerate.java
com.homelysoft.thenewboston.Data.java
com.homelysoft.thenewboston.Email.java
com.homelysoft.thenewboston.ExternalData.java
com.homelysoft.thenewboston.Flipper.java
com.homelysoft.thenewboston.Home.java
com.homelysoft.thenewboston.HotOrNot.java
com.homelysoft.thenewboston.InternalData.java
com.homelysoft.thenewboston.OpenedClass.java
com.homelysoft.thenewboston.OurViewClient.java
com.homelysoft.thenewboston.Photo.java
com.homelysoft.thenewboston.Preferences.java
com.homelysoft.thenewboston.SQLView.java
com.homelysoft.thenewboston.SQLite.java
com.homelysoft.thenewboston.SharedPrefs.java
com.homelysoft.thenewboston.Slider.java
com.homelysoft.thenewboston.SoundPoolPlay.java
com.homelysoft.thenewboston.Splash.java
com.homelysoft.thenewboston.StartingPoint.java
com.homelysoft.thenewboston.Tabs.java
com.homelysoft.thenewboston.TextPlay.java
com.homelysoft.thenewboston.gfx.GFXSurface.java
com.homelysoft.thenewboston.gfx.GFX.java
com.homelysoft.thenewboston.gfx.MyBringBack.java
com.homelysoft.thenewboston.vect.Vector.java