diff --git a/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java b/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java index 5afa53f..d125da9 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java @@ -11,7 +11,6 @@ import android.widget.EditText; import android.widget.TextView; -import org.ntlab.amaryllis.client.entities.LoginJson; import org.ntlab.amaryllis.client.entities.SignUpJson; import org.ntlab.amaryllis.client.resources.AccountsRest; @@ -24,8 +23,8 @@ public class LoginActivity extends AppCompatActivity implements TextWatcher { TextView passWordTextView; EditText passWordEditText; - TextView uidTextView; - EditText uidEditText; + TextView nameTextView; + EditText nameText; Button loginButton; @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,30 +36,32 @@ .build(); final AccountsRest LoginService = retrofit.create(AccountsRest.class); setContentView(R.layout.activity_login); + nameText = (EditText) findViewById(R.id.name); + nameText.addTextChangedListener(this); + nameTextView = findViewById(R.id.name); passWordEditText = (EditText) findViewById(R.id.passWord); passWordEditText.addTextChangedListener(this); passWordTextView = findViewById(R.id.passWord); - uidEditText = (EditText) findViewById(R.id.uid); - uidEditText.addTextChangedListener(this); - uidTextView = findViewById(R.id.uid); loginButton = (Button)findViewById(R.id.login); loginButton.setEnabled(false); - uidEditText.setText( ((Amaryllis) getApplication()).getUid()); loginButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - Call call = LoginService.accountLogin(uidEditText.getText().toString(),passWordEditText.getText().toString()); - call.enqueue(new Callback(){ + Call call = LoginService.putAccounts(nameText.getText().toString(),passWordEditText.getText().toString()); + call.enqueue(new Callback(){ @Override - public void onResponse(Call call, Response response) { - LoginJson loginJson =response.body(); + public void onResponse(Call call, Response response) { + SignUpJson signUpJson =response.body(); Amaryllis app = (Amaryllis) getApplication(); - app.setToken(loginJson.getToken()); + app.setToken(signUpJson.getToken()); + app.setUid(nameText.getText().toString()); + app.setPassword(passWordEditText.getText().toString()); Intent intent = new Intent(LoginActivity.this, MainActivity.class); startActivity(intent); + finish(); } @Override - public void onFailure(Call call, Throwable t) { + public void onFailure(Call call, Throwable t) { } }); } @@ -80,7 +81,7 @@ @Override public void afterTextChanged(Editable s) { - if(passWordTextView.length()>3 && uidTextView.length()>0 ){ + if(passWordTextView.length()>3 && nameTextView.length()>0 ){ loginButton.setEnabled(true); } else{