Skip to content

Commit

Permalink
Merge pull request #40 from OpenSRP/translation-fixes
Browse files Browse the repository at this point in the history
Translation fixes
  • Loading branch information
hamza-vd authored Dec 11, 2020
2 parents ba2f9e9 + 787e4a3 commit 16f3cc2
Show file tree
Hide file tree
Showing 11 changed files with 286 additions and 87 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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: Android CI with Gradle

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
unit_tests:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- 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
run: chmod +x gradlew
- name: Run unit tests with Gradle
run: ./gradlew :opensrp-chw-referral:jacocoTestReport --stacktrace
- name: Upload coverage to Coveralls with Gradle
run: ./gradlew coveralls --stacktrace
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ buildscript {
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}"
Expand All @@ -38,6 +39,7 @@ allprojects {
maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "https://plugins.gradle.org/m2/" }
}
}
subprojects {
Expand All @@ -64,6 +66,7 @@ configure(allprojects) { project ->
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=1.3.5-SNAPSHOT
VERSION_NAME=1.3.6-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Chw Referral Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.joda.time.Period
import org.smartregister.chw.referral.R
import org.smartregister.chw.referral.domain.MemberObject
import org.smartregister.chw.referral.util.Constants
import org.smartregister.chw.referral.util.ReferralUtil
import org.smartregister.view.activity.SecuredActivity
import org.smartregister.view.customcontrols.CustomFontTextView
import java.math.BigDecimal
Expand Down Expand Up @@ -98,7 +99,7 @@ open class ReferralDetailsViewActivity : SecuredActivity() {
referralDateCalendar.timeInMillis = BigDecimal(it.chwReferralDate).toLong()
referralDate.text = dateFormatter.format(referralDateCalendar.time)
referralFacility.text = it.chwReferralHf
referralType.text = it.chwReferralService
referralType.text = ReferralUtil.getTranslatedReferralServiceType(this, it.chwReferralService!!)
if (!it.primaryCareGiver.isNullOrEmpty() && clientAge.toInt() < 5)
careGiverName.text = String.format("CG : %s", it.primaryCareGiver)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.smartregister.chw.referral.R
import org.smartregister.chw.referral.fragment.BaseReferralRegisterFragment
import org.smartregister.chw.referral.util.Constants
import org.smartregister.chw.referral.util.DBConstants
import org.smartregister.chw.referral.util.ReferralUtil
import org.smartregister.commonregistry.CommonPersonObjectClient
import org.smartregister.cursoradapter.RecyclerViewProvider
import org.smartregister.util.Utils
Expand All @@ -28,45 +29,45 @@ import java.util.*
import org.smartregister.configurableviews.model.View as ConfigurableView

open class ReferralRegisterProvider(
private val context: Context, private val paginationClickListener: View.OnClickListener,
private var onClickListener: View.OnClickListener,
private val visibleColumns: Set<ConfigurableView>?
private val context: Context, private val paginationClickListener: View.OnClickListener,
private var onClickListener: View.OnClickListener,
private val visibleColumns: Set<ConfigurableView>?
) : RecyclerViewProvider<ReferralRegisterProvider.RegisterViewHolder> {

private val inflater =
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater

override fun getView(
cursor: Cursor, smartRegisterClient: SmartRegisterClient,
registerViewHolder: RegisterViewHolder
cursor: Cursor, smartRegisterClient: SmartRegisterClient,
registerViewHolder: RegisterViewHolder
) {
if (visibleColumns!!.isEmpty())
populatePatientColumn(
smartRegisterClient as CommonPersonObjectClient, registerViewHolder
smartRegisterClient as CommonPersonObjectClient, registerViewHolder
)
}

override fun getFooterView(
viewHolder: RecyclerView.ViewHolder, currentPageCount: Int, totalPageCount: Int,
hasNext: Boolean, hasPrevious: Boolean
viewHolder: RecyclerView.ViewHolder, currentPageCount: Int, totalPageCount: Int,
hasNext: Boolean, hasPrevious: Boolean
) {
(viewHolder as FooterViewHolder)
.apply {
pageInfoView.text = MessageFormat.format(
context.getString(org.smartregister.R.string.str_page_info),
currentPageCount,
totalPageCount
)
nextPageView.visibility = if (hasNext) View.VISIBLE else View.INVISIBLE
nextPageView.setOnClickListener(paginationClickListener)
previousPageView.visibility = if (hasPrevious) View.VISIBLE else View.INVISIBLE
previousPageView.setOnClickListener(paginationClickListener)
}
.apply {
pageInfoView.text = MessageFormat.format(
context.getString(org.smartregister.R.string.str_page_info),
currentPageCount,
totalPageCount
)
nextPageView.visibility = if (hasNext) View.VISIBLE else View.INVISIBLE
nextPageView.setOnClickListener(paginationClickListener)
previousPageView.visibility = if (hasPrevious) View.VISIBLE else View.INVISIBLE
previousPageView.setOnClickListener(paginationClickListener)
}
}

override fun updateClients(
villageFilter: FilterOption?, serviceModeOption: ServiceModeOption?,
searchFilter: FilterOption?, sortOption: SortOption?
villageFilter: FilterOption?, serviceModeOption: ServiceModeOption?,
searchFilter: FilterOption?, sortOption: SortOption?
) = null

override fun onServiceModeSelected(serviceModeOption: ServiceModeOption) = Unit
Expand All @@ -76,41 +77,44 @@ open class ReferralRegisterProvider(
override fun inflater() = inflater

override fun createViewHolder(parent: ViewGroup) = RegisterViewHolder(
inflater.inflate(R.layout.referral_register_list_row_item, parent, false)
inflater.inflate(R.layout.referral_register_list_row_item, parent, false)
)

override fun createFooterHolder(parent: ViewGroup) = FooterViewHolder(
inflater.inflate(R.layout.smart_register_pagination, parent, false)
inflater.inflate(R.layout.smart_register_pagination, parent, false)
)

override fun isFooterViewHolder(viewHolder: RecyclerView.ViewHolder) =
viewHolder is FooterViewHolder
viewHolder is FooterViewHolder

private fun populatePatientColumn(
pc: CommonPersonObjectClient, viewHolder: RegisterViewHolder
pc: CommonPersonObjectClient, viewHolder: RegisterViewHolder
) {
try {
val firstName = Utils.getName(
Utils.getValue(pc.columnmaps, DBConstants.Key.FIRST_NAME, true),
Utils.getValue(pc.columnmaps, DBConstants.Key.MIDDLE_NAME, true)
Utils.getValue(pc.columnmaps, DBConstants.Key.FIRST_NAME, true),
Utils.getValue(pc.columnmaps, DBConstants.Key.MIDDLE_NAME, true)
)
val dobString = Utils.getValue(pc.columnmaps, DBConstants.Key.DOB, false)
val age = Period(DateTime(dobString), DateTime()).years
val patientName = Utils.getName(
firstName, Utils.getValue(pc.columnmaps, DBConstants.Key.LAST_NAME, true)
firstName, Utils.getValue(pc.columnmaps, DBConstants.Key.LAST_NAME, true)
)
with(viewHolder) {
this.patientName.text = String.format(
Locale.getDefault(), "%s, %d", patientName, age
Locale.getDefault(), "%s, %d", patientName, age
)
textViewGender.text = Utils.getValue(pc.columnmaps, DBConstants.Key.GENDER, true)
textViewGender.text = ReferralUtil.getTranslatedGenderString(context,
Utils.getValue(pc.columnmaps, DBConstants.Key.GENDER, true))
textViewVillage.text =
Utils.getValue(pc.columnmaps, DBConstants.Key.VILLAGE_TOWN, true)
textViewService.text = Utils.getValue(
pc.columnmaps, DBConstants.Key.REFERRAL_SERVICE, true
Utils.getValue(pc.columnmaps, DBConstants.Key.VILLAGE_TOWN, true)

val referralType = Utils.getValue(
pc.columnmaps, DBConstants.Key.REFERRAL_SERVICE, true
)
textViewService.text = ReferralUtil.getTranslatedReferralServiceType(context, referralType)
textViewFacility.text = Utils.getValue(
pc.columnmaps, DBConstants.Key.REFERRAL_HF, true
pc.columnmaps, DBConstants.Key.REFERRAL_HF, true
)

patientColumn.apply {
Expand All @@ -126,8 +130,8 @@ open class ReferralRegisterProvider(
registerColumns.setOnClickListener(onClickListener)
registerColumns.setOnClickListener { patientColumn.performClick() }
setReferralStatusColor(
context, textReferralStatus,
Utils.getValue(pc.columnmaps, DBConstants.Key.REFERRAL_STATUS, true)
context, textReferralStatus,
Utils.getValue(pc.columnmaps, DBConstants.Key.REFERRAL_STATUS, true)
)
}
} catch (e: IllegalStateException) {
Expand All @@ -139,19 +143,19 @@ open class ReferralRegisterProvider(
when (status) {
Constants.BusinessStatus.REFERRED -> {
textViewStatus.setTextColor(
ContextCompat.getColor(context, R.color.alert_in_progress_blue)
ContextCompat.getColor(context, R.color.alert_in_progress_blue)
)
textViewStatus.text = context.getString(R.string.referral_status_pending)
}
Constants.BusinessStatus.EXPIRED -> {
textViewStatus.setTextColor(
ContextCompat.getColor(context, R.color.alert_urgent_red)
ContextCompat.getColor(context, R.color.alert_urgent_red)
)
textViewStatus.text = context.getString(R.string.referral_status_failed)
}
Constants.BusinessStatus.COMPLETE -> {
textViewStatus.setTextColor(
ContextCompat.getColor(context, R.color.alert_complete_green)
ContextCompat.getColor(context, R.color.alert_complete_green)
)
textViewStatus.text = context.getString(R.string.referral_status_successful)
}
Expand Down
Loading

0 comments on commit 16f3cc2

Please sign in to comment.