Skip to content

Commit

Permalink
MI | Updating register activity to EC #433
Browse files Browse the repository at this point in the history
Signed-off-by: mib.iqbal <[email protected]>
  • Loading branch information
mib-iqbal committed Mar 29, 2017
1 parent 8ff2fa8 commit df890a6
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 202 deletions.
2 changes: 1 addition & 1 deletion opensrp-app/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:summary="Defines the base server url that handles requests"
android:dialogTitle="OpenSRP base URL"
android:dialogMessage="Enter Base Server Url"
android:defaultValue="http://192.168.12.1:8080/opensrp"
android:defaultValue="http://192.168.12.1:8080/opensrp-demo"
android:persistent="true"/>

</PreferenceCategory>
Expand Down
2 changes: 1 addition & 1 deletion opensrp-app/src/main/java/org/ei/opensrp/AllConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static class CloudantSync {
public static final String BATCHES_REPLICATED = "BATCHES_REPLICATED";
public static final String COUCHDB_PORT = "5984";

public static final String COUCH_DATABASE_NAME = "opensrp2";
public static final String COUCH_DATABASE_NAME = "opensrp-demo";
public static final String COUCH_DATABASE_USER = "admin";
public static final String COUCH_DATABASE_PASS = "Satu2345";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void reloadReplicationSettings(PullFilter pullFilter) throws URISyntaxExc
CloudantDataHandler mCloudantDataHandler = CloudantDataHandler.getInstance(mContext);
Datastore mDatastore = mCloudantDataHandler.getDatastore();

ReplicatorBuilder.Pull mPullBuilder = ReplicatorBuilder.pull().to(mDatastore).from(pullUri);
ReplicatorBuilder.Pull mPullBuilder = ReplicatorBuilder.pull().to(mDatastore).from(uri);
ReplicatorBuilder.Push mPushBuilder = ReplicatorBuilder.push().from(mDatastore).to(uri);

String username = AllConstants.CloudantSync.COUCH_DATABASE_USER;
Expand Down
2 changes: 1 addition & 1 deletion opensrp-sdidtk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
buildToolsVersion androidBuildToolsVersion

defaultConfig {
applicationId "org.ei.opensrp.sdidtk"
applicationId "org.ei.opensrp.ec_sdidtk"
minSdkVersion 16
targetSdkVersion 21
versionCode 21
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ei.opensrp.ddtk;

import android.database.Cursor;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand All @@ -9,6 +10,7 @@

import org.ei.opensrp.Context;
import org.ei.opensrp.commonregistry.CommonPersonObjectController;
import org.ei.opensrp.cursoradapter.SmartRegisterQueryBuilder;
import org.ei.opensrp.event.Listener;

import org.ei.opensrp.service.PendingFormSubmissionService;
Expand All @@ -20,6 +22,12 @@
import org.ei.opensrp.view.controller.NativeAfterANMDetailsFetchListener;
import org.ei.opensrp.view.controller.NativeUpdateANMDetailsTask;
import org.ei.opensrp.view.fragment.DisplayFormFragment;
import org.opensrp.api.domain.Location;
import org.opensrp.api.util.EntityUtils;
import org.opensrp.api.util.LocationTree;
import org.opensrp.api.util.TreeNode;

import java.util.Map;

import static android.widget.Toast.LENGTH_SHORT;
import static java.lang.String.valueOf;
Expand Down Expand Up @@ -69,13 +77,13 @@ public void onEvent(String data) {
};

private TextView ecRegisterClientCountView;

private int childcount;

@Override
protected void onCreation() {
//home dashboard
setContentView(R.layout.smart_registers_ddtk_home);
navigationController = new TestNavigationController(this,anmController);
navigationController = new org.ei.opensrp.ddtk.SdidtkNavigationController(this,anmController,context());
setupViews();
initialize();
DisplayFormFragment.formInputErrorMessage = getResources().getString(R.string.forminputerror);
Expand All @@ -86,7 +94,7 @@ protected void onCreation() {

private void setupViews() {
findViewById(R.id.btn_test_register).setOnClickListener(onRegisterStartListener);
// findViewById(R.id.btn_test2_register).setOnClickListener(onRegisterStartListener);
// findViewById(R.id.btn_test2_register).setOnClickListener(onRegisterStartListener);

findViewById(R.id.btn_reporting).setOnClickListener(onButtonsClickListener);

Expand Down Expand Up @@ -129,13 +137,14 @@ public void afterFetch(HomeContext anmDetails) {
}

private void updateRegisterCounts(HomeContext homeContext) {
CommonPersonObjectController hhcontroller = new CommonPersonObjectController(context().allCommonsRepositoryobjects("anak"),
context().allBeneficiaries(), context().listCache(),
context().personObjectClientsCache(),"nama_anak","Jenis_kelamin","nama_ibu", CommonPersonObjectController.ByColumnAndByDetails.byDetails);


SmartRegisterQueryBuilder sqb = new SmartRegisterQueryBuilder();
Cursor childcountcursor = context().commonrepository("anak").RawCustomQueryForAdapter(sqb.queryForCountOnRegisters("ec_anak_search", "ec_anak_search.is_closed=0"));
childcountcursor.moveToFirst();
childcount= childcountcursor.getInt(0);
childcountcursor.close();

ecRegisterClientCountView.setText(valueOf(hhcontroller.getClients().size()));
ecRegisterClientCountView.setText(valueOf(childcount));
// ecRegisterClientCountView.setText(valueOf(hhcontroller.getClients().size()));

}

Expand Down Expand Up @@ -170,7 +179,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
this.recreate();
return true;
case R.id.help:
// startActivity(new Intent(this, tutorialCircleViewFlow.class));
// startActivity(new Intent(this, tutorialCircleViewFlow.class));
return true;
default:
return super.onOptionsItemSelected(item);
Expand All @@ -182,6 +191,11 @@ public void updateFromServer() {
this, context().actionService(), context().formSubmissionSyncService(),
new SyncProgressIndicator(), context().allFormVersionSyncService());
updateActionsTask.updateFromServer(new SyncAfterFetchListener());
String locationjson = context().anmLocationController().get();
LocationTree locationTree = EntityUtils.fromJson(locationjson, LocationTree.class);

Map<String,TreeNode<String, Location>> locationMap =
locationTree.getLocationsHierarchy();
}

@Override
Expand Down Expand Up @@ -226,18 +240,16 @@ public void onClick(View view) {
navigationController.startECSmartRegistry();
break;

// case R.id.btn_test2_register:
// navigationController.startANCSmartRegistry();
// break;
// case R.id.btn_test2_register:
// navigationController.startANCSmartRegistry();
// break;
/*
case R.id.btn_pnc_register:
// navigationController.startPNCSmartRegistry();
break;
case R.id.btn_child_register:
// navigationController.startChildSmartRegistry();
break;
case R.id.btn_fp_register:
// navigationController.startFPSmartRegistry();
break; */
Expand All @@ -258,4 +270,4 @@ public void onClick(View view) {
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,35 @@

import static android.preference.PreferenceManager.getDefaultSharedPreferences;

public class TestNavigationController extends org.ei.opensrp.view.controller.NavigationController {
public class SdidtkNavigationController extends org.ei.opensrp.view.controller.NavigationController {
private Activity activity;
private ANMController anmController;
private org.ei.opensrp.Context context;

public TestNavigationController(Activity activity, ANMController anmController) {
public SdidtkNavigationController(Activity activity, ANMController anmController) {
super(activity,anmController);
this.activity = activity;
this.anmController = anmController;
}
public SdidtkNavigationController(Activity activity, ANMController anmController, org.ei.opensrp.Context context) {
this(activity,anmController);
this.context=context;
}
@Override
public void startECSmartRegistry() {
activity.startActivity(new Intent(activity, FormulirDdtkSmartRegisterActivity.class));
/// activity.startActivity(new Intent(activity, HouseHoldSmartRegisterActivity.class));
/// activity.startActivity(new Intent(activity, HouseHoldSmartRegisterActivity.class));
SharedPreferences sharedPreferences = getDefaultSharedPreferences(this.activity);

if(sharedPreferences.getBoolean("firstlauch",true)) {
sharedPreferences.edit().putBoolean("firstlauch",false).commit();
// activity.startActivity(new Intent(activity, tutorialCircleViewFlow.class));
// activity.startActivity(new Intent(activity, tutorialCircleViewFlow.class));
}

}
@Override
public void startFPSmartRegistry() {
// activity.startActivity(new Intent(activity, ElcoSmartRegisterActivity.class));
// activity.startActivity(new Intent(activity, ElcoSmartRegisterActivity.class));
}
@Override
public void startANCSmartRegistry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public int weightSum() {

@Override
public int[] weights() {
return new int[]{10,7,7,8,8,8};
return new int[]{11,7,7,8,8,6};
}

@Override
Expand Down
Loading

0 comments on commit df890a6

Please sign in to comment.