Skip to content
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

Feature/givewell #2805

Merged
merged 67 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
88dd6b4
Safeguard sendBroadcast calls to not crash
shubham1g5 Aug 6, 2024
67df855
Add android lifecycle process dependency
avazirna Aug 1, 2024
647d8bf
Make CommCareApplication a lifecycle-aware component
avazirna Aug 1, 2024
76fc7e4
Attach lifecycle observer
avazirna Aug 1, 2024
e93dd1e
use a flag exit to exit the form
shubham1g5 Aug 5, 2024
cea8cbf
Save form as incomplete when going to background
shubham1g5 Aug 5, 2024
ec96345
Safeguard save on pause with checks
shubham1g5 Aug 6, 2024
c32e81e
Put the auto-save behind a custom dev preference
shubham1g5 Aug 8, 2024
62bb311
Return serialized form index
avazirna Aug 7, 2024
e00dcea
Save current form index in app preferences
avazirna Aug 7, 2024
2b301ea
Save serialized form index when saving session state
avazirna Aug 7, 2024
10bd885
Add SSD record Id to serialized form index
avazirna Aug 7, 2024
34cf2ee
Fix form Storage test
shubham1g5 Aug 8, 2024
1522bfb
Retrieve serialized form index
avazirna Aug 7, 2024
3b021bc
Deserialize and initialize form index to return to
avazirna Aug 7, 2024
51f268b
Jump to last form index
avazirna Aug 7, 2024
86d35ba
Verify serialized form index based on SSD Id
avazirna Aug 7, 2024
13e057a
Retrieve form index in a Pair format
avazirna Aug 8, 2024
8ee1d13
Deserialize FormIndex when retrieving from app preferences
avazirna Aug 8, 2024
c329378
Log exception
avazirna Aug 8, 2024
3215e25
Log form index serialization exceptions
avazirna Aug 8, 2024
9e39622
Log JSON <-> Pair conversion errors
avazirna Aug 8, 2024
e129ee4
Use a Model to save interrupted form state
shubham1g5 Aug 8, 2024
a45d5cf
Fix test
shubham1g5 Aug 8, 2024
550d26d
Move autosave preference from developer options to user settings
ctsims Aug 8, 2024
4fd4cee
Add logging when session recovery is identified
ctsims Aug 8, 2024
50ef0b3
Adds logging on user session expiry
shubham1g5 Aug 9, 2024
20104f4
Clear state on user exiting/saving the form
shubham1g5 Aug 9, 2024
ee48781
Show button to re-process quarantine form even for local process erro…
shubham1g5 Aug 12, 2024
20e00aa
Remove unused methods
avazirna Aug 9, 2024
b34b7cb
Remove comment
avazirna Aug 9, 2024
64c6f70
Refactor
avazirna Aug 9, 2024
7bbf4f3
Logs while saving and clearing the interrupted state
shubham1g5 Sep 5, 2024
2e0274f
Clears interruptes state as soon as we are saving a completed form
shubham1g5 Sep 5, 2024
294848f
Do not save read only forms again
shubham1g5 Sep 5, 2024
031978c
Reword Finish to Exit for read only forms
shubham1g5 Sep 5, 2024
658de7d
Add logging around form entry start
avazirna Sep 5, 2024
63c476e
Log when CommCare is terminated
avazirna Sep 13, 2024
7b599c0
Update model
avazirna Aug 12, 2024
acbce28
Check form record Id when restoring Form index
avazirna Aug 12, 2024
8cc2dbd
Set default state to formRecordId
avazirna Sep 16, 2024
ad2501d
Handle update from previous version of InterruptedFormState model
avazirna Sep 16, 2024
5ad2c02
Add SAVE_UNRECOVERABLE_ERROR SaveStatus for malformed or corrupted fo…
avazirna Sep 18, 2024
cdda600
Quarantine only malformed or corrupted form XML as local processing e…
avazirna Sep 18, 2024
621792e
Revert "Show button to re-process quarantine form even for local proc…
avazirna Sep 18, 2024
4299831
Nit
avazirna Sep 19, 2024
7b57114
Expand SAVE_UNRECOVERABLE_ERROR to other applicable error types
avazirna Sep 19, 2024
e3acf14
Add interruption reason related flag to InterruptedFormState
avazirna Sep 19, 2024
2c3b7bb
Remove exit flag from formSaveCallback
avazirna Sep 16, 2024
3023424
Replace exit flag with sessionExpiredOrSuspended flag
avazirna Sep 19, 2024
37e044e
Save interruption reason flag
avazirna Sep 19, 2024
1836d2f
Pass InterruptionFormState to form controller
avazirna Sep 19, 2024
d643cca
Show message when restoring session after session pause
avazirna Sep 19, 2024
312ade0
Add userTriggered flag when saving forms
avazirna Sep 19, 2024
2b994db
Don't show message when auto saving
avazirna Sep 19, 2024
57a5117
Merge pull request #2857 from dimagi/add-form-instance-id-to-interrup…
avazirna Sep 20, 2024
eaba92b
Nit
avazirna Sep 20, 2024
503c57c
Merge pull request #2859 from dimagi/quarantine-malformed-form-xml-as…
avazirna Sep 20, 2024
296dc38
Refactor
avazirna Sep 27, 2024
6aaf0ff
Revert "Remove exit flag from formSaveCallback"
avazirna Oct 22, 2024
3ade9b2
Refactor
avazirna Oct 22, 2024
7218aba
Make class field nullable
avazirna Oct 22, 2024
a776076
Merge branch 'feature/givewell' into adjust-user-messages-when-autosa…
avazirna Oct 23, 2024
a27ab98
Nit
avazirna Oct 23, 2024
019cd2d
Correct userTriggered flag when updating attachments
avazirna Oct 23, 2024
dec7568
Refactor
avazirna Oct 23, 2024
aebd94e
Merge pull request #2858 from dimagi/adjust-user-messages-when-autosa…
avazirna Oct 23, 2024
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: 2 additions & 0 deletions app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ form.entry.incomplete.save.success=Form saved as incomplete
form.entry.save.error=Sorry, form save failed. Please contact CommCare Support to look into the issue.
form.entry.save.invalid.unicode=Could not save '${0}' text in form.
form.entry.finish.button=FINISH
form.entry.exit.button=EXIT
form.entry.restart.after.expiration=You were logged out due to session expiration. The form you were in the middle of has been saved and resumed.
form.entry.restart.after.session.pause=CommCare was closed and the form you were in the middle of has been saved and resumed.

login.attempt.badcred=Username or password are incorrect. Please try again.

Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"

// Markdown
implementation "io.noties.markwon:core:$markwon_version"
Expand Down
7 changes: 7 additions & 0 deletions app/res/xml/main_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
android:entryValues="@array/pref_enabled_vals"
android:key="cc-enable-tts"
android:title="Enable Text To Speech"/>
<androidx.preference.ListPreference
android:defaultValue="no"
android:enabled="true"
android:entries="@array/pref_enabled_labels"
android:entryValues="@array/pref_enabled_vals"
android:key="cc-auto-form-save-on-pause"
android:title="Auto Save Form on Pause"/>
<Preference
android:key="disable-analytics-button"/>
<Preference
Expand Down
19 changes: 18 additions & 1 deletion app/src/org/commcare/CommCareApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.multidex.MultiDexApplication;
import androidx.preference.PreferenceManager;
import androidx.work.BackoffPolicy;
Expand Down Expand Up @@ -143,7 +147,9 @@
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

public class CommCareApplication extends MultiDexApplication {
import static androidx.lifecycle.Lifecycle.Event.ON_DESTROY;

public class CommCareApplication extends MultiDexApplication implements LifecycleEventObserver {

private static final String TAG = CommCareApplication.class.getSimpleName();

Expand Down Expand Up @@ -256,6 +262,8 @@ public void onCreate() {
customiseOkHttp();

setRxJavaGlobalHandler();

ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}

protected void loadSqliteLibs() {
Expand Down Expand Up @@ -1224,4 +1232,13 @@ private void setRxJavaGlobalHandler() {
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), throwable);
});
}

@Override
public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
switch (event) {
case ON_DESTROY:
Logger.log(LogTypes.TYPE_MAINTENANCE, "CommCare has been closed");
break;
}
}
}
4 changes: 3 additions & 1 deletion app/src/org/commcare/CommCareNoficationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import static android.content.Context.NOTIFICATION_SERVICE;

import static org.commcare.sync.ExternalDataUpdateHelper.sendBroadcastFailSafe;

/**
* Handles displaying and clearing pinned notifications for CommCare
*/
Expand Down Expand Up @@ -112,7 +114,7 @@ public void clearNotifications(String category) {

public ArrayList<NotificationMessage> purgeNotifications() {
synchronized (pendingMessages) {
context.sendBroadcast(new Intent(ACTION_PURGE_NOTIFICATIONS));
sendBroadcastFailSafe(context, new Intent(ACTION_PURGE_NOTIFICATIONS), null);
ArrayList<NotificationMessage> cloned = (ArrayList<NotificationMessage>)pendingMessages.clone();
clearNotifications(null);
return cloned;
Expand Down
Loading