Example #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_run_key);

    Intent intent = getIntent();
    final String key = intent.getStringExtra(MainActivity.EXTRA_KEY);

    TextView textView = (TextView) findViewById(R.id.text_run_key_status);
    textView.setText(String.format("Running go function keyed by '%s'", key));

    mOutput = (TextView) findViewById(R.id.text_run_key_output);

    if (savedInstanceState != null) {
      mLines = (String[]) savedInstanceState.getCharSequenceArray(OUTPUT_DATA);
      mNextLine = savedInstanceState.getInt(OUTPUT_NEXT);
      write(null); // force a redraw of the output TextView.
      if (savedInstanceState.getBoolean(STARTED)) {
        return;
      }
    }

    final VContext ctx =
        V.init(
            this, new Options().set(OptionDefs.LOG_VLEVEL, 0).set(OptionDefs.LOG_VMODULE, "*=0"));
    try {
      mRemoteInspectors = new RemoteInspectors(ctx);
    } catch (VException e) {
      Log.e(TAG, "Failed to enable remote inspection: " + e.toString());
    }
    synchronized (this) {
      mLines = new String[10];
      mNextLine = 0;
    }
    Futures.addCallback(
        BlessingsManager.getBlessings(ctx, this, BLESSINGS_KEY, true),
        new FutureCallback<Blessings>() {
          @Override
          public void onSuccess(Blessings b) {
            Log.v(TAG, "Received blessings " + b.toString());
            AsyncTask.execute(
                new Runnable() {
                  @Override
                  public void run() {
                    try {
                      (new Vango()).run(ctx, key, RunKeyActivity.this);
                    } catch (Exception e) {
                      write(e.toString());
                    }
                  }
                });
          }

          @Override
          public void onFailure(Throwable t) {
            Log.d(TAG, "Failed to get blessings", t);
          }
        });
  }
Example #2
0
  /** Called when the user clicks the Remote Inspect button */
  public void runRemoteInspect(View view) {
    String email;
    try {
      email = mRemoteInspectors.invite("helper", Duration.standardDays(7));
    } catch (VException e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
      return;
    }
    // This whole app lives to be thrown away after testing, so don't worry about
    // using resource ids for the strings.
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_SUBJECT, "Please look at vango");
    intent.putExtra(Intent.EXTRA_TEXT, email);

    if (intent.resolveActivity(getPackageManager()) != null) {
      startActivity(intent);
    } else {
      Toast.makeText(this, "No email client installed", Toast.LENGTH_LONG).show();
    }
  }