Skip to content

Commit

Permalink
MI | migrate SDIDTK to EC #opensrp#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 24, 2017
1 parent b311cd4 commit 8464b62
Show file tree
Hide file tree
Showing 21 changed files with 1,168 additions and 170 deletions.
89 changes: 50 additions & 39 deletions opensrp-app/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<style name="CustomFontTextViewStyle.ListView.Small" parent="CustomFontTextViewStyle">
<item name="fontVariant">medium</item>
<item name="android:textSize">15sp</item>
<item name="android:textSize">13sp</item>
<item name="android:height">18dp</item>
</style>

Expand All @@ -46,7 +46,7 @@
<style name="CustomFontTextViewStyle.ListView.Small.NoHeight" parent="@android:style/Widget.TextView">
<item name="fontVariant">medium</item>
<item name="android:textColor">@android:color/black</item>
<!--<item name="android:paddingLeft">10dp</item>-->
<item name="android:paddingLeft">10dp</item>
<item name="android:ellipsize">none</item>
</style>

Expand All @@ -65,9 +65,18 @@
<item name="android:ellipsize">none</item>
</style>

<style name="CustomFontTextViewStyle.ListView.Normal.Obsetri">
<item name="fontVariant">medium</item>
<item name="android:textSize">13sp</item>
<item name="android:gravity">left</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">3dp</item>
<item name="android:ellipsize">none</item>
</style>

<style name="CustomFontTextViewStyle.ListView.Medium" parent="CustomFontTextViewStyle">
<item name="fontVariant">bold</item>
<item name="android:textSize">17sp</item>
<item name="android:textSize">15sp</item>
</style>

<style name="CustomFontTextViewStyle.ListView.Medium.TwoLine">
Expand All @@ -77,6 +86,15 @@
<item name="android:ellipsize">none</item>
</style>


<style name="CustomFontTextViewStyle.ListView.Medium.FourLine">
<item name="android:maxLines">4</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingRight">5dp</item>
<item name="android:ellipsize">none</item>
</style>


<style name="CustomFontTextViewStyle.ListView.Normal.MultipleLines">
<item name="android:textSize">16sp</item>
<item name="fontVariant">regular</item>
Expand All @@ -91,6 +109,10 @@
<item name="android:paddingLeft">0dp</item>
</style>

<style name="CustomFontTextViewStyle.ListView.Medium.NoPadding.NoBold">
<item name="fontVariant">medium</item>
</style>

<style name="CustomFontTextViewStyle.ListView.Medium.White">
<item name="android:textColor">@android:color/white</item>
</style>
Expand Down Expand Up @@ -177,7 +199,7 @@
<item name="android:textSize">20sp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:background">@drawable/home_button_background</item>
<item name="android:background">#1d3651</item>
<item name="android:layout_margin">5dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:clickable">true</item>
Expand All @@ -196,6 +218,19 @@
<item name="android:textColor">@android:color/white</item>
</style>

<style name="CustomFontTextViewStyle.Badge2">
<item name="fontVariant">bold</item>
<item name="android:layout_gravity">top|center</item>
<item name="android:layout_marginTop">10dp</item>
<item name="android:layout_marginRight">-50dp</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:gravity">center</item>
<item name="android:background">@drawable/badge</item>
<item name="android:textColor">@android:color/white</item>
</style>

<style name="FPModalTabStyle" parent="CustomFontTextViewStyle.ListView.Medium">
<item name="android:layout_height">@dimen/fp_modal_header_text_height</item>
<item name="android:padding">5dp</item>
Expand All @@ -206,43 +241,19 @@
<item name="android:clickable">true</item>
</style>


<style name="TreeNodeStyle">
<item name="android:paddingLeft">20dp</item>
</style>

<style name="TreeNodeStyleDivided">
<item name="android:showDividers">middle</item>
<item name="android:divider">@android:drawable/divider_horizontal_bright</item>
</style>

<style name="progress_dialog_theme">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowBackground">@color/transparent</item>
</style>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

<style name="AppThemeNoTitle" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">@null</item>
<style name="HorizontalDivider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">#BDBDBD</item>
</style>

<style name="AppThemeNoActionBarAndTitle" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">@null</item>
<style name="CardViewContainerPadding">
<item name="android:clipToPadding">false</item>
<item name="android:scrollbarStyle">outsideOverlay</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
</style>

</resources>
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 = "opensrp3";
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/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<application android:allowBackup="true"
android:label="@string/app_name"
android:name=".application.ECPApplication"
android:name=".application.SdidtkApplication"
>

<activity
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 @@ -95,7 +103,7 @@ private void setupViews() {
}

private void initialize() {
pendingFormSubmissionService = context.pendingFormSubmissionService();
pendingFormSubmissionService = context().pendingFormSubmissionService();
SYNC_STARTED.addListener(onSyncStartListener);
SYNC_COMPLETED.addListener(onSyncCompleteListener);
FORM_SUBMITTED.addListener(onFormSubmittedListener);
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 @@ -179,9 +188,14 @@ public boolean onOptionsItemSelected(MenuItem item) {

public void updateFromServer() {
UpdateActionsTask updateActionsTask = new UpdateActionsTask(
this, context.actionService(), context.formSubmissionSyncService(),
new SyncProgressIndicator(), context.allFormVersionSyncService());
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 All @@ -196,7 +210,7 @@ protected void onDestroy() {

private void updateSyncIndicator() {
if (updateMenuItem != null) {
if (context.allSharedPreferences().fetchIsSyncInProgress()) {
if (context().allSharedPreferences().fetchIsSyncInProgress()) {
updateMenuItem.setActionView(R.layout.progress);
} else
updateMenuItem.setActionView(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@

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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.res.Configuration;

import org.ei.opensrp.Context;
import org.ei.opensrp.commonregistry.CommonFtsObject;
import org.ei.opensrp.ddtk.LoginActivity;
import org.ei.opensrp.sync.DrishtiSyncScheduler;
import org.ei.opensrp.view.activity.DrishtiApplication;
Expand All @@ -16,18 +17,22 @@
* Created by koros on 1/22/16.
*/

public class ECPApplication extends DrishtiApplication {
public class SdidtkApplication extends DrishtiApplication {

@Override
public void onCreate() {
DrishtiSyncScheduler.setReceiverClass(SyncBroadcastReceiver.class);
super.onCreate();
// ACRA.init(this);
// ACRA.init(this);

DrishtiSyncScheduler.setReceiverClass(SyncBroadcastReceiver.class);

// ErrorReportingFacade.initErrorHandler(getApplicationContext());
/**
* ENABLE THIS AGAIN AFTER FINISH TESTING*/
// FlurryFacade.init(this);
context = Context.getInstance();
context.updateApplicationContext(getApplicationContext());
context.updateCommonFtsObject(createCommonFtsObject());
applyUserLanguagePreference();
cleanUpSyncState();
}
Expand Down Expand Up @@ -69,4 +74,49 @@ private void updateConfiguration(Configuration config) {
getBaseContext().getResources().getDisplayMetrics());
}

}
private String[] getFtsSearchFields(String tableName){
if(tableName.equals("ec_anak")){
String[] ftsSearchFields = { "namaBayi","tanggalLahirAnak" };
return ftsSearchFields;
} else if (tableName.equals("ec_kartu_ibu")){
String[] ftsSearchFields = { "namalengkap", "namaSuami" };
return ftsSearchFields;
}
return null;
}

private String[] getFtsSortFields(String tableName){
if(tableName.equals("ec_anak")){
String[] sortFields = { "namaBayi","tanggalLahirAnak"};
return sortFields;
} else if(tableName.equals("ec_kartu_ibu")){
String[] sortFields = { "namalengkap", "namaSuami"};
return sortFields;
}
return null;
}

private String[] getFtsMainConditions(String tableName){
if(tableName.equals("ec_anak")){
String[] mainConditions = {"is_closed", "details" , "namaBayi"};
return mainConditions;
} else if(tableName.equals("ec_kartu_ibu")){
String[] mainConditions = { "is_closed", "namalengkap"};
return mainConditions;
}
return null;
}
private String[] getFtsTables(){
String[] ftsTables = { "ec_anak", "ec_kartu_ibu" };
return ftsTables;
}
private CommonFtsObject createCommonFtsObject(){
CommonFtsObject commonFtsObject = new CommonFtsObject(getFtsTables());
for(String ftsTable: commonFtsObject.getTables()){
commonFtsObject.updateSearchFields(ftsTable, getFtsSearchFields(ftsTable));
commonFtsObject.updateSortFields(ftsTable, getFtsSortFields(ftsTable));
commonFtsObject.updateMainConditions(ftsTable, getFtsMainConditions(ftsTable));
}
return commonFtsObject;
}
}
Loading

0 comments on commit 8464b62

Please sign in to comment.