Skip to content

Commit

Permalink
WD|Fixed Initial Register on Ibu using old layout #4
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Nov 14, 2017
1 parent 645aeb0 commit daf999a
Show file tree
Hide file tree
Showing 109 changed files with 2,927 additions and 3,277 deletions.
27 changes: 15 additions & 12 deletions opensrp-bidan/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<application
android:name=".application.BidanApplication"
android:allowBackup="true"
android:icon="@drawable/opensrp_logo"
>
<activity
android:name=".activity.LoginActivity"
Expand All @@ -28,6 +29,20 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.SettingsActivity"
android:screenOrientation="landscape" />

<activity android:name=".activity.BidanHomeActivity"
android:screenOrientation="landscape"
android:theme="@style/BidanAppTheme"
/>

<activity android:name=".activity.KIbuSmartRegisterActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppThemeNoActionBarAndTitle"
android:windowSoftInputMode="adjustResize" />
<!--<activity-->
<!--android:name=".activity.ChildSmartRegisterActivity"-->
<!--android:configChanges="keyboardHidden|orientation|screenSize"-->
Expand Down Expand Up @@ -59,9 +74,6 @@
<!--</receiver>-->

<!--<activity android:name=".activity.ProviderProfileActivity" />-->
<activity
android:name=".activity.SettingsActivity"
android:screenOrientation="landscape" />
<!--<activity-->
<!--android:name=".activity.ChildImmunizationActivity"-->
<!--android:screenOrientation="portrait"-->
Expand Down Expand Up @@ -116,16 +128,7 @@
<!--android:theme="@style/AppThemeNoTitle.NoActionBar">-->

<!--</activity>-->
<activity android:name=".activity.BidanHomeActivity"
android:screenOrientation="landscape"
android:theme="@style/BidanAppTheme"
/>

<!--<activity android:name=".activity.KIbuSmartRegisterActivity"-->
<!--android:configChanges="keyboardHidden|orientation|screenSize"-->
<!--android:screenOrientation="landscape"-->
<!--android:theme="@style/AppThemeNoActionBarAndTitle"-->
<!--android:windowSoftInputMode="adjustResize" />-->

</application>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
package org.smartregister.bidan.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.text.TextUtils;
import android.view.MenuItem;

import android.view.View;
import android.widget.TextView;

import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Hours;
import org.joda.time.Minutes;
import org.joda.time.Seconds;
import org.smartregister.Context;
import org.smartregister.bidan.R;
import org.smartregister.bidan.application.BidanApplication;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.service.intent.SyncIntentService;
import org.smartregister.bidan.sync.ECSyncUpdater;
import org.smartregister.domain.FetchStatus;
import org.smartregister.provider.SmartRegisterClientsProvider;
import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity;

import java.util.Calendar;

/**
* Created by sid-tech on 11/14/17.
*/
Expand All @@ -19,6 +40,42 @@ public class BaseRegisterActivity extends SecuredNativeSmartRegisterActivity
public static final String IS_REMOTE_LOGIN = "is_remote_login";
private Snackbar syncStatusSnackbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_bidan);

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

BaseActivityToggle toggle = new BaseActivityToggle(this, drawer,
R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}

public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);

}
};

drawer.setDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

Bundle extras = this.getIntent().getExtras();
if (extras != null) {
boolean isRemote = extras.getBoolean(IS_REMOTE_LOGIN);
if (isRemote) {
updateFromServer();
}
}
}


@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
return false;
Expand Down Expand Up @@ -58,4 +115,82 @@ protected void onInitialization() {
public void startRegistration() {

}

private void updateFromServer() {
startService(new Intent(getApplicationContext(), SyncIntentService.class));
}



private void updateLastSyncText() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null && navigationView.getMenu() != null) {
TextView syncMenuItem = ((TextView) navigationView.findViewById(R.id.nav_synctextview));
if (syncMenuItem != null) {
String lastSync = getLastSyncTime();

if (!TextUtils.isEmpty(lastSync)) {
lastSync = " " + String.format(getString(R.string.last_sync), lastSync);
}
syncMenuItem.setText(String.format(getString(R.string.sync_), lastSync));
}
}
}

private String getLastSyncTime() {
String lastSync = "";
long milliseconds = ECSyncUpdater.getInstance(this).getLastCheckTimeStamp();
if (milliseconds > 0) {
DateTime lastSyncTime = new DateTime(milliseconds);
DateTime now = new DateTime(Calendar.getInstance());
Minutes minutes = Minutes.minutesBetween(lastSyncTime, now);
if (minutes.getMinutes() < 1) {
Seconds seconds = Seconds.secondsBetween(lastSyncTime, now);
lastSync = seconds.getSeconds() + "s";
} else if (minutes.getMinutes() >= 1 && minutes.getMinutes() < 60) {
lastSync = minutes.getMinutes() + "m";
} else if (minutes.getMinutes() >= 60 && minutes.getMinutes() < 1440) {
Hours hours = Hours.hoursBetween(lastSyncTime, now);
lastSync = hours.getHours() + "h";
} else {
Days days = Days.daysBetween(lastSyncTime, now);
lastSync = days.getDays() + "d";
}
}
return lastSync;
}

@Override
protected Context context() {
return BidanApplication.getInstance().context();
}


////////////////////////////////////////////////////////////////
// Inner classes
////////////////////////////////////////////////////////////////
private class BaseActivityToggle extends ActionBarDrawerToggle {

private BaseActivityToggle(Activity activity, DrawerLayout drawerLayout, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) {
super(activity, drawerLayout, openDrawerContentDescRes, closeDrawerContentDescRes);
}

/*public BaseActivityToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) {
super(activity, drawerLayout, toolbar, openDrawerContentDescRes, closeDrawerContentDescRes);
}*/

@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!SyncStatusBroadcastReceiver.getInstance().isSyncing()) {
updateLastSyncText();
}
}

@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,152 @@
package org.smartregister.bidan.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import org.smartregister.bidan.R;
import org.smartregister.bidan.application.BidanApplication;
import org.smartregister.bidan.controller.NavigationControllerINA;
import org.smartregister.view.controller.ANMController;
import org.smartregister.view.controller.NavigationController;
import org.smartregister.view.viewpager.OpenSRPViewPager;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;

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

public class BidanHomeActivity extends Activity {
public class BidanHomeActivity extends AppCompatActivity {

SimpleDateFormat timer = new SimpleDateFormat("hh:mm:ss");

@Bind(R.id.view_pager)
protected OpenSRPViewPager mPager;
private MenuItem updateMenuItem;
private MenuItem remainingFormsToSyncMenuItem;
private TextView ecRegisterClientCountView;
private TextView kartuIbuANCRegisterClientCountView;
private TextView kartuIbuPNCRegisterClientCountView;
private TextView anakRegisterClientCountView;
private TextView kohortKbCountView;
protected NavigationController navigationController;
protected ANMController anmController;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

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

}

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

// setContentView(R.layout.smart_registers_home_bidan);

// navigationController = new NavigationControllerINA(this, anmController, context());
// setupViews();
// initialize();
// DisplayFormFragment.formInputErrorMessage = getResources().getString(R.string.forminputerror);
// DisplayFormFragment.okMessage = getResources().getString(R.string.okforminputerror);
// context.formSubmissionRouter().getHandlerMap().put("census_enrollment_form", new ANChandler());
// int SDK_INT = android.os.Build.VERSION.SDK_INT;
// if (SDK_INT > 8)
// {
// StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
// .permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
}

protected void onResumption() {

}

private void setupViews() {

getSupportActionBar().setTitle("");
getSupportActionBar().setIcon(getResources().getDrawable(R.mipmap.logo));
getSupportActionBar().setLogo(R.mipmap.logo);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

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
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_kartu_ibu_register:
navigationController.startECSmartRegistry();
break;

case R.id.btn_kohort_kb_register:
navigationController.startFPSmartRegistry();
break;

case R.id.btn_kartu_ibu_anc_register:
navigationController.startANCSmartRegistry();
break;

case R.id.btn_anak_register:
navigationController.startChildSmartRegistry();
break;

case R.id.btn_kartu_ibu_pnc_register:
navigationController.startPNCSmartRegistry();
break;
}
String HomeEnd = timer.format(new Date());
Map<String, String> Home = new HashMap<String, String>();
Home.put("end", HomeEnd);
// FlurryAgent.logEvent("home_dashboard",Home, true);
}
};

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

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_reporting:
navigationController.startReports();
break;

// case R.id.btn_videos:
// navigationController.startVideos();
// break;
}
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.smartregister.bidan.activity;

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

public class KChildSmartRegisterActivity {
}
Loading

0 comments on commit daf999a

Please sign in to comment.