Beispiel #1
0
  /** Called with the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.braindump);
    setHandler(new ProgressDialogHandler(this));
    mThis = this;

    if (getLastNonConfigurationInstance() != null) {
      Log.d(TAG, "re-using saved hivemind!");
      mHivemind = (HmClient) getLastNonConfigurationInstance();
      mHivemind.setUiHandler(this.getHandler());
    } else {
      // no saved instance. make a fresh one.
      Log.d(TAG, "no saved hivemind. making a new one");
      mHivemind = new HmClient(this);
      mHivemind.setUiHandler(this.getHandler());
      // use ssl, if prefs say so.
      mHivemind.setSsl(getPreferences(Context.MODE_PRIVATE).getBoolean("use_ssl", false));
    }

    mText = (EditText) findViewById(R.id.text);
    SharedPreferences mPrefs = getPreferences(Context.MODE_PRIVATE);

    // if this is our first run, prompt for authentication
    if (mPrefs.getBoolean("is_first_run", true)) {
      mPrefs.edit().putBoolean("is_first_run", false).commit();
      Intent i = new Intent("org.nerdcircus.android.hiveminder.LOGIN");
      startActivity(i);
    }

    // restore saved braindump contents.
    if (mPrefs.contains("saved-braindump-text")) {
      mText.setText(mPrefs.getString("saved-braindump-text", ""));
    }

    Button clearbtn = (Button) findViewById(R.id.clear);
    clearbtn.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            clearTextField();
          }
        });

    Button dumpbutton = (Button) findViewById(R.id.dump);
    dumpbutton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            String text = mText.getText().toString();
            try {
              saveBraindumpText(text);
              dumpBrain(text);
            } catch (HmAuthException e) {
              Log.d(TAG, "not logged in. launching Login.");
              Intent i = new Intent("org.nerdcircus.android.hiveminder.LOGIN");
              startActivity(i);
            }
          }
        });
  }
Beispiel #2
0
 protected void onResume() {
   super.onResume();
   if (mPrefs == null) {
     mPrefs = getPreferences(Context.MODE_PRIVATE);
   }
   // XXX: this function kept throwing NPEs here without the above.
   // seems like onCreate() is not called first?
   if (mPrefs.contains("saved-braindump-text")) {
     mText.setText(mPrefs.getString("saved-braindump-text", ""));
     mText.selectAll(); // select it all, so we can erase if we want.
   }
   // in case we ran login, reload the sid cookie.
   mHivemind.reloadSidCookie();
 }
Beispiel #3
0
 public void dumpBrain(final String brain) throws HmAuthException {
   showDialog(1);
   // mHivemind.doThreadedBraindump(brain);
   mHivemind.doBraindumpAsyncTask(brain);
 }