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
14 changes: 13 additions & 1 deletion app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ menu.privilege.claim.disable=Disable Privileges
menu.data.change.logs=Data Change Logs
menu.enable.rate.limit.popup=Enable Rate Limit Error Popup
menu.enable.manual.form.quarantine=Enable Manual Form Quarantine
menu.enable.connect.id=Enable ConnectID

install.fail.error=We encountered an ${0} error processing your request. Please try again later. If the problem persists, contact CommCare Support.

Expand All @@ -134,6 +135,8 @@ sync.fail.recovery.failure=There was an error trying to recover from a bad local
sync.fail.unsent=Having issues communicating with the server to send forms. Will try again later.
sync.fail.individual=1 or more forms failed to send due to individual problems. See quarantined forms for details.
sync.fail.invalid.case.graph=1 or more forms introduced an invalid case relationship.
sync.fail.token.unavailable=Couldn't contact server. Please make sure an internet connection is available or try again later.
sync.fail.token.denied=Please re-login into your ConnectID account, then try again.

form.send.rate.limit.error.toast=Form submission rate limit reached. Your forms are being saved locally and will be submitted to the server later.
form.send.rate.limit.error.title=You've reached your form submission rate limit
Expand Down Expand Up @@ -199,7 +202,7 @@ post.generic.error=An error occurred while preparing the HTTP request
post.dialog.title=Claiming...
post.dialog.body=Claiming chosen data from server
post.io.error=Error reading server response: ${0}
post.unknown.response=Received unknown resonse code (${0}) from server
post.unknown.response=Received unknown response code (${0}) from server
post.client.error=Client-side error (code ${0}) received from network request.
post.server.error=Server-side error (code ${0}) received from network request.
post.gone.error=Case is not present on server.
Expand Down Expand Up @@ -371,6 +374,7 @@ select.detail.callout.title=Select phone number action
select.detail.callout.call=Call
select.detail.callout.sms=Send SMS


home.logged.in.message=Logged In: ${0}
notification.logged.in=Logged Into ${0}

Expand Down Expand Up @@ -553,6 +557,14 @@ notification.bad.certificate.detail=CommCare couldn't validate the security info
notification.bad.certificate.action=Check your device's time and date to make sure they are correct. If the problem persists, try to connect to a secure server with the phone's browser
notification.bad.certificate.button=Go to settings

notification.token.unavailable.title=Couldn't connect to the server.
notification.token.unavailable.detail=CommCare had an issue authenticating the user.
notification.token.unavailable.action=Check your device's time and date to make sure they are correct, then try again.

notification.token.denied.title=Couldn't connect to the server.
notification.token.denied.detail=CommCare can no longer communicate with the ConnectID server.
notification.token.denied.action=Please re-login into your ConnectID account, then try again.

notification.restore.storagefull.title=Couldn't save your application's resources
notification.restore.storagefull.detail=CommCare was not able to save one or more of your application's resources on the device. This could be because the entire application was too large, or because an individual fixture exceeded 1MB.
notification.restore.storagefull.action=Check the amount of space available on your device. If the SD card isn't full, then it's likely one of your fixtures is too large (> 1MB) and needs to be reduced or split.
Expand Down
11 changes: 11 additions & 0 deletions app/res/drawable-anydpi/ic_marker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
</vector>
2 changes: 1 addition & 1 deletion app/res/xml/app_manager_developer_preferences.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:key="enable-mobile-privilege"/>
</PreferenceScreen>
</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class CommCareVerificationActivity
private static final String KEY_REQUIRE_REFRESH = "require_referesh";
public static final String KEY_LAUNCH_FROM_SETTINGS = "from_settings";

public static final String KEY_LAUNCH_FROM_CONNECT = "from_connect";

private static final int DIALOG_VERIFY_PROGRESS = 0;
private static final String MISSING_MEDIA_TEXT_KEY = "missing-media-text-key";
private static final String NEW_MEDIA_KEY = "new-media-to-validate";
Expand All @@ -68,6 +70,7 @@ public class CommCareVerificationActivity
* CommCareHomeActivity
*/
private boolean fromSettings;
private boolean fromConnect;
private boolean isFirstLaunch;

@Override
Expand All @@ -86,6 +89,8 @@ protected void onCreate(Bundle savedInstanceState) {

this.fromSettings = this.getIntent().
getBooleanExtra(KEY_LAUNCH_FROM_SETTINGS, false);
this.fromConnect = this.getIntent().
Copy link
Contributor

Choose a reason for hiding this comment

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

we have removed this flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is not true anymore after #3072

getBooleanExtra(KEY_LAUNCH_FROM_CONNECT, false);
this.fromManager = this.getIntent().
getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER, false);
if (fromManager) {
Expand Down Expand Up @@ -129,7 +134,7 @@ protected void onResume() {
// then something was done on the Manager screen that means we no longer want to be here --
// VerificationActivity should be displayed to a user only if we were explicitly sent from
// the manager, or if the state of installed apps calls for it
boolean shouldBeHere = fromManager || fromSettings || MultipleAppsUtil.shouldSeeMMVerification();
boolean shouldBeHere = fromManager || fromSettings || fromConnect || MultipleAppsUtil.shouldSeeMMVerification();
if (!shouldBeHere) {
// send back to dispatch activity
setResult(RESULT_OK);
Expand Down
7 changes: 3 additions & 4 deletions app/src/org/commcare/activities/EntitySelectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
android.R.drawable.ic_menu_sort_alphabetically);
if (isMappingEnabled) {
menu.add(0, MENU_MAP, MENU_MAP, Localization.get("select.menu.map")).setIcon(
android.R.drawable.ic_menu_mapmode);
R.drawable.ic_marker).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

if (entitySelectSearchUI != null) {
Expand Down Expand Up @@ -757,7 +757,6 @@ public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(MENU_SORT).setEnabled(adapter != null);
// hide sorting menu when using async loading strategy
menu.findItem(MENU_SORT).setVisible((shortSelect == null || shortSelect.hasSortField()));

if (menu.findItem(R.id.menu_settings) != null) {
// For the same reason as in onCreateOptionsMenu(), we may be trying to call this
// before we're ready
Expand All @@ -777,9 +776,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
createSortMenu();
return true;
case MENU_MAP:
Intent i = new Intent(this,
Intent intent = new Intent(this,
HiddenPreferences.shouldUseMapboxMap() ? EntityMapboxActivity.class : EntityMapActivity.class);
this.startActivityForResult(i, MAP_SELECT);
this.startActivityForResult(intent, MAP_SELECT);
return true;
// handling click on the barcode scanner's actionbar
// trying to set the onclicklistener in its view in the onCreateOptionsMenu method does not work because it returns null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ protected void userTriggeredLogout() {
protected void userPressedOpportunityStatus() {
Intent i = new Intent();
i.putExtra(REDIRECT_TO_CONNECT_OPPORTUNITY_INFO, true);
setResult(RESULT_OK);
setResult(RESULT_OK, i);
finish();
}

Expand Down
46 changes: 26 additions & 20 deletions app/src/org/commcare/activities/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public class LoginActivity extends CommCareActivity<LoginActivity>
private static final int MENU_CONNECT_SIGN_IN = Menu.FIRST + 5;
private static final int MENU_CONNECT_FORGET = Menu.FIRST + 6;
public static final String NOTIFICATION_MESSAGE_LOGIN = "login_message";
public final static String KEY_LAST_APP = "id-last-seated-app";
public final static String KEY_ENTERED_USER = "entered-username";
public final static String KEY_ENTERED_PW_OR_PIN = "entered-password-or-pin";
public static final String KEY_LAST_APP = "id-last-seated-app";
public static final String KEY_ENTERED_USER = "entered-username";
public static final String KEY_ENTERED_PW_OR_PIN = "entered-password-or-pin";

private static final int SEAT_APP_ACTIVITY = 0;
public final static String USER_TRIGGERED_LOGOUT = "user-triggered-logout";
public static final String USER_TRIGGERED_LOGOUT = "user-triggered-logout";

public final static String LOGIN_MODE = "login-mode";
public final static String MANUAL_SWITCH_TO_PW_MODE = "manually-swithced-to-password-mode";
public static final String LOGIN_MODE = "login-mode";
public static final String MANUAL_SWITCH_TO_PW_MODE = "manually-swithced-to-password-mode";

private static final int TASK_KEY_EXCHANGE = 1;
private static final int TASK_UPGRADE_INSTALL = 2;
Expand All @@ -121,6 +121,7 @@ public class LoginActivity extends CommCareActivity<LoginActivity>
private ConnectIDManager.ConnectAppMangement connectAppState = Unmanaged;
private boolean connectLaunchPerformed;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -272,7 +273,8 @@ public void startDataPull(DataPullMode mode, String password) {
uiController.getEnteredPasswordOrPin());
break;
case CCZ_DEMO:
OfflineUserRestore offlineUserRestore = CommCareApplication.instance().getCommCarePlatform().getDemoUserRestore();
OfflineUserRestore offlineUserRestore = CommCareApplication.instance().getCommCarePlatform()
.getDemoUserRestore();
uiController.setUsername(offlineUserRestore.getUsername());
uiController.setPasswordOrPin(OfflineUserRestore.DEMO_USER_PASSWORD);
formAndDataSyncer.performDemoUserRestore(this, offlineUserRestore);
Expand Down Expand Up @@ -307,7 +309,6 @@ protected boolean checkForSeatedAppChange() {
return false;
}


// cancels all worker tasks for previously seated app
private static void disableWorkForLastSeatedApp() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(CommCareApplication.instance());
Expand Down Expand Up @@ -356,9 +357,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
uiController.refreshForNewApp();
invalidateOptionsMenu();
usernameBeforeRotation = passwordOrPinBeforeRotation = null;
} else if (resultCode == ConnectConstants.LOGIN_CONNECT_LAUNCH_REQUEST_CODE) {
} else if (requestCode == ConnectConstants.LOGIN_CONNECT_LAUNCH_REQUEST_CODE) {
connectIDManager.handleFinishedActivity(this, resultCode);
}

super.onActivityResult(requestCode, resultCode, intent);
}

Expand Down Expand Up @@ -404,6 +406,7 @@ private boolean tryLocalLogin(final String username, String passwordOrPin,
LoginMode loginMode, boolean blockRemoteKeyManagement,
DataPullMode pullModeToUse) {
try {

final boolean triggerMultipleUsersWarning = getMatchingUsersCount(username) > 1
&& warnMultipleAccounts;

Expand Down Expand Up @@ -574,6 +577,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
registerConnectIdUser();
return true;
case MENU_CONNECT_FORGET:
FirebaseAnalyticsUtil.reportCccForget();
connectIDManager.forgetUser(AnalyticsParamValue.CCC_FORGOT_USER_LOGIN_PAGE);
uiController.setPasswordOrPin("");
setConnectAppState(Unmanaged);
Expand All @@ -585,7 +589,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void loginDemoUser() {
OfflineUserRestore offlineUserRestore = CommCareApplication.instance().getCommCarePlatform().getDemoUserRestore();
OfflineUserRestore offlineUserRestore = CommCareApplication.instance().getCommCarePlatform()
.getDemoUserRestore();
FirebaseAnalyticsUtil.reportPracticeModeUsage(offlineUserRestore);

if (offlineUserRestore != null) {
Expand All @@ -612,7 +617,8 @@ public void raiseLoginMessage(MessageTag messageTag, boolean showTop) {
}

@Override
public void raiseLoginMessage(MessageTag messageTag, boolean showTop, NotificationActionButtonInfo.ButtonAction buttonAction) {
public void raiseLoginMessage(MessageTag messageTag, boolean showTop,
NotificationActionButtonInfo.ButtonAction buttonAction) {
NotificationMessage message = NotificationMessageFactory.message(messageTag,
NOTIFICATION_MESSAGE_LOGIN, buttonAction);
raiseMessage(message, showTop);
Expand Down Expand Up @@ -674,12 +680,9 @@ protected void restoreEnteredTextFromRotation() {
}
}


protected void populateAppSpinner(ArrayList<ApplicationRecord> readyApps) {
ArrayList<String> appNames = new ArrayList<>();

appIdDropdownList.clear();

for (ApplicationRecord r : readyApps) {
appNames.add(r.getDisplayName());
appIdDropdownList.add(r.getUniqueId());
Expand Down Expand Up @@ -730,7 +733,8 @@ protected void deliverResult(LoginActivity receiver,
Toast.LENGTH_LONG).show();
UpdateActivity.OnSuccessfulUpdate(false, false);
} else {
CommCareApplication.notificationManager().reportNotificationMessage(NotificationMessageFactory.message(result));
CommCareApplication.notificationManager().reportNotificationMessage(
NotificationMessageFactory.message(result));
}

localLoginOrPullAndLogin(uiController.isRestoreSessionChecked());
Expand Down Expand Up @@ -763,7 +767,9 @@ private void localLoginOrPullAndLogin(boolean restoreSession) {
}

// If local login was not successful
startDataPull(CommCareApplication.instance().isConsumerApp() ? DataPullMode.CONSUMER_APP : DataPullMode.NORMAL,
startDataPull(CommCareApplication.instance().isConsumerApp() ?
DataPullMode.CONSUMER_APP :
DataPullMode.NORMAL,
uiController.getEnteredPasswordOrPin());
}

Expand Down Expand Up @@ -801,11 +807,11 @@ public void handlePullTaskResult(ResultAndError<DataPullTask.PullTaskResult> res
case EMPTY_URL:
raiseLoginMessage(StockMessages.Empty_Url, true);
break;
case TOKEN_UNAVAILABLE:
raiseLoginMessage(StockMessages.TokenUnavailable, false);
case TOKEN_DENIED:
raiseLoginMessage(StockMessages.TokenDenied, false);
case AUTH_FAILED:
if (connectIDManager.isSeatedAppLinkedToConnectId(uiController.getEnteredUsername())) {
Logger.exception("Token auth error for connect managed app",
new Throwable("Token Auth failed during login for a ConnectID managed app"));
}
raiseLoginMessage(StockMessages.Auth_BadCredentials, false);
break;
case BAD_DATA_REQUIRES_INTERVENTION:
Expand Down
22 changes: 14 additions & 8 deletions app/src/org/commcare/activities/LoginActivityUIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import android.widget.Spinner;
import android.widget.TextView;

import androidx.preference.PreferenceManager;

import org.commcare.CommCareApplication;
import org.commcare.CommCareNoficationManager;
import org.commcare.android.database.app.models.UserKeyRecord;
import org.commcare.android.database.global.models.ApplicationRecord;
import org.commcare.connect.ConnectIDManager;
import org.commcare.connect.database.ConnectUserDatabaseUtil;
import org.commcare.connect.ConnectIDManager;
import org.commcare.dalvik.R;
import org.commcare.google.services.analytics.FirebaseAnalyticsUtil;
import org.commcare.interfaces.CommCareActivityUIController;
import org.commcare.models.database.SqlStorage;
import org.commcare.preferences.DevSessionRestorer;
Expand All @@ -42,14 +41,15 @@
import org.commcare.views.PasswordShow;
import org.commcare.views.RectangleButtonWithText;
import org.commcare.views.UiElement;

import org.javarosa.core.services.locale.Localization;

import java.util.ArrayList;
import java.util.Vector;

import javax.annotation.Nullable;

import androidx.preference.PreferenceManager;

/**
* Handles login activity UI
*
Expand All @@ -70,6 +70,9 @@ public class LoginActivityUIController implements CommCareActivityUIController {
@UiElement(value = R.id.btn_view_notifications)
private RectangleButtonWithText notificationButton;

@UiElement(value = R.id.connect_login_button)
private Button connectLoginButton;

@UiElement(value = R.id.edit_username, locale = "login.username")
private AutoCompleteTextView username;

Expand All @@ -96,8 +99,7 @@ public class LoginActivityUIController implements CommCareActivityUIController {

@UiElement(value = R.id.primed_password_message, locale = "login.primed.prompt")
private TextView loginPrimedMessage;
@UiElement(value = R.id.connect_login_button)
private Button connectLoginButton;

@UiElement(value = R.id.login_or)
private TextView orLabel;

Expand Down Expand Up @@ -157,7 +159,10 @@ public void setupUI() {
setTextChangeListeners();
setBannerLayoutLogic();

loginButton.setOnClickListener(arg0 -> activity.initiateLoginAttempt(isRestoreSessionChecked()));
loginButton.setOnClickListener(arg0 -> {
FirebaseAnalyticsUtil.reportLoginClicks();
activity.initiateLoginAttempt(isRestoreSessionChecked());
});

passwordOrPin.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Expand Down Expand Up @@ -198,7 +203,6 @@ private void setupUsernameEntryBox() {

private void setBannerLayoutLogic() {
final View activityRootView = activity.findViewById(R.id.screen_login_main);
final SharedPreferences prefs = CommCareApplication.instance().getCurrentApp().getAppPreferences();
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
() -> {
int hideAll = getResources().getInteger(
Expand All @@ -225,6 +229,7 @@ public void refreshView() {

// Decide whether or not to show the app selection spinner based upon # of usable apps
ArrayList<ApplicationRecord> readyApps = MultipleAppsUtil.getUsableAppRecords();

ApplicationRecord presetAppRecord = getPresetAppRecord(readyApps);
boolean noApps = readyApps.isEmpty();
if (readyApps.size() == 1 || presetAppRecord != null) {
Expand Down Expand Up @@ -458,6 +463,7 @@ protected void setMultipleAppsUiState(ArrayList<String> appNames, int position)
spinner.setVisibility(View.VISIBLE);
}


protected void setPermissionsGrantedState() {
loginButton.setEnabled(true);
errorContainer.setVisibility(View.GONE);
Expand Down
Loading
Loading