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
2 changes: 1 addition & 1 deletion app/src/org/commcare/activities/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private boolean handleConnectSignIn(CommCareActivity<?> context, String username
if (connectIDManager.isloggedIn()) {
connectIDManager.completeSignin();
String appId = CommCareApplication.instance().getCurrentApp().getUniqueId();
ConnectJobRecord job = connectIDManager.setConnectJobForApp(context, appId);
ConnectJobRecord job = ConnectManager.setConnectJobForApp(context, appId);

if (job != null) {
connectIDManager.updateAppAccess(context, appId, username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private Vector<String> getHiddenButtons() {
if (!CommCareApplication.instance().getCurrentApp().hasVisibleTrainingContent()) {
hiddenButtons.add("training");
}
if (!ConnectIDManager.getInstance().shouldShowJobStatus(activity, ccApp.getUniqueId())) {
if (!ConnectManager.shouldShowJobStatus(activity, ccApp.getUniqueId())) {
hiddenButtons.add("connect");
}
return hiddenButtons;
Expand Down
6 changes: 0 additions & 6 deletions app/src/org/commcare/activities/connect/ConnectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ public void setTitle(CharSequence title) {
getSupportActionBar().setTitle(title);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @androidx.annotation.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ConnectIDManager.getInstance().handleFinishedActivity(this, resultCode);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_connect, menu);
Expand Down
16 changes: 9 additions & 7 deletions app/src/org/commcare/activities/connect/ConnectIdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ private void updateBackButton() {
}

private void beginSecondaryPhoneVerification(Context parent) {
NavDirections navDirections = ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentToConnectidMessage
(parent.getString(R.string.connect_recovery_alt_title),
parent.getString(R.string.connect_recovery_alt_message),
ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE,
parent.getString(R.string.connect_password_fail_button),
parent.getString(R.string.connect_recovery_alt_change_button),null,null);
CommCareNavController.navigateSafely(controller,navDirections);
NavDirections navDirections =
ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentToConnectidMessage
(parent.getString(R.string.connect_recovery_alt_title),
parent.getString(R.string.connect_recovery_alt_message),
ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE,
parent.getString(R.string.connect_password_fail_button),
parent.getString(R.string.connect_recovery_alt_change_button), null,
null).setIsCancellable(false);
CommCareNavController.navigateSafely(controller, navDirections);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.commcare.models.framework.Persisting;
import org.commcare.modern.database.Table;
import org.commcare.modern.models.MetaField;
import org.commcare.utils.JsonExtensions;
import org.javarosa.core.model.utils.DateUtils;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -90,8 +91,7 @@ public static ConnectJobDeliveryRecord fromJson(JSONObject json, int jobId) thro
delivery.slug = json.getString(META_SLUG);
delivery.entityId = json.getString(META_ENTITY_ID);
delivery.entityName = json.getString(META_ENTITY_NAME);
delivery.reason = json.getString(META_REASON);

delivery.reason = JsonExtensions.optStringSafe(json, META_REASON,"");
delivery.flags = ConnectJobDeliveryFlagRecord.fromJson(json.getJSONObject(META_FLAGS), deliveryId);

return delivery;
Expand Down
38 changes: 0 additions & 38 deletions app/src/org/commcare/connect/ConnectIDManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public enum ConnectAppMangement {
private static volatile ConnectIDManager manager = null;
private ConnectIdStatus connectStatus = ConnectIdStatus.NotIntroduced;
private Context parentActivity;
private String primedAppIdForAutoLogin = null;
private int failedPinAttempts = 0;
private ConnectJobRecord activeJob = null;


//Singleton, private constructor
Expand Down Expand Up @@ -453,28 +451,14 @@ public void goToConnectJobsList(Context parent) {


public void goToActiveInfoForJob(Activity activity, boolean allowProgression) {
///TODO uncomment with connect pahse pr
completeSignin();
Intent i = new Intent(activity, ConnectActivity.class);
i.putExtra("info", true);
i.putExtra("buttons", allowProgression);
activity.startActivity(i);
}

public ConnectJobRecord setConnectJobForApp(Context context, String appId) {
ConnectJobRecord job = null;
ConnectAppRecord appRecord = getAppRecord(context, appId);
if (appRecord != null) {
job = ConnectJobUtils.getCompositeJob(context, appRecord.getJobId());
}
setActiveJob(job);
return job;
}

public boolean isLoginManagedByConnectId(String appId, String userId) {
AuthInfo.ProvidedAuth auth = getCredentialsForApp(appId, userId);
return auth != null;
}

private ConnectAppRecord getAppRecord(Context context, String appId) {
return ConnectJobUtils.getAppRecord(context, appId);
Expand Down Expand Up @@ -586,10 +570,6 @@ public void beginSecondaryPhoneVerification(CommCareActivity<?> parent, int requ
launchConnectId(parent, ConnectConstants.VERIFY_PHONE, requestCode);
}

public void setActiveJob(ConnectJobRecord job) {
activeJob = job;
}

public boolean isSeatedAppLinkedToConnectId(String username) {
try {
if (isloggedIn()) {
Expand All @@ -616,14 +596,6 @@ public ConnectAppMangement evaluateAppState(Context context, String appId, Strin
ConnectAppMangement.Unmanaged;
}

private boolean isConnectApp(Context context, String appId) {
return evaluateAppState(context, appId, "") == ConnectIDManager.ConnectAppMangement.Connect;
}

public boolean isLoggedInWithConnectApp(Context context, String appId) {
return isloggedIn() && isConnectApp(context, appId);
}

public static AuthInfo.TokenAuth getHqTokenIfLinked(String username) throws TokenRequestDeniedException, TokenUnavailableException {
if (!manager.isloggedIn()) {
return null;
Expand Down Expand Up @@ -659,16 +631,6 @@ public void setFailureAttempt(int failureAttempt) {
failedPinAttempts = failureAttempt;
}

public boolean shouldShowJobStatus(Context context, String appId) {
ConnectAppRecord record = getAppRecord(context, appId);
if(record == null || activeJob == null) {
return false;
}

//Only time not to show is when we're in learn app but job is in delivery state
return !record.getIsLearning() || activeJob.getStatus() != ConnectJobRecord.STATUS_DELIVERING;
}


/**
* Interface for handling callbacks when a ConnectID activity finishes
Expand Down
28 changes: 25 additions & 3 deletions app/src/org/commcare/connect/ConnectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public static void updateSecondaryPhoneConfirmationTile(Context context, View ti
public static ConnectUserRecord getUser(Context context) {
return ConnectUserDatabaseUtil.getUser(context);
}
private static ConnectJobRecord activeJob = null;

private ConnectJobRecord activeJob = null;


public static boolean wasAppLaunchedFromConnect(String appId) {
Expand All @@ -172,13 +172,15 @@ public static boolean wasAppLaunchedFromConnect(String appId) {
}

public static void setActiveJob(ConnectJobRecord job) {
getInstance().activeJob = job;
activeJob = job;
}

public static ConnectJobRecord getActiveJob() {
return getInstance().activeJob;
return activeJob;
}



private static void launchConnectId(CommCareActivity<?> parent, String task, ConnectActivityCompleteListener listener) {
Intent intent = new Intent(parent, ConnectIdActivity.class);
intent.putExtra("TASK", task);
Expand All @@ -195,6 +197,26 @@ public static void goToMessaging(Context parent) {
parent.startActivity(i);
}

public static ConnectJobRecord setConnectJobForApp(Context context, String appId) {
ConnectJobRecord job = null;
ConnectAppRecord appRecord = getAppRecord(context, appId);
if (appRecord != null) {
job = ConnectJobUtils.getCompositeJob(context, appRecord.getJobId());
}
setActiveJob(job);
return job;
}

public static boolean shouldShowJobStatus(Context context, String appId) {
ConnectAppRecord record = getAppRecord(context, appId);
if(record == null || activeJob == null) {
return false;
}

//Only time not to show is when we're in learn app but job is in delivery state
return !record.getIsLearning() || activeJob.getStatus() != ConnectJobRecord.STATUS_DELIVERING;
}

public static ConnectAppRecord getAppRecord(Context context, String appId) {
return ConnectJobUtils.getAppRecord(context, appId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.common.base.Strings;

import org.commcare.android.database.connect.models.ConnectJobDeliveryFlagRecord;
import org.commcare.android.database.connect.models.ConnectJobDeliveryRecord;
import org.commcare.android.database.connect.models.ConnectJobRecord;
Expand Down Expand Up @@ -190,7 +192,7 @@ public void bind(Context context, ConnectJobDeliveryRecord delivery) {
statusText.setText(delivery.getStatus());

String descriptionText = delivery.getReason();
if(descriptionText == null) {
if(Strings.isNullOrEmpty(descriptionText)) {
if(delivery.getFlags() != null) {
List<String> flagStrings = new ArrayList<>();
for (ConnectJobDeliveryFlagRecord flag : delivery.getFlags()) {
Expand Down