Android Open Source - ssidLogger Main Activity






From Project

Back to project page ssidLogger.

License

The source code is released under:

MIT License

If you think the Android project ssidLogger 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 org.zordius.ssidlogger;
//from   w  w  w. j  av a2 s .c  o  m
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.ToggleButton;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    syncStatus();
    bindDone();
  }

  public void bindDone() {
    // handle set logfile
    ((EditText) findViewById(R.id.editFilename))
        .setOnEditorActionListener(new EditText.OnEditorActionListener() {
          public boolean onEditorAction(TextView v, int actionId,
              KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              if (!WifiReceiver.setLogFile(v.getContext(),
                  ((EditText) v).getText().toString())) {
                syncStatus();
              }
            }
            return false;
          }
        });

    // handle comment
    ((EditText) findViewById(R.id.editComment))
        .setOnEditorActionListener(new EditText.OnEditorActionListener() {
          public boolean onEditorAction(TextView v, int actionId,
              KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
              doComment();
              return true;
            }
            return false;
          }
        });
  }

  public void syncStatus() {
    ((ToggleButton) findViewById(R.id.logSwitch)).setChecked(WifiReceiver
        .isEnabled(this));
    ((EditText) findViewById(R.id.editFilename))
        .setText(WifiReceiver.getLogFileName(this),
            TextView.BufferType.EDITABLE);
  }

  public void onClickLog(View v) {
    WifiReceiver.toggleScan(this, ((ToggleButton) v).isChecked());
  }

  public void onClickScan(View v) {
    WifiReceiver.doScan(this);
  }

  public void doComment() {
    EditText cmt = (EditText) findViewById(R.id.editComment);
    WifiReceiver.writeLog(this, "COMMENT " + cmt.getText().toString());
    cmt.setText("", TextView.BufferType.EDITABLE);
  }
}




Java Source Code List

org.zordius.ssidlogger.MainActivity.java
org.zordius.ssidlogger.WifiReceiver.java