Hi everyone in this tutorial we're going to continue building this application.
So first let's run the application.
Now let me show you the emulator and here you can see that these buttons are actually on the top edge
of this view.
There is a problem here.
Let's go back to android soon and let's go to this activity on the last minute exam.
And here you can see that before go to create a constraint from the top edge of this button to the bottom
edge of these critics for example so that you can see this little circle that is pulsating.
So here let's create a constraint to the bottom edge of this.
It takes here and release it.
So now you can see that this constraint is created.
So let's actually change the top margin of this button here cinches this number to number 10.
And then person it'll change your keyboard so you can see that it's not changing.
And it's not allowing this margin here to be actually executed.
I think it's a bug in Android studio and in the newest version of Android studio.
So let's actually select a spot in here again.
Let's create a constraint to the bottom edge of this button here.
Now let's also change the top margin to number 10.
So now that we have this this constraint actually create it let's run the application.
Let me show you the emulator.
So now you can see that these buttons are actually position here correctly.
So let's go back to roundlets studio.
Let's click on this main activity so now let me show you the emulator.
So first we need to actually declare some objects of type text and we need to also create some objects
of a button.
So here inside this main activity class to stay in here private as it takes.
And here I can say EDT.
Enter name but I can't say it is in the name semicolon private.
It takes EDT M8 semicolon private's edit text EDT password semi-colon.
Now let's declare the button.
So private's BOTTEN PTEN signing semicolon and private's button.
And sign up between Sign up semicolon.
So now let's go inside this uncreate method and let's initialize our objects here our value is actually.
So here the first one is it is the name assignment operator.
Let's cast this object to an edit text object find view by ID or ID that EDT.
Idiotcy internet.
EDT enter ne semicolon EDT.
E-mail.
Assignment operator.
Let's cast this object to an edit text object find view by ID or ID that EDT.
Email.
EDT enter the email actually semicolon.
And finally EDT password assignment operator.
Let's cast this object to an edit text object find view ID or that Id dot EDT password EDT Enter password
semicolon and and here I can't see PTEN assigning assignment operator unless this object to a button
object find view by ID or that ID that PTEN sign in semicolon.
And finally here and sign up assignment operator button find you by ID or thought Id Dud's PTEN sign
up semicolon.
So now it's time to connect our Android studio project to the firebase.
So here at the top menu here you can see these tools here right.
Just click on Tools and then click on firebase.
So he had this assistant is actually open right.
So now we have this often dictation.
So look at this description.
It says signing and manage users with ease accept accepting emails Google signing Facebook and other
luggin providers.
So let's click on it and click on email and password and dictation.
First we need to connect our application to the Firebrace So just click on this button.
Now it says starting connect dialog out this window is opened here now we are going to create a new
Firebrace project firebase a fire authentication.
So this is going to be the name of our firebase project.
So here I just need to so here make sure to actually specify a country or region and click on connected
to Firebrace so that this message pops up and says firebase project create it and collect connected
locally to module app..
Now it's connected right.
So now it's time to add firebase often to Kaisha to our application.
So just click on the spot in and click on accept changes.
So here it says dependencies set up correctly right.
So now let me show you the browser here.
Firebrace.
So let's go to console.
Now you can see our project here right.
Firebrace fired authentication.
Right let's click on this one here.
This is the name of our project.
Now let's click on often to cation.
So here let's actually set up sign in Meffert.
Leslie can see this pattern here.
Now you can see this e-mail or passwords right.
So here you can see this a little.
I can hear this pencil I can actually click on it.
Now lets enable this option here.
Email or passport.
And it says allow users to sign up using their email address and password.
Or as the case also provide e-mail address verification password recovery and email address change primitives.
You can actually take a look at the documentation.
Let me open it another tap here so you can see actually the documentation here.
So now let me close this this top here.
So let's click on safe here so as you can see are actually enabled this option.
Let's click on safe.
Now it says e-mail or password enabled.
Right.
So now let's go back to android studio.
So first let me show you these tabs here we can see you can see these.
This users stop if I click on it you can see that it says no users for this project.
So if any users actually sign up to our application we can see those users here.
So let's go back to android city.
And here let me actually close this assistant here.
So now let's actually declared a valuable insight.
Our main activity so just open here private.
And the name of this rally is going to be firebase of and the name is going to be firebase over semicolon.
So let's go inside our uncreate Smurfette here and here let's initialize our variable firebase of so
they've been here firebase of assignment operator and just that here firebase of that get instance semi-colon.
So first of all we need to actually create an effort in order to allow the user to sign up to our application.
So inside this class inside this main activity class here before the curly brace of these main activity
class I'm going to create a method.
So just type in here private's Voyt and the name of this method is sign up sign up user.
We e-mailed and password.
So let's put up her of here.
The first argument the first parameter here of this method is going to be of type streams and the name
is going to be e-mail.
Use that e-mail user e-mail.
Come on.
And the second parameter is going to be again of type streams and the name is going to be user password.
So let's open and closed this method by using the curly braces so insert is Smurfette.
So I can't say firebase of that create user with IIM-A and password here.
So now you can see that this Meffert accepts two arguments.
The first one is going to be the emet right.
So we have an argument here from the Smurfit so I can see a user M8 comma user password.
The second one is password right.
It was a password.
And let me create a new line here.
I can actually put it here because I want to show you that I am going to call another method on these.
And the result of the Smurfette.
So I can't say that at uncomplete listener.
So this is if it actually needs two arguments the first one is going to be the activity here.
So let's specify the activity just like in human activity that this coma and now we need to actually
created the anonymous in a class and you in on your instance.
So just open a new on.
So just put this or here is just hold down the shift key on your keyboard and then present the little
Oceania keyboard uncomplete listener right here right.
So like this one and then press are interchangeable.
So these codes are actually generated for you automatically.
So let me create a new line so that you can see what's going on here.
Let's create another new line here so you can see that first we said firebase ofat create use the read
email and password.
So we passed the use that email and the past for here.
So we get these values from the Smurfette as an argument and we called this move it at uncomplete listener.
And the result of this Smurfette.
So whatever happens this is going to be caught at whatever happens when the user wants to sign up.
These at uncompleted this and it is going to be called.
And we have one Mefford uncomplete So if it is going to be called when ever it was actually for example
successful or it was some kind of error that we can we can actually solve it or for example the users
of internet connection is gone.
Right.
And we have.
Let me let's put a semicolon here.
At the end of this actually practice is here.
Let's go inside this Meffert uncomplete right.
This means that the task is actually completed.
Whether it's was successful or it was actually for but it actually failed.
So it is Smurfit.
I can't say so first but let's check for the condition of actually failing.
For example the user has actually failed to sign up to an application.
In that case I want to show a message to the user that there wasn't a problem and the user can actually
try again.
So I can actually say.
So it just I think he had enough banned or not this is actually the bank operator or the not operator
task that is successful if the process of signing up to the application was not successful.
So look at this bank operator here is not operator then in that case we can actually say just open and
close this if statement by using these curly braces.
You can't say toast that make you text first let's specify the context.
Make sure to just type in main activity that is if you just type in here is that Michoud is here.
If you're just typing here does this he refers to this anonymous in a class here that we actually created.
So this is not correct.
We want to actually refer to the context which is going to be main activity that is.
OK come on.
So the message is going to be that there wasn't a problem.
Try again
OK and come on now let's specify the duration of this message which is going to be length short and
we can't call this method show this use Toast object.
So let me create a new line here.
So that's it.
So now let's create an else statement so this is a statement here is going to be executed.
If this condition he had face this was a statement he had means that the user has successfully signed
up to our application.
So in that case again I can actually create a post message so toast that major text.
So now let's specify the context which is going to be main activity that this come up and the message
here is going to be actually 6.
You are successfully you are successfully signed up signed up to signed up.
That's OK.
And now I can actually specify the duration so come up I can say lenth short that show that we create
a new fly here.
So that's it.
Now if they use it to successfully signed up to our application now we need to specify the user profile.
So when the user actually is signed in the user can actually see the display the name the display name
the image or any other for example values.
So now after this toasts message we are going to call another method and that if it is going to be specified
specified user profile lets put up in our practices here semicolon.
So we have not created this method yet.
Right.
So let's scroll down here.
And after the curly brace of the Smurfit and before the end and calibrates of this class let's create
another method.
So just like in here private void and the name of this is going to be specify a user profile.
Just put a pair of parenthesis here and open and close this method by using these curly braces.
So inside is curly braces.
I can't say.
So just typing here.
Firebase user just referred to this one here firebase user and the name is going to be firebase user
assignment operator.
So now I can say firebase oath that gets instance that gets callant user.
So first we need to get the current user firebase user of our application.
Right.
And then after this line of code I can say if firebase user is not equal to gnarl then I can open and
close this statement by using these curly braces.
So here I can actually say user profile change request so lets create a variable after you use a profile
change change request and the name is going to be user profile change request assignment operator new
user profile change request that builder here.
So now let me create a new line here not to step in here at DOT and here you can see that we can specify
the display name and the photo you are right.
So first in this application we just want to specify the display name and just type in here said display
name.
So we are ready to get the display name from the EDT name right at the emulator.
So here we the user enters the name right.
So we are going to get the display name from this from the value of this text.
So instead the apprentice's I can say.
EDT.
Name that get text.
That too is strange.
And then here finally we are going to actually call this method that pilt here.
If you want to you can also specify the photo you are.
I just step in here that said photo.
You are right but for this application we just want to specify the display name because the later in
the welcome screen and the other will welcome a screen.
We are going to get the display name from the user and we're going to show it to the user.
So just typing here just call this method that's built and semicolon.
So after this line of code here let me create a new line here so that you can see what's going on.
After this line of code I can refer to this firebase use that valuable that up date profile update profile.
And here we need to pass this a variable of type if it does one user profile change requests or just
past this user profile change request thought at uncomplete listener OK new and just hold the shift
key on your keyboard and then press on the little Or key on your keyboard and then present it on your
keyboard.
So now let me create on your line and after it is the end in practice it's just put a semicolon and
inside is accomplishment.
Here we can say that we have this task here right and we can see if task that is successful we can open
and close this statement by using the curly braces.
Let's create an else statement for another condition that actually the task was not successful.
So if we just show our message to the user here and that may create a comment here task was successful.
OK and here inside is else black I can't say task was not successful.
So later we're going to get the display name from the firebase user.
But for now just look at this method here and just understand what's going on here.
First we're getting the firebase user and we are checking that if the firebase use that is not known
then we are going to actually say user profile change request and we are going to specify the display
name the display name is going to be this one editing that takes the string.
And finally we are going to call this method build and then we are going to say firebase use that update
profile.
And we say user profile change request that at uncomplete listener.
So that's it this is our method.
Now let's create another I'm afraid.
In order to allow the user to sign in to our application.
So again before the end in curly brace of this main activity class I'm going to create another method.
So here just typing private void and the name of that effort is going to be signing the user signing
the user with e-mailed and password.
So let's specify some parameters for this method.
The first one is going to be for the e-mail which is going to be a stream and the name is going to be
e-mail.
Use that e-mail actually use e-mail.
Come on.
And the second parameter is going to be a again of type strange and the name is going to be used a password
user password.
So let's open and close this method by using the curly braces here.
Now inside the Smurfit I can say firebase oath firebase oath does signing a signing with email and password.
So if you need to pass the email first so the email is here.
Use an email comma and the password is going to be use a password dot at uncomplete listener at uncomplete
listener.
So here instead Apprentice's just a point here new and then here just hold down the shift key on your
keyboard and then press on the little all key on your keyboard so that you can see this option.
Uncomplete listen at here right.
And then press on your keyboard so that Android studio puts out these codes here automatically for you.
So lets put a semicolon here at the end of this prentices.
Now let me create a new line here so that you can see what's going on here.
First we actually referred to these firebase of instance and then be said that signing with email and
passport.
So if you passed these user email and this use a password that you receive as arguments from the Smurfette
and we said that at uncomplete listener.
So inside this uncle uncomplete my friend here we can actually to say.
So you can see that we have this task object as an argument of these accomplis methods.
Let's check for the condition that determines that the user has actually failed has been faked to sign
into our application.
So I can't say if not task object that is successful if the task of director is received is not successful
here then this means that the user is paid to sign in to our application.
So in that case we can actually show a message to the user in order to let him or her know that the
signing process was not successful.
So I can say that Mike takes the first minute to pass the context which is going to be main activity
that does come up.
And the message is going to be.
For example there was an error.
There was an error come up and then we can specify the duration then short data show data show.
So let me create a new line here so that you can see what's going on here.
Now we can create an else statement.
So this Atlas Plug here determines that if the above condition this one is actually false This means
that the user has successfully signed in to our application.
In that case we want to transition to an all other activity so we don't have that activity yet.
So let's actually put this courtsey of let's create an Internet object here into it and we can say well
come intent will come intent assignment operator new intent.
So first we need to pass the context which is going to be main activity that these come are.
And now we need to pass the class or the activity that we want to transition to.
So we want to transition to the Vellacott activity which we has not created yet so we can say well come
that class color.
So now say it's thought activity will come in.
And finally we want to close the colorant activity.
We want to eliminate the cult activity from their views.
So we can say finish.
So it when we call them if at finish the cult activity is going to be eliminated from the views.
So now let's actually open our review here.
So now we're going to create a new activity so just open this up for them open the door for her.
So that now you can see this package right.
Right click on this package new.
And now let's click on this activity and let's go to these Actually it is empty activity and the activity.
So the name of the activity is going to be wellcome.
OK this is the name of the activity and it's going to generate a lay out a name or lay out file actually
with this name activity on it like Wellcome and it's going to have a backwards compatibility make sure
that this check box is not checked.
Lots of activity this development if it is not going to be that lot of activity.
A lot of activity is going to be the main activity.
OK.
And this is the package name.
Let's get it unfinished.
So let's wait a little bit here.
OK.
So now that they're welcome activity is created.
Let's go to our actually at the welcome screen.
Let's open our test folder here and let's open the layout folder and you can see that this activity
underlined Welkom is actually created.
This one is exemplified.
Let's start because Handyside.
So now let's try a text view into our constraint lay out here so here inside the pallet section you
can see this takes you to distract the states here and put it under center here of this screen and you
can see that are some constraints and actually created here.
So selectees takes you first of all let me double click on the stop in order to make this area wider
select is text view.
Let's give an ID to this text.
So the idea is going to be TXI the Wellcome and then person until Chanur keyboard.
So now I think the position of this view is actually good if you want to you can actually change the
position of the text view.
Now let's try a button here into this.
Lay out here and put it here so you can see that our constraint is actually created to the right of
the screen and another constraint is actually created to the left here on the left edge of the screen.
So now let's create a create a constraint to the bottom of this takes you let's create a constraint
from the top edge of this button to the bottom of the state's view so you can see this little circle
that is pulsating.
So let's actually create this constraint here to the bottom of the state's view and let's change the
top margin to 20 and then present until January 3rd.
So now let's select the spot and let's keep an and it is button so the button is going to be between.
Sign out and then press on until your keyboard.
So now let's leave a text or text value to this button.
So the text is going to be.
So here you can see the states attribute the text is going to be sign out sign out
from the from the
and then press Enter key on your keyboard.
So this is the text of this button.
So let's go to our welcome activity class here.
Inside this class let's declared an object a value of type takes few.
So just they've been here a private text view private text view and their name is going to be the Wellcome
semicolon.
Private button and the name is going to be PETN who actually sign out and sign out semicolon.
So let's go to our uncreate method here.
And first let's initialize RTX the welcome here so we actually welcome an assignment operator and land
at an inside Apprentice's just cast this object to a text view object find view by ID or dot ID DOT
takes the welcome the XTi the come semicolon and then let's refer to our PTEN sign out.
Assignment operator let's cast this object to our button object find view by ID or that ID that PTEN
sign out semicolon.
So now that we have actually initialized our objects here.
So let's create a listener for this spot and so here I can say between sign out that sits on click listener
knew and then hold the shift piano keyboard and then present the little Vicci on your keyboard.
Select this option here uncle or cousin it and then person on your keyboard so that is going to create
an anonymous in a class here and that anonymous in a class is going to actually implement this uncle
class or interface.
And then we have this uncle Mefford override it here.
So now that we actually initialized objects and we actually created our listener for the Spartan.
So let's go back to our main activity class here so you can see that we create has some if it's here
and we haven't still called this method from anywhere inside this class.
So we have this Smurfette here sign in.
They use the read e-mail and password.
We have this specify user profile so we called the Smurfette does specify user profile from the Smurfette
from Sign-Up user with email and passport.
But we haven't still called dismembered from anywhere inside our class.
So let's scroll to the top here let's go into these uncreate Smurfette.
So you can see that we have two buttons here right.
We have this between signing and between Sign up.
So let's create a listener for both of these buttons.
First of all let's create a listener for the city and sign up button.
So let's say BT and sign up that set and click listener new and then hold down the shift key on your
keyboard and then press under the original keyboard.
Select this option here so that so that the Android studio is going to actually write all the codes
for you and the person in the Intel channel people.
So now let's create a listener for their beauty and sign in.
So just here between signing data sets uncooked listener new view that unclick listener so you can see
that here.
Right.
So let's go into our Actually Betty and sign up that Satanical question.
And inside is onco Smurfette here.
First of all we need to get the e-mail we get the e-mail from the EDT e-mail and we get a passport from
the EDT passport because we want to get these values from the user.
So the input is going to be provided by the use of.
So let's say let's create a local variable here inside this uncle Mayford strange and the name of this
variable is going to be user user made like assignment operator.
So now let's actually refer to our EDT email that just text that to strange semicolon.
Now let's get the passports from the user again.
Let's create a variable of type street the name of the variable is going to be user password assignment
operator.
And again EDT password.
That's a text that stream semi-colon.
So now that we have to use that email and they use a password here now we can actually call that sign
up the users beep email and password Meffert that be created inside our class.
So let's actually first of that method sign up sign up the user with email and password.
Choose this one.
Sign up users with email and password.
Now if it needs to arguments.
So let me call this Meffert again so that you can see those arguments.
If the first argument is going to be use it and the second argument is going to be used that passport.
So if you have to use an e-mail here and the use of Hallsworth here so this user e-mail Khama user password.
Right.
So now let's go to our Betty and sign in that certain click listen in my foot here and inside his uncle.
Again we need to get the e-mail and the passport right.
So let's copy these two lines of plot here inside this uncle of this PTEN sign up that said Uncle Clisson
let's copy these two lines of code and let's paste it here.
And now we can actually call this Smurfette signing the user with IIM-A and password.
OK at this time let's call this method saying the user will email and password.
So again we need to pass that use an e-mail comma and user password right.
So that's it.
So now that we actually provide some implementations for these two methods here we can run our application.
So first let me let me open the web browser.
So here it is my firebase console and you can see that I actually click on it clicked on often location
and it says no users for this project yet.
So let's go back to our Android studio.
Let's run our application let's select one of these devices and then click on OK.
So now you can see that our application is running on the simulator.
So let's pro-white our name for the user.
So the name of the use that is for example person person a right and let's provide an email here for
example I can say person A at sign exampled dot com example that's come and here the password of the
user.
We can't say a b c d.
One two three four five six seven eight right now if I click on signing now it says there was an error
right.
We cannot sign in because the user is not signed up to our application yet let's get he can sign up.
Now it says you are successfully signed up.
Now if I go back to our firebase consul here let's actually refresh this page here.
Now you can see that this person here is actually created the identifier is this email.
And you can see the date of the creation signed in here the signing date.
And they use edu I.D..
Right.
This is actually a unique value for each user.
So now let's.
Let me show you the emulator.
So now I want to sign in.
Let's go to consignee.
Let's wait a little bit here.
Now it transitioned to this welcome activity here.
And you can see that we have nothing in place of this text view and we have this button here sign up
from the from the app.
If I click on this one button here nothing happens.
So let's go back to our Android studio here.
And now let's go to our welcome activity.
So here let's create an instance of type firebase.
OK.
So here inside this welcome class let's create a variable of type of firebase of firebase 0.
And the name of this instance is going to be firebase over semicolon.
Let's go into our uncreate method here and let's initialize initialize our firebase of so let's refer
to these fires of assignment operator.
And here I can say firebase of that get instance semi-colon.
So now we have an instance of the fire.
Right.
So here let me show you that.
Let me show the firebase concert here.
Let me show you that if you want to I can actually delete this user here.
I can just click on this ellipsis button and here I can click on delete account or disable account or
reset passport.
So let's go back to android studio.
So here I want to check for that condition here.
So now after this line of code after getting the instance of the firebase off I can say if Firebrace
oaf that gets current user gets kind of user is equal to Gnarl.
This means if the current user does not exist or if the current users account is actually deleted then
I don't want the user to be inside this activity.
I want to actually go back.
I want the user to move to the main activity here first I can say to create an intent here so intent
main activity intent may activity intent assignment operator.
So here we can say new intent and then first we need to actually pass the context which is going to
be a welcome that does come up and then we need to pass the class that we're going to transition to.
So the class is going to be main activity that class main activity that class semi-colon.
So now that we have this intent here I can see start activity.
So now we need to pass the intent main activity intent.
And finally I want to close this activity the current activity level comm activity.
You want to eliminate the current activity from the view stacks so I can say finish.
Right.
So now after this if statement here I can create another if statement and I can't say enough firebase
of that gets current user is not equal to knol.
This means that actually our ease of use they're here inside that application and the kind of user is
not equal to anon.
That means that we have a user right.
So now I can CTX TXI the Welkom that set text and I can put two coats here and on here I can say how
are you.
How are you comma space.
Plus I use the concatenation operator here.
Firebase oath that gets current user that gets this plaining that get display name.
That's it.
In this way we get that explaining from the user.
So you may remember that we actually created MFX inside our main activity class here.
And this is them efforts specify user profile.
And here we are specified.
They use their display name here right set to display name it its name but it takes that to strange
right.
So inside this Welkom class we are getting the display name from that value and we are sitting that
this plane into this text the Wellcome.
So now it's time to actually implement this Arncliffe method here of this city and sign out that said
unclick the center first of all we want to sign out from the firebase.
So I'm going to say firebase oath that sign out.
OK.
It's as simple as that by just calling the Smurfette on our Firebrace into instance we are going to
sign we're going to get signed out from our Firebrace project.
And here time to actually write the codes in order to let the USEF to go back to the main activity to
the luggin page actually.
So now we have actually already created these quotes here inside our statement let's copy these quotes
here and let's paste them here inside.
It's unclear if at and below this line of code first we created this intent and then we called this
Meffert.
And finally we called the finish of it.
OK.
So now let's run our application again.
Let me show you the emulator.
So here we have the name of the user.
So for example the name of the use that is for example be e-mail that user is the person the person
at sign example does come and the password of the user is for example 1 2 3 4 5 6 A B C D E F.
OK.
So now let's click on sign up.
Now it's going to say you're successfully signed up to our application to the app.
Now you can see this message if I go to our firebase console let's refresh this page here.
So here you can see these are actually the image here.
This is actually signed up successfully.
Let's let me show you the emulator.
So now let's sign in.
Now it says how are you.
Be and we have this button sign on from the app.
If I click on it now we're going to get signed out from the app.
Right.
So that's it.
If I go back to android studio we can add another functionality and extra functionality to this application.
Let's go to our main activity class and let's go to our uncreate Smurfette here.
So here after getting the instance this firebase of instance year we can actually say if firebase oaf
that the current user is not equal to Gnarl.
This means that a user already actually created an account and signed it signed into the firebase app.
Then in that case we can actually just transition to the Welcome screen we can create and intent here
intent Wellcome intent Welkom intent.
As Simon approached your new intent and first we need to pass the context which is going to be main
activity that this karma Welkom that class Wellcome thought class semicolon and then we can say start
activity Welkom intent.
And finally we can actually call this method finish so that that this view here is I mean I think it
is going to be removed from their views.
OK.
So let's run the application now.
Let me show you the emulator.
Now we can see.
So for example let's actually for example say name of the user is see the email of the use it is.
See person C per cent as an example that's come and pass will of the use that is for example again one
two three four five six seven eight is s the b c v.
OK.
Let's click on sign up.
Now it says you are successfully signed up to the app.
If I click on signing.
OK so now you are signing into our application.
So not is that we are still signed into our application and now you want to actually close this app.
Ok close.
So let's go back to android studio let's run the app again.
Let me show you the emulator and now you're going to automatically signed up signed in to our firebase
app.
You can see that here.
How do you see sign out from the app.
That's it.
So these are actually capabilities of the firebase backend.
And if you want to if you want to add more features to your application make sure to actually firebase
documentation or searching that stack overflow in order to solve the solution for your problems for
your program problems.
And then you will be able to actually create awesome applications.
So that's it.
If you have any questions please post the discussion in the course and then I do my best to answer all
of your questions.
Thank you very much for watching and I'll see you in the next tutorial.