コード例 #1
0
  /**
   * Creates and sets an appropriate result Intent to be return to Tasker containing the necessary
   * variables and the blurb.
   */
  private void packResult() {
    String textToType = mEtTextToType.getText().toString();
    boolean clearText = mCbClearText.isChecked();
    boolean performAction = mCbPerformAction.isChecked();
    String blurb =
        String.format(
            getString(R.string.blurb),
            textToType,
            (clearText ? getString(R.string.yes) : getString(R.string.no)),
            (performAction ? getString(R.string.yes) : getString(R.string.no)));

    Intent resultIntent = new Intent();
    resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);

    Bundle resultBundle = new Bundle(5);
    resultBundle.putInt(Constants.EXTRA_BUNDLE_VERSION, Constants.BUNDLE_VERSION);
    resultBundle.putString(Constants.EXTRA_TEXT, textToType);
    resultBundle.putBoolean(Constants.EXTRA_CLEAR_BEFORE, clearText);
    resultBundle.putBoolean(Constants.EXTRA_END_WITH_ACTION, performAction);

    if (TaskerPlugin.Setting.hostSupportsOnFireVariableReplacement(this)) {
      TaskerPlugin.Setting.setVariableReplaceKeys(
          resultBundle, new String[] {Constants.EXTRA_TEXT});
    }

    resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle);

    if (TaskerPlugin.Setting.hostSupportsSynchronousExecution(getIntent().getExtras())) {
      TaskerPlugin.Setting.requestTimeoutMS(resultIntent, 2000);
    }

    setResult(TaskerPlugin.Setting.RESULT_CODE_OK, resultIntent);
  }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    mEtTextToType = (EditText) findViewById(R.id.et_text_to_be_typed);
    mCbClearText = (CheckBox) findViewById(R.id.cb_clear_text);
    mCbPerformAction = (CheckBox) findViewById(R.id.cb_perform_action);

    if (savedInstanceState == null) {
      Bundle localeBundle =
          getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
      if (localeBundle != null) {
        String text = localeBundle.getString(Constants.EXTRA_TEXT);
        if (text != null) {
          mEtTextToType.setText(text);
        }
        boolean clearText = localeBundle.getBoolean(Constants.EXTRA_CLEAR_BEFORE, false);
        mCbClearText.setChecked(clearText);
        boolean performAction = localeBundle.getBoolean(Constants.EXTRA_END_WITH_ACTION, false);
        mCbPerformAction.setChecked(performAction);
      }
    }

    if (!TaskerPlugin.Setting.hostSupportsOnFireVariableReplacement(this)) {
      mEtTextToType.setHint(R.string.variable_replacement_not_ok);
    }

    if (!isKeyboardEnabled()) {
      showDialogKeyboardNotEnabled();
    }
  }