Welcome back.
And this video, we are going to do the final preparation for then finally adding the sign up functionality.
So we're still not going to have the Senate functionality itself, but at least we're going to have
everything prepared so that we can then finally use Firebase correctly.
So far, the only firebase stuff that we had was to get the current user where we use the firebase off
to get the instance and then to get get the current user and then its user or its unique ID.
So every user has a unique ID.
OK, so we have this base activity which we prepared in the last video.
Right.
And it's off type of combat activity.
Now we want to reuse this base activity or we want to inherit from this base activity in our sign up
activity because we want to be able to use all of the functionality of an app combat activity.
But at the same time of our basic liberty, which contains features such as displaying the snack bar
when an error occurs or displaying the progress dialog.
All right.
So in our sign up activity, let's go ahead and create two functions.
One is just going to be there to validate a form so private fun validate form where we have the name
and the email and then finally the password.
And it should only have to pass this password, which is also substring.
OK, so we get all of those values and then we want to see if what we have gotten is not empty.
So we want to basically just see has the user entered something or not.
So we're just going to return when the textual details text utils is empty for the name.
What do we want to execute then?
Well, we're just going to show the error snack bar and we're going to say, please enter a name.
And we were going to return false in this case.
So you can see that this function should return a boolean.
OK, so here at the top, let me bring that into line.
So here, validate, form, name, email, password.
And it's going to return a boolean.
So when false return when false.
But then what other options do we have?
Well, we have the other option where the Texas Empty Fort e-mail, so here, let's replace this with
email.
Please enter and email.
And then the last one, well, to be precise, email address.
All right, let's just do that again for the last one.
It's the password.
So we're checking.
Is the password empty?
If it's empty, please enter.
A password should be displayed to the user and otherwise return.
True.
Uh, actually, just going to be a true.
All right, so here, of course, else needs to also be in a lot expression, so else return.
True.
OK, so this is the idea of this validate form.
Now, of course, we need a function which will use this, and I'm just going to create a function which
will register a user.
And for now it's just going to prepare everything.
So private fun register user where I have the name, which will be of type string and which we get from
etty name dot text to string.
And what I'm going to do is I'm also going to trim a little bit.
So let's say the user has entered a empty space somewhere in between.
Then I want to clean that up as well.
So trim curly brackets I t
less equal empty space.
OK, so this is how you can trim something so we can trim, for example, an empty space that the user
has entered to at the end of the human address or of the name.
This happens quite often when you copy and paste something.
Right then we have the same thing for the email, so.
Let's do this for the email, which is also a string, but it's ETTY email, by the way.
Where do I get them from while they are inside of our activity?
Sign up, SML.
OK, so that's where I'm using those from same for to email.
It's this one here.
And then let's do the same thing for the password.
So here password, not a question is, do we actually want to trim an empty space or not?
Maybe the user has added an empty space in his email address, but I'm just going to assume that it's
not the case or, I mean, in this password.
But I'm just going to assume that this is not the case.
So I'm just going to trim it in the password as well.
So if you have an empty space in your password, it's not going to work with our application.
So this is something that you can potentially leave out.
It really depends on how you design your login features or your sign of features.
OK, so if.
We validate the form with all of those names and emails and everything, and it returns true, then
we want to actually register the user.
So only if all of those values have been entered.
Here to name the email the password and then the user press sign up, at that point we want to sign
him up, but only if he entered values.
OK, that's the idea behind this validate form.
And for now, we can just do something, a basic test to see.
That we can register a user, so let's just test it real quick.
So I'm just going to paste a little toast in here.
Now we can register a new user or we could write something like registration, complete or worked or
whatever.
OK, so of course, we need to call this function somewhere.
Register user.
Where would be a good point?
Well, once the user pressed this button here.
So let's look at the button.
What's it called like let's scroll down.
That's called button sign up.
So if Putten sign up is Prest, so set on click listener, call register user.
OK, so at this point, the user click the button and our registered user function should be triggered
where we get the name email password from the edit text, then we validate if they're empty or not.
And if they're not empty, we write something like now we can register a new user.
And of course here at this point, we will then actually do the registration in Firebase.
OK, so I say, let's just test it.
And when running it, we're getting an error here, which says while Google Services Chaston is missing,
so we need to add it in order to use the Google services plug in.
And yeah, let's just do that.
Therefore, you can go to your project and firebase, then to the project settings and here on the general
scrolling down, you will see that there are no apps in your project yet.
So we can add an app.
In this case, we're going to select the Android icon here and here.
We need to enter the name of our project.
OK.
So it's just going to be this name here and my case, it's EU that authorities approach Roger Manaj
and that's why it's important that you have unique names.
Right.
So you should, of course, call your project differently.
And you can add an app nickname if you want to, and you could also add the signing certificate optional,
but I'm just going to register it with the package name.
And if that shouldn't work just with the packaging, then you might need to add the other elements as
well so that you can see you have to go to project and then drag it into your apps.
So let's just download this file.
Then save it here or save it somewhere where you can find it and then go to your project.
Then select project here at the top left.
So you need to move over to project because usually I'm using Android because it's more convenient,
right?
Well, then when it project, you can open your project, then you can open the app folder, and that
is where you need to drag it.
So I'm just going to drag this.
Google Services JSON file into the app folder, and I'm just going to press, OK, once that is done,
we can go back to the settings and.
Google firebase.
Here and press next.
You can see that it says that we should make some changes to our project level build gradle.
Which is basically what we have done before.
All right, so the app on the app level, you need to add this implementation and on the project level,
you need to add this class path, OK?
And if we look at our project, I can see that we already had added that.
OK, so if I move back to Android now.
It's a lot easier to find it there, they're so here, Bill Gradle, that's where we added this implementation,
right?
Implementation Firebase Augmentin and the other one in the project built Gradle.
We have added this class Parva.
Com that Google Jemez Google services for three three, which is the same as you can see here and here,
the implementation as well.
Also the plugin, by the way, you can see that we need to use this plugin, but we've added this already.
OK, and then.
We needed to sink it, but we already have done that, so let's press next and see if it's going to
work.
And of course, we need to run our app to verify so or verify it.
So let's do that real quick.
Let's run it again.
Now, this time it's hopefully not going to crash.
And this can take a little longer than two times before.
As soon as it's done, it's installing and launching the activity, so it's launching our application
and then we can check again.
If it's going to communicate with the servers.
And in case it doesn't, what we can do is we can go out and uninstall this application, so let's uninstall
Project Menasche.
And as you can see, I have multiple iterations of it.
So hot press drag uninstall.
And once you understand that, let's run it again.
OK, this time it was a lot quicker.
Now, let's see.
If the app starts communicating with the service.
In case it doesn't respond or doesn't change here, within a couple of minutes, you can just go ahead
and skip that step.
It still might work later on or still should work later on.
But you will see that your apps, you will find your app here.
And yeah, you can just then go ahead and use this app inside of.
Firebase or with Firebase?
All right, at this point, let's go ahead and test our application because we prepared so much stuff.
So we're InDesign up screen now.
Let's sign up and you can see please enter a name because there's no name there.
So they sent their name.
Let's enter an email address, email at email dot com.
So here at e-mail on this case, it's going to be e-mail dot com and the password is going to be one,
three, four, five, six plus password ever, and then sign up.
And we can see now it can register a new user.
Of course, we're not communicating with the server at that point, but that's what we're going to add
in the next video or maybe later.
All right.
I'll see you in the next one.