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/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ dependencies {
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'com.google.firebase:firebase-analytics:20.1.2'
implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation 'com.google.firebase:firebase-messaging:24.0.0'
implementation 'com.google.firebase:firebase-perf:21.0.1'
implementation 'com.google.firebase:firebase-crashlytics:18.3.7'

Expand Down
12 changes: 11 additions & 1 deletion app/src/org/commcare/activities/DispatchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.commcare.recovery.measures.RecoveryMeasuresHelper;
import org.commcare.utils.AndroidShortcuts;
import org.commcare.utils.CommCareLifecycleUtils;
import org.commcare.utils.FirebaseMessagingUtil;
import org.commcare.utils.MultipleAppsUtil;
import org.commcare.utils.SessionUnavailableException;
import org.javarosa.core.services.locale.Localization;
Expand Down Expand Up @@ -104,6 +105,11 @@ protected void onCreate(Bundle savedInstanceState) {
}
}


private Intent checkIfAnyPNIntentPresent(){
return FirebaseMessagingUtil.getIntentForPNIfAny(this,getIntent());
}

/**
* A workaround required by Android Bug #2373 -- An app launched from the Google Play store
* has different intent flags than one launched from the App launcher, which ruins the back
Expand Down Expand Up @@ -155,7 +161,11 @@ private void dispatch() {
}

CommCareApp currentApp = CommCareApplication.instance().getCurrentApp();
if (currentApp == null) {

Intent pnIntent = checkIfAnyPNIntentPresent();
if(pnIntent!=null) {
startActivity(pnIntent);
}else if (currentApp == null) {
if (MultipleAppsUtil.usableAppsPresent()) {
AppUtils.initFirstUsableAppRecord();
// Recurse in order to make the correct decision based on the new state
Expand Down
7 changes: 4 additions & 3 deletions app/src/org/commcare/activities/connect/ConnectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;

Expand Down Expand Up @@ -80,9 +81,9 @@ private int getStartDestinationId(Bundle startArgs) {

private void initStateFromExtras() {
redirectionAction = getIntent().getStringExtra(REDIRECT_ACTION);
int opportunityId = getIntent().getIntExtra(ConnectConstants.OPPORTUNITY_ID, -1);
if (opportunityId > 0) {
job = ConnectJobUtils.getCompositeJob(this, opportunityId);
String opportunityId = getIntent().getStringExtra(ConnectConstants.OPPORTUNITY_ID);
if(!TextUtils.isEmpty(opportunityId)){
job = ConnectJobUtils.getCompositeJob(this, Integer.parseInt(opportunityId));
}
}

Expand Down
37 changes: 29 additions & 8 deletions app/src/org/commcare/fragments/connect/ConnectUnlockFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.commcare.connect.ConnectConstants.SHOW_LAUNCH_BUTTON;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -55,17 +57,36 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
binding = FragmentConnectUnlockBinding.inflate(inflater, container, false);
binding.getRoot().setBackgroundColor(getResources().getColor(R.color.white));

PersonalIdManager.getInstance().unlockConnect((CommCareActivity<?>)requireActivity(), success -> {
if (success) {
retrieveOpportunities();
} else {
requireActivity().finish();
}
});

return binding.getRoot();
}

private final Runnable unlockRunnable = new Runnable() {
@Override
public void run() {
PersonalIdManager.getInstance().unlockConnect((CommCareActivity<?>) requireActivity(), success -> {
if (success) {
retrieveOpportunities();
} else {
requireActivity().finish();
}
});
}
};


@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
new Handler().post(unlockRunnable);
}


@Override
public void onDestroyView() {
binding = null;
super.onDestroyView();
}

private void retrieveOpportunities() {
ConnectUserRecord user = ConnectUserDatabaseUtil.getUser(getContext());
new ConnectApiHandler<ConnectOpportunitiesResponseModel>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CommCareFirebaseMessagingService extends FirebaseMessagingService {
public void onMessageReceived(RemoteMessage remoteMessage) {
Logger.log(LogTypes.TYPE_FCM, "CommCareFirebaseMessagingService Message received: " +
remoteMessage.getData());
FirebaseMessagingUtil.handleNotification(getApplicationContext(), remoteMessage.getData(),remoteMessage.getNotification());
FirebaseMessagingUtil.handleNotification(getApplicationContext(), remoteMessage.getData(),remoteMessage.getNotification(),true);
}

@Override
Expand Down
Loading
Loading