diff --git a/opensrp-gizi/build.gradle b/opensrp-gizi/build.gradle index af3d0f6..8c6b20d 100644 --- a/opensrp-gizi/build.gradle +++ b/opensrp-gizi/build.gradle @@ -33,7 +33,7 @@ android { multiDexEnabled true buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l" buildConfigField "boolean", "TIME_CHECK", "false" - resValue "string", 'opensrp_url', '"http://192.168.1.253:8080/opensrp"' + resValue "string", 'opensrp_url', '"http://118.91.130.18:9090/opensrp"' } dexOptions { diff --git a/opensrp-gizi/src/main/AndroidManifest.xml b/opensrp-gizi/src/main/AndroidManifest.xml index 0c05afa..a26dd47 100644 --- a/opensrp-gizi/src/main/AndroidManifest.xml +++ b/opensrp-gizi/src/main/AndroidManifest.xml @@ -5,26 +5,22 @@ - - - - - + + android:windowSoftInputMode="stateAlwaysHidden|adjustResize" + > diff --git a/opensrp-gizi/src/main/assets/ec_client_classification.json b/opensrp-gizi/src/main/assets/ec_client_classification.json index 6bf3ff5..e651e91 100644 --- a/opensrp-gizi/src/main/assets/ec_client_classification.json +++ b/opensrp-gizi/src/main/assets/ec_client_classification.json @@ -86,12 +86,6 @@ "rule": { "type": "event", "fields": [ - { - "field":"obs.fieldCode", - "concept": "159917AAAAAAAAAAAAAAAAAAAAAAAAAA", - "values": ["151849AAAAAAAAAAAAAAAAAAAAAAAAAA"], - "creates_case":["ec_anak"] - }, { "field":"eventType", "field_value": "Child Registration", diff --git a/opensrp-gizi/src/main/assets/www/form/registrasi_anak/form_definition.json b/opensrp-gizi/src/main/assets/www/form/registrasi_anak/form_definition.json index cd4c07d..dcf5816 100644 --- a/opensrp-gizi/src/main/assets/www/form/registrasi_anak/form_definition.json +++ b/opensrp-gizi/src/main/assets/www/form/registrasi_anak/form_definition.json @@ -10,6 +10,11 @@ "name": "id", "shouldLoadValue": true }, + { + "name": "ibu_entity_id", + "source": "kartu_ibu.id", + "shouldLoadValue": true + }, { "name": "existing_Village", "bind": "/model/instance/registrasi_anak/Village", diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/GiziSmartRegisterActivity.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/GiziSmartRegisterActivity.java index a7764e9..675c5fc 100755 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/GiziSmartRegisterActivity.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/GiziSmartRegisterActivity.java @@ -23,7 +23,7 @@ import org.smartregister.provider.SmartRegisterClientsProvider; import org.smartregister.service.ZiggyService; import org.smartregister.gizi.R; -import org.smartregister.sync.ClientProcessor; +import org.smartregister.gizi.sync.ClientProcessor; import org.smartregister.util.FormUtils; import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity; import org.smartregister.view.dialog.DialogOption; diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/LoginActivity.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/LoginActivity.java index 5b37c0b..1273f96 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/LoginActivity.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/activity/LoginActivity.java @@ -10,6 +10,7 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.util.DisplayMetrics; import android.view.KeyEvent; @@ -23,21 +24,25 @@ import android.widget.ImageView; import android.widget.TextView; -import com.flurry.android.FlurryAgent; - +import org.json.JSONException; +import org.json.JSONObject; +import org.smartregister.Context; +import org.smartregister.gizi.activity.GiziHomeActivity; +import org.smartregister.gizi.application.GiziApplication; import org.smartregister.gizi.R; import org.smartregister.gizi.application.GiziApplication; -import org.smartregister.Context; import org.smartregister.domain.LoginResponse; import org.smartregister.domain.Response; import org.smartregister.domain.ResponseStatus; import org.smartregister.event.Listener; +//import org.smartregister.vaksinator.lib.ErrorReportingFacade; import org.smartregister.repository.AllSharedPreferences; import org.smartregister.sync.DrishtiSyncScheduler; import org.smartregister.util.Log; import org.smartregister.view.BackgroundAction; import org.smartregister.view.LockingBackgroundTask; import org.smartregister.view.ProgressIndicator; +import org.smartregister.gizi.activity.SettingsActivity; import java.io.IOException; import java.text.SimpleDateFormat; @@ -45,6 +50,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +//import io.fabric.sdk.android.Fabric; import static android.preference.PreferenceManager.getDefaultSharedPreferences; import static android.view.inputmethod.InputMethodManager.HIDE_NOT_ALWAYS; @@ -55,7 +61,8 @@ import static org.smartregister.util.Log.logError; import static org.smartregister.util.Log.logVerbose; -public class LoginActivity extends Activity { +public class LoginActivity extends AppCompatActivity { + private static final String TAG = LoginActivity.class.getSimpleName(); private Context context; private EditText userNameEditText; private EditText passwordEditText; @@ -69,52 +76,71 @@ public class LoginActivity extends Activity { public static final String Bengali_LANGUAGE = "Bengali"; public static final String Bahasa_LANGUAGE = "Bahasa"; - + // public static Generator generator; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); logVerbose("Initializing ..."); - try { + + try{ AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(this)); String preferredLocale = allSharedPreferences.fetchLanguagePreference(); - Resources res = Context.getInstance().applicationContext().getResources(); + Resources res = getOpenSRPContext().applicationContext().getResources(); // Change locale settings in the app. DisplayMetrics dm = res.getDisplayMetrics(); android.content.res.Configuration conf = res.getConfiguration(); conf.locale = new Locale(preferredLocale); res.updateConfiguration(conf, dm); - } catch (Exception e) { + }catch(Exception e){ } - setContentView(org.smartregister.R.layout.login); - ImageView loginglogo = (ImageView) findViewById(R.id.login_logo); - loginglogo.setImageDrawable(getResources().getDrawable(R.mipmap.gizilogin)); - context = Context.getInstance().updateApplicationContext(this.getApplicationContext()); + setContentView(R.layout.login); + + positionViews(); + initializeLoginFields(); initializeBuildDetails(); setDoneActionHandlerOnPasswordField(); initializeProgressDialog(); - getActionBar().setTitle(""); - getActionBar().setIcon(getResources().getDrawable(org.smartregister.gizi.R.mipmap.logo)); - getActionBar().setBackgroundDrawable(getResources().getDrawable(org.smartregister.gizi.R.color.action_bar_background)); setLanguage(); - -// debugApp(); + // debugApp(); } - private void debugApp(){ + /* private void debugApp() { + Config config = new Config(); + String uname = "demo1", pwd = "Satu2345"; + try { + uname = config.getCredential("uname", getApplicationContext()); + pwd = config.getCredential("pwd", getApplicationContext()); + } catch (IOException e) { + e.printStackTrace(); + } + LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.login, null); if (context.userService().hasARegisteredUser()){ -// localLogin(view, "demo_test", "Demo@123"); - localLogin(view, "user28", "1Sampai8"); + localLoginWith(uname, pwd); + //localLogin(view, uname, pwd); } else { -// remoteLogin(view, "demo_test", "Demo@123"); - remoteLogin(view, "user28", "1Sampai8"); + remoteLogin(view, uname, pwd); } + }*/ + + private void positionViews() { + ImageView loginglogo = (ImageView)findViewById(R.id.login_logo); + loginglogo.setImageDrawable(getResources().getDrawable(R.mipmap.login_logo)); + context = Context.getInstance().updateApplicationContext(this.getApplicationContext()); +// getActionBar().setTitle(""); +// getActionBar().setIcon(getResources().getDrawable(R.mipmap.logo)); +// getActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.action_bar_background)); + + } + + public static Context getOpenSRPContext() { + return GiziApplication.getInstance().context(); } @Override @@ -127,7 +153,7 @@ public boolean onCreateOptionsMenu(Menu menu) @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getTitle().toString().equalsIgnoreCase("Settings")){ - startActivity(new Intent(this,SettingsActivity.class)); + startActivity(new Intent(this, SettingsActivity.class)); return true; } return super.onOptionsItemSelected(item); @@ -142,10 +168,6 @@ private void initializeBuildDetails() { } } - public static Context getOpenSRPContext() { - return GiziApplication.getInstance().getContext(); - } - @Override protected void onResume() { super.onResume(); @@ -183,7 +205,7 @@ private void setDoneActionHandlerOnPasswordField() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { - login(findViewById(org.smartregister.R.id.login_loginButton)); + login(findViewById(R.id.login_loginButton)); } return false; } @@ -200,8 +222,10 @@ private void initializeProgressDialog() { private void localLogin(View view, String userName, String password) { if (getOpenSRPContext().userService().isUserInValidGroup(userName, password)) { localLoginWith(userName, password); - // ErrorReportingFacade.setUsername("", userName); - FlurryAgent.setUserId(userName); + + // Tracking Error +// ErrorReportingFacade.setUsername("", userName); +// FlurryAgent.setUserId(userName); } else { showErrorDialog(getString(org.smartregister.R.string.login_failed_dialog_message)); view.setClickable(true); @@ -211,8 +235,8 @@ private void localLogin(View view, String userName, String password) { private void remoteLogin(final View view, final String userName, final String password) { tryRemoteLogin(userName, password, new Listener() { public void onEvent(LoginResponse loginResponse) { - // ErrorReportingFacade.setUsername("", userName); - FlurryAgent.setUserId(userName); +// ErrorReportingFacade.setUsername("", userName); +// FlurryAgent.setUserId(userName); if (loginResponse == SUCCESS) { remoteLoginWith(userName, password, loginResponse.payload()); } else { @@ -328,16 +352,18 @@ private void hideKeyboard() { private void localLoginWith(String userName, String password) { context.userService().localLogin(userName, password); - // LoginActivity.generator = new Generator(context,userName,password); + // LoginActivity.generator = new Generator(context, userName, password); goToHome(); - DrishtiSyncScheduler.startOnlyIfConnectedToNetwork(getApplicationContext()); + //DrishtiSyncScheduler.startOnlyIfConnectedToNetwork(getApplicationContext()); } private void remoteLoginWith(String userName, String password, String userInfo) { context.userService().remoteLogin(userName, password, userInfo); - // LoginActivity.generator = new Generator(context,userName,password); + String locationId = getUserDefaultLocationId(userInfo); + saveDefaultLocationId(userName,locationId); + // LoginActivity.generator = new Generator(context, userName, password); goToHome(); - DrishtiSyncScheduler.startOnlyIfConnectedToNetwork(getApplicationContext()); + //DrishtiSyncScheduler.startOnlyIfConnectedToNetwork(getApplicationContext()); } private void goToHome() { @@ -393,6 +419,23 @@ public static String switchLanguagePreference() { } } + public String getUserDefaultLocationId(String userInfo) { + try { + JSONObject userLocationJSON = new JSONObject(userInfo); + return userLocationJSON.getJSONObject("team").getJSONArray("location").getJSONObject(0).getString("name"); + } catch (JSONException e) { + android.util.Log.v("Error : ", e.getMessage()); + } + + return null; + } + + public void saveDefaultLocationId(String userName, String locationId) { + if (userName != null) { + context.userService().getAllSharedPreferences().savePreference(userName + "-locationid", locationId); + } + } + /* private void tryGetUniqueId(final String username, final String password, final Listener afterGetUniqueId) { LockingBackgroundTask task = new LockingBackgroundTask(new ProgressIndicator() { @Override @@ -413,7 +456,7 @@ public ResponseStatus actionToDoInBackgroundThread() { return (LoginActivity.generator.uniqueIdService().getLastUsedId(username, password)); } - @Override + @Override public void postExecuteInUIThread(ResponseStatus result) { afterGetUniqueId.onEvent(result); } diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/application/SyncGiziBroadcastReceiver.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/application/SyncGiziBroadcastReceiver.java index 5f48523..ddb08a6 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/application/SyncGiziBroadcastReceiver.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/application/SyncGiziBroadcastReceiver.java @@ -24,7 +24,7 @@ public void onReceive(Context context, Intent intent) { new SyncProgressIndicator(), org.smartregister.Context.getInstance().allFormVersionSyncService()); - // updateActionsTask.setAdditionalSyncService(org.ei.opensrp.Context.getInstance().uniqueIdService()); + // updateActionsTask.setAdditionalSyncService(org.ei.opensrp.Context.getInstance().uniqueIdService()); updateActionsTask.updateFromServer(new SyncAfterFetchListener()); } diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/fragment/GiziSmartRegisterFragment.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/fragment/GiziSmartRegisterFragment.java index 18bac7e..185d16b 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/fragment/GiziSmartRegisterFragment.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/fragment/GiziSmartRegisterFragment.java @@ -34,7 +34,7 @@ import org.smartregister.provider.SmartRegisterClientsProvider; import org.smartregister.gizi.R; -import org.smartregister.sync.ClientProcessor; +import org.smartregister.gizi.sync.ClientProcessor; import org.smartregister.util.StringUtil; import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity; import org.smartregister.view.contract.ECClient; diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/provider/ChildSmartClientsProvider.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/provider/ChildSmartClientsProvider.java index c3ebdeb..b5dc484 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/provider/ChildSmartClientsProvider.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/provider/ChildSmartClientsProvider.java @@ -107,12 +107,14 @@ public void getView(Cursor cursor, SmartRegisterClient client, final View conver String namaayah = getValue(kiparent.getColumnmaps(), "namaSuami", true); String namaibu = getValue(kiparent.getColumnmaps(), "namalengkap", true); fillValue((TextView) convertView.findViewById(R.id.ParentName), namaibu+","+namaayah); - + String subVillages = getValue(kiparent.getDetails(), "address1", true); + fillValue((TextView) convertView.findViewById(R.id.txt_child_subVillage), subVillages); } String dob= pc.getColumnmaps().get("tanggalLahirAnak").substring(0, pc.getColumnmaps().get("tanggalLahirAnak").indexOf("T")); String age = ""+monthRangeToToday(dob); //get child detail value - String subVillages = getValue(kiparent.getDetails(), "address1", true); + + // String ages = getValue(pc.getColumnmaps(), "namaBayi", true); String dateOfBirth = getValue(pc.getColumnmaps(), "tanggalLahirAnak", true); String gender = getValue(pc.getDetails(), "gender", true); @@ -125,7 +127,7 @@ public void getView(Cursor cursor, SmartRegisterClient client, final View conver String wasting_status = getValue(pc.getDetails(), "wasting", true); //set child detail value - fillValue((TextView) convertView.findViewById(R.id.txt_child_subVillage), subVillages); + fillValue((TextView) convertView.findViewById(R.id.txt_child_age), age); fillValue((TextView) convertView.findViewById(R.id.txt_child_date_of_birth), "DOB :"+dob); fillValue((TextView) convertView.findViewById(R.id.txt_child_gender), gender); diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/service/FormSubmissionSyncService.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/service/FormSubmissionSyncService.java index ef7241d..f2474db 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/service/FormSubmissionSyncService.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/service/FormSubmissionSyncService.java @@ -24,7 +24,7 @@ public FetchStatus sync() { CountDownLatch mCountDownLatch = new CountDownLatch(2); mCloudantSyncHandler.setCountDownLatch(mCountDownLatch); mCloudantSyncHandler.startPullReplication(); -// mCloudantSyncHandler.startPushReplication(); + mCloudantSyncHandler.startPushReplication(); mCountDownLatch.await(); diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/ClientProcessor.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/ClientProcessor.java index 1fafd87..dd6fe61 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/ClientProcessor.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/ClientProcessor.java @@ -143,9 +143,9 @@ public Boolean processEvent(JSONObject event, JSONObject clientClassificationJso } // Check if child is deceased and skip - if (client.has("deathdate") && !client.getString("deathdate").isEmpty()) { + /*if (client.has("deathdate") && !client.getString("deathdate").isEmpty()) { return false; - } + }*/ // Get the client type classification JSONArray clientClasses = clientClassificationJson diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantDataHandler.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantDataHandler.java index 6c12118..4e1b189 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantDataHandler.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantDataHandler.java @@ -388,4 +388,4 @@ public List allClients() { public Datastore getDatastore() { return mDatastore; } -} +} \ No newline at end of file diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantSyncListener.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantSyncListener.java index 5b6f6ea..404221e 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantSyncListener.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/sync/CloudantSyncListener.java @@ -18,4 +18,4 @@ void replicationComplete() { */ void replicationError() { } -} +} \ No newline at end of file diff --git a/opensrp-gizi/src/main/java/org/smartregister/gizi/utils/AllConstantsINA.java b/opensrp-gizi/src/main/java/org/smartregister/gizi/utils/AllConstantsINA.java index fd5d9c2..42b262c 100644 --- a/opensrp-gizi/src/main/java/org/smartregister/gizi/utils/AllConstantsINA.java +++ b/opensrp-gizi/src/main/java/org/smartregister/gizi/utils/AllConstantsINA.java @@ -29,10 +29,10 @@ public static class CloudantSync { public static final String REPLICATION_ERROR = "REPLICATION_ERROR"; public static final String DOCUMENTS_REPLICATED = "DOCUMENTS_REPLICATED"; public static final String BATCHES_REPLICATED = "BATCHES_REPLICATED"; - public static final String COUCHDB_PORT = "COUCHDB_PORT"; - public static final String COUCH_DATABASE_NAME = "COUCH_DATABASE_NAME"; - public static final String COUCH_DATABASE_USER = "COUCH_DATABASE_USER"; - public static final String COUCH_DATABASE_PASS = "COUCH_DATABASE_PASS"; + public static final String COUCHDB_PORT = "5983"; + public static final String COUCH_DATABASE_NAME = "opensrp"; + public static final String COUCH_DATABASE_USER = "rootuser"; + public static final String COUCH_DATABASE_PASS = "Satu23456"; } } \ No newline at end of file diff --git a/opensrp-gizi/src/main/java/util/VaksinatorFormUtils.java b/opensrp-gizi/src/main/java/util/VaksinatorFormUtils.java index 4ba147e..66d5961 100644 --- a/opensrp-gizi/src/main/java/util/VaksinatorFormUtils.java +++ b/opensrp-gizi/src/main/java/util/VaksinatorFormUtils.java @@ -23,7 +23,7 @@ import org.smartregister.domain.form.FormSubmission; import org.smartregister.domain.form.SubForm; import org.smartregister.service.intentservices.ReplicationIntentService; -import org.smartregister.sync.CloudantDataHandler; +import org.smartregister.gizi.sync.CloudantDataHandler; import org.smartregister.util.AssetHandler; import org.smartregister.util.Log; import org.w3c.dom.Attr; diff --git a/opensrp-gizi/src/main/res/values/strings.xml b/opensrp-gizi/src/main/res/values/strings.xml index 5ab75fd..82d57f5 100644 --- a/opensrp-gizi/src/main/res/values/strings.xml +++ b/opensrp-gizi/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ Gizi +