diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
index f23e4e4..b06432c 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
@@ -27,7 +27,9 @@ import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.Switch;
import android.widget.TextView;
+import android.widget.ToggleButton;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.JwtToken;
@@ -73,6 +75,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
private EditText mPasswordView;
private View mProgressView;
private View mLoginFormView;
+ private boolean loginOption;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -94,6 +97,14 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
}
});
+ Switch tutorLogin = (Switch) findViewById(R.id.tutor_login_switch);
+ tutorLogin.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ loginOption = tutorLogin.isChecked();
+ }
+ });
+
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@@ -198,7 +209,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true);
- mAuthTask = new UserLoginTask(email, password);
+ mAuthTask = new UserLoginTask(email, password,loginOption);
mAuthTask.execute((Void) null);
}
}
@@ -311,14 +322,16 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
private final String mEmail;
private final String mPassword;
+ private boolean isTutor;
private LdapService ldapService;
private CompositeDisposable disposable = new CompositeDisposable();
private Boolean isAuthorizate;
// Constructor
- UserLoginTask(String email, String password) {
+ UserLoginTask(String email, String password, Boolean loginOption) {
mEmail = email;
mPassword = password;
+ isTutor=loginOption;
this.ldapService = ApiClient.getClient(getApplicationContext())
.create(LdapService.class);
this.isAuthorizate = false;
@@ -326,8 +339,8 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
@Override
protected Boolean doInBackground(Void... params) {
- LdapUser user = new LdapUser("string",mPassword,"string","tutor","string","string",mEmail);
-
+ LdapUser user = new LdapUser("string",mPassword,"string",(isTutor)?"tutor":"student","string","string",mEmail);
+ Log.d("LoginRole","Login role is : " + user.getTitle());
disposable.add(
ldapService
.fakeValidate(user)
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 6784ef7..c2c77b7 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -64,6 +64,12 @@
+
+