Skip to content

Commit

Permalink
Fix Sql lock on ECRegister by Replace FormUtils #4
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Dec 4, 2017
1 parent e9b2e07 commit 0beaf2a
Show file tree
Hide file tree
Showing 31 changed files with 6,369 additions and 126 deletions.
16 changes: 5 additions & 11 deletions opensrp-bidan-cloudant-nofr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,32 @@ repositories {
apply plugin: 'com.android.application'

dependencies {

compile fileTree(include: ['commons-validator-1.6.jar'], dir: 'libs')

// compile project(':opensrp-app')
// compile project(':opensrp-app')
compile('org.smartregister:opensrp-client-core:1.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
}

// FORM
compile('org.smartregister:opensrp-client-enketo:1.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
}


compile ('com.android.support:design:22.2.1'){
compile('com.android.support:design:22.2.1') {
exclude group: 'com.android.support', module: 'recyclerview-v7'

}

testCompile 'junit:junit:4.12'
testCompile ('org.robolectric:robolectric:3.4') {
testCompile('org.robolectric:robolectric:3.4') {

exclude group: 'com.google.guava', module: 'guava'
exclude group: 'org.apache.maven', module: 'maven-model'
exclude group: 'org.apache.maven', module:'maven-ant-tasks'
exclude group: 'org.apache.maven', module: 'maven-ant-tasks'
exclude group: 'com.android.support'
exclude group: 'com.thoughtworks.xstream', module: 'xstream'
}
testCompile ("org.robolectric:shadows-multidex:3.4-rc2") {
testCompile('org.robolectric:shadows-multidex:3.4-rc2') {
exclude group: 'com.google.guava', module: 'guava'
}
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
Expand Down
39 changes: 33 additions & 6 deletions opensrp-bidan-cloudant-nofr/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
package="org.smartregister.bidan">

<application
android:name="org.smartregister.bidan.application.BidanApplication"
android:name=".application.BidanApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="org.smartregister.bidan.activity.LoginActivity"
android:name=".activity.LoginActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Holo"
Expand All @@ -26,29 +26,56 @@
android:screenOrientation="landscape"
android:theme="@style/AppTheme" />

<activity android:name=".activity.IbuSmartRegisterActivity"
<activity
android:name=".activity.NativeKISmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.DetailMotherActivity"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoTitle" />

<activity
android:name=".activity.NativeKISmartRegisterActivity"
android:name=".activity.NativeKIFPSmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.DetailFPActivity"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoTitle" />

<activity
android:name=".activity.NativeKIPNCSmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.DetailPNCActivity"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoTitle" />

<activity android:name=".activity.NativeKIANCSmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.DetailIbuActivity"
android:name=".activity.DetailANCActivity"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoTitle" />

<activity android:name=".activity.NativeKIAnakSmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="org.smartregister.bidan.activity.DetailChildActivity"
android:name=".activity.DetailChildActivity"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoTitle" />
</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
package org.smartregister.bidan.activity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import org.smartregister.Context;
import org.smartregister.bidan.R;
import org.smartregister.commonregistry.AllCommonsRepository;
import org.smartregister.commonregistry.CommonPersonObject;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.repository.DetailsRepository;
import org.smartregister.view.activity.DrishtiApplication;

import java.io.File;
import java.util.HashMap;

import static org.smartregister.util.StringUtil.humanize;

//import org.smartregister.bidan.lib.FlurryFacade;

/**
* Created by Iq on 07/09/16.
*/
public class DetailANCActivity extends Activity {

//image retrieving
private static final String TAG = DetailANCActivity.class.getSimpleName();
public static CommonPersonObjectClient ancClient;
static String entityid;
private static HashMap<String, String> hash;
private boolean updateMode = false;

public static void setImagetoHolderFromUri(Activity activity, String file, ImageView view, int placeholder) {
view.setImageDrawable(activity.getResources().getDrawable(placeholder));
File externalFile = new File(file);
if (externalFile.exists()) {
Uri external = Uri.fromFile(externalFile);
view.setImageURI(external);
}

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context context = Context.getInstance();
setContentView(R.layout.child_detail_activity);

final ImageView childview = (ImageView)findViewById(R.id.childdetailprofileview);
//header
// TextView today = (TextView) findViewById(R.id.detail_today);

//profile
TextView nama = (TextView) findViewById(R.id.txt_child_name);
TextView mother = (TextView) findViewById(R.id.txt_mother_name);
TextView father = (TextView) findViewById(R.id.txt_father_number);
TextView dob = (TextView) findViewById(R.id.txt_dob);

// TextView phone = (TextView) findViewById(R.id.txt_contact_phone_number);
// TextView risk1 = (TextView) findViewById(R.id.txt_risk1);
// TextView risk2 = (TextView) findViewById(R.id.txt_risk2);
// TextView risk3 = (TextView) findViewById(R.id.txt_risk3);
// TextView risk4 = (TextView) findViewById(R.id.txt_risk4);

//detail data
TextView txt_noBayi = (TextView) findViewById(R.id.txt_noBayi);
TextView txt_jenisKelamin = (TextView) findViewById(R.id.txt_jenisKelamin);
TextView txt_beratLahir = (TextView) findViewById(R.id.txt_beratLahir);
TextView tinggi = (TextView) findViewById(R.id.txt_hasilPengukuranTinggiBayihasilPengukuranTinggiBayi);
TextView berat = (TextView) findViewById(R.id.txt_indikatorBeratBedanBayi);
TextView asi = (TextView) findViewById(R.id.txt_pemberianAsiEksklusif);
TextView status_gizi = (TextView) findViewById(R.id.txt_statusGizi);
TextView kpsp = (TextView) findViewById(R.id.txt_hasilDilakukannyaKPSP);
TextView vita = (TextView) findViewById(R.id.txt_pelayananVita);
TextView hb0 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiHb07);
TextView pol1 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiBCGdanPolio1);
TextView pol2 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB1Polio2);
TextView pol3 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB2Polio3);
TextView pol4 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB3Polio4);
TextView campak = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiCampak);

TextView growthChartButton = (TextView)findViewById(R.id.chart_label);
ImageButton back = (ImageButton) findViewById(org.smartregister.R.id.btn_back_to_home);

growthChartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
DetailANCActivity.ancClient = ancClient;
startActivity(new Intent(DetailANCActivity.this, DetailANCActivity.class));
overridePendingTransition(0, 0);
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
startActivity(new Intent(DetailANCActivity.this, NativeKIAnakSmartRegisterActivity.class));
overridePendingTransition(0, 0);
}
});


DetailsRepository detailsRepository = Context.getInstance().detailsRepository();
detailsRepository.updateDetails(ancClient);

String gender = ancClient.getDetails().containsKey("gender") ? ancClient.getDetails().get("gender"):"laki";


//start profile image
int placeholderDrawable= gender.equalsIgnoreCase("male") ? R.drawable.child_boy_infant:R.drawable.child_girl_infant;
childview.setTag(R.id.entity_id, ancClient.getCaseId());//required when saving file to disk
if (ancClient.getCaseId() != null) {
//image already in local storage most likey ):
//set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally
// DrishtiApplication.getCachedImageLoaderInstance().getImageByClientId(ancClient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable));

DetailANCActivity.setImagetoHolderFromUri(this,
DrishtiApplication.getAppDir() + File.separator + ancClient.getDetails().get("base_entity_id") + ".JPEG",
childview, ancClient.getDetails().get("gender").equals("female") ? R.drawable.child_girl_infant : R.drawable.child_boy_infant);
}

//end profile image

AllCommonsRepository childRepository = Context.getInstance().allCommonsRepositoryobjects("ec_anak");

CommonPersonObject childobject = childRepository.findByCaseID(ancClient.entityId());

// AllCommonsRepository iburep = org.smartregister.Context.getInstance().allCommonsRepositoryobjects("ec_ibu");
// final CommonPersonObject ibuparent = iburep.findByCaseID(childobject.getColumnmaps().get("relational_id"));

AllCommonsRepository kirep = Context.getInstance().allCommonsRepositoryobjects("ec_kartu_ibu");
final CommonPersonObject kiparent = kirep.findByCaseID(childobject.getColumnmaps().get("relational_id"));


nama.setText(String.format("%s%s", getResources().getString(R.string.name), humanize(ancClient.getColumnmaps().get("namaBayi") != null ? ancClient.getColumnmaps().get("namaBayi") : "-")));
mother.setText(String.format("%s%s", getResources().getString(R.string.child_details_mothers_name_label), humanize(kiparent.getColumnmaps().get("namalengkap") != null ? kiparent.getColumnmaps().get("namalengkap") : "-")));
father.setText(String.format("%s%s", getResources().getString(R.string.child_details_fathers_name_label), humanize(kiparent.getColumnmaps().get("namaSuami") != null ? kiparent.getColumnmaps().get("namaSuami") : "-")));
dob.setText(String.format("%s%s", getResources().getString(R.string.date_of_birth), humanize(ancClient.getColumnmaps().get("tanggalLahirAnak") != null ? ancClient.getColumnmaps().get("tanggalLahirAnak") : "-")));

txt_noBayi.setText(String.format("%s: ", humanize(ancClient.getDetails().get("noBayi") != null ? ancClient.getDetails().get("noBayi") : "-")));
txt_jenisKelamin.setText(String.format(": %s", humanize(ancClient.getDetails().get("gender") != null ? ancClient.getDetails().get("gender") : "-")));
txt_beratLahir.setText(String.format(": %s", humanize(ancClient.getDetails().get("beratLahir") != null ? ancClient.getDetails().get("beratLahir") : "-")));
tinggi.setText(String.format(": %s", humanize(ancClient.getDetails().get("hasilPengukuranTinggiBayihasilPengukuranTinggiBayi") != null ? ancClient.getDetails().get("hasilPengukuranTinggiBayihasilPengukuranTinggiBayi") : "-")));
berat.setText(String.format(": %s", humanize(ancClient.getDetails().get("indikatorBeratBedanBayi") != null ? ancClient.getDetails().get("indikatorBeratBedanBayi") : "-")));
asi.setText(String.format(": %s", humanize(ancClient.getDetails().get("pemberianAsiEksklusif") != null ? ancClient.getDetails().get("pemberianAsiEksklusif") : "-")));
status_gizi.setText(String.format(": %s", humanize(ancClient.getDetails().get("statusGizi") != null ? ancClient.getDetails().get("statusGizi") : "-")));
kpsp.setText(String.format(": %s", humanize(ancClient.getDetails().get("hasilDilakukannyaKPSP") != null ? ancClient.getDetails().get("hasilDilakukannyaKPSP") : "-")));
hb0.setText(String.format(": %s", humanize(ancClient.getDetails().get("hb0") != null ? ancClient.getDetails().get("hb0") : "-")));
pol1.setText(String.format(": %s", humanize(ancClient.getDetails().get("polio1") != null ? ancClient.getDetails().get("polio1") : ancClient.getDetails().get("bcg") != null ? ancClient.getDetails().get("bcg") : "-")));
pol2.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb1") != null ? ancClient.getDetails().get("dptHb1") : ancClient.getDetails().get("polio2") != null ? ancClient.getDetails().get("polio2") : "-")));
pol3.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb2") != null ? ancClient.getDetails().get("dptHb2") : ancClient.getDetails().get("polio3") != null ? ancClient.getDetails().get("polio3") : "-")));
pol4.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb3") != null ? ancClient.getDetails().get("dptHb3") : ancClient.getDetails().get("polio4") != null ? ancClient.getDetails().get("polio4") : "-")));
campak.setText(String.format(": %s", humanize(ancClient.getDetails().get("campak") != null ? ancClient.getDetails().get("campak") : "-")));
vita.setText(String.format(": %s", humanize(ancClient.getDetails().get("pelayananVita") != null ? ancClient.getDetails().get("pelayananVita") : "-")));

// hash = Tools.retrieveHash(context.applicationContext());

childview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// FlurryFacade.logEvent("taking_child_pictures_on_anak_detail_view");
entityid = ancClient.entityId();
// if (hash.containsValue(entityid)) {
// updateMode = true;
// }
Toast.makeText(DetailANCActivity.this, "Replace for Camera", Toast.LENGTH_SHORT).show();
// Intent takePictureIntent = new Intent(DetailChildActivity.this, SmartShutterActivity.class);
// takePictureIntent.putExtra("org.sid.sidface.SmartShutterActivity.updated", updateMode);
// takePictureIntent.putExtra("IdentifyPerson", false);
// takePictureIntent.putExtra("org.sid.sidface.ImageConfirmation.id", entityid);
// takePictureIntent.putExtra("org.sid.sidface.ImageConfirmation.origin", TAG); // send Class Name
// startActivityForResult(takePictureIntent, 2);

}
});

}

@Override
public void onBackPressed() {
finish();
startActivity(new Intent(this, NativeKIAnakSmartRegisterActivity.class));
overridePendingTransition(0, 0);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
// refresh
Log.e(TAG, "onActivityResult: refresh" );
finish();
startActivity(getIntent());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onClick(View v) {
if (childclient.getCaseId() != null) {
//image already in local storage most likey ):
//set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally
// DrishtiApplication.getCachedImageLoaderInstance().getImageByClientId(childclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable));
// DrishtiApplication.getCachedImageLoaderInstance().getImageByClientId(ancClient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable));

DetailChildActivity.setImagetoHolderFromUri(this,
DrishtiApplication.getAppDir() + File.separator + childclient.getDetails().get("base_entity_id") + ".JPEG",
Expand Down
Loading

0 comments on commit 0beaf2a

Please sign in to comment.