diff --git a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/CadastroUsuarioActivity.java b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/CadastroUsuarioActivity.java index 9241575..311a00c 100644 --- a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/CadastroUsuarioActivity.java +++ b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/CadastroUsuarioActivity.java @@ -12,6 +12,7 @@ import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; import br.com.whatsappandroid.cursoandroid.whatsapp2.R; import br.com.whatsappandroid.cursoandroid.whatsapp2.config.ConfiguracaoFirebase; @@ -60,6 +61,11 @@ private void cadastrarUsuario(){ public void onComplete(@NonNull Task task) { if( task.isSuccessful() ){ Toast.makeText(CadastroUsuarioActivity.this, "Sucesso ao cadastrar usuário", Toast.LENGTH_LONG ).show(); + + FirebaseUser usuarioFirebase = task.getResult().getUser(); + usuario.setId(usuarioFirebase.getUid()); + usuario.salvar(); + }else{ Toast.makeText(CadastroUsuarioActivity.this, "Erro ao cadastrar usuário", Toast.LENGTH_LONG ).show(); } diff --git a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/LoginActivity.java b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/LoginActivity.java index f76ca8c..cc7df38 100644 --- a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/LoginActivity.java +++ b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/activity/LoginActivity.java @@ -12,16 +12,11 @@ public class LoginActivity extends AppCompatActivity { - private DatabaseReference referenciaFirebase; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); - referenciaFirebase = ConfiguracaoFirebase.getFirebase(); - referenciaFirebase.child("pontos").setValue(800); - } public void abrirCadastroUsuario(View view){ diff --git a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/model/Usuario.java b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/model/Usuario.java index 5227d84..599e6d5 100644 --- a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/model/Usuario.java +++ b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/model/Usuario.java @@ -1,5 +1,10 @@ package br.com.whatsappandroid.cursoandroid.whatsapp2.model; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.Exclude; + +import br.com.whatsappandroid.cursoandroid.whatsapp2.config.ConfiguracaoFirebase; + public class Usuario { private String id; @@ -10,6 +15,12 @@ public class Usuario { public Usuario() { } + public void salvar(){ + DatabaseReference referenciaFirebase = ConfiguracaoFirebase.getFirebase(); + referenciaFirebase.child("usuarios").child( getId() ).setValue( this ); + } + + @Exclude public String getId() { return id; } @@ -34,6 +45,7 @@ public void setEmail(String email) { this.email = email; } + @Exclude public String getSenha() { return senha; } diff --git a/app/src/main/res/layout/activity_cadastro_usuario.xml b/app/src/main/res/layout/activity_cadastro_usuario.xml index cce4ad9..0b6787a 100644 --- a/app/src/main/res/layout/activity_cadastro_usuario.xml +++ b/app/src/main/res/layout/activity_cadastro_usuario.xml @@ -29,7 +29,8 @@ android:layout_marginTop="244dp" android:ems="10" android:hint="Digite seu nome" - android:inputType="textPersonName" /> + android:inputType="textPersonName" + android:textColor="@android:color/white" /> + android:inputType="textEmailAddress" + android:textColor="@android:color/white" /> + android:inputType="textPassword" + android:textColor="@android:color/white" />