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
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);
Comment on lines 582 to +584
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Bug fix: Now correctly passing intent data with result

This change fixes a critical issue where the intent containing the REDIRECT_TO_CONNECT_OPPORTUNITY_INFO flag wasn't being passed to the calling activity, causing the job status button click functionality to fail.

🤖 Prompt for AI Agents (early access)
In app/src/org/commcare/activities/HomeScreenBaseActivity.java around lines 582 to 584, the intent with the REDIRECT_TO_CONNECT_OPPORTUNITY_INFO flag was not properly passed back to the calling activity. Fix this by creating a new Intent, adding the flag as an extra, and then passing this intent to setResult with RESULT_OK to ensure the calling activity receives the data correctly.

finish();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
import org.commcare.modern.models.MetaField;
import org.commcare.utils.CrashUtil;
import org.javarosa.core.model.utils.DateUtils;
import org.joda.time.LocalDate;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;

import androidx.annotation.NonNull;

/**
* Data class for holding info related to a Connect job
*
Expand Down Expand Up @@ -466,22 +461,17 @@ public String getWorkingHours() {
}

try {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
//DateTimeFormatter is more efficient than SimpleDateFormat
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(WORKING_HOURS_SOURCE_FORMAT);
LocalTime start = LocalTime.parse(dailyStart, formatter);
LocalTime end = LocalTime.parse(dailyFinish, formatter);
formatter = DateTimeFormatter.ofPattern(WORKING_HOURS_TARGET_FORMAT);
return String.format(WORKING_HOURS_PATTERN,formatter.format(start),formatter.format(end));
}else{
// remove this code whenever we change minSdk to 26
SimpleDateFormat formatter = new SimpleDateFormat(WORKING_HOURS_SOURCE_FORMAT);
Date start = formatter.parse(dailyStart);
Date end = formatter.parse(dailyFinish);
formatter = new SimpleDateFormat(WORKING_HOURS_TARGET_FORMAT);
return String.format(WORKING_HOURS_PATTERN,formatter.format(start),formatter.format(end));
}
} catch(Exception e) {
SimpleDateFormat utcFormat = new SimpleDateFormat(WORKING_HOURS_SOURCE_FORMAT, Locale.getDefault());
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date startTime = utcFormat.parse(dailyStart);
Date endTime = utcFormat.parse(dailyFinish);
SimpleDateFormat localFormat = new SimpleDateFormat(WORKING_HOURS_TARGET_FORMAT, Locale.getDefault());

String startTimeLocal = localFormat.format(startTime);
String endTimeLocal = localFormat.format(endTime);

return String.format(WORKING_HOURS_PATTERN, startTimeLocal, endTimeLocal);
} catch (Exception e) {
CrashUtil.reportException(new Exception("Error parsing working hours", e));
return null;
}
Expand Down
1 change: 0 additions & 1 deletion app/src/org/commcare/connect/ConnectConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;
Expand Down