Skip to content

Commit

Permalink
Merge branch 'master' into android-14-update
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Nov 14, 2024
2 parents e8879bc + d8894ff commit 5f83b76
Show file tree
Hide file tree
Showing 38 changed files with 514 additions and 185 deletions.
5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
## Product Description
<!-- For non-invisible changes, describe user-facing effects. Would be good to add screenshots/videos for any major user facing changes -->

## Safety Assurance
## PR Checklist

- [ ] If the PR is high risk, "High Risk" label is set
- [ ] If I think the PR is high risk, "High Risk" label is set
- [ ] I have confidence that this PR will not introduce a regression for the reasons below
- [ ] Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly
- [ ] Does the PR introduce any major changes worth communicating ? If yes, "Release Note" label is set and a "Release Note" is specified in PR description.

### Automated test coverage

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ CommCare is an easily customizable, open source mobile platform that supports fr

This repository represents the Android version of CommCare. It depends on the [CommCare Core](https://github.com/dimagi/commcare-core) repository, which contains the XForm engine and case/lookup table implementations.

## End-to-End Development

CommCare Android is a mobile CommCare Platform client runtime, and requires a backend environment for full end-to-end usage and to test platform development.

If you don't have an access to another backend, or if you will be doing full platform development, after completing this setup you can follow [the end-to-end development guide](https://github.com/dimagi/commcare-hq/blob/master/local_dev_guide.rst) which explains how to establish a local environment for CommCare's full client/server software.

## Setup

To set up an Android dev environment for commcare-android, do the following:
Expand Down Expand Up @@ -34,7 +40,6 @@ git clone https://github.com/dimagi/commcare-core.git
- Click "OK" to use the Gradle wrapper
- Wait while Android Studio spins its wheels
- Download any build dependencies that the SDK Manager tells you you need.
- Disable _Instant Run_ found in Settings > Build, Execution, Deployment > Instant Run. (It does not play well with multidexing, which we have enabled, or with some of the processes we have set up for Google Services)

## Building

Expand Down
6 changes: 4 additions & 2 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 Expand Up @@ -896,8 +898,8 @@ repeat.dialog.go.back=Go Back
repeat.dialog.leave=Do Not Add
repeat.dialog.exit=Do Not Add. I'm Finished.
repeat.dialog.add=Add Group
repeat.dialog.add.another=Add another "${0}" group?
repeat.dialog.add.new=Add a new "${0}" group?
repeat.dialog.add.another=Add another ${0}?
repeat.dialog.add.new=Add a new ${0}?
lookup.table.missing.error=Unable to find lookup table "${0}". Make sure it exists and this user has access to it.

ethiopian_months=Mäskäräm,T’ïk’ïmt,Hïdar,Tahsas,T’ïr,Yäkatit,Mägabit,Miyaziya,Gïnbot,Säne,Hämle,Nähäse,P’agume
Expand Down
8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies {
testImplementation('org.robolectric:robolectric:4.8.2') {
exclude(group: 'org.bouncycastle', module: 'bcprov-jdk15on')
}
testImplementation 'org.robolectric:shadows-multidex:4.8.2'
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'androidx.test:runner:1.5.2'
testImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down Expand Up @@ -75,14 +74,13 @@ dependencies {
implementation (name: 'volley-1.1.0', ext: 'aar')
implementation (name: 'storage-2.1.0', ext: 'aar')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'org.bouncycastle:bcprov-jdk15to18:1.72'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-maps:19.0.0'
implementation 'joda-time:joda-time:2.9.4'
implementation 'net.zetetic:android-database-sqlcipher:4.5.3@aar'
implementation 'androidx.sqlite:sqlite:2.2.0'
Expand All @@ -109,6 +107,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 Expand Up @@ -251,7 +250,7 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
multiDexEnabled true

applicationId 'org.commcare.dalvik'
testNamespace 'org.commcare.dalvik.test'

Expand Down Expand Up @@ -462,7 +461,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
testProguardFiles 'test-proguard.cfg'

multiDexKeepProguard file('proguard-multidex.pro')
// enable crashlytics
buildConfigField 'boolean', 'USE_CRASHLYTICS', 'true'
ext.enableCrashlytics = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import kotlin.math.absoluteValue

@RunWith(AndroidJUnit4::class)
@LargeTest
@BrowserstackTests
class DateWidgetsTests : BaseTest() {
companion object {
const val CCZ_NAME = "date_widgets_tests.ccz"
Expand Down Expand Up @@ -162,4 +161,4 @@ class DateWidgetsTests : BaseTest() {
val newDate = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(date)
return newDate
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.commcare.androidTests

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -44,15 +45,16 @@ class DialogTests: BaseTest() {
onView(withId(R.id.nav_btn_next))
.perform(click())

withText("Add a new \"Error on add\" group?").isDisplayed()
onView(withId(R.id.choice_dialog_panel_2)).check(matches(withText("Add a new Error on add?")))

InstrumentationUtility.rotateLeft()
//TODO Expect dialog to not persist due to a activity lifecycle bug in our dialog framework.
withText("Add a new \"Error on add\" group?").doesNotExist()
withText(R.id.choice_dialog_panel_2).doesNotExist()

InstrumentationUtility.rotatePortrait()
onView(withId(R.id.nav_btn_next))
.perform(click())
onView(withText("ADD GROUP"))
onView(withId(R.id.choice_dialog_panel_2))
.perform(click())

checkDialogExistence_withRotation("Error Occurred")
Expand Down
2 changes: 0 additions & 2 deletions app/proguard-multidex.pro

This file was deleted.

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
5 changes: 5 additions & 0 deletions app/res/xml/preferences_developer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@
android:entryValues="@array/pref_enabled_vals"
android:key="cc-enable-certificate-transparency"
android:title="Certificate Transparency"/>
<EditTextPreference
android:dialogMessage="The URL must use the HTTPS protocol"
android:enabled="true"
android:key="log_receiver_url"
android:title="Override Log Submission Server"/>
</PreferenceScreen>
19 changes: 17 additions & 2 deletions app/src/org/commcare/CommCareApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -17,7 +18,10 @@
import android.util.Log;

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

public class CommCareApplication extends MultiDexApplication {
public class CommCareApplication extends Application implements LifecycleEventObserver {

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

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

setRxJavaGlobalHandler();

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

protected void loadSqliteLibs() {
Expand Down Expand Up @@ -1224,4 +1230,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 5f83b76

Please sign in to comment.