Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation Fixes #91

Merged
merged 5 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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-malaria:jacocoTestReport --stacktrace
- name: Generate Javadoc with Gradle
run: ./gradlew javadoc
- name: Upload coverage to Coveralls with Gradle
run: ./gradlew :opensrp-chw-malaria:coveralls --stacktrace
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath 'com.android.tools.build:gradle:3.5.3'
}
}

Expand Down Expand Up @@ -55,7 +57,7 @@ subprojects {
// Improve build server performance by allowing disabling of pre-dexing
// (see http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.)
project.plugins.whenPluginAdded { plugin ->
if("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.2.18-SNAPSHOT
VERSION_NAME=1.2.19-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client CHW Malaria Library
Expand Down
14 changes: 8 additions & 6 deletions opensrp-chw-malaria/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
description = 'OpenSRP chw malaria client library'

buildscript {
repositories {
Expand All @@ -7,13 +6,16 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
}
}

apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.android.library'
plugins {
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.10.2'
id 'com.android.library'
}

description = 'OpenSRP chw malaria client library'

jacoco {
toolVersion = "0.8.0"
Expand Down Expand Up @@ -148,7 +150,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
getReports().getHtml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/html"))

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$ViewBinder*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/classes", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"

sourceDirectories = files([mainSrc])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void setProfileViewWithData() {
int age = new Period(new DateTime(memberObject.getAge()), new DateTime()).getYears();
textViewName.setText(String.format("%s %s %s, %d", memberObject.getFirstName(),
memberObject.getMiddleName(), memberObject.getLastName(), age));
textViewGender.setText(memberObject.getGender());
textViewGender.setText(MalariaUtil.getGenderTranslated(this, memberObject.getGender()));
textViewLocation.setText(memberObject.getAddress());
textViewUniqueID.setText(memberObject.getUniqueId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.Toast;

import org.json.JSONObject;
import org.opensrp.api.constants.Gender;
import org.smartregister.chw.malaria.MalariaLibrary;
import org.smartregister.chw.malaria.contract.BaseMalariaCallDialogContract;
import org.smartregister.chw.malaria.dao.MalariaDao;
Expand Down Expand Up @@ -137,4 +138,13 @@ protected Void doInBackground(Void... voids) {
}

}

public static String getGenderTranslated(Context context, String gender) {
if (gender.equalsIgnoreCase(Gender.MALE.toString())) {
return context.getResources().getString(R.string.male);
} else if (gender.equalsIgnoreCase(Gender.FEMALE.toString())) {
return context.getResources().getString(R.string.female);
}
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.joda.time.Period;
import org.smartregister.chw.malaria.fragment.BaseMalariaRegisterFragment;
import org.smartregister.chw.malaria.util.DBConstants;
import org.smartregister.chw.malaria.util.MalariaUtil;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.cursoradapter.RecyclerViewProvider;
import org.smartregister.malaria.R;
Expand Down Expand Up @@ -62,8 +63,10 @@ private String updateMemberGender(CommonPersonObjectClient commonPersonObjectCli
return context.getResources().getString(R.string.anc_string);
} else if ("0".equals(Utils.getValue(commonPersonObjectClient.getColumnmaps(), DBConstants.KEY.IS_PNC_CLOSED, false))) {
return context.getResources().getString(R.string.pnc_string);
} else
return Utils.getValue(commonPersonObjectClient.getColumnmaps(), DBConstants.KEY.GENDER, true);
} else {
String gender = Utils.getValue(commonPersonObjectClient.getColumnmaps(), DBConstants.KEY.GENDER, true);
return MalariaUtil.getGenderTranslated(context, gender);
}
}

private void populatePatientColumn(CommonPersonObjectClient pc, final RegisterViewHolder viewHolder) {
Expand Down
2 changes: 2 additions & 0 deletions opensrp-chw-malaria/src/main/res/values-sw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@
<string name="pnc_string">Baada ya kujifungua</string>
<string name="visit_done">Tembeleo limekamilika</string>
<string name="edit">HARIRI</string>
<string name="male">Me</string>
<string name="female">Ke</string>

</resources>
2 changes: 2 additions & 0 deletions opensrp-chw-malaria/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@
<string name="pnc_string">PNC</string>
<string name="visit_done">Visit Done</string>
<string name="edit">EDIT</string>
<string name="male">Male</string>
<string name="female">Female</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ public void isPncClosed() throws Exception {
@Test
public void updateMemberGender() throws Exception {
Activity activity = Mockito.mock(Activity.class);
Resources resources = Mockito.mock(Resources.class);
MalariaRegisterProvider provider = new MalariaRegisterProvider(activity, listener, listener, null);
Map<String, String> map = new HashMap<>();
map.put(DBConstants.KEY.GENDER, "Male");

Mockito.when(activity.getResources()).thenReturn(resources);
Mockito.when(commonPersonObjectClient.getColumnmaps()).thenReturn(map);
Assert.assertEquals("Male", Whitebox.invokeMethod(provider, "updateMemberGender", commonPersonObjectClient));
Assert.assertEquals(resources.getString(R.string.male), Whitebox.invokeMethod(provider, "updateMemberGender", commonPersonObjectClient));
}


Expand Down