Skip to content

Commit 053ba68

Browse files
committed
Added screenshots for "Enable login"
1 parent 39067fb commit 053ba68

File tree

11 files changed

+20
-13
lines changed

11 files changed

+20
-13
lines changed

codelabs/chat/README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ In this section we made our app show the chat messages. It was a lot of work, bu
323323
As a final step, we're going to allow the users of our app to log in using email and password.
324324

325325
1. In the Login & Auth tab of your Firebase dashboard, enable Email & Password authentication
326-
[screenshot:enable email+password auth]
326+
327+
![Enable email+password auth in dashboard](images/6_1.png)
328+
327329
2. First add a button to the top right of activity_main.xml
328330

329331
<Button
@@ -335,8 +337,13 @@ As a final step, we're going to allow the users of our app to log in using email
335337
android:layout_alignRight="@android:id/list"
336338
android:layout_alignEnd="@android:id/list" />
337339

338-
[screenshot:main_activity.xml with login button]
339-
3. Now create a new layout called dialog_signin.xml, which we'll use to model the body of the sign-in dialog
340+
![main_activity.xml with login button](images/6_2.png)
341+
342+
3. Now create a new layout called dialog_signin.xml
343+
344+
![Menu option to add a new layout xml](images/6_3.png)
345+
346+
4. In this dialog_signin.xml, we'll model the body of the sign-in dialog
340347

341348
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
342349
android:orientation="vertical"
@@ -367,7 +374,7 @@ As a final step, we're going to allow the users of our app to log in using email
367374
We have two `EditText controls` under each other, one for the user's name, the other for their password.
368375
The rest of the popup will be handled by a stock Android dialog.
369376

370-
[screenshot:dialog_signin.xml (or maybe the design view)]
377+
![dialog_signin.xml](images/6_4.png)
371378

372379
4. Since our app will display the sign-in dialog as a popup, add the handling to MainActivity.java:
373380

@@ -396,11 +403,11 @@ As a final step, we're going to allow the users of our app to log in using email
396403

397404
This method builds and show the dialog, with our two text boxes as the main body.
398405

399-
[screenshot:login dialog]
406+
![Login dialog](images/6_5.png)
400407

401408
When the user clicks OK, it extracts the email address and password from the text controls.
402409

403-
[screenshot:login OnClickHandler]
410+
![login OnClickHandler code](images/6_6.png)
404411

405412
5. Now wire the values that we got from the dialog to the Firebase Authentication back-end. Replace the `TODO` with the following code:
406413

@@ -419,15 +426,15 @@ As a final step, we're going to allow the users of our app to log in using email
419426

420427
Either way, we next call `authWithPassword` to authenticate the (pre-existing or just-created) user.
421428

422-
[screenshot:OnClickHandler with the login behavior]
429+
![OnClickHandler with the login behavior](images/6_7.png)
423430

424431
6. With the above we have the registration/login flow working. But we still need to listen to when Firebase Authentication tells us the user has been authenticated, so that we can store the username and use that in the chat message instead of the hard-coded value we have now.
425432

426433
Add a field to the class to hold the user name:
427434

428435
String mUsername;
429436

430-
Add the end of the `onCreate` method, add a callback method that listens for authentication state changes in Firebase:
437+
Add the end of the `onCreate` method, add a callback method that listens for authentication state changes in Firebase:
431438

432439
mFirebaseRef.addAuthStateListener(new Firebase.AuthStateListener() {
433440
@Override
@@ -445,15 +452,15 @@ Add the end of the `onCreate` method, add a callback method that listens for aut
445452

446453
Firebase calls our listener whenever the authentication state changes, so whenever the user logs in or out. When the user logs in, we store their email address in our field and hide the login button.
447454

448-
[screenshot:authstatelistener]
455+
![AuthStateListener](images/6_8.png)
449456

450457
Firebase Authentication supports multiple authentication providers and each of them exposes a different set of data. For example, if we'd allow our users to authenticate with their existing Twitter account, we could identify them by their twitter handle.
451458

452459
7. Finally, replace the hard-coded username with the field we just populated:
453460

454-
mFirebaseRef.push().setValue(new ChatMessage(mUsername, message));
461+
mFirebaseRef.push().setValue(new ChatMessage(MainActivity.this.mUsername, message));
455462

456-
[screenshot:messages with one from [email protected]]
463+
![messages with one from [email protected]](images/6_9.png)
457464

458465
We could definitely improve the layout of things. But this step has been long enough as it is. So let's wrap up with a few notes.
459466

@@ -465,7 +472,7 @@ Add the end of the `onCreate` method, add a callback method that listens for aut
465472

466473
9. If you want to know which users logged in to your application, you can find them in the Login & Auth tab of your Firebase's dashboard.
467474

468-
[screenshot:auth dashboard with some users]
475+
![Auth dashboard with some users](images/6_10.png)
469476

470477
This is also where you can configure the password reset emails that you can send to your users, in case they forgot their password.
471478

@@ -475,7 +482,7 @@ Wrap-up
475482

476483
Congratulations! You've just built a fully functional multi-user chat application that uses Firebase to store the data and authentication users.
477484

478-
[screenshot:app]
485+
![Chat app with login](images/0_1.png)
479486

480487
As a reward for finishing the codelab you’ve earned a promo code! When you’re ready to put your Firebase app in production, you can use the promo code `androidcodelab49` for $49 off your first month of a paid Firebase plan. Just enter the code when you upgrade your Firebase.
481488

codelabs/chat/images/6_1.png

163 KB
Loading

codelabs/chat/images/6_10.png

126 KB
Loading

codelabs/chat/images/6_2.png

275 KB
Loading

codelabs/chat/images/6_3.png

348 KB
Loading

codelabs/chat/images/6_4.png

238 KB
Loading

codelabs/chat/images/6_5.png

78.2 KB
Loading

codelabs/chat/images/6_6.png

263 KB
Loading

codelabs/chat/images/6_7.png

257 KB
Loading

codelabs/chat/images/6_8.png

245 KB
Loading

0 commit comments

Comments
 (0)