Skip to content

Commit

Permalink
Merge pull request #2805 from dimagi/feature/givewell
Browse files Browse the repository at this point in the history
Feature/givewell
  • Loading branch information
avazirna authored Oct 23, 2024
2 parents 890cece + aebd94e commit 6bd56ed
Show file tree
Hide file tree
Showing 23 changed files with 359 additions and 75 deletions.
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

0 comments on commit 6bd56ed

Please sign in to comment.