SlideShare a Scribd company logo
1 of 16
Download to read offline
Creating an Uber Clone - Part XIV
fab.addActionListener(e -> {
String number = phoneNumber.getText();
if(number.startsWith("0")) {
number = number.substring(1);
}
String phone = countryCodeButton.getText() + "-" + number;
EnterSMSVerificationDigitsForm es =
new EnterSMSVerificationDigitsForm(phone);
es.show();
es.addShowListener(ee -> {
if(SMSInterceptor.isSupported()) {
SMSInterceptor.grabNextSMS(s -> {
if(UserService.validateSMSActivationCode(s)) {
new EnterPasswordForm(phone).show();
ToastBar.showMessage("Automatically Validated Phone Number!",
FontImage.MATERIAL_THUMB_UP);
}
});
}
UserService.sendSMSActivationCode(phone);
});
});
EnterMobileNumberForm
fab.addActionListener(e -> {
String number = phoneNumber.getText();
if(number.startsWith("0")) {
number = number.substring(1);
}
String phone = countryCodeButton.getText() + "-" + number;
EnterSMSVerificationDigitsForm es =
new EnterSMSVerificationDigitsForm(phone);
es.show();
es.addShowListener(ee -> {
if(SMSInterceptor.isSupported()) {
SMSInterceptor.grabNextSMS(s -> {
if(UserService.validateSMSActivationCode(s)) {
new EnterPasswordForm(phone).show();
ToastBar.showMessage("Automatically Validated Phone Number!",
FontImage.MATERIAL_THUMB_UP);
}
});
}
UserService.sendSMSActivationCode(phone);
});
});
EnterMobileNumberForm
fab.addActionListener(e -> {
String number = phoneNumber.getText();
if(number.startsWith("0")) {
number = number.substring(1);
}
String phone = countryCodeButton.getText() + "-" + number;
EnterSMSVerificationDigitsForm es =
new EnterSMSVerificationDigitsForm(phone);
es.show();
es.addShowListener(ee -> {
if(SMSInterceptor.isSupported()) {
SMSInterceptor.grabNextSMS(s -> {
if(UserService.validateSMSActivationCode(s)) {
new EnterPasswordForm(phone).show();
ToastBar.showMessage("Automatically Validated Phone Number!",
FontImage.MATERIAL_THUMB_UP);
}
});
}
UserService.sendSMSActivationCode(phone);
});
});
EnterMobileNumberForm
fab.addActionListener(e -> {
String number = phoneNumber.getText();
if(number.startsWith("0")) {
number = number.substring(1);
}
String phone = countryCodeButton.getText() + "-" + number;
EnterSMSVerificationDigitsForm es =
new EnterSMSVerificationDigitsForm(phone);
es.show();
es.addShowListener(ee -> {
if(SMSInterceptor.isSupported()) {
SMSInterceptor.grabNextSMS(s -> {
if(UserService.validateSMSActivationCode(s)) {
new EnterPasswordForm(phone).show();
ToastBar.showMessage("Automatically Validated Phone Number!",
FontImage.MATERIAL_THUMB_UP);
}
});
}
UserService.sendSMSActivationCode(phone);
});
});
EnterMobileNumberForm
public final boolean isValid(String s) {
return UserService.validateSMSActivationCode(s);
}
EnterSMSVerificationDigitsForm
private int resendTime = 120;
private UITimer timer;
private String formatSeconds(int time) {
return twoDigits(time / 60) + ":" + twoDigits(time % 60);
}
private String twoDigits(int t) {
if(t < 10) {
return "0" + t;
}
return "" + t;
}
EnterSMSVerificationDigitsForm
private int resendTime = 120;
private UITimer timer;
private String formatSeconds(int time) {
return twoDigits(time / 60) + ":" + twoDigits(time % 60);
}
private String twoDigits(int t) {
if(t < 10) {
return "0" + t;
}
return "" + t;
}
EnterSMSVerificationDigitsForm
Label resend = new Label("Resend code in " +
formatSeconds(resendTime), "ResendCode");
add(SOUTH, resend);
timer = UITimer.timer(1000, true, this, () -> {
if(resendTime > 0) {
resendTime--;
resend.setText("Resend code in " +
formatSeconds(resendTime));
return;
}
timer.cancel();
UserService.resendSMSActivationCode(phone);
});
EnterSMSVerificationDigitsForm
Label resend = new Label("Resend code in " +
formatSeconds(resendTime), "ResendCode");
add(SOUTH, resend);
timer = UITimer.timer(1000, true, this, () -> {
if(resendTime > 0) {
resendTime--;
resend.setText("Resend code in " +
formatSeconds(resendTime));
return;
}
timer.cancel();
UserService.resendSMSActivationCode(phone);
});
EnterSMSVerificationDigitsForm
Label resend = new Label("Resend code in " +
formatSeconds(resendTime), "ResendCode");
add(SOUTH, resend);
timer = UITimer.timer(1000, true, this, () -> {
if(resendTime > 0) {
resendTime--;
resend.setText("Resend code in " +
formatSeconds(resendTime));
return;
}
timer.cancel();
UserService.resendSMSActivationCode(phone);
});
EnterSMSVerificationDigitsForm
InfiniteProgress ip = new InfiniteProgress();
Dialog dlg = ip.showInifiniteBlocking();
boolean exists = UserService.userExists(phone);
dlg.dispose();
getToolbar().setBackCommand("",
Toolbar.BackCommandPolicy.AS_ARROW,
e -> previous.showBack());
Container box = new Container(BoxLayout.y());
box.setScrollableY(true);
if(exists) {
box.add(new SpanLabel(
"Welcome back, signin to continue", "FlagButton"));
} else {
box.add(new SpanLabel(
"Please enter a new password", "FlagButton"));
}
EnterPasswordForm
InfiniteProgress ip = new InfiniteProgress();
Dialog dlg = ip.showInifiniteBlocking();
boolean exists = UserService.userExists(phone);
dlg.dispose();
getToolbar().setBackCommand("",
Toolbar.BackCommandPolicy.AS_ARROW,
e -> previous.showBack());
Container box = new Container(BoxLayout.y());
box.setScrollableY(true);
if(exists) {
box.add(new SpanLabel(
"Welcome back, signin to continue", "FlagButton"));
} else {
box.add(new SpanLabel(
"Please enter a new password", "FlagButton"));
}
EnterPasswordForm
fab.addActionListener(e -> {
Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking();
if(exists) {
UserService.loginWithPhone(phone, password.getText(), (value) -> {
MapForm.get().show();
}, (sender, err, errorCode, errorMessage) -> {
ipDlg.dispose();
error.setText("Login error");
error.setVisible(true);
revalidate();
});
} else {
if(UserService.addNewUser(new User().
phone.set(phone).
password.set(password.getText()).
driver.set(false))) {
MapForm.get().show();
} else {
ipDlg.dispose();
error.setText("Signup error");
error.setVisible(true);
revalidate();
}
}
EnterPasswordForm
fab.addActionListener(e -> {
Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking();
if(exists) {
UserService.loginWithPhone(phone, password.getText(), (value) -> {
MapForm.get().show();
}, (sender, err, errorCode, errorMessage) -> {
ipDlg.dispose();
error.setText("Login error");
error.setVisible(true);
revalidate();
});
} else {
if(UserService.addNewUser(new User().
phone.set(phone).
password.set(password.getText()).
driver.set(false))) {
MapForm.get().show();
} else {
ipDlg.dispose();
error.setText("Signup error");
error.setVisible(true);
revalidate();
}
}
EnterPasswordForm
fab.addActionListener(e -> {
Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking();
if(exists) {
UserService.loginWithPhone(phone, password.getText(), (value) -> {
MapForm.get().show();
}, (sender, err, errorCode, errorMessage) -> {
ipDlg.dispose();
error.setText("Login error");
error.setVisible(true);
revalidate();
});
} else {
if(UserService.addNewUser(new User().
phone.set(phone).
password.set(password.getText()).
driver.set(false))) {
MapForm.get().show();
} else {
ipDlg.dispose();
error.setText("Signup error");
error.setVisible(true);
revalidate();
}
}
EnterPasswordForm

More Related Content

Similar to Creating an Uber Clone - Part XIV.pdf

from datetime import datetime def CreateUsers()- print('##### Crea.pdf
from datetime import datetime def CreateUsers()-     print('##### Crea.pdffrom datetime import datetime def CreateUsers()-     print('##### Crea.pdf
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
atozworkwear
 
i need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docxi need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docx
hendriciraida
 
Here I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdfHere I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdf
Conint29
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
hendriciraida
 
Work in TDW
Work in TDWWork in TDW
Work in TDW
saso70
 
i need to modify this c++ so when the user enter services thats not an.docx
i need to modify this c++ so when the user enter services thats not an.docxi need to modify this c++ so when the user enter services thats not an.docx
i need to modify this c++ so when the user enter services thats not an.docx
hendriciraida
 

Similar to Creating an Uber Clone - Part XIV.pdf (20)

Creating a Facebook Clone - Part VIII - Transcript.pdf
Creating a Facebook Clone - Part VIII - Transcript.pdfCreating a Facebook Clone - Part VIII - Transcript.pdf
Creating a Facebook Clone - Part VIII - Transcript.pdf
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdf
 
Tdd.eng.ver
Tdd.eng.verTdd.eng.ver
Tdd.eng.ver
 
Miscellaneous Features - Part 2 - Transcript.pdf
Miscellaneous Features - Part 2 - Transcript.pdfMiscellaneous Features - Part 2 - Transcript.pdf
Miscellaneous Features - Part 2 - Transcript.pdf
 
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
from datetime import datetime def CreateUsers()-     print('##### Crea.pdffrom datetime import datetime def CreateUsers()-     print('##### Crea.pdf
from datetime import datetime def CreateUsers()- print('##### Crea.pdf
 
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdfCreating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bca
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODES
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE
 
Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)
 
i need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docxi need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docx
 
Here I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdfHere I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdf
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdf
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
 
Understanding Async/Await in Javascript
Understanding Async/Await in JavascriptUnderstanding Async/Await in Javascript
Understanding Async/Await in Javascript
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part X - Transcript.pdf
Creating a Whatsapp Clone - Part X - Transcript.pdfCreating a Whatsapp Clone - Part X - Transcript.pdf
Creating a Whatsapp Clone - Part X - Transcript.pdf
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphics
 
Work in TDW
Work in TDWWork in TDW
Work in TDW
 
i need to modify this c++ so when the user enter services thats not an.docx
i need to modify this c++ so when the user enter services thats not an.docxi need to modify this c++ so when the user enter services thats not an.docx
i need to modify this c++ so when the user enter services thats not an.docx
 

More from ShaiAlmog1

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 
Creating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdfCreating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdf
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 

Creating an Uber Clone - Part XIV.pdf

  • 1. Creating an Uber Clone - Part XIV
  • 2. fab.addActionListener(e -> { String number = phoneNumber.getText(); if(number.startsWith("0")) { number = number.substring(1); } String phone = countryCodeButton.getText() + "-" + number; EnterSMSVerificationDigitsForm es = new EnterSMSVerificationDigitsForm(phone); es.show(); es.addShowListener(ee -> { if(SMSInterceptor.isSupported()) { SMSInterceptor.grabNextSMS(s -> { if(UserService.validateSMSActivationCode(s)) { new EnterPasswordForm(phone).show(); ToastBar.showMessage("Automatically Validated Phone Number!", FontImage.MATERIAL_THUMB_UP); } }); } UserService.sendSMSActivationCode(phone); }); }); EnterMobileNumberForm
  • 3. fab.addActionListener(e -> { String number = phoneNumber.getText(); if(number.startsWith("0")) { number = number.substring(1); } String phone = countryCodeButton.getText() + "-" + number; EnterSMSVerificationDigitsForm es = new EnterSMSVerificationDigitsForm(phone); es.show(); es.addShowListener(ee -> { if(SMSInterceptor.isSupported()) { SMSInterceptor.grabNextSMS(s -> { if(UserService.validateSMSActivationCode(s)) { new EnterPasswordForm(phone).show(); ToastBar.showMessage("Automatically Validated Phone Number!", FontImage.MATERIAL_THUMB_UP); } }); } UserService.sendSMSActivationCode(phone); }); }); EnterMobileNumberForm
  • 4. fab.addActionListener(e -> { String number = phoneNumber.getText(); if(number.startsWith("0")) { number = number.substring(1); } String phone = countryCodeButton.getText() + "-" + number; EnterSMSVerificationDigitsForm es = new EnterSMSVerificationDigitsForm(phone); es.show(); es.addShowListener(ee -> { if(SMSInterceptor.isSupported()) { SMSInterceptor.grabNextSMS(s -> { if(UserService.validateSMSActivationCode(s)) { new EnterPasswordForm(phone).show(); ToastBar.showMessage("Automatically Validated Phone Number!", FontImage.MATERIAL_THUMB_UP); } }); } UserService.sendSMSActivationCode(phone); }); }); EnterMobileNumberForm
  • 5. fab.addActionListener(e -> { String number = phoneNumber.getText(); if(number.startsWith("0")) { number = number.substring(1); } String phone = countryCodeButton.getText() + "-" + number; EnterSMSVerificationDigitsForm es = new EnterSMSVerificationDigitsForm(phone); es.show(); es.addShowListener(ee -> { if(SMSInterceptor.isSupported()) { SMSInterceptor.grabNextSMS(s -> { if(UserService.validateSMSActivationCode(s)) { new EnterPasswordForm(phone).show(); ToastBar.showMessage("Automatically Validated Phone Number!", FontImage.MATERIAL_THUMB_UP); } }); } UserService.sendSMSActivationCode(phone); }); }); EnterMobileNumberForm
  • 6. public final boolean isValid(String s) { return UserService.validateSMSActivationCode(s); } EnterSMSVerificationDigitsForm
  • 7. private int resendTime = 120; private UITimer timer; private String formatSeconds(int time) { return twoDigits(time / 60) + ":" + twoDigits(time % 60); } private String twoDigits(int t) { if(t < 10) { return "0" + t; } return "" + t; } EnterSMSVerificationDigitsForm
  • 8. private int resendTime = 120; private UITimer timer; private String formatSeconds(int time) { return twoDigits(time / 60) + ":" + twoDigits(time % 60); } private String twoDigits(int t) { if(t < 10) { return "0" + t; } return "" + t; } EnterSMSVerificationDigitsForm
  • 9. Label resend = new Label("Resend code in " + formatSeconds(resendTime), "ResendCode"); add(SOUTH, resend); timer = UITimer.timer(1000, true, this, () -> { if(resendTime > 0) { resendTime--; resend.setText("Resend code in " + formatSeconds(resendTime)); return; } timer.cancel(); UserService.resendSMSActivationCode(phone); }); EnterSMSVerificationDigitsForm
  • 10. Label resend = new Label("Resend code in " + formatSeconds(resendTime), "ResendCode"); add(SOUTH, resend); timer = UITimer.timer(1000, true, this, () -> { if(resendTime > 0) { resendTime--; resend.setText("Resend code in " + formatSeconds(resendTime)); return; } timer.cancel(); UserService.resendSMSActivationCode(phone); }); EnterSMSVerificationDigitsForm
  • 11. Label resend = new Label("Resend code in " + formatSeconds(resendTime), "ResendCode"); add(SOUTH, resend); timer = UITimer.timer(1000, true, this, () -> { if(resendTime > 0) { resendTime--; resend.setText("Resend code in " + formatSeconds(resendTime)); return; } timer.cancel(); UserService.resendSMSActivationCode(phone); }); EnterSMSVerificationDigitsForm
  • 12. InfiniteProgress ip = new InfiniteProgress(); Dialog dlg = ip.showInifiniteBlocking(); boolean exists = UserService.userExists(phone); dlg.dispose(); getToolbar().setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> previous.showBack()); Container box = new Container(BoxLayout.y()); box.setScrollableY(true); if(exists) { box.add(new SpanLabel( "Welcome back, signin to continue", "FlagButton")); } else { box.add(new SpanLabel( "Please enter a new password", "FlagButton")); } EnterPasswordForm
  • 13. InfiniteProgress ip = new InfiniteProgress(); Dialog dlg = ip.showInifiniteBlocking(); boolean exists = UserService.userExists(phone); dlg.dispose(); getToolbar().setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> previous.showBack()); Container box = new Container(BoxLayout.y()); box.setScrollableY(true); if(exists) { box.add(new SpanLabel( "Welcome back, signin to continue", "FlagButton")); } else { box.add(new SpanLabel( "Please enter a new password", "FlagButton")); } EnterPasswordForm
  • 14. fab.addActionListener(e -> { Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking(); if(exists) { UserService.loginWithPhone(phone, password.getText(), (value) -> { MapForm.get().show(); }, (sender, err, errorCode, errorMessage) -> { ipDlg.dispose(); error.setText("Login error"); error.setVisible(true); revalidate(); }); } else { if(UserService.addNewUser(new User(). phone.set(phone). password.set(password.getText()). driver.set(false))) { MapForm.get().show(); } else { ipDlg.dispose(); error.setText("Signup error"); error.setVisible(true); revalidate(); } } EnterPasswordForm
  • 15. fab.addActionListener(e -> { Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking(); if(exists) { UserService.loginWithPhone(phone, password.getText(), (value) -> { MapForm.get().show(); }, (sender, err, errorCode, errorMessage) -> { ipDlg.dispose(); error.setText("Login error"); error.setVisible(true); revalidate(); }); } else { if(UserService.addNewUser(new User(). phone.set(phone). password.set(password.getText()). driver.set(false))) { MapForm.get().show(); } else { ipDlg.dispose(); error.setText("Signup error"); error.setVisible(true); revalidate(); } } EnterPasswordForm
  • 16. fab.addActionListener(e -> { Dialog ipDlg = new InfiniteProgress().showInifiniteBlocking(); if(exists) { UserService.loginWithPhone(phone, password.getText(), (value) -> { MapForm.get().show(); }, (sender, err, errorCode, errorMessage) -> { ipDlg.dispose(); error.setText("Login error"); error.setVisible(true); revalidate(); }); } else { if(UserService.addNewUser(new User(). phone.set(phone). password.set(password.getText()). driver.set(false))) { MapForm.get().show(); } else { ipDlg.dispose(); error.setText("Signup error"); error.setVisible(true); revalidate(); } } EnterPasswordForm