Skip to content

Commit

Permalink
Migrate core to 6 - Memory Leak Fixes (#302)
Browse files Browse the repository at this point in the history
* Migrate dependencies
  - Refactor failing tests
  - Add support for tagging GM and Vaccine events with extra details
  - Migrate/Update Sample app configuration 

* Fix unit tests 💚

* Fix bugs
- Nullify overflow menu during ondestroy
- Fix details map nullPointer exception 
- Fixes sample app crashes if Firebase not configured

* Refactors + Enhancements
- BaseChildRegister updatelocation() using app-executors
- Move BaseChildRegisterFragment countsearch queries to background
- Move Countexecute from UIthread in BaseAdvancedSearchFragment
- Add overDueCount Setter and Getter in BaseChildRegisterFragment 
- Add App Version Name to Event Tagging

* Disable bottom nav menu items on click
- Closes #301  
 
* Automate Artifact Release via CI/CD 👷
- Add CI configuration for automated releases
- Bump up version
 
* Update Build Status & Coveralls badges

* Remove use of deprecated methods

* Bump up version to 1.0.0-SNAPSHOT


---------

Co-authored-by: Hamza Ahmed Khan <[email protected]>
Co-authored-by: hilpitome <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>
Co-authored-by: Simon Njoroge <[email protected]>
  • Loading branch information
5 people authored Feb 9, 2023
1 parent 5de53b3 commit c32aa9d
Show file tree
Hide file tree
Showing 61 changed files with 1,013 additions and 824 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Install NDK
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
- name: Grant execute permission for gradlew
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Snapshot Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run unit tests with Gradle
run: ./gradlew :opensrp-child:clean :opensrp-child:testDebugUnitTest --stacktrace

- name: Generate & upload library snapshot artifact AAR (Android Archive) file
run: ./gradlew :opensrp-child:uploadArchives -PmavenLocal=false --stacktrace -PsonatypeUsername=${{ secrets.NEXUS_USERNAME }} -PsonatypePassword=${{ secrets.NEXUS_PASSWORD }}

- name: Github Release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Build status](https://github.com/OpenSRP/opensrp-client-reveal/workflows/Android%20CI%20with%20Gradle/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/OpenSRP/opensrp-client-child/badge.svg?branch=master)](https://coveralls.io/github/OpenSRP/opensrp-client-child?branch=master)
![Build status](https://github.com/OpenSRP/opensrp-client-child/workflows/Android%20CI%20with%20Gradle/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/opensrp/opensrp-client-child/badge.svg?branch=master)](https://coveralls.io/github/opensrp/opensrp-client-child?branch=master)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9676b69b02be4d37ad73bcab80f6c5fc)](https://www.codacy.com/gh/opensrp/opensrp-client-child/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=OpenSRP/opensrp-client-child&amp;utm_campaign=Badge_Grade)
# opensrp-client-child
OpenSRP client child health module library
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ buildscript {
}

dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
classpath 'org.smartregister:gradle-jarjar-plugin:1.0.0-SNAPSHOT'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

Expand All @@ -34,11 +34,11 @@ subprojects {

group = 'org.smartregister'

ext.androidToolsBuildGradle = '4.1.2'
ext.androidBuildToolsVersion = '29.0.2'
ext.androidToolsBuildGradle = '4.2.2'
ext.androidBuildToolsVersion = '30.0.2'
ext.androidMinSdkVersion = 18
ext.androidCompileSdkVersion = 29
ext.androidTargetSdkVersion = 29
ext.androidCompileSdkVersion = 31
ext.androidTargetSdkVersion = 31

ext.androidAnnotationsVersion = '3.0.1'
ext.androidAnnotationsAPIVersion = '3.0.1'
Expand All @@ -48,7 +48,7 @@ subprojects {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "http://acra.googlecode.com/svn/repository/releases" }
maven { url "https://acra.googlecode.com/svn/repository/releases" }
maven { url "https://repo.maven.apache.org/maven2" }
mavenLocal()
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.10.2-SNAPSHOT
VERSION_NAME=1.0.0-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Child Library
Expand All @@ -16,4 +16,4 @@ org.gradle.jvmargs=-Xmx2048m
android.enableD8=true
android.enableD8.desugaring=true
android.enableJetifier=true
android.jetifier.blacklist=shadows
android.jetifier.blacklist=shadows,bcprov-jdk15on
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 14 15:25:46 EAT 2021
#Tue Jun 14 15:00:53 EAT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
55 changes: 34 additions & 21 deletions opensrp-child/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

buildscript {
repositories {
gradlePluginPortal()
Expand All @@ -17,7 +20,7 @@ plugins {
description = 'OpenSRP child client library'

jacoco {
toolVersion = "0.8.5"
toolVersion = "0.8.8"
}

android {
Expand Down Expand Up @@ -94,6 +97,14 @@ android {
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
testLogging {
// Enables easier debugging of tests in Github Actions CI
events TestLogEvent.FAILED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
}
}

allprojects {
Expand All @@ -107,9 +118,9 @@ allprojects {

dependencies {

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6'

api('org.smartregister:opensrp-client-core:5.0.6-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand All @@ -122,7 +133,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-v4'
}

api('org.smartregister:opensrp-client-native-form:2.1.18-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-native-form:3.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -134,7 +145,7 @@ dependencies {
exclude group: 'com.github.raihan-mpower', module:'FancyAlertDialog-Android'
}

implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.code.gson:gson:2.9.0'

api('org.smartregister:opensrp-client-configurable-views:1.1.5-SNAPSHOT@aar') {
transitive = true
Expand All @@ -144,15 +155,15 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api('org.smartregister:opensrp-client-immunization:4.0.6-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-immunization:5.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api('org.smartregister:opensrp-client-growth-monitoring:2.0.7-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-growth-monitoring:3.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand All @@ -161,31 +172,32 @@ dependencies {
}

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'net.zetetic:android-database-sqlcipher:4.4.0@aar'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'net.zetetic:android-database-sqlcipher:4.5.1@aar'
implementation 'com.jakewharton.timber:timber:5.0.1'

implementation 'androidx.leanback:leanback:1.0.0'
implementation 'org.pcollections:pcollections:3.1.3'
implementation 'androidx.leanback:leanback:1.1.0-rc02'
implementation 'org.pcollections:pcollections:3.1.4'

implementation 'com.google.guava:guava:29.0-android'
implementation 'com.google.guava:guava:31.1-android'
implementation 'id.zelory:compressor:2.1.1'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.0"
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
def robolectricVersion = '4.1'
testImplementation("org.robolectric:robolectric:$robolectricVersion") {
exclude group: 'com.google.auto.service', module: 'auto-service'
exclude group: 'com.android.support'
}
testImplementation "org.robolectric:shadows-multidex:$robolectricVersion"
testImplementation "org.robolectric:shadows-support-v4:3.3.2"
testImplementation("org.robolectric:shadows-support-v4:3.4-rc2") {
exclude group: 'com.google.guava', module: 'guava'
}

androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'junit', module: 'junit'
}
Expand All @@ -197,9 +209,10 @@ dependencies {
testImplementation "org.powermock:powermock-module-javaagent:$powerMockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion"
testImplementation("org.powermock:powermock-classloading-xstream:$powerMockVersion")

testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.0'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test:core:1.4.0-rc01'
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,30 @@ public class ChildLibrary {
private LocationPickerView locationPickerView;
private EventBus eventBus;

private ChildLibrary(Context contextArg, Repository repositoryArg, ChildMetadata metadataArg, int applicationVersion, int databaseVersion) {
private ChildLibrary(Context contextArg, Repository repositoryArg, ChildMetadata metadataArg, int applicationVersion, String applicationVersionName, int databaseVersion) {
this.context = contextArg;
this.repository = repositoryArg;
this.metadata = metadataArg;
this.applicationVersion = applicationVersion;
this.applicationVersionName = applicationVersionName;
this.databaseVersion = databaseVersion;
}

public static void init(Context context, Repository repository, ChildMetadata metadataArg, int applicationVersion,
int databaseVersion) {
public static void init(Context context, Repository repository, ChildMetadata metadataArg, int applicationVersion, String applicationVersionName, int databaseVersion) {
if (instance == null) {
instance = new ChildLibrary(context, repository, metadataArg, applicationVersion, databaseVersion);
instance = new ChildLibrary(context, repository, metadataArg, applicationVersion, applicationVersionName, databaseVersion);
}
}

/**
* This init method is deprecated, use {@link #init(Context context, Repository repository, ChildMetadata metadataArg, int applicationVersion, String applicationVersionName, int databaseVersion)} instead which adds application version name.
*/
@Deprecated
public static void init(Context context, Repository repository, ChildMetadata metadataArg, int applicationVersion, int databaseVersion) {
init(context, repository, metadataArg, applicationVersion, null, databaseVersion);

}

public static ChildLibrary getInstance() {
if (instance == null) {
throw new IllegalStateException(" Instance does not exist!!! Call " + ChildLibrary.class.getName() +
Expand All @@ -62,6 +71,10 @@ public static ChildLibrary getInstance() {
return instance;
}

public static void destroyInstance() {
instance = null;
}

public ChildMetadata metadata() {
return metadata;
}
Expand Down Expand Up @@ -159,5 +172,4 @@ public void setApplicationVersionName(String applicationVersionName) {
public LocationRepository getLocationRepository() {
return CoreLibrary.getInstance().context().getLocationRepository();
}

}
Loading

0 comments on commit c32aa9d

Please sign in to comment.