Skip to content

Commit

Permalink
Merge pull request #501 from opensrp/issue/support/249-update-malawi-…
Browse files Browse the repository at this point in the history
…prod-url
  • Loading branch information
ekigamba authored Dec 5, 2022
2 parents b58c16c + 1f94a26 commit 92876a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
14 changes: 9 additions & 5 deletions opensrp-giz-malawi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android {
applicationId "org.smartregister.giz"
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode 40
versionName "0.4.2"
versionCode 45
versionName "0.4.5"
multiDexEnabled true
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "false"
Expand Down Expand Up @@ -110,12 +110,13 @@ 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'
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'
Expand All @@ -138,12 +139,13 @@ 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'
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'
Expand All @@ -165,12 +167,13 @@ 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'
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'
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,6 +18,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;
Expand All @@ -31,6 +33,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;
Expand Down Expand Up @@ -363,6 +366,22 @@ public void onCreate() {

initMinimumDateForReportGeneration();

updateBaseUrlFromBuildConfigChange();
}

private void updateBaseUrlFromBuildConfigChange() {
AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences();
int currUrlVersion = BuildConfig.URL_VERSION;
String prefVal = allSharedPreferences.getPreference(GizConstants.Pref.URL_VERSION);
int prefUrlVersion = TextUtils.isEmpty(prefVal) ? 0 : Integer.parseInt(prefVal);

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);
}
}

private void initMinimumDateForReportGeneration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 92876a4

Please sign in to comment.