Skip to content

Commit

Permalink
Cadastro de motorista
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbmarcio committed Nov 24, 2017
1 parent cc3d344 commit 08b70a6
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 24 deletions.
Binary file not shown.
5 changes: 5 additions & 0 deletions 4.Sistema/LOCCARR/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:9.6.1'
implementation 'com.google.firebase:firebase-database:9.6.1'
implementation 'com.firebaseui:firebase-ui-database:0.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
Expand All @@ -31,3 +33,6 @@ dependencies {
apply plugin: 'com.google.gms.google-services'





5 changes: 4 additions & 1 deletion 4.Sistema/LOCCARR/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
</intent-filter>
</activity>
<activity android:name=".Dashboard" />
<activity android:name=".Cadastrar"></activity>
<activity android:name=".Cadastrar" />
<activity android:name=".ManterMotorista" />
<activity android:name=".CadastroMotorista" />
<activity android:name=".ExclusaoMotorista"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ public void onComplete(@NonNull Task<AuthResult> task) {
}
});

firebaseUser = firebaseAuth.getCurrentUser();

firebaseUser.sendEmailVerification()
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Toast.makeText(Cadastrar.this, "E-mail de confirmação enviado para "+firebaseUser.getEmail()+".", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Cadastrar.this, "Não foi possível enviar o e-mail de confirmação.", Toast.LENGTH_SHORT).show();
}
}
});
//firebaseUser = firebaseAuth.getCurrentUser();

//firebaseUser.sendEmailVerification()
// .addOnCompleteListener(this, new OnCompleteListener<Void>() {
// @Override
// public void onComplete(@NonNull Task<Void> task) {
// if (task.isSuccessful()){
// Toast.makeText(Cadastrar.this, "E-mail de confirmação enviado para "+firebaseUser.getEmail()+".", Toast.LENGTH_SHORT).show();
// } else {
// Toast.makeText(Cadastrar.this, "Não foi possível enviar o e-mail de confirmação.", Toast.LENGTH_SHORT).show();
// }
// }
//});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package br.com.flores.marcio.loccarr;

import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.util.Calendar;
import java.util.Date;

import br.com.flores.marcio.loccarr.Modelos.Motorista;

public class CadastroMotorista extends AppCompatActivity {
EditText editNome, editCnh, editData;
String nome, cnh, data;
DatabaseReference databaseReference;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cadastro_motorista);

editNome = findViewById(R.id.editNome);
editCnh = findViewById(R.id.editCnh);
editData = findViewById(R.id.editData);
}

public void cadastrar (View view){
nome = editNome.getText().toString().trim();
cnh = editCnh.getText().toString().trim();
String matricula = nome+cnh;
data = editData.getText().toString().trim();

if(TextUtils.isEmpty(nome)){
Toast.makeText(this, "O nome não pode estar em branco.", Toast.LENGTH_SHORT).show();
return;
}

if(TextUtils.isEmpty(cnh)){
Toast.makeText(this, "A CNH não pode estar em branco..", Toast.LENGTH_SHORT).show();
return;
}

databaseReference = FirebaseDatabase.getInstance().getReference("Motorista");

Motorista motorista = new Motorista(nome, cnh, matricula, data);
databaseReference.child(cnh).setValue(motorista);
Toast.makeText(this, "Motorista cadastrado.", Toast.LENGTH_SHORT).show();
finish();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package br.com.flores.marcio.loccarr;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class Dashboard extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
}

public void manterMotorista (View view){
startActivity(new Intent(getApplicationContext(), ManterMotorista.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package br.com.flores.marcio.loccarr;

import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;

public class ExclusaoMotorista extends AppCompatActivity {
EditText editCnh;
String cnh;
DatabaseReference databaseReference;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exclusao_motorista);

editCnh = findViewById(R.id.editCnh);
}

public void excluir (View view){

databaseReference = FirebaseDatabase.getInstance().getReference("Motorista");

//String nome = databaseReference.

cnh = editCnh.getText().toString().trim();

Query query = databaseReference.orderByChild("Motorista").equalTo(cnh);
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
databaseReference.removeValue();
Toast.makeText(ExclusaoMotorista.this, "Motorista excluído.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(ExclusaoMotorista.this, "Não foi possível excluir o motorista. Confira a CNH.", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onCancelled(DatabaseError databaseError) {

}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package br.com.flores.marcio.loccarr;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class ManterMotorista extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manter_motorista);
}

public void cadastrarMotorista (View view){
startActivity(new Intent(getApplicationContext(), CadastroMotorista.class));
}

public void excluirMotorista (View view){
startActivity(new Intent(getApplicationContext(), ExclusaoMotorista.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package br.com.flores.marcio.loccarr.Modelos;

import java.util.Date;

/**
* Created by marci on 24/11/2017.
*/

public class Motorista {
public String nome, matricula, cnh, dataIngresso;

public Motorista(String nome, String matricula, String cnh, String dataIngresso) {
this.nome = nome;
this.matricula = matricula;
this.cnh = cnh;
this.dataIngresso = dataIngresso;
}

public String getNome() {
return nome;
}

public String getMatricula() {
return matricula;
}

public String getCnh() {
return cnh;
}

public String getDataIngresso() {
return dataIngresso;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context="br.com.flores.marcio.loccarr.CadastroMotorista">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nome do motorista"
android:inputType="textPersonName"
android:id="@+id/editNome"/>

<EditText
android:id="@+id/editCnh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/editNome"
android:inputType="number"
android:hint="CNH do motorista" />

<EditText
android:id="@+id/editData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/editCnh"
android:hint="Data de ingresso (DDMMAAAA)"
android:inputType="number" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/editData"
android:background="@color/colorPrimary"
android:onClick="cadastrar"
android:text="Cadastrar"
android:textColor="@color/colorWhite" />

</RelativeLayout>
20 changes: 20 additions & 0 deletions 4.Sistema/LOCCARR/app/src/main/res/layout/activity_dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context="br.com.flores.marcio.loccarr.Dashboard">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manter\nMotorista"
android:background="@color/colorPrimary"
android:textColor="@color/colorWhite"
android:textSize="30dp"
android:padding="7dp"
android:onClick="manterMotorista"/>

</RelativeLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context="br.com.flores.marcio.loccarr.ExclusaoMotorista">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="CNH do motorista"
android:id="@+id/editCnh"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/editCnh"
android:text="Excluir"
android:background="@color/colorPrimary"
android:textColor="@color/colorWhite"
android:id="@+id/botaoExcluir"
android:onClick="excluir"/>

</RelativeLayout>
10 changes: 0 additions & 10 deletions 4.Sistema/LOCCARR/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@
android:hint="Senha"
android:inputType="textPassword" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Esqueci a minha senha"
android:id="@+id/textEsqueci"
android:layout_below="@id/buttonLogin"
android:textColor="@color/colorAccent"
android:textAlignment="center"
android:textSize="25dp"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Loading

0 comments on commit 08b70a6

Please sign in to comment.