Merge branch 'feature/login-role-switch' of s416084/find-my-tutor-android into bottomNaviWithFrags
This commit is contained in:
commit
460f3f6520
@ -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)
|
||||
|
@ -64,6 +64,12 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/tutor_login_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Login as Tutor" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/email_sign_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
|
Loading…
Reference in New Issue
Block a user