Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/recent-updates' into v0.2.1-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
dubdabasoduba committed Nov 26, 2021
2 parents 6a5698e + e62bbae commit ca1f851
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 17 deletions.
8 changes: 4 additions & 4 deletions opensrp-unicef-tunisia/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '11'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand All @@ -158,7 +158,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '12'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand Down Expand Up @@ -190,7 +190,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '13'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '15'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand Down Expand Up @@ -286,7 +286,7 @@ dependencies {
exclude group: 'com.github.lecho', module: 'hellocharts-library'
}

implementation('org.smartregister:opensrp-client-immunization:4.0.0-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-immunization:4.0.3-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'com.android.support', module: 'design'
Expand Down
24 changes: 24 additions & 0 deletions opensrp-unicef-tunisia/src/main/assets/preterm_vaccines.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,30 @@
}
]
}
},
{
"name": "VHA",
"type": "vha",
"openmrs_date": {
"parent_entity": "",
"entity": "concept",
"entity_id": "vha"
},
"openmrs_calculate": {
"parent_entity": "",
"entity": "concept",
"entity_id": "vha_calculation",
"calculation": 0
},
"schedule": {
"due": [
{
"reference": "dob",
"offset": "+360d",
"window": "+30d"
}
]
}
}
]
},
Expand Down
24 changes: 24 additions & 0 deletions opensrp-unicef-tunisia/src/main/assets/vaccines.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,30 @@
}
]
}
},
{
"name": "VHA",
"type": "vha",
"openmrs_date": {
"parent_entity": "",
"entity": "concept",
"entity_id": "vha"
},
"openmrs_calculate": {
"parent_entity": "",
"entity": "concept",
"entity_id": "vha_calculation",
"calculation": 0
},
"schedule": {
"due": [
{
"reference": "dob",
"offset": "+360d",
"window": "+30d"
}
]
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ object ReportingUtils {
}
}

fun dateFormatter(pattern: String = "yyyy-MM") = SimpleDateFormat(pattern, Locale.ENGLISH)
fun dateFormatter(pattern: String = "yyyy-MM", locale : Locale = Locale.ENGLISH ) = SimpleDateFormat(pattern, locale)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class MonthlyReportsActivity : MultiLanguageActivity() {
}
containerViewPager.apply {
adapter = reportsPagerAdapter
currentItem = intent.getIntExtra(Constants.SELECT_TAB, 1)
currentItem = intent.getIntExtra(Constants.SELECT_TAB, 0)
setReportSyncButtonVisibility(currentItem);
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrolled(
position: Int,
Expand All @@ -60,10 +61,7 @@ class MonthlyReportsActivity : MultiLanguageActivity() {
}

override fun onPageSelected(position: Int) {
if (position == 0)
reportSyncBtn.visibility = View.VISIBLE
else
reportSyncBtn.visibility = View.GONE
setReportSyncButtonVisibility(position)
}

override fun onPageScrollStateChanged(state: Int) {
Expand Down Expand Up @@ -98,6 +96,13 @@ class MonthlyReportsActivity : MultiLanguageActivity() {
}
}

private fun setReportSyncButtonVisibility(position: Int) {
if (position == 0)
reportSyncBtn.visibility = View.VISIBLE
else
reportSyncBtn.visibility = View.GONE
}

private fun getLoggedInUserInitials(): String {
val allSharedPreferences = Context.getInstance().allSharedPreferences()
return allSharedPreferences.getANMPreferredName(allSharedPreferences.fetchRegisteredANM())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.smartregister.path.reporting.monthly.daily
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.ConfigurationCompat
import androidx.recyclerview.widget.RecyclerView
import com.github.florent37.expansionpanel.viewgroup.ExpansionLayoutCollection
import kotlinx.android.extensions.LayoutContainer
Expand Down Expand Up @@ -47,17 +48,16 @@ class DailyTalliesRecyclerAdapter(val onClickListener: View.OnClickListener) :
val (day, tallies) = dailyTallies

//Set year header
yearHeaderTextView.text = day
val dayDate = dateFormatter("MMMM yyyy").parse(day)
yearHeaderTextView.text = dateFormatter("MMMM yyyy", locale = ConfigurationCompat.getLocales(sentReportContainer.resources.configuration)[0]).format(dayDate!!)

//Set tallies

sentReportContainer.removeAllViews()
tallies.forEach {
val view = LayoutInflater.from(containerView.context).inflate(R.layout.sent_monthly_report_list_item,
sentReportContainer, false).apply {
tag = it
dateReportSentTextView.text = dateFormatter("dd MMMM yy").format(it.day)
.translateString(context)
dateReportSentTextView.text = dateFormatter("dd MMMM yy", locale = ConfigurationCompat.getLocales(resources.configuration)[0]).format(it.day)
sentReportDetailsTextView.visibility = View.GONE
setOnClickListener(onClickListener)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.core.os.ConfigurationCompat
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.vijay.jsonwizard.activities.MultiLanguageActivity
import kotlinx.android.synthetic.main.activity_report_indicators.*
import kotlinx.android.synthetic.main.sent_reports_expansion_panel_item.*
import kotlinx.coroutines.launch
import org.smartregister.path.reporting.monthly.domain.DailyTally
import org.smartregister.path.reporting.monthly.domain.MonthlyTally
Expand Down Expand Up @@ -68,7 +70,7 @@ class ReportIndicatorsActivity : MultiLanguageActivity() {
getString(R.string.monthly_sent_reports_with_year, translatedYearMonth) else
getString(R.string.month_year_draft, translatedYearMonth)

backButton.setOnClickListener { navigateToMonthlyReports(2) }
backButton.setOnClickListener { navigateToMonthlyReports(if (getBooleanExtra(SHOW_DATA, false)) 2 else 1) }
} ?: run {
serializableExtra = getSerializableExtra(DAILY_TALLIES)

Expand All @@ -80,7 +82,9 @@ class ReportIndicatorsActivity : MultiLanguageActivity() {
if (serializableExtra is Map<*, *>)
reportIndicatorsViewModel.dailyTalliesMap.value = (serializableExtra as Map<String, DailyTally>).toMutableMap()

yearMonthTextView.text = getString(R.string.daily_tallies_with_day, getStringExtra(DAY))
val day = ReportingUtils.dateFormatter("dd MMMM yy").parse(getStringExtra(DAY)!!)
yearMonthTextView.text = getString(R.string.daily_tallies_with_day, ReportingUtils.dateFormatter("dd MMMM yy",
locale = ConfigurationCompat.getLocales(resources.configuration)[0]).format(day!!))

//Navigate to ReportIndicatorsSummaryFragment when show data is true
if (getBooleanExtra(SHOW_DATA, false)) {
Expand Down Expand Up @@ -110,7 +114,6 @@ class ReportIndicatorsActivity : MultiLanguageActivity() {

private fun navigateToMonthlyReports(selectTab: Int = 1) {
startActivity(Intent(this@ReportIndicatorsActivity, MonthlyReportsActivity::class.java).apply {
if (intent.getBooleanExtra(SHOW_DATA, false))
putExtra(MonthlyReportsActivity.Constants.SELECT_TAB, selectTab)
})
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.smartregister.reporting.repository.IndicatorQueryRepository;
import org.smartregister.reporting.repository.IndicatorRepository;
import org.smartregister.repository.AlertRepository;
import org.smartregister.repository.AllSharedPreferences;
import org.smartregister.repository.EventClientRepository;
import org.smartregister.repository.Hia2ReportRepository;
import org.smartregister.repository.LocationRepository;
Expand Down Expand Up @@ -131,6 +132,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
break;
case 14:
upgradeToVersion14(db);
case 15:
upgradeToVersion15(db);
default:
break;
}
Expand Down Expand Up @@ -346,4 +349,16 @@ private void upgradeToVersion14(SQLiteDatabase db) {
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL);
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX);
}

private void upgradeToVersion15(SQLiteDatabase db) {
try{
AllSharedPreferences sharedPreferences = UnicefTunisiaApplication.getInstance().context().userService()
.getAllSharedPreferences();
db.execSQL(VaccineRepository.UPDATE_TABLE_VACCINES_ADD_OUTREACH_COL);
db.execSQL(VaccineRepository.UPDATE_OUTREACH_QUERRY, new String[]{sharedPreferences.fetchDefaultLocalityId(sharedPreferences.fetchPioneerUser())});

} catch (Exception e) {
Timber.e(e, "upgradeToVersion15");
}
}
}
2 changes: 2 additions & 0 deletions opensrp-unicef-tunisia/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,6 @@
<!-- Card support strings -->
<string name="opensrp_id">IDV NUMBER</string>
<string name="percentage_sign">%1$s\%%</string>
<string name="vha">VHA</string>

</resources>

0 comments on commit ca1f851

Please sign in to comment.