From e184bf48ddd013dd07d3b5bf15b952b6733de059 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 15 Dec 2022 12:06:19 +0300 Subject: [PATCH 1/3] Append APK file name with version and variant --- opensrp-giz-malawi/build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 0273face..1cba4ed3 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -213,6 +213,19 @@ android { } } + // https://stackoverflow.com/a/27119543/152938 + applicationVariants.all { variant -> + variant.outputs.all { output -> + outputFileName = new File(outputFileName.replace(".apk", "-${defaultConfig.versionName}.apk")) + } + } + + testVariants.all { variant -> + variant.outputs.all { output -> + outputFileName = new File(outputFileName.replace(".apk", "-${defaultConfig.versionName}.apk")) + } + } + packagingOptions { exclude 'META-INF/LICENSE.md' exclude 'META-INF/NOTICE.md' From 298ac1f4bfbf9e87ed5962d9c7ee2425673941a2 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 15 Dec 2022 12:07:42 +0300 Subject: [PATCH 2/3] Separate oauth client id and secret for different variants --- .gitignore | 1 + README.md | 2 + opensrp-giz-malawi/build.gradle | 66 +++++++++++++++++++-------------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 11dbe9dc..fab06d91 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ target/ tmp/ opensrp-giz-malawi/debug/ opensrp-giz-malawi/preview/ +opensrp-giz-malawi/releaseDebug/ *google-services.json \ No newline at end of file diff --git a/README.md b/README.md index 31f8e529..eb4dd6fa 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ These instructions will get you a copy of the project up and running on your loc ## Development setup +Get the + ### Steps to set up [OpenSRP android client app build](https://smartregister.atlassian.net/wiki/spaces/Documentation/pages/6619236/OpenSRP+App+Build) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 1cba4ed3..bcaa22f9 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -25,6 +25,30 @@ jacoco { toolVersion = jacocoVersion } +Properties properties = new Properties() +if (project.rootProject.file("local.properties").exists()) { + properties.load(project.rootProject.file("local.properties").newDataInputStream()) +} else{ + project.logger.error("local.properties file does not exist") +} + +ext.getLocalProperty = { key -> + if (properties != null && properties.containsKey(key)) { + return properties[key] + } else { + project.logger.error(key + " could not be found. Setting it to an empty string") + return "\"\"" + } +} + + +ext.checkKeys = { keys -> + keys.each { key -> + if (properties == null || !properties.containsKey(key)) { + project.logger.error(key + " is missing from the local.properties") + } + } +} android { useLibrary 'org.apache.http.legacy' @@ -50,34 +74,7 @@ android { testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - if (project.rootProject.file("local.properties").exists()) { - - Properties properties = new Properties() - properties.load(project.rootProject.file("local.properties").newDataInputStream()) - - if (properties != null && properties.containsKey("oauth.client.id")) { - - buildConfigField "String", "OAUTH_CLIENT_ID", properties["oauth.client.id"] - - } else { - project.logger.error("oauth.client.id variable is not set in your local.properties") - buildConfigField "String", "OAUTH_CLIENT_ID", "\"sample_client_id\"" - } - - - if (properties != null && properties.containsKey("oauth.client.secret")) { - - buildConfigField "String", "OAUTH_CLIENT_SECRET", properties["oauth.client.secret"] - - } else { - project.logger.error("oauth.client.secret variable is not set in your local.properties") - buildConfigField "String", "OAUTH_CLIENT_SECRET", "\"sample_client_secret\"" - } - } else { - buildConfigField "String", "OAUTH_CLIENT_ID", '""' - buildConfigField "String", "OAUTH_CLIENT_SECRET", '""' - } - + checkKeys(["oauth.client.id.production", "oauth.client.secret.production", "oauth.client.id.stage", "oauth.client.secret.stage", "oauth.client.id.preview", "oauth.client.secret.preview"]) javaCompileOptions { annotationProcessorOptions { @@ -128,6 +125,10 @@ android { buildConfigField "int", "GROWTH_MONITORING_SYNC_TIME", '15' buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Province", "District", "Facility", "Village"}' buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"Country", "Province", "District", "Health Facility", "Village"}' + + buildConfigField "String", "OAUTH_CLIENT_ID", getLocalProperty("oauth.client.id.production") + buildConfigField "String", "OAUTH_CLIENT_SECRET", getLocalProperty("oauth.client.secret.production") + } releaseDebug { @@ -157,6 +158,9 @@ android { buildConfigField "int", "GROWTH_MONITORING_SYNC_TIME", '15' buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Province", "District", "Facility", "Village"}' buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"Country", "Province", "District", "Health Facility", "Village"}' + + buildConfigField "String", "OAUTH_CLIENT_ID", getLocalProperty("oauth.client.id.production") + buildConfigField "String", "OAUTH_CLIENT_SECRET", getLocalProperty("oauth.client.secret.production") } preview { @@ -185,6 +189,9 @@ android { buildConfigField "int", "GROWTH_MONITORING_SYNC_TIME", '15' buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Province", "District", "Facility", "Village"}' buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"Country", "Province", "District", "Health Facility", "Village"}' + + buildConfigField "String", "OAUTH_CLIENT_ID", getLocalProperty("oauth.client.id.preview") + buildConfigField "String", "OAUTH_CLIENT_SECRET", getLocalProperty("oauth.client.secret.preview") } debug { @@ -210,6 +217,9 @@ android { buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Province", "District", "Facility", "Village"}' buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"Country", "Province", "District", "Health Facility", "Village"}' testCoverageEnabled true + + buildConfigField "String", "OAUTH_CLIENT_ID", getLocalProperty("oauth.client.id.stage") + buildConfigField "String", "OAUTH_CLIENT_SECRET", getLocalProperty("oauth.client.secret.stage") } } From c6e5a00f7b2623516f9cf35fb1f97b33efe1f7e2 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Mon, 19 Dec 2022 22:04:00 +0300 Subject: [PATCH 3/3] Draft commit --- opensrp-giz-malawi/build.gradle | 4 ++-- .../java/org/smartregister/giz/presenter/LoginPresenter.java | 1 + .../giz/processor/GizMalawiProcessorForJava.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index bcaa22f9..fb2574e9 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -142,7 +142,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro' resValue "string", 'opensrp_url', '"https://opensrp.health.gov.mw/opensrp/"' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10' - buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '2' buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "VACCINE_SYNC_TIME", '0' buildConfigField "int", "DATABASE_VERSION", '20' @@ -314,7 +314,7 @@ dependencies { exclude group: 'io.ona.rdt-capture', module: 'lib' } - api('org.smartregister:opensrp-client-core:5.0.9-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-core:5.0.12-LOCAL-SNAPSHOT@aar') { transitive = true exclude group: 'id.zelory', module: 'compressor' exclude group: 'com.github.bmelnychuk', module: 'atv' diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/presenter/LoginPresenter.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/presenter/LoginPresenter.java index 57effe73..9c9af481 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/presenter/LoginPresenter.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/presenter/LoginPresenter.java @@ -38,6 +38,7 @@ public LoginPresenter(BaseLoginContract.View loginView) { mLoginView = new WeakReference<>(loginView); mLoginInteractor = new LoginInteractor(this); mLoginModel = new BaseLoginModel(); + } @Override diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/processor/GizMalawiProcessorForJava.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/processor/GizMalawiProcessorForJava.java index f07eb817..21e96e55 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/processor/GizMalawiProcessorForJava.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/processor/GizMalawiProcessorForJava.java @@ -140,7 +140,7 @@ public synchronized void processClient(List eventClientList, boolea @Override public void processClient(List eventClients) throws Exception { - ClientClassification clientClassification = assetJsonToJava("ec_client_classification.json", + /*ClientClassification clientClassification = assetJsonToJava("ec_client_classification.json", ClientClassification.class); Table vaccineTable = assetJsonToJava("ec_client_vaccine.json", Table.class); Table weightTable = assetJsonToJava("ec_client_weight.json", Table.class); @@ -232,7 +232,7 @@ else if (eventType.equals(VaccineIntentService.EVENT_TYPE) || eventType Runnable runnable = () -> updateClientAlerts(clientsForAlertUpdates); appExecutors.diskIO().execute(runnable); - } + }*/ }