@Override
  protected void onStart() {
    super.onStart();

    utility.updateHeader(
        Utility.NO_FILE,
        R.string.pref_hardware_config_filename,
        R.id.active_filename,
        R.id.included_header);
    Intent intent = getIntent();
    Serializable extra = intent.getSerializableExtra(EDIT_MOTOR_CONTROLLER_CONFIG);

    if (extra != null) {
      motorControllerConfigurationConfig = (MotorControllerConfiguration) extra;
      motors = (ArrayList<DeviceConfiguration>) motorControllerConfigurationConfig.getMotors();
      motor1 = (MotorConfiguration) motors.get(0);
      motor2 = (MotorConfiguration) motors.get(1);

      controller_name.setText(motorControllerConfigurationConfig.getName());

      motor1_name.setText(motor1.getName());
      motor2_name.setText(motor2.getName());

      addListenerOnPort1();
      handleDisabledMotor(motor1, checkbox_motor1);
      addListenerOnPort2();
      handleDisabledMotor(motor2, checkbox_motor2);
    }
  }
  private void saveState() {

    Intent returnIntent = new Intent();
    ArrayList<DeviceConfiguration> motors = new ArrayList<>();
    if (motor1Enabled) {
      String name = motor1_name.getText().toString();
      MotorConfiguration newMotor = new MotorConfiguration(name);
      newMotor.setDisabled(false);
      newMotor.setPort(1);
      motors.add(newMotor);
    } else {
      motors.add(new MotorConfiguration(1));
    } // add disabled motor

    if (motor2Enabled) {
      String name = motor2_name.getText().toString();
      MotorConfiguration newMotor = new MotorConfiguration(name);
      newMotor.setDisabled(false);
      newMotor.setPort(2);
      motors.add(newMotor);
    } else {
      motors.add(new MotorConfiguration(2));
    } // add disabled motor

    motorControllerConfigurationConfig.addMotors(motors);
    motorControllerConfigurationConfig.setName(controller_name.getText().toString());
    returnIntent.putExtra(EDIT_MOTOR_CONTROLLER_CONFIG, motorControllerConfigurationConfig);

    setResult(RESULT_OK, returnIntent);
    finish();
  }
 private MotorControllerConfiguration m48a(
     SerialNumber serialNumber, String str, String str2, String str3) {
   MotorControllerConfiguration motorControllerConfiguration;
   if (serialNumber.equals(ControllerConfiguration.NO_SERIAL_NUMBER)) {
     motorControllerConfiguration = new MotorControllerConfiguration();
   } else {
     motorControllerConfiguration = (MotorControllerConfiguration) this.f101e.get(serialNumber);
   }
   motorControllerConfiguration.setName(str3);
   List arrayList = new ArrayList();
   MotorConfiguration motorConfiguration = new MotorConfiguration(1, str, true);
   MotorConfiguration motorConfiguration2 = new MotorConfiguration(2, str2, true);
   arrayList.add(motorConfiguration);
   arrayList.add(motorConfiguration2);
   motorControllerConfiguration.addMotors(arrayList);
   return motorControllerConfiguration;
 }
 private void m58b(SerialNumber serialNumber, String str) {
   LegacyModuleControllerConfiguration legacyModuleControllerConfiguration =
       (LegacyModuleControllerConfiguration) this.f101e.get(serialNumber);
   legacyModuleControllerConfiguration.setName(str);
   MotorControllerConfiguration a =
       m48a(ControllerConfiguration.NO_SERIAL_NUMBER, "motor_1", "motor_2", "wheels");
   a.setPort(0);
   ServoControllerConfiguration a2 =
       m49a(ControllerConfiguration.NO_SERIAL_NUMBER, m65f(), "servos");
   a2.setPort(1);
   DeviceConfiguration a3 = m47a(ConfigurationType.IR_SEEKER, "ir_seeker", 2);
   DeviceConfiguration a4 = m47a(ConfigurationType.LIGHT_SENSOR, "light_sensor", 3);
   List arrayList = new ArrayList();
   arrayList.add(a);
   arrayList.add(a2);
   arrayList.add(a3);
   arrayList.add(a4);
   for (int i = 4; i < 6; i++) {
     arrayList.add(new DeviceConfiguration(i));
   }
   legacyModuleControllerConfiguration.addDevices(arrayList);
 }