-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Referral Notifications - Background Sync #2680
Changes from all commits
f865524
8fc36d8
2500bb5
13c1ca4
491e08d
b363687
8652d7b
076adaa
1080733
e5317c7
7f137fa
13cf532
d72ed7c
1b529f3
106b465
11516b7
1194304
e6a6ea6
c61d023
722b24f
78439ad
d2e4af1
d683391
2f0f48b
0bc0b04
a13afe8
0c2f463
308a828
7ca96a8
51510e4
6e0d9d7
7ed33cf
71a7306
dfbe5ec
1c84b3a
c0412b5
e699380
cfcd5dc
6d42c01
414cccb
c7a70c1
cd27032
b9525ed
68e05d0
415bc8b
f6416f3
bb99c16
30e2de6
e1daf72
ff10165
be12087
edfce31
65cc28e
f1fbb2a
d96060d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,9 @@ | |
import org.commcare.models.AndroidSessionWrapper; | ||
import org.commcare.models.FormRecordProcessor; | ||
import org.commcare.models.database.SqlStorage; | ||
import org.commcare.preferences.HiddenPreferences; | ||
import org.commcare.services.FCMMessageData; | ||
import org.commcare.services.PendingSyncAlertBroadcastReceiver; | ||
import org.commcare.tasks.FormLoaderTask; | ||
import org.commcare.tasks.SaveToDiskTask; | ||
import org.commcare.tts.TextToSpeechCallback; | ||
|
@@ -102,6 +105,7 @@ | |
import androidx.core.app.ActivityCompat; | ||
|
||
import static org.commcare.android.database.user.models.FormRecord.QuarantineReason_LOCAL_PROCESSING_ERROR; | ||
import static org.commcare.sync.FirebaseMessagingDataSyncer.PENGING_SYNC_ALERT_ACTION; | ||
|
||
/** | ||
* Displays questions, animates transitions between | ||
|
@@ -171,6 +175,9 @@ public class FormEntryActivity extends SaveSessionCommCareActivity<FormEntryActi | |
|
||
private boolean fullFormProfilingEnabled = false; | ||
private EvaluationTraceReporter traceReporter; | ||
|
||
private PendingSyncAlertBroadcastReceiver pendingSyncAlertBroadcastReceiver = new PendingSyncAlertBroadcastReceiver(); | ||
|
||
private TextToSpeechCallback mTTSCallback = new TextToSpeechCallback() { | ||
@Override | ||
public void initFailed() { | ||
|
@@ -878,6 +885,8 @@ protected void onPause() { | |
PollSensorController.INSTANCE.stopLocationPolling(); | ||
} | ||
TextToSpeechConverter.INSTANCE.stop(); | ||
|
||
unregisterReceiver(pendingSyncAlertBroadcastReceiver); | ||
} | ||
|
||
private void saveInlineVideoState() { | ||
|
@@ -925,6 +934,12 @@ public void onResumeSessionSafe() { | |
restorePriorStates(); | ||
|
||
reportVideoUsageIfAny(); | ||
|
||
IntentFilter intentFilter = new IntentFilter(PENGING_SYNC_ALERT_ACTION); | ||
registerReceiver(pendingSyncAlertBroadcastReceiver, intentFilter); | ||
|
||
// Flag that a background sync shouldn't be triggered when this activity is in the foreground | ||
CommCareApplication.instance().setBackgroundSyncSafe(false); | ||
} | ||
|
||
private void reportVideoUsageIfAny() { | ||
|
@@ -1499,6 +1514,25 @@ public void onRequestPermissionsResult(int requestCode, | |
} | ||
} | ||
|
||
@Override | ||
public void alertPendingSync(FCMMessageData fcmMessageData) { | ||
if (!HiddenPreferences.isPendingSyncRequest(fcmMessageData.getUsername())) { | ||
HiddenPreferences.setPendingSyncRequest(fcmMessageData); | ||
|
||
if (!HiddenPreferences.isPendingSyncDialogDisabled()) { | ||
StandardAlertDialog dialog = StandardAlertDialog.getBasicAlertDialogWithDisablingCheckbox(this, | ||
Localization.get("background.sync.pending.form.entry.title"), | ||
Localization.get("background.sync.pending.form.entry.detail"), (buttonView, isChecked) -> { | ||
HiddenPreferences.setPendingSyncDialogDisabled(isChecked); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think users are right decision makers on whether to show pending sync warnings or not. I think it should be an custom app setting instead or we should always show the warning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thinking here was to (1) let the user decide whether they would like to be disrupted every time a new sync request comes through (2) Make the users aware of sync being triggered after form submissions. I'm happy to go with your lead here but ultimately, it's the user who gets disrupted by this. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to let it be for now and we can come back to it later if needed. |
||
}); | ||
dialog.setPositiveButton(Localization.get("dialog.ok"), (dialog1, which) -> { | ||
dialog1.dismiss(); | ||
}); | ||
showAlertDialog(dialog); | ||
} | ||
} | ||
} | ||
|
||
|
||
public static class FormQueryException extends Exception { | ||
public FormQueryException(String msg) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing
@Override