Пример #1
0
 private void startControllerAutomatically() {
   if (SshControllerUtils.isAutoConnectEnabled() && autoChoose) {
     // Then, if there is a status = true, we connect to it
     for (int i = 0; i < SshControllerUtils.getControllers().size(); i++) {
       if (SshControllerUtils.getControllers().get(i).parent.state
           == Constants._SSHCONFIGURATION_CONNECTED) {
         CurrentConfiguration.controller = SshControllerUtils.getControllers().get(i);
         startControllerActivity();
       }
     }
   }
 }
Пример #2
0
 /** Will start the controller activity with the specified controller if this one is enabled */
 @Override
 public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
   if (SshControllerUtils.getControllers().get(position).parent.state
       == Constants._SSHCONFIGURATION_CONNECTED) {
     CurrentConfiguration.controller = SshControllerUtils.getControllers().get(position);
     startControllerActivity();
   } else {
     // Display error message
     Toast.makeText(
             getApplicationContext(),
             getText(R.string.cannot_get_ssh_connections),
             Toast.LENGTH_LONG)
         .show();
   }
 }
Пример #3
0
  /** Method used to rename or delete a controller, to be changed */
  @Override
  public boolean onItemLongClick(AdapterView<?> arg0, View v, final int position, long id) {
    Log.i(this.getClass().getName(), "click on item: " + position);

    // AlertDialog actionAlert=new AlertDialog.Builder(
    // SshControllerActivity.instance).create();

    AlertDialog actionAlert = new AlertDialog.Builder(this).create();
    actionAlert.setTitle(getString(R.string.manage_controller_title));
    actionAlert.setMessage(
        getString(
            R.string.manage_controller_message,
            SshControllerUtils.getControllers().get(position).name));
    actionAlert.setButton(
        AlertDialog.BUTTON_POSITIVE,
        getString(R.string.delete),
        new OnClickListener() {

          @Override
          public void onClick(DialogInterface arg0, int arg1) {
            AlertDialog deleteAlert =
                new AlertDialog.Builder(CurrentConfiguration.instance).create();
            deleteAlert.setTitle(getString(R.string.delete_controller_title));
            deleteAlert.setMessage(
                getString(
                    R.string.delete_controller_message,
                    SshControllerUtils.getControllers().get(position).name));
            deleteAlert.setButton(
                AlertDialog.BUTTON_POSITIVE,
                getString(R.string.yes),
                new OnClickListener() {

                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {
                    SshControllerUtils.deleteController(
                        SshControllerUtils.getControllers().get(position));
                    SshControllerUtils.saveSshConfigurations();
                    ((MainActivity) CurrentConfiguration.instance)
                        .controllerAdapter.notifyDataSetChanged();
                  }
                });
            deleteAlert.setButton(
                AlertDialog.BUTTON_NEGATIVE,
                getString(R.string.cancel),
                new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {}
                });
            deleteAlert.show();
          }
        });
    actionAlert.setButton(
        AlertDialog.BUTTON_NEGATIVE,
        getString(R.string.rename),
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0, int arg1) {

            AlertDialog renameAlert =
                new AlertDialog.Builder(CurrentConfiguration.instance).create();
            renameAlert.setTitle(getString(R.string.rename_controller_title));
            renameAlert.setMessage(
                getString(
                    R.string.rename_controller_message,
                    SshControllerUtils.getControllers().get(position).name));

            final EditText input = new EditText(CurrentConfiguration.instance);
            renameAlert.setView(input);

            renameAlert.setButton(
                AlertDialog.BUTTON_POSITIVE,
                getString(R.string.rename),
                new OnClickListener() {

                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {
                    SshControllerUtils.getControllers().get(position).name =
                        input.getText().toString();
                    SshControllerUtils.saveSshConfigurations();
                    ((MainActivity) CurrentConfiguration.instance)
                        .controllerAdapter.notifyDataSetChanged();
                  }
                });
            renameAlert.setButton(
                AlertDialog.BUTTON_NEGATIVE,
                getString(R.string.cancel),
                new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface arg0, int arg1) {}
                });
            renameAlert.show();
          }
        });

    actionAlert.setButton(
        AlertDialog.BUTTON_NEUTRAL,
        getString(R.string.cancel),
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0, int arg1) {}
        });
    actionAlert.show();
    return true;
  }