Skip to content

Commit

Permalink
robovm#32 Allow to type the email when checkout on Androïd and iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rastaman committed Nov 7, 2015
1 parent 016c894 commit 32759d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (ROBOVM_ACCOUNT_EMAIL == null || ROBOVM_ACCOUNT_EMAIL.isEmpty()) {
return createInstructions(inflater, container, savedInstanceState);
}
return createLoginView(inflater, container, savedInstanceState);
}

Expand All @@ -78,13 +75,13 @@ private View createLoginView(LayoutInflater inflater, ViewGroup container, Bundl
loadUserImage();

EditText textView = (EditText) view.findViewById(R.id.email);
textView.setEnabled(false);
textView.setText(ROBOVM_ACCOUNT_EMAIL);
textView.setEnabled(true);
textView.setText("Username");

password = (EditText) view.findViewById(R.id.password);
login = (Button) view.findViewById(R.id.signInBtn);
login.setOnClickListener((b) -> {
login(ROBOVM_ACCOUNT_EMAIL, password.getText().toString());
login(textView.getText().toString(), password.getText().toString());
});

return view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class LoginViewController extends UIViewController {
// TODO: Enter your RoboVM account email address here
// If you do not have a RoboVM Account please sign up here:
// https://account.robovm.com/#/register
private static final String ROBOVM_ACCOUNT_EMAIL = "";
// private static final String ROBOVM_ACCOUNT_EMAIL = "";

private UIView contentView;
private LoginView loginView;
Expand All @@ -52,7 +52,7 @@ public LoginViewController() {
}

public boolean shouldShowInstructions() {
return ROBOVM_ACCOUNT_EMAIL == null || ROBOVM_ACCOUNT_EMAIL.isEmpty();
return false;//ROBOVM_ACCOUNT_EMAIL == null || ROBOVM_ACCOUNT_EMAIL.isEmpty();
}

@Override
Expand All @@ -71,16 +71,10 @@ public void viewDidLayoutSubviews() {
@Override
public void loadView() {
super.loadView();

getView().addSubview(scrollView = new UIScrollView(getView().getBounds()));
if (shouldShowInstructions()) {
scrollView.addSubview(contentView = new PrefillRoboVMAccountInstructionsView());
} else {
loginView = new LoginView(ROBOVM_ACCOUNT_EMAIL);
loginView
.setLoginSuccessListener((v) -> login(ROBOVM_ACCOUNT_EMAIL, loginView.getPasswordField().getText()));
loginView = new LoginView("");
loginView.setLoginSuccessListener((v) -> login(loginView.getEmailField().getText(), loginView.getPasswordField().getText()));
scrollView.addSubview(contentView = loginView);
}
}

private void login(String username, String password) {
Expand Down
9 changes: 5 additions & 4 deletions ios/src/main/java/org/robovm/store/views/LoginView.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ public LoginView(String robovmAccountEmail) {

emailField = new UITextField(new CGRect(10, 10, 300, 30));
emailField.setBorderStyle(UITextBorderStyle.RoundedRect);
emailField.setText(robovmAccountEmail);
emailField.setText("Email");
emailField.setTranslatesAutoresizingMaskIntoConstraints(false);
emailField.setDelegate(new UITextFieldDelegateAdapter() {
@Override
public boolean shouldBeginEditing(UITextField textField) {
return false;
public boolean shouldReturn(UITextField textField) {
textField.resignFirstResponder();
return true;
}
});
addSubview(emailField);
Expand Down Expand Up @@ -110,7 +111,7 @@ public boolean shouldReturn(UITextField textField) {
}
});

passwordField.becomeFirstResponder();
emailField.becomeFirstResponder();
}

private void displayGravatar(String email) {
Expand Down

0 comments on commit 32759d3

Please sign in to comment.