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
13 changes: 9 additions & 4 deletions app/src/org/commcare/connect/PersonalIdManager.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.commcare.connect;

import static org.commcare.google.services.analytics.AnalyticsParamValue.FAILURE_UNLOCK_FAILED;
import static org.commcare.google.services.analytics.AnalyticsParamValue.FAILURE_USER_DENIED;
import static org.commcare.google.services.analytics.AnalyticsParamValue.SYNC_SUCCESS;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
Expand Down Expand Up @@ -41,6 +37,7 @@
import org.commcare.core.network.AuthInfo;
import org.commcare.dalvik.R;
import org.commcare.google.services.analytics.FirebaseAnalyticsUtil;
import org.commcare.navdrawer.BaseDrawerActivity;
import org.commcare.pn.workermanager.NotificationsSyncWorkerManager;
import org.commcare.util.LogTypes;
import org.commcare.utils.BiometricsHelper;
Expand All @@ -53,6 +50,10 @@
import java.util.Date;
import java.util.concurrent.TimeUnit;

import static org.commcare.google.services.analytics.AnalyticsParamValue.FAILURE_UNLOCK_FAILED;
import static org.commcare.google.services.analytics.AnalyticsParamValue.FAILURE_USER_DENIED;
import static org.commcare.google.services.analytics.AnalyticsParamValue.SYNC_SUCCESS;

/**
* Manager class for PersonalID, handles workflow navigation and user management
*
Expand Down Expand Up @@ -200,6 +201,10 @@ public void completeSignin() {
scheduleHeartbeat();
NotificationsSyncWorkerManager.schedulePeriodicPushNotificationRetrieval(CommCareApplication.instance());
CrashUtil.registerUserData();

if (parentActivity instanceof BaseDrawerActivity) {
((BaseDrawerActivity<?>) parentActivity).openDrawer();
}
}

public void handleFinishedActivity(CommCareActivity<?> activity, int resultCode) {
Expand Down
21 changes: 20 additions & 1 deletion app/src/org/commcare/navdrawer/BaseDrawerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
import org.commcare.activities.CommCareActivity
import org.commcare.connect.ConnectActivityCompleteListener
import org.commcare.connect.ConnectNavHelper.unlockAndGoToConnectJobsList
import org.commcare.connect.ConnectNavHelper.unlockAndGoToWorkHistory
import org.commcare.connect.ConnectNavHelper.unlockAndGoToMessaging
import org.commcare.connect.ConnectNavHelper.unlockAndGoToWorkHistory
import org.commcare.navdrawer.BaseDrawerController.NavItemType
import org.commcare.pn.helper.NotificationBroadcastHelper
import org.commcare.utils.FirebaseMessagingUtil
import org.javarosa.core.services.Logger

abstract class BaseDrawerActivity<T> : CommCareActivity<T>() {

Expand Down Expand Up @@ -138,6 +139,24 @@ abstract class BaseDrawerActivity<T> : CommCareActivity<T>() {
}

protected fun closeDrawer() {
if (drawerController == null) {
Logger.exception(
"There was an error closing the app's sidebar.",
NullPointerException("The BaseDrawerController is null!")
)
}

drawerController?.closeDrawer()
}

fun openDrawer() {
if (drawerController == null) {
Logger.exception(
"There was an error opening the app's sidebar.",
NullPointerException("The BaseDrawerController is null!")
)
}

drawerController?.openDrawer()
Copy link
Contributor

Choose a reason for hiding this comment

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

can we soft assert using Logger.exception that drawerController is non null here. Just so that if we start calling this before drawerController is initialized, we should get to know about it from logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah for sure, I'll add this to closeDrawer() too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shubham1g5 Let me know if I can improve the wording of the logs

}
}
4 changes: 4 additions & 0 deletions app/src/org/commcare/navdrawer/BaseDrawerController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ class BaseDrawerController(
binding.drawerLayout.closeDrawer(GravityCompat.START)
}

fun openDrawer() {
binding.drawerLayout.openDrawer(GravityCompat.START)
}

fun handleOptionsItem(item: MenuItem): Boolean {
return drawerToggle.onOptionsItemSelected(item)
}
Expand Down