Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ login.password=Password
login.pin.password=PIN
login.primed.prompt=Your password has been saved for you! Just press 'Log In'.
login.button=Log In
login.app.connect=Go to Connect Jobs
login.sync=Synchronize with server
login.bad.password=We couldn't find a user with this password. Please try another!
login.welcome.single=Welcome back! Please log in.
Expand Down
79 changes: 30 additions & 49 deletions app/src/org/commcare/activities/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,38 +204,32 @@ protected void onSaveInstanceState(Bundle savedInstanceState) {
* upon successful login
*/
protected void initiateLoginAttempt(boolean restoreSession) {
if(isConnectJobsSelected()) {

LoginMode loginMode = uiController.getLoginMode();

//See whether login is managed by ConnectID
String seatedAppId = CommCareApplication.instance().getCurrentApp().getUniqueId();
String username = uiController.getEnteredUsername();

if(appLaunchedFromConnect) {
//Auto login
doLogin(loginMode, restoreSession, "AUTO");
}
else if(uiController.loginManagedByConnectId()) {
//Unlock and then auto login
ConnectManager.unlockConnect(this, success -> {
if(success) {
ConnectManager.goToConnectJobsList(this);
String pass = ConnectManager.getStoredPasswordForApp(seatedAppId, username);
doLogin(loginMode, restoreSession, pass);
}
});
} else {
LoginMode loginMode = uiController.getLoginMode();

//See whether login is managed by ConnectID
String seatedAppId = CommCareApplication.instance().getCurrentApp().getUniqueId();
String username = uiController.getEnteredUsername();

if(appLaunchedFromConnect) {
//Auto login
doLogin(loginMode, restoreSession, "AUTO");
}
else if(uiController.loginManagedByConnectId()) {
//Unlock and then auto login
ConnectManager.unlockConnect(this, success -> {
if(success) {
String pass = ConnectManager.getStoredPasswordForApp(seatedAppId, username);
doLogin(loginMode, restoreSession, pass);
}
});
}
else {
//Manual login
String passwordOrPin = uiController.getEnteredPasswordOrPin();
doLogin(loginMode, restoreSession, passwordOrPin);
}
}
else {
//Manual login
String passwordOrPin = uiController.getEnteredPasswordOrPin();
doLogin(loginMode, restoreSession, passwordOrPin);
}

}

private void doLogin(LoginMode loginMode, boolean restoreSession, String passwordOrPin) {
Expand Down Expand Up @@ -737,12 +731,6 @@ protected void populateAppSpinner(ArrayList<ApplicationRecord> readyApps) {

appIdDropdownList.clear();

boolean includeConnect = ConnectManager.isConnectIdConfigured();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will prevent the menu option from being added and is a good start, but there's a bit more we need to do to get rid of the functionality. Check out the isConnectJobsSelected function (line 763), which should now be deleted and any callers should always assume the false case.

We can also remove the login.app.connect entry from android_translatable_strings.txt, since that string isn't used anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OrangeAndGreen Made the changes as per the comment

if (includeConnect) {
appNames.add(Localization.get("login.app.connect"));
appIdDropdownList.add("");
}

for (ApplicationRecord r : readyApps) {
appNames.add(r.getDisplayName());
appIdDropdownList.add(r.getUniqueId());
Expand All @@ -766,26 +754,19 @@ protected void populateAppSpinner(ArrayList<ApplicationRecord> readyApps) {
selectedAppIndex = -1;
}

private boolean isConnectJobsSelected() {
return ConnectManager.isConnectIdConfigured() && uiController.getSelectedAppIndex() == 0;
}

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
boolean selectedConnect = isConnectJobsSelected();
if(selectedConnect) {
uiController.setLoginInputsVisibility(false);
} else {
// Retrieve the app record corresponding to the app selected
selectedAppIndex = position;
String appId = appIdDropdownList.get(selectedAppIndex);
if (appId.length() > 0) {
uiController.setLoginInputsVisibility(true);
if (!seatAppIfNeeded(appId)) {
checkForSavedCredentials();
}

// Retrieve the app record corresponding to the app selected
selectedAppIndex = position;
String appId = appIdDropdownList.get(selectedAppIndex);
if (appId.length() > 0) {
uiController.setLoginInputsVisibility(true);
if (!seatAppIfNeeded(appId)) {
checkForSavedCredentials();
}
}

}

protected boolean seatAppIfNeeded(String appId) {
Expand Down