From 3d1e74afb2c5207022fe73615a70ff7a9f7c23e7 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 3 Nov 2022 17:02:13 +0300 Subject: [PATCH 1/6] Detect build config url changes and update preferences --- .../giz/application/GizMalawiApplication.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java index 31c776a1..e540b7cc 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java @@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull; import org.json.JSONException; import org.json.JSONObject; +import org.smartregister.AllConstants; import org.smartregister.Context; import org.smartregister.CoreLibrary; import org.smartregister.anc.library.AncLibrary; @@ -31,6 +32,7 @@ import org.smartregister.configurableviews.ConfigurableViewsLibrary; import org.smartregister.configurableviews.helper.JsonSpecHelper; import org.smartregister.giz.BuildConfig; +import org.smartregister.giz.R; import org.smartregister.giz.activity.AllClientsRegisterActivity; import org.smartregister.giz.activity.AncRegisterActivity; import org.smartregister.giz.activity.ChildFormActivity; @@ -363,6 +365,18 @@ public void onCreate() { initMinimumDateForReportGeneration(); + updateBaseUrl(); + } + + private void updateBaseUrl() { + AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); + String currUrl = getString(R.string.opensrp_url); + + if (!currUrl.equals(allSharedPreferences.fetchBaseURL(""))) { + allSharedPreferences.savePreference(AllConstants.DRISHTI_BASE_URL, currUrl); + Timber.e("Changed URL to %s", currUrl); + allSharedPreferences.updateUrl(currUrl); + } } private void initMinimumDateForReportGeneration() { From d265be0503534cd28890feb60d2215bd986db344 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 3 Nov 2022 17:07:48 +0300 Subject: [PATCH 2/6] Update Malawi production URL - Bump to 0.4.4 --- opensrp-giz-malawi/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 7d3cb513..d57d1933 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -36,7 +36,7 @@ android { minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion versionCode 40 - versionName "0.4.2" + versionName "0.4.4" multiDexEnabled true buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "false" @@ -110,7 +110,7 @@ android { zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro' - resValue "string", 'opensrp_url', '"https://his-mw.smartregister.org/opensrp/"' + resValue "string", 'opensrp_url', '"https://opensrp.health.gov.mw/opensrp/"' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100' buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' From f8c5108d7422d465ee29a06722a662739d3a6179 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 3 Nov 2022 18:10:57 +0300 Subject: [PATCH 3/6] Bump versionName to 0.4.5 and code to 45 --- opensrp-giz-malawi/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index d57d1933..532583f6 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -35,8 +35,8 @@ android { applicationId "org.smartregister.giz" minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion - versionCode 40 - versionName "0.4.4" + versionCode 45 + versionName "0.4.5" multiDexEnabled true buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "false" From 93acb349c4e1f35ded3170b7ea549cb3c208308a Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 10 Nov 2022 17:56:34 +0300 Subject: [PATCH 4/6] Update URL only from BuildConfig values only when it changes - Allow changes from the preferences without reversal due to bug comparing R.string.opensrp_url and preference-url --- opensrp-giz-malawi/build.gradle | 4 ++++ .../giz/application/GizMalawiApplication.java | 9 +++++++-- .../java/org/smartregister/giz/util/GizConstants.java | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 532583f6..c78220a1 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -116,6 +116,7 @@ android { buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "VACCINE_SYNC_TIME", '0' buildConfigField "int", "DATABASE_VERSION", '19' + buildConfigField "int", "URL_VERSION", '1' buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "true" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' @@ -144,6 +145,7 @@ android { buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "VACCINE_SYNC_TIME", '0' buildConfigField "int", "DATABASE_VERSION", '19' + buildConfigField "int", "URL_VERSION", '1' buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "true" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' @@ -171,6 +173,7 @@ android { buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "VACCINE_SYNC_TIME", '0' buildConfigField "int", "DATABASE_VERSION", '19' + buildConfigField "int", "URL_VERSION", '1' buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "true" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' @@ -194,6 +197,7 @@ android { buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "VACCINE_SYNC_TIME", '0' buildConfigField "int", "DATABASE_VERSION", '19' + buildConfigField "int", "URL_VERSION", '1' buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "true" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java index e540b7cc..d29d5329 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; +import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Pair; @@ -370,10 +371,14 @@ public void onCreate() { private void updateBaseUrl() { AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); - String currUrl = getString(R.string.opensrp_url); + int currUrlVersion = BuildConfig.URL_VERSION; + String prefVal = allSharedPreferences.getPreference(GizConstants.Pref.URL_VERSION); + int prefUrlVersion = TextUtils.isEmpty(prefVal) ? 0 : Integer.parseInt(prefVal); - if (!currUrl.equals(allSharedPreferences.fetchBaseURL(""))) { + if (currUrlVersion > prefUrlVersion) { + String currUrl = getString(R.string.opensrp_url); allSharedPreferences.savePreference(AllConstants.DRISHTI_BASE_URL, currUrl); + allSharedPreferences.savePreference(GizConstants.Pref.URL_VERSION, String.valueOf(currUrlVersion)); Timber.e("Changed URL to %s", currUrl); allSharedPreferences.updateUrl(currUrl); } diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/util/GizConstants.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/util/GizConstants.java index 8780306d..e5e56fcb 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/util/GizConstants.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/util/GizConstants.java @@ -84,6 +84,7 @@ public interface IntentKey { public interface Pref { String APP_VERSION_CODE = "APP_VERSION_CODE"; String INDICATOR_DATA_INITIALISED = "INDICATOR_DATA_INITIALISED"; + String URL_VERSION = "URL_VERSION"; } public interface File { From b85b0453f2389d987336890b29fb766e996d9419 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Fri, 11 Nov 2022 12:08:27 +0300 Subject: [PATCH 5/6] Update preview URL --- opensrp-giz-malawi/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index c78220a1..775360fd 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -167,7 +167,7 @@ android { signingConfig signingConfigs.debug proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro' - resValue "string", 'opensrp_url', '"https://jembi-staging.smartregister.org/opensrp/"' + resValue "string", 'opensrp_url', '"https://jembi-preview.smartregister.org/opensrp/"' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100' buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' From 1f94a262e8e701526a38c2aeb5ca63e054c1a8ef Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Mon, 5 Dec 2022 11:29:43 +0300 Subject: [PATCH 6/6] Update releaseDebug url --- opensrp-giz-malawi/build.gradle | 2 +- .../smartregister/giz/application/GizMalawiApplication.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 775360fd..ce3ce50d 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -139,7 +139,7 @@ android { signingConfig signingConfigs.debug proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro' - resValue "string", 'opensrp_url', '"https://his-mw.smartregister.org/opensrp/"' + 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_SOURCE", '2' diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java index d29d5329..b67fe5c8 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/application/GizMalawiApplication.java @@ -366,10 +366,10 @@ public void onCreate() { initMinimumDateForReportGeneration(); - updateBaseUrl(); + updateBaseUrlFromBuildConfigChange(); } - private void updateBaseUrl() { + private void updateBaseUrlFromBuildConfigChange() { AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); int currUrlVersion = BuildConfig.URL_VERSION; String prefVal = allSharedPreferences.getPreference(GizConstants.Pref.URL_VERSION);