Welcome back.
And this video, we are going to set up the authentication system, at least signing up because we need
both ways, right?
We need to be able to sign up and then we also need to be able to sign in.
And, of course, in order to be able to sign in, we need to have a user with the data.
And so we need to sign up before.
OK, so if you want to know all about it, I in general would recommend to check out documentation any
time that work with something, check out the documentation to get a better understanding of what is
going on and how things work and so forth.
So here, for example, in the documentation you can go to Geitz and then in Android or the Android
user custom system.
So it cost custom authentication system and there you can check out how it's done.
So you need to add something to your bill to Gradle, which is this implementation here.
And then when you scroll down you will see that you can find the code in Java and in Scotland for Android.
And it just shows you what kind of code you will need in order to create a new user.
OK, so we're going to set all of that up.
I would still recommend to check out what you can see here.
So email link authentication.
So if you want the user to be able to only authenticate via a link once you registered or if you want
to allow Facebook login or Google sign in.
So you can see there are many different options available here.
But we're just going to use this custom all system, custom authentication system, which is a email
system.
So it's going to be very basic and simple for our testing purposes.
But at this point, you should be able to read through documentation and use other kind of authentication.
Here, for example, if you want to use the Facebook login, you can find the code here and it will
show you how you can implement that to your code or to your project.
All right.
So, of course, you need to have a project in Firebase and therefore you need to have a Google Mail
account or Gmail account and you can go to the console via the button here at the top.
Right.
Or you can just go to a console that firebase dot Google dot com and then log in with your account.
And by this, of course, I mean your Google Gmail account.
OK, then you can create a new project.
And by the way, if you want to create projects, you have to have a payment system or payment data
in the background.
So you need to set things up in Google for this to work, OK?
It's not going to cost you as long as you're not using or as long as you don't have hundreds or thousands
of users who are using your application.
Only at that point it will start to cost.
But if you want to know more about it, definitely check out the payment structure of Google Firebase.
All right.
So at this point, we can give it a name.
And I'm just going to call this one project manager or Project Manoug.
And then you can see it gives me the internal name Project Manager 96 EDV.
So let's continue.
Then you can implement the Google Analytics for Firebase projects, which will give you a B testing
features, creg for free users features and so forth, so we can just leave it installed or leave it
active.
You can see it's free.
Unlimited reporting.
Don't press continue, and here you need to sign a Google analytics account if you have one, otherwise
you need to create a Google analytics account at this point.
So I'm just going to choose mine that I already have and I'm going to create a project.
This can then take a little while, but as soon as it's ready, we can go ahead and use it.
All right, there we are, he says your new project is ready, so let's go ahead and continue.
So there is our project Manaj project, and you can see that we have a bunch of options here on the
left hand side, which is pretty good because we, first of all, need, of course, authentication
because we need to create users and then, of course, authenticate them.
Then you can see here we have something called a database, we have storage functions, machine learning
kit and hosting the ones that we're going to be in.
It's going to be authentication database and storage.
And when it comes to the database, there are different options.
So the there is this option of the real time database and there is this option of the cloud forest or
we're going to look into the differences later on.
But for now, just know that we're going to use a cloud firestorm because our application is going to
use a many to many relationship.
And when you have something like that and cloud storage is a lot easier to handle and also a lot more
performant than a real time database.
But in short, if you have an application which just displays a very limited amount of data or where
there is no direct relationship between every user and another user or a user and another board in our
case and so forth, then the real time database might be the better choice for you because it's, uh,
it's just made for these kind of applications.
OK, for now, however, let's go back to our project.
Let's go to our blog at Gradle, but this time the project won and here we need to have a nuclear dependency.
So let's add a new dependency.
And the one that we're going to use is this one.
OK, so it's going to be com that Google, that James Colon, Google minus services colon for the three.
The three is the one that we're going to use here.
So once you've added that, sink it.
OK, so sink the project.
And then we need to add a plug in once the creative process is done and our built out cradle, which
is the module app, so you can see currently we are in the project one, but then we also have this
module, app one.
And here I need to add a new Plug-In.
And the plugging that I'm going to use is the following.
So apply plug in come that Google that James, that Google minus services.
All right.
And the next thing is we will also need to implement a dependency.
OK, so in the same file, scroll down all the way to your dependencies and then add this implementation
here.
OK, implementation conduct.
Google that firebase and firebase minus auth column 19.
Dot 2.0.
Once you have added that, also sink it, so let's synchronize it.
All right, next thing is that we're going to set up a new activity, and before we do that, I think
it makes sense to clean up our project folder a little bit.
So currently we just have this one folder in which we have all of our activities.
But now we are going to also add models and to help our classes and so forth.
So let's go ahead and create new packages here.
So one is going to be the activities package and I want to drag all of those activities inside of this
activities class and or activities folder.
And then we need to refactor and it says count multiple one.
So let's move one by one refactor.
And then the next one and so forth, so we need to drag all of those in there because, as I said,
we will have multiple more classes and it's going to be something like 20.
So it really makes sense to have it all tidy and separate it so that it's easier to find everything
you need once you need it.
All right, so these are the activities and then we also need to create a new folder.
So new directory.
Also, a new package, and it's not going to be inside of activities, it's going to be.
Model or models?
And then let's create a new one.
You package and I'm going to call this one.
Utils.
And for now, let's just leave it with that.
OK, so inside of activities, I will create a new activity and this one will be an activity that we
are going to use to reuse several functions that we're going to need in multiple different activities.
OK, so let's go ahead and call this one based activity based activity.
And the first thing that I'm going to add in here is the ah, so we need to import.
Ah, OK, then as you can see, it's inside of our activities.
So this base activity is basically going to be our replacement for the EP combat activity for our our
other activities.
OK, so currently our activities are inheriting from EP combat activity.
If you look at interactivity, for example, you can see it's inheriting from a combat activity.
If you look at all of our other activities, they all do.
But now if we want to put something in between which we can then reuse all the time, then we can just
make everything inherit from our base activity.
So let's just do that.
Let's say that it should inherit from base activity.
Now, at this point, we need to make base activity hoeben, so let's look at it, you can see now it's
an open space activity.
And we will later on do that for all the other activities.
OK, but for now, let's go ahead and create a variable here, which I'm going to use for tracking the
back button functionality.
So double back to exit pressed once as I'm going to call it, so to false.
So the idea is if the user pressed back twice, then the application should close.
Just as an example, then I need a dialogue.
So I'm going to create a late init variable called M Progress Dialogue, which will be a dialogue.
OK, so the idea behind this dialogue is that we want to display a.
Progress dialogue to the user each time that something is loading at this, will I pretty much happen
in every activity?
Right.
So the user wants to sign in.
Of course, it's not going to happen instantly.
It's going to take a little while.
So even if it's just a couple of milliseconds, but still, it's good to have something that displays
to the user.
There is something happening in the background, such as logging in, such as storing the data, such
as loading the data, those kind of things.
So we are going to require this and we have used this quite a lot already.
Right.
So we have worked with progress dialogues multiple times.
So I think I'm not going to surprise you when I had this progress dialogue function here where I'm assigning
or initializing our end progress dialogue, which is displayed in a variable with the new dialogue,
then setting the progress dialog content for you to be a dialogue, progress, which we still need to
set up.
Inside of that, we have a TV progress text which we assign to text.
To that, we pass to the show progress dialogue function, OK, and then of course we show this dialogue.
So let's create this layout so this dialogue progress XML file, let's go ahead and create that.
So let's press, OK, and here basically it's just going to be the progress bar with a TextView, as
we have used it multiple times in this course already, we will need some more dimensions.
So let's add the dimensions and texts to our project as well.
So here, values, dimensions.
So here at the very bottom, I'm just going to add those four dimensions here, progress, dila content,
putting progress, bar size progress, text margin start and progress, text size.
OK, so going back to the dialogue progress, it's just we're missing the string.
So let's go over to the strengths as well.
And let's add this little string in here.
So the string should be actually with two strings that we're going to need.
One is going to be please click back again to exit and the other one is going to please, please wait.
OK.
Now in our progress.
You can see it's just as little progress as I can, and then the police wait text.
So TextView and before that, a progress bar, which is this sort of circular item that we have there.
And in my case, it's complaining about this progress text so less imported from our progress dialogue.
OK, so this is going to be the function to show a progress dialogue.
Now let's add the function to hide the progress dialogue.
So it's basically just going to be dismissing our progress dialogue.
And then what we will need is to get the current user I.D. and this is going to be the first time where
we're actually going to use Firebase.
So fun you function get current user ID, which will return a string.
So it's going to be a unique user idea that we will get as a result and it should return Firebase.
Authentication so of get instance, current user and from the current user, the unique ID.
OK, so let's import Firebase for this to work.
So this is how we can get the current user ID.
We will need that in order to display the relevant data.
So, of course, we only want to show the user the project that he's assigned to and the tasks that
he's assigned to and nothing else.
Right.
So that's the idea behind this.
Then we need a function to double back to exit.
So if somebody presses the back button twice, he should just.
Close the application, so we're just going to check if double back to exit pressed once is true, if
it's true, then do the super on back press function and return.
And then.
Otherwise or on top of that, this portable back to exit press was going to set that to true because
at that point it already would have been pressed.
So let's say we press it, we press it again.
So if it was pressed already, then he would go back.
But if he only pressed back once, then we want to display something to the user.
So it's not really going to close the application directly, but it's just going to display to the user
a little toast.
OK, so when he pressed back once, it's just going to say, please click back once again to exit the
application.
So the first click is just going to show this text and the second click will actually do the on back
press functionality.
So we don't want the user to accidentally close the activity that he's in and that's how we can make
sure of that.
All right.
And then.
We want this to happen with a little delay, so if the user didn't press back for a little while, then
we want to reset everything.
So reset the back button functionality, so to speak.
OK, so let's say you press once and then 20 seconds later you press again and then suddenly you won't
see the screen anymore.
So what we can do is we can use the handler again.
It could just say handler, do something a little bit delayed.
So let's import Tendler real quick so that we can actually use it and Android os this one and then use
post Delate and here we can run some code.
And the code that I want to run is I want to double pressed to exit false after two thousand milliseconds.
So basically if the user pressed back twice to beg pardon twice within two seconds, then it will close
the application or close the activity that he's depending on where he is.
OK, so that's the idea behind this whole double back to exit function.
And then I want to display the arrows to the user about not just in a very super short toast, but actually
in a snack bar.
OK, so if the user gets an error for some reason, I don't know, the Internet connection doesn't work
or the operation didn't work, then we want to display an error and that should be available in all
functions.
Right, or in all of our activities, to be precise.
So we want to have a message that we want to display when we call this function and we want to display
this message as a snack bar.
So let's create a snack bar here.
If you don't know what a snack bar is.
Check out the video and snack bar.
So basically, it's a little text at the bottom of the screen that says something to the user.
In our case, I want to use snack bar, dot make and here.
Fine view by ID and droits, our I.D..
That content.
Then after the closing, Prickett, the message that we want to display, then snack bar thought length
along.
OK, so let me put that into multiple lines, so that's a little more readable.
So we create the snack bar, we make it, we find that you buy the Android content.
So we displayed in the content.
We display the message that we prepared and we display the snack bar for a comparatively long time,
even though it's just going to be a couple of seconds, OK?
And then I need a snack bar view, which will be my snack bar that you and I need the snack bar view
in order to, for example, set my individual background color.
So if you want to have an individual background color, you can do that this way.
OK, so in an area it might make sense to change the color to, for example, a red color.
OK, so here I'm going to say context compared, get color for this.
And are that color that snack bar.
Error color.
Of course, we need to set that color up, so let's import the context combat and then let's create
this color.
All right.
So let's create color resource, Napat color.
And actually, maybe not this way, but let's go to our callers.
Year and resources, they'll use colors, XML.
And let's add that snack bar, so here, color, name, snack, bar or color, which will be hash F
seven two four zero zero, which is going to be a very red color.
All right.
So let's see.
The arrow disappeared.
All right.
That's very good.
OK, and then, of course, we need to show the snack bar, right.
So just preparing it is not going to be enough.
So we prepared to snack bar.
We added that the snack bar views.
So the subway edited to how the snack bar is going to look.
Right.
But then we need to display the snack bar by showing it.
OK, snack bar show.
All right, so I'd say we make a pass here because it's going to be a mother part where we actually
are going to set up the signing up feature.
And yeah, let's just go there.
See you in the next video.