Skip to content

Commit

Permalink
WD| Init Kohort Ibu #4 .
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Nov 7, 2017
1 parent 23014a5 commit ee54679
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 42 deletions.
1 change: 1 addition & 0 deletions opensrp-bidan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ dependencies {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
}

compile('org.smartregister:opensrp-client-immunization:1.1.4-SNAPSHOT@aar') {
transitive = true
}
Expand Down
2 changes: 1 addition & 1 deletion opensrp-bidan/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
</activity>
<activity android:name=".activity.BidanHomeActivity"
android:screenOrientation="landscape"
android:theme="@style/AppTheme"
android:theme="@style/BidanAppTheme"
/>
<activity android:name=".activity.NativeKISmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import org.json.JSONObject;
import org.smartregister.bidan.R;
import org.smartregister.bidan.application.BidanApplication;
import org.smartregister.bidan.controller.NavigationControllerINA;
import org.smartregister.view.activity.SecuredActivity;
import org.smartregister.view.controller.ANMController;
import org.smartregister.view.controller.NavigationController;
import org.smartregister.view.viewpager.OpenSRPViewPager;
Expand All @@ -21,11 +26,16 @@

import butterknife.Bind;

import static android.widget.Toast.LENGTH_SHORT;
import static org.smartregister.event.Event.FORM_SUBMITTED;
import static org.smartregister.event.Event.SYNC_COMPLETED;
import static org.smartregister.event.Event.SYNC_STARTED;

/**
* Created by sid-tech on 11/7/17.
*/

public class BidanHomeActivity extends AppCompatActivity {
public class BidanHomeActivity extends SecuredActivity {

@Bind(R.id.view_pager)
protected OpenSRPViewPager mPager;
Expand All @@ -48,37 +58,8 @@ public class BidanHomeActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.bidan_landing);
navigationController = new NavigationControllerINA(this, anmController, BidanApplication.getInstance().context());

String HomeStart = timer.format(new Date());
Map<String, String> Home = new HashMap<String, String>();
Home.put("start", HomeStart);
// FlurryAgent.logEvent("home_dashboard", Home, true);

setupViews();

}

private void setupViews() {
findViewById(R.id.btn_kartu_ibu_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kartu_ibu_anc_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kartu_ibu_pnc_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_anak_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kohort_kb_register).setOnClickListener(onRegisterStartListener);


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

ecRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_register_client_count);
kartuIbuANCRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_anc_register_client_count);
kartuIbuPNCRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_pnc_register_client_count);
anakRegisterClientCountView = (TextView) findViewById(R.id.txt_anak_client_count);
kohortKbCountView = (TextView) findViewById(R.id.txt_kohort_kb_register_count);
}


// BaseActivity
// @Override
// protected int getContentView() {
Expand Down Expand Up @@ -116,6 +97,105 @@ protected void onDestroy() {
super.onDestroy();
}

@Override
protected void onCreation() {
setContentView(R.layout.bidan_landing);
navigationController = new NavigationControllerINA(this, anmController, BidanApplication.getInstance().context());

String HomeStart = timer.format(new Date());
Map<String, String> Home = new HashMap<>();
Home.put("start", HomeStart);
// FlurryAgent.logEvent("home_dashboard", Home, true);

setupViews();
initGui();
}

@Override
protected void onResumption() {
// LoginActivity.setLanguage();
// updateRegisterCounts();
// updateSyncIndicator();
// updateRemainingFormsToSyncCount();
// initFR();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
attachLogoutMenuItem(menu);
return true;
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
updateMenuItem = menu.findItem(R.id.updateMenuItem);
remainingFormsToSyncMenuItem = menu.findItem(R.id.remainingFormsToSyncMenuItem);

// updateSyncIndicator();
// updateRemainingFormsToSyncCount();
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.updateMenuItem:
// updateFromServer();
return true;
case R.id.switchLanguageMenuItem:
String newLanguagePreference = LoginActivity.switchLanguagePreference();
LoginActivity.setLanguage();
Toast.makeText(this, "Language preference set to " + newLanguagePreference + ". Please restart the application.", LENGTH_SHORT).show();
this.recreate();
return true;
case R.id.help:
String anmID;
try {
anmID = new JSONObject(context().anmController().get()).get("anmName").toString();
}catch (org.json.JSONException e){
anmID = "undefined";
}
Toast.makeText(this, String.format("%s current user = %s",context().getStringResource(R.string.app_name),anmID), LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}


private void initGui() {
// pendingFormSubmissionService = context().pendingFormSubmissionService();
// SYNC_STARTED.addListener(onSyncStartListener);
// SYNC_COMPLETED.addListener(onSyncCompleteListener);
// FORM_SUBMITTED.addListener(onFormSubmittedListener);
// ACTION_HANDLED.addListener(updateANMDetailsListener);
getSupportActionBar().setTitle("");
getSupportActionBar().setIcon(getResources().getDrawable(R.mipmap.logo));
getSupportActionBar().setLogo(R.mipmap.logo);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
// LoginActivity.setLanguage();
}

private void setupViews() {
findViewById(R.id.btn_kartu_ibu_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kartu_ibu_anc_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kartu_ibu_pnc_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_anak_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_kohort_kb_register).setOnClickListener(onRegisterStartListener);
findViewById(R.id.btn_reporting).setOnClickListener(onButtonsClickListener);
// findViewById(R.id.btn_videos).setOnClickListener(onButtonsClickListener);

ecRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_register_client_count);
kartuIbuANCRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_anc_register_client_count);
kartuIbuPNCRegisterClientCountView = (TextView) findViewById(R.id.txt_kartu_ibu_pnc_register_client_count);
anakRegisterClientCountView = (TextView) findViewById(R.id.txt_anak_client_count);
kohortKbCountView = (TextView) findViewById(R.id.txt_kohort_kb_register_count);
}

private View.OnClickListener onRegisterStartListener = new View.OnClickListener() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class LoginActivity extends AppCompatActivity {
private EditText passwordEditText;
private ProgressDialog progressDialog;
public static final String ENGLISH_LOCALE = "en";
private static final String BAHASA_LOCALE = "in";
private static final String URDU_LOCALE = "ur";
private static final String ENGLISH_LANGUAGE = "English";
private static final String URDU_LANGUAGE = "Urdu";
Expand Down Expand Up @@ -454,15 +455,15 @@ public static String switchLanguagePreference() {
AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(getOpenSRPContext().applicationContext()));

String preferredLocale = allSharedPreferences.fetchLanguagePreference();
if (URDU_LOCALE.equals(preferredLocale)) {
allSharedPreferences.saveLanguagePreference(URDU_LOCALE);
if (BAHASA_LOCALE.equals(preferredLocale)) {
allSharedPreferences.saveLanguagePreference(BAHASA_LOCALE);
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(URDU_LOCALE);
conf.locale = new Locale(BAHASA_LOCALE);
res.updateConfiguration(conf, dm);
return URDU_LANGUAGE;
return BAHASA_LOCALE;
} else {
allSharedPreferences.saveLanguagePreference(ENGLISH_LOCALE);
Resources res = getOpenSRPContext().applicationContext().getResources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public void startRegistration() {

}



private final Listener<FetchStatus> onDataFetchedListener = new Listener<FetchStatus>() {
@Override
public void onEvent(FetchStatus fetchStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
//import org.smartregister.bidan.provider.ChildSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
//import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.commonregistry.CommonRepository;
Expand Down Expand Up @@ -78,11 +79,10 @@ public FilterOption searchFilterOption() {

@Override
public ServiceModeOption serviceMode() {
// return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
// R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
// R.string.child_next_vaccine
// }, new int[]{5, 2, 2, 3, 3});
return null;
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions opensrp-bidan/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<style name="PathAppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />

<style name="BidanAppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
Expand Down

0 comments on commit ee54679

Please sign in to comment.