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
22 changes: 9 additions & 13 deletions app/src/org/commcare/activities/CommCareSetupActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
* Responsible for identifying the state of the application (uninstalled,
* installed) and performing any necessary setup to get to a place where
* CommCare can load normally.
* <p>
*
* If the startup activity identifies that the app is installed properly it
* should not ever require interaction or be visible to the user.
*
Expand All @@ -86,8 +86,7 @@ public class CommCareSetupActivity extends CommCareActivity<CommCareSetupActivit
RuntimePermissionRequester {

private static final String TAG = CommCareSetupActivity.class.getSimpleName();
private static final int MENU_CONNECT_SIGN_IN = Menu.FIRST + 4;
private static final int MENU_CONNECT_FORGET = Menu.FIRST + 5;

private static final String KEY_UI_STATE = "current_install_ui_state";
private static final String KEY_LAST_INSTALL_MODE = "offline_install";
private static final String KEY_FROM_EXTERNAL = "from_external";
Expand Down Expand Up @@ -121,6 +120,8 @@ public enum UiState {
public static final int MENU_ARCHIVE = Menu.FIRST;
private static final int MENU_SMS = Menu.FIRST + 2;
private static final int MENU_FROM_LIST = Menu.FIRST + 3;
private static final int MENU_CONNECT_SIGN_IN = Menu.FIRST + 4;
private static final int MENU_CONNECT_FORGET = Menu.FIRST + 5;

// Activity request codes
public static final int BARCODE_CAPTURE = 1;
Expand Down Expand Up @@ -510,8 +511,8 @@ public boolean onPrepareOptionsMenu(Menu menu) {
* UPDATE: 16/Jan/2019: This code path is no longer in use, since we have turned off sms install
* in response to Google play console policies for now. We are going to watch out for a while
* for any changes in policies in near future before completely removing the surrounding code
* <p>
* <p>
*
*
* Scan SMS messages for texts with profile references.
*
* @param installTriggeredManually if scan was triggered manually, then
Expand Down Expand Up @@ -639,7 +640,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
private void updateConnectButton() {
installFragment.updateConnectButton(!fromManager && !fromExternal && ConnectIDManager.getInstance().isloggedIn(), v -> {
ConnectIDManager.getInstance().unlockConnect(this, success -> {
// ConnectManager.goToConnectJobsList(this);
ConnectIDManager.getInstance().goToConnectJobsList(this);
});
});
}
Expand Down Expand Up @@ -740,11 +741,7 @@ public void failInvalidReference(InvalidReferenceException e, AppInstallStatus s

@Override
public void failBadReqs(String versionRequired, String versionAvailable, boolean majorIsProblem) {
String versionMismatch = Localization.get("install.version.mismatch", new String[]{versionRequired, versionAvailable});
Intent intent = new Intent(this, PromptApkUpdateActivity.class);
intent.putExtra(PromptApkUpdateActivity.REQUIRED_VERSION, versionRequired);
intent.putExtra(PromptApkUpdateActivity.CUSTOM_PROMPT_TITLE, versionMismatch);
startActivity(intent);
ResourceInstallUtils.showApkUpdatePrompt(this, versionRequired, versionAvailable);
}

@Override
Expand Down Expand Up @@ -780,8 +777,7 @@ public void failWithNotification(AppInstallStatus statusFailState, NotificationA

@Override
public void failTargetMismatch() {
Intent intent = new Intent(this, TargetMismatchErrorActivity.class);
startActivity(intent);
ResourceInstallUtils.showTargetMismatchError(this);
}


Expand Down
6 changes: 2 additions & 4 deletions app/src/org/commcare/activities/DispatchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ public class DispatchActivity extends AppCompatActivity {
public static final String START_FROM_LOGIN = "process_successful_login";
public static final String EXECUTE_RECOVERY_MEASURES = "execute_recovery_measures";
public static final String SESSION_REBUILD_REQUEST = "session_rebuild_request";

public static final String REDIRECT_TO_CONNECT_OPPORTUNITY_INFO = "redirect-to-connect-opportunity-info";
private static final int LOGIN_USER = 0;
private static final int HOME_SCREEN = 1;
public static final int INIT_APP = 2;
public static final int RECOVERY_MEASURES = 3;
private boolean connectIdManagedLogin;
private boolean connectManagedLogin;


/**
Expand All @@ -68,7 +65,8 @@ public class DispatchActivity extends AppCompatActivity {
private boolean startFromLogin;
private LoginMode lastLoginMode;
private boolean userManuallyEnteredPasswordMode;

private boolean connectIdManagedLogin;
private boolean connectManagedLogin;
private boolean shouldFinish;
private boolean userTriggeredLogout;
private boolean shortcutExtraWasConsumed;
Expand Down
2 changes: 1 addition & 1 deletion app/src/org/commcare/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ private void handleFormLoadCompletion(AndroidFormController fc) {
String localeKey =
(fc.getInterruptedFormState() == null
|| fc.getInterruptedFormState().isInterruptedDueToSessionExpiration())
? "form.entry.restart.after.expiration" : "form.entry.restart.after.session.pause";
? "form.entry.restart.after.expiration" : "form.entry.restart.after.session.pause";
Toast.makeText(this, Localization.get(localeKey), Toast.LENGTH_LONG).show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected void showPreviousView(boolean showSwipeAnimation) {

//Did we jump at all? (not sure how we could have, but there might be a mismatch)
if (lastValidIndex.equals(startIndex)) {
//If not, don't even bother changing the view.
//If not, don't even bother changing the view.
//NOTE: This needs to be the same as the
//exit condition below, in case either changes
activity.triggerUserQuitInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class FullscreenVideoViewActivity : AppCompatActivity() {
}
return -1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();
refreshUI();
refreshUi();
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ensure no stale references to refreshUI remain.
Although you've updated calls to refreshUi(), let's verify there are no leftover calls to the old refreshUI() method elsewhere, which could lead to compilation errors.


🏁 Script executed:

#!/bin/bash
# Verify no stale references to 'refreshUI'
rg -n 'refreshUI\('

Length of output: 1024


Update stale refreshUI() references to refreshUi()
Several remaining calls and declarations of the old refreshUI() method must be renamed to refreshUi() to prevent compilation errors. Please update the following locations:

  • app/src/org/commcare/activities/RootMenuHomeActivity.java:
    • public void refreshUI() → refreshUi()
  • app/src/org/commcare/activities/StandardHomeActivity.java (line 263):
    • public void refreshUI() → refreshUi()
  • app/src/org/commcare/activities/HomeScreenBaseActivity.java:
    • Lines 623, 810, 825, 930, 1004, 1111, 1317, 1352: change refreshUI();refreshUi();
    • Line 1511: change abstract void refreshUI();abstract void refreshUi();

After renaming these, rerun your build to confirm no stale references remain.

🤖 Prompt for AI Agents (early access)
In app/src/org/commcare/activities/RootMenuHomeActivity.java, rename the method declaration from refreshUI() to refreshUi(). In app/src/org/commcare/activities/StandardHomeActivity.java at line 263, rename the method declaration from refreshUI() to refreshUi(). In app/src/org/commcare/activities/HomeScreenBaseActivity.java, update all calls to refreshUI() to refreshUi() at lines 623, 810, 825, 930, 1004, 1111, 1317, and 1352, and rename the abstract method declaration at line 1511 from refreshUI() to refreshUi(). After making these changes, rebuild the project to ensure no stale references remain.

}

private void refreshUI() {
private void refreshUi() {
TextView enabledTextView = findViewById(R.id.enabled_textview);
TextView notEnabledTextView = findViewById(R.id.not_enabled_textview);
Button claimButton = findViewById(R.id.claim_button);
Expand Down Expand Up @@ -108,7 +108,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
GlobalPrivilegesManager.enablePrivilege(p, activatedPrivileges.first);
}
}
refreshUI();
refreshUi();

} catch (PrivilegesUtility.UnrecognizedPayloadVersionException e) {
e.printStackTrace();
Expand Down Expand Up @@ -158,7 +158,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
for (String privilege : GlobalPrivilegesManager.getEnabledPrivileges()) {
GlobalPrivilegesManager.disablePrivilege(privilege);
}
refreshUI();
refreshUi();
return true;
// Respond to the action bar's Up/Home button
case android.R.id.home:
Expand Down
2 changes: 1 addition & 1 deletion app/src/org/commcare/activities/HomeButtons.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class HomeButtons {

private final static String[] buttonNames =
new String[]{"start", "training", "saved", "incomplete","connect", "sync", "report", "logout"};
new String[]{"start", "training", "saved", "incomplete", "connect", "sync", "report", "logout"};

/**
* Note: The order in which home cards are returned by this method should be consistent with
Expand Down
1 change: 1 addition & 0 deletions app/src/org/commcare/activities/SettingsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class SettingsHelper {
public static void launchDateSettings(Context context) {
context.startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
}

public static void launchSecuritySettings(Context context) {
context.startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ConnectConstants.CONNECT_UNLOCK_PIN) {
//PIN unlock should only be requested while BiometricConfig fragment is active, else this will crash
getCurrentFragment().handleFinishedPinActivity(requestCode, resultCode, data);
} else if (requestCode == ConnectConstants.CONNECTID_REQUEST_CODE) {
} else if (requestCode == ConnectConstants.CONNECT_JOB_INFO) {
handleRedirection(data);
}
if (requestCode == RESULT_OK) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/org/commcare/adapters/EntityListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private View getTileView(Entity<TreeReference> entity, EntityViewTile tile) {
int[] titleColor = AndroidUtil.getThemeColorIDs(commCareActivity, new int[]{R.attr.entity_select_title_text_color});
if (tile == null) {
tile = EntityViewTile.createTileForEntitySelectDisplay(commCareActivity, detail, entity,
currentSearchTerms, mImageLoader, mFuzzySearchEnabled, selectActivityInAwesomeMode);
currentSearchTerms, mImageLoader, mFuzzySearchEnabled, selectActivityInAwesomeMode);
} else {
tile.setSearchTerms(currentSearchTerms);
tile.addFieldViews(commCareActivity, detail, entity);
Expand Down Expand Up @@ -437,4 +437,4 @@ public void saveCalloutDataToSession() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,4 @@ public void setUuid(String uuid) {
public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}
}
}
15 changes: 15 additions & 0 deletions app/src/org/commcare/android/logging/ReportingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.commcare.AppUtils;
import org.commcare.CommCareApp;
import org.commcare.CommCareApplication;
import org.commcare.connect.ConnectIDManager;
import org.commcare.dalvik.BuildConfig;
import org.commcare.preferences.HiddenPreferences;
import org.commcare.preferences.ServerUrls;
Expand Down Expand Up @@ -141,4 +142,18 @@ public static String getAppBuildProfileId() {
return "";
}
}

public static String getUserForCrashes() {
String user = getUser();
if(user.isEmpty()) {
try {
if (ConnectIDManager.getInstance().isloggedIn()) {
return ConnectIDManager.getInstance().getUser(CommCareApplication.instance()).getUserId();
}
} catch (Exception ignored) {
}
}

return null;
}
}
6 changes: 5 additions & 1 deletion app/src/org/commcare/connect/ConnectConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
public class ConnectConstants {
public static final int CONNECT_ID_TASK_ID_OFFSET = 1000;
public final static int CREDENTIAL_PICKER_REQUEST = 2000;
public static final int CONNECTID_REQUEST_CODE = 1034;
public static final int LOGIN_CONNECT_LAUNCH_REQUEST_CODE = 1050;
public static final int COMMCARE_SETUP_CONNECT_LAUNCH_REQUEST_CODE = 1051;
public static final int STANDARD_HOME_CONNECT_LAUNCH_REQUEST_CODE = 1052;
public static final int CONFIGURE_BIOMETRIC_REQUEST_CODE = 1053;
public static final int NETWORK_ACTIVITY_ID = 7000;
public static final String USERNAME = "USERNAME";
public static final String PASSWORD = "PASSWORD";
Expand All @@ -28,6 +28,10 @@ public class ConnectConstants {
public static final String METHOD_CHANGE_PRIMARY = "CHANGE_PRIMARY";
public static final String METHOD_CHANGE_ALTERNATE = "CHANGE_ALTERNATE";
public static final String METHOD_RECOVER_PRIMARY = "RECOVER_PRIMARY";
public static final String CCC_DEST_OPPORTUNITY_SUMMARY_PAGE = "ccc_opportunity_summary_page";
public static final String CCC_DEST_LEARN_PROGRESS = "ccc_learn_progress";
public static final String CCC_DEST_DELIVERY_PROGRESS = "ccc_delivery_progress";
public static final String CCC_DEST_PAYMENTS = "ccc_payment";
public static final String CONNECT_KEY_USERNAME = "username";
public static final String CONNECT_KEY_NAME = "name";
public static final String CONNECT_KEY_SECRET = "secret";
Expand Down
2 changes: 1 addition & 1 deletion app/src/org/commcare/connect/ConnectIDManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void onAuthenticationFailed() {
public void completeSignin() {
connectStatus = ConnectIdStatus.LoggedIn;
scheduleHearbeat();
CrashUtil.registerConnectUser();
CrashUtil.registerUserData();
}

public void handleFinishedActivity(CommCareActivity<?> activity, int resultCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public InputStream getStream(Map<String, String> params) throws IOException {
}
throw e;
}

if (response.isSuccessful()) {
responseHeaders = response.headers();
return response.body().byteStream();
Expand Down
28 changes: 28 additions & 0 deletions app/src/org/commcare/engine/resource/ResourceInstallUtils.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.commcare.engine.resource;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import org.commcare.CommCareApp;
import org.commcare.CommCareApplication;
import org.commcare.activities.PromptApkUpdateActivity;
import org.commcare.activities.TargetMismatchErrorActivity;
import org.commcare.android.database.global.models.ApplicationRecord;
import org.commcare.core.network.CaptivePortalRedirectException;
import org.commcare.engine.resource.installers.SingleAppInstallation;
Expand All @@ -26,6 +30,7 @@
import org.commcare.utils.SessionUnavailableException;
import org.commcare.views.notifications.NotificationActionButtonInfo;
import org.javarosa.core.services.Logger;
import org.javarosa.core.services.locale.Localization;
import org.javarosa.core.util.PropertyUtils;

import java.net.MalformedURLException;
Expand Down Expand Up @@ -145,6 +150,29 @@ public static void handleAppInstallResult(ResourceEngineTask resourceEngineTask,
}
}

/**
* Shows Apk update prompt to user
* @param context current context
* @param versionRequired apk version required
* @param versionAvailable apk version available
*/
public static void showApkUpdatePrompt(Context context, String versionRequired, String versionAvailable) {
String versionMismatch = Localization.get("install.version.mismatch", new String[]{versionRequired, versionAvailable});
Intent intent = new Intent(context, PromptApkUpdateActivity.class);
intent.putExtra(PromptApkUpdateActivity.REQUIRED_VERSION, versionRequired);
intent.putExtra(PromptApkUpdateActivity.CUSTOM_PROMPT_TITLE, versionMismatch);
context.startActivity(intent);
}

/**
* Show target mismatch error during CC App installation
* @param context current context
*/
public static void showTargetMismatchError(Context context) {
Intent intent = new Intent(context, TargetMismatchErrorActivity.class);
context.startActivity(intent);
}

/**
* @return Version from profile in the app's upgrade table; -1 if upgrade
* profile not found.
Expand Down
10 changes: 6 additions & 4 deletions app/src/org/commcare/fragments/BreadcrumbBarHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ public class BreadcrumbBarHelper {
public void attachBreadcrumbBar(CommCareActivity activity) {
boolean breadCrumbsEnabled = !DeveloperPreferences.isActionBarEnabled();
ActionBar actionBar = activity.getSupportActionBar();
if (!breadCrumbsEnabled) {
configureSimpleNav(activity, actionBar);
} else {
attachBreadcrumbBar(activity, actionBar);
if (actionBar != null) {
if (!breadCrumbsEnabled) {
configureSimpleNav(activity, actionBar);
} else {
attachBreadcrumbBar(activity, actionBar);
}
}

try {
Expand Down
4 changes: 0 additions & 4 deletions app/src/org/commcare/heartbeat/HeartbeatRequester.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

import androidx.work.WorkManager;

import com.google.common.collect.ArrayListMultimap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down
2 changes: 1 addition & 1 deletion app/src/org/commcare/logic/AndroidFormController.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ public FormDef getFormDef() {
public InterruptedFormState getInterruptedFormState(){
return interruptedFormState;
}
}
}
4 changes: 2 additions & 2 deletions app/src/org/commcare/models/AndroidSessionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public class AndroidSessionWrapper implements SessionWrapperInterface {
private static final String TAG = AndroidSessionWrapper.class.getSimpleName();
//The state descriptor will need these
//The state descriptor will need these
private final SessionWrapper session;
private int formRecordId = -1;
private int sessionStateRecordId = -1;
Expand Down Expand Up @@ -394,4 +394,4 @@ public void executeEndpointStack(Endpoint endpoint, HashMap args) {
Endpoint.populateEndpointArgumentsToEvaluationContext(endpoint, args, evaluationContext);
executeStackActions(endpoint.getStackOperations(), evaluationContext);
}
}
}
2 changes: 1 addition & 1 deletion app/src/org/commcare/sync/ExternalDataUpdateHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public static void sendBroadcastFailSafe(Context context, Intent intent, @Nullab
Logger.exception("Exception when sending a broadcast with intent " + intent, e);
}
}
}
}
1 change: 1 addition & 0 deletions app/src/org/commcare/sync/FirebaseMessagingDataSyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ private void informUserAboutPendingSync(FCMMessageData fcmMessageData) {
Bundle b = new Bundle();
b.putSerializable(FCM_MESSAGE_DATA, FirebaseMessagingUtil.serializeFCMMessageData(fcmMessageData));
intent.putExtra(FCM_MESSAGE_DATA_KEY, b);

ExternalDataUpdateHelper.sendBroadcastFailSafe(context, intent, null);
}

Expand Down
Loading
Loading