1
package com.projeto.comandapack;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import static com.projeto.comandapack.R.id.txtCaminhoBd;
import static com.projeto.comandapack.R.id.txtSenhaBd;
import static com.projeto.comandapack.R.id.txtUsuarioBd;
public class ConfiguracaoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_configuracao);
}
public void conexaoBanco(View view){
final EditText caminhoBanco = findViewById(txtCaminhoBd);
final EditText usuarioBd = findViewById(txtUsuarioBd);
final EditText senhaBd = findViewById(txtSenhaBd);
ConexaoBanco conexaoComBanco = new ConexaoBanco(caminhoBanco.getText().toString(),usuarioBd.getText().toString(), senhaBd.getText().toString());
if (conexaoComBanco.testaConexao())
Toast.makeText(getApplicationContext(), "Não foi possível conectar, reveja as informações", Toast.LENGTH_LONG).show();
else {
findViewById(txtCaminhoBd).setEnabled(false);
findViewById(txtUsuarioBd).setEnabled(false);
findViewById(txtUsuarioBd).setEnabled(false);
Toast.makeText(getApplicationContext(), "Conexão bem sucedida", Toast.LENGTH_LONG).show();
}
}
public void limpaConfig(View view){
final EditText caminhoBanco = findViewById(txtCaminhoBd);
final EditText usuarioBd = findViewById(txtUsuarioBd);
final EditText senhaBd = findViewById(txtSenhaBd);
caminhoBanco.setText("");
usuarioBd.setText("");
senhaBd.setText("");
findViewById(txtCaminhoBd).setEnabled(true);
findViewById(txtUsuarioBd).setEnabled(true);
findViewById(txtUsuarioBd).setEnabled(true);
}
public void btnVoltar(View view){
Intent it = new Intent(ConfiguracaoActivity.this, MainActivity.class);
startActivity(it);
}
}