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 #123

Merged
merged 6 commits into from
Dec 15, 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
4 changes: 2 additions & 2 deletions opensrp-chw-hf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('org.smartregister:opensrp-client-chw-core:1.5.10-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-chw-core:1.5.22-SNAPSHOT@aar') {
// implementation(project(":opensrp-chw-core")) {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -166,7 +166,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
//Do not upgrade to 24.jre-1 due to compatibility issues
implementation 'com.google.guava:guava:20.0'
implementation 'com.google.guava:guava:24.1-jre'

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,9 @@ private void setupMenuOptions(Menu menu) {
public FamilyProfilePresenter getFamilyProfilePresenter() {
return (FamilyProfilePresenter) presenter;
}

@Override
public void setEventDate(String s) {
// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import org.smartregister.chw.core.fragment.CoreAllClientsRegisterFragment;
import org.smartregister.chw.hf.R;
import org.smartregister.chw.hf.provider.HfOpdRegisterProvider;
import org.smartregister.chw.hf.utils.AllClientsUtils;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter;

public class AllClientsRegisterFragment extends CoreAllClientsRegisterFragment {

Expand All @@ -22,5 +24,13 @@ public void setupViews(View view) {
protected void goToClientDetailActivity(@NonNull CommonPersonObjectClient commonPersonObjectClient) {
AllClientsUtils.goToClientProfile(this.getActivity(), commonPersonObjectClient);
}

@Override
public void initializeAdapter() {
HfOpdRegisterProvider childRegisterProvider = new HfOpdRegisterProvider(getActivity(), registerActionHandler, paginationViewHandler);
clientAdapter = new RecyclerViewPaginatedAdapter(null, childRegisterProvider, context().commonrepository(this.tablename));
clientAdapter.setCurrentlimit(20);
clientsView.setAdapter(clientAdapter);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ public void getView(Cursor cursor, SmartRegisterClient client, RegisterViewHolde
@Override
public void setAddressAndGender(CommonPersonObjectClient pc, RegisterViewHolder viewHolder) {
String address = Utils.getValue(pc.getColumnmaps(), ChildDBConstants.KEY.FAMILY_HOME_ADDRESS, true);
String gender = Utils.getValue(pc.getColumnmaps(), DBConstants.KEY.GENDER, true);
String gender_key = Utils.getValue(pc.getColumnmaps(), DBConstants.KEY.GENDER, true);
String gender = "";
if (gender_key.equalsIgnoreCase("Male")) {
gender = context.getString(org.smartregister.chw.core.R.string.male);
} else if (gender_key.equalsIgnoreCase("Female")) {
gender = context.getString(org.smartregister.chw.core.R.string.female);
}
fillValue(viewHolder.textViewAddressGender, gender + " \u00B7 " + address);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.smartregister.chw.hf.provider;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;

import org.smartregister.chw.core.utils.CoreConstants;
import org.smartregister.chw.hf.R;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.family.util.DBConstants;
import org.smartregister.family.util.Utils;
import org.smartregister.opd.holders.OpdRegisterViewHolder;
import org.smartregister.opd.provider.OpdRegisterProvider;
import org.smartregister.opd.utils.OpdDbConstants;

public class HfOpdRegisterProvider extends OpdRegisterProvider {
private final Context context;

public HfOpdRegisterProvider(@NonNull Context context, @NonNull View.OnClickListener onClickListener, @NonNull View.OnClickListener paginationClickListener) {
super(context, onClickListener, paginationClickListener);
this.context = context;
}

@Override
public void populatePatientColumn(CommonPersonObjectClient commonPersonObjectClient, OpdRegisterViewHolder viewHolder) {
super.populatePatientColumn(commonPersonObjectClient, viewHolder);
String registerType = org.smartregister.util.Utils.getValue(commonPersonObjectClient.getColumnmaps(),
OpdDbConstants.KEY.REGISTER_TYPE, true);

if (!TextUtils.isEmpty(registerType)) {
viewHolder.showRegisterType();
String type = getTranslatedRegisterType(registerType);
fillValue(viewHolder.tvRegisterType, type);
} else {
viewHolder.hideRegisterType();
}
}

private String getTranslatedRegisterType(String registerType) {
if (registerType.equalsIgnoreCase(CoreConstants.REGISTER_TYPE.CHILD)) {
return context.getString(R.string.menu_child);
} else if (registerType.equalsIgnoreCase(CoreConstants.REGISTER_TYPE.ANC)) {
return context.getString(R.string.menu_anc);
} else if (registerType.equalsIgnoreCase(CoreConstants.REGISTER_TYPE.PNC)) {
return context.getString(R.string.menu_pnc);
} else if (registerType.equalsIgnoreCase(CoreConstants.REGISTER_TYPE.FAMILY_PLANNING)) {
return context.getString(R.string.menu_family_planning);
} else if (registerType.equalsIgnoreCase(CoreConstants.REGISTER_TYPE.MALARIA)) {
return context.getString(R.string.menu_malaria);
}
return registerType;
}

@Override
public void setAddressAndGender(CommonPersonObjectClient pc, OpdRegisterViewHolder viewHolder) {
super.setAddressAndGender(pc, viewHolder);
String gender_key = Utils.getValue(pc.getColumnmaps(), DBConstants.KEY.GENDER, true);
String gender = "";
if (gender_key.equalsIgnoreCase("Male")) {
gender = context.getString(org.smartregister.chw.core.R.string.male);
} else if (gender_key.equalsIgnoreCase("Female")) {
gender = context.getString(org.smartregister.chw.core.R.string.female);
}
fillValue(viewHolder.textViewGender, gender);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.smartregister.chw.hf;

import android.app.Activity;
import android.content.Intent;

import org.junit.Assert;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.shadows.ShadowApplication;

import timber.log.Timber;

public abstract class BaseActivityUnitTest extends BaseUnitTest {

protected void destroyController() {
try {
getActivity().finish();
getActivityController().pause().stop().destroy(); //destroy controller if we can

} catch (Exception e) {
Timber.e(e);
}
System.gc();
}

protected abstract Activity getActivity();

protected abstract ActivityController getActivityController();

protected void assertActivityStarted(Activity currActivity, Activity nextActivity) {
Intent expectedIntent = new Intent(currActivity, nextActivity.getClass());
Intent actual = ShadowApplication.getInstance().getNextStartedActivity();
Assert.assertEquals(expectedIntent.getComponent(), actual.getComponent());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.smartregister.chw.hf;

import android.os.Build;

import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith (RobolectricTestRunner.class)
@Config(application = HealthFacilityApplication.class, sdk = Build.VERSION_CODES.P)
public abstract class BaseUnitTest {
protected static final String DUMMY_USERNAME = "myusername";
protected static final String DUMMY_PASSWORD = "mypassword";
}
Loading