Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.tget); // Layouts xmls exist for both landscape or portrait modes

    Intent intent = getIntent();
    String title = intent.getStringExtra(TITLE);
    if (title != null) setTitle(title);
    ArrayList<String> consoleText = intent.getStringArrayListExtra(CONSOLE_TEXT);
    if (theText == null) theText = "";

    lockReleased = false;

    theTextView = (EditText) findViewById(R.id.the_text); // The text display area

    int count = consoleText.size();
    for (int i = 0; i < count; ++i) {
      theText = theText + consoleText.get(i) + '\n';
    }

    theText = theText + Run.TextInputString;
    PromptIndex = theText.length();

    theTextView.setText(theText); // The Editor's display text
    theTextView.setTypeface(Typeface.MONOSPACE);
    theTextView.setSelection(theText.length());

    Basic.TextStyle style = Basic.defaultTextStyle; // Get text color from Settings
    theTextView.setTextColor(style.mTextColor);
    theTextView.setBackgroundColor(style.mBackgroundColor);
    theTextView.setCursorVisible(true);

    theTextView.setTextSize(1, Settings.getFont(this));

    theTextView.addTextChangedListener(inputTextWatcher);

    theTextView.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              handleEOL();
              return true;
            }
            return false;
          }
        });
  }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(Settings.getSreenOrientation(this));
    originalText = Editor.DisplayText; // Save in case of BACK Key

    setContentView(R.layout.search); // Layouts xmls exist for both landscape or portrait modes

    rText = (EditText) findViewById(R.id.replace_text); // The replace text
    sText = (EditText) findViewById(R.id.search_text); // The search for text

    nextButton = (Button) findViewById(R.id.next_button); // The buttons
    replaceButton = (Button) findViewById(R.id.replace_button);
    replaceAllButton = (Button) findViewById(R.id.replace_all_button);
    doneButton = (Button) findViewById(R.id.done_button);

    theTextView = (EditText) findViewById(R.id.the_text); // The text display area
    theTextView.setText(Editor.DisplayText); // The Editor's display text

    if (Settings.getEditorColor(this).equals("BW")) {
      theTextView.setTextColor(0xff000000);
      theTextView.setBackgroundColor(0xffffffff);
      rText.setTextColor(0xff000000);
      rText.setBackgroundColor(0xffffffff);
      theTextView.setTextColor(0xff000000);
      theTextView.setBackgroundColor(0xffffffff);
    } else if (Settings.getEditorColor(this).equals("WB")) {
      theTextView.setTextColor(0xffffffff);
      theTextView.setBackgroundColor(0xff000000);
      rText.setTextColor(0xffffffff);
      rText.setBackgroundColor(0xff000000);
      sText.setTextColor(0xffffffff);
      sText.setBackgroundColor(0xff000000);
    } else if (Settings.getEditorColor(this).equals("WBL")) {
      theTextView.setTextColor(0xffffffff);
      theTextView.setBackgroundColor(0xff006478);
      rText.setTextColor(0xffffffff);
      rText.setBackgroundColor(0xff006478);
      sText.setTextColor(0xffffffff);
      sText.setBackgroundColor(0xff006478);
    }

    theTextView.setTextSize(1, Settings.getFont(this));

    // If there is a block of text selected in the Editor then make that
    // block of text the search for text

    if (Editor.selectionStart != Editor.selectionEnd) {
      int s = Editor.selectionStart;
      int e = Editor.selectionEnd;
      if (e < s) {
        s = e;
        e = Editor.selectionStart;
      }
      sText.setText(Editor.DisplayText.substring(s, e));
    }

    Index = -1; // Current Index into text, set for nothing found
    nextIndex = 0; // next Index

    nextButton.setOnClickListener(
        new OnClickListener() { // ***** Next Button ****

          public void onClick(View v) {
            Editor.DisplayText =
                theTextView.getText().toString(); // Grab the text that the user is seeing
            // She may edited it
            if (nextIndex < 0) nextIndex = 0; // If nextIndex <0 then a previous search
            // search has finished. Start next search
            // from the start
            if (doNext()) return; // If this next found something, return
            nextIndex = -1; // Else indicate not found and (Index also -1 now)
            Toaster(searchText + " not found."); // tell the user not found
            return;
          }
        });

    replaceButton.setOnClickListener(
        new OnClickListener() { // ***** Replace Button ****

          public void onClick(View v) {
            if (Index < 0) { // If nothing has been found....
              Toaster("Nothing found to replace");
              return;
            }
            doReplace(); // else replace what was found
            return;
          }
        });

    replaceAllButton.setOnClickListener(
        new OnClickListener() { // ******* Replace All Button *****

          public void onClick(View v) {
            doReplaceAll();
          }
        });

    doneButton.setOnClickListener(
        new OnClickListener() { // **** Done Button ****

          public void onClick(View v) {
            Editor.DisplayText =
                theTextView.getText().toString(); // Grab the text that the user is seeing
            Editor.mText.setText(Editor.DisplayText); // Set the Editor's EditText TextView text
            if (!mChanged) {
              mChanged = !originalText.equals(Editor.DisplayText); // She may have edited it
            }
            if (mChanged) {
              Basic.Saved = false;
            }
            if (nextIndex < 0) nextIndex = 0; // If nextIndex indicates done, then set to start
            if (Index < 0) Index = 0; // If Index indicates not found, set to start
            if (nextIndex < Index) {
              int ni = nextIndex;
              nextIndex = Index;
              Index = ni;
            }
            Editor.mText.setSelection(Index, nextIndex); // Set the cursor or selection highlight
            finish(); // Done with this module
            return;
          }
        });
  }