Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
259f267
Extracting submit form error to a handler method and relocating fetch…
viniciusboson Nov 29, 2015
5d48348
Refactoring sendOdkResultToServer method to more succint and readable…
viniciusboson Nov 30, 2015
e7ad26c
Commenting getCursorAtRightPosition metahod
viniciusboson Nov 30, 2015
28e84df
Refactoring sendFormToServer call to be more succint. No side effects
viniciusboson Nov 30, 2015
a75e268
Improving variable name to be more readable
viniciusboson Nov 30, 2015
e7847ae
Refactoring updateClientCache method. It was too long and to hard to …
viniciusboson Nov 30, 2015
35dd211
OpenMrsJsonRequest was creating a response listener only to delegate …
viniciusboson Dec 1, 2015
2f46d8a
Adjusments based on Code Review
viniciusboson Dec 2, 2015
00a9c4f
Fixing the javadoc description
viniciusboson Dec 2, 2015
4de0f18
If submission is canceled, there is no need to try submiting it
viniciusboson Dec 3, 2015
67861a0
Refactoring form submssion to save it locally, whether or not it was …
viniciusboson Dec 3, 2015
3062cb9
Refactoring sendOdkResultToServer to trigger failed events rather the…
viniciusboson Dec 3, 2015
e98ca30
Refactoring event error trigger to a try-catch approach
viniciusboson Dec 3, 2015
3d3c961
Saving local form cache, submitted or not
viniciusboson Dec 4, 2015
c807abe
SQLite does not support boolean. Changing submitted type from boolean…
viniciusboson Dec 4, 2015
1de8809
Merging from feature/clean-up-OdkActivityLauncher
Dec 17, 2015
015ead8
Extracting submit form error to a handler method and relocating fetch…
viniciusboson Nov 29, 2015
76f7ff9
Refactoring sendOdkResultToServer method to more succint and readable…
viniciusboson Nov 30, 2015
ddc2970
Commenting getCursorAtRightPosition metahod
viniciusboson Nov 30, 2015
c104845
Refactoring sendFormToServer call to be more succint. No side effects
viniciusboson Nov 30, 2015
29a8e4b
Improving variable name to be more readable
viniciusboson Nov 30, 2015
97a6ed2
Refactoring updateClientCache method. It was too long and to hard to …
viniciusboson Nov 30, 2015
0ede562
OpenMrsJsonRequest was creating a response listener only to delegate …
viniciusboson Dec 1, 2015
2505277
Adjusments based on Code Review
viniciusboson Dec 2, 2015
5f2b64a
Fixing the javadoc description
viniciusboson Dec 2, 2015
8ad2b78
If submission is canceled, there is no need to try submiting it
viniciusboson Dec 3, 2015
1a8ff8d
Merging branch with upstream/dev
Dec 17, 2015
9779c96
Refactoring sendOdkResultToServer to trigger failed events rather the…
viniciusboson Dec 3, 2015
792facd
Refactoring event error trigger to a try-catch approach
viniciusboson Dec 3, 2015
6a8432d
Saving local form cache, submitted or not
viniciusboson Dec 4, 2015
e0afa56
SQLite does not support boolean. Changing submitted type from boolean…
viniciusboson Dec 4, 2015
d6582a5
Resolving merging conflit with upstream/dev
Dec 17, 2015
fa32e3b
Resolving merging conflit with upstream/dev
Dec 17, 2015
9c457ce
Resolving merging conflit with upstream/dev
Dec 17, 2015
5808855
Resolving merging conflit with upstream/dev
Dec 17, 2015
5b26307
Refactoring updateClientCache method. It was too long and to hard to …
viniciusboson Nov 30, 2015
13b0a65
Adjusments based on Code Review
viniciusboson Dec 2, 2015
1a810c2
Refactoring validations to be in different methods and to throw a che…
Dec 17, 2015
7553429
resolving conflit of merging with upstream/dev
Dec 17, 2015
d54b6ed
Refactiong resubmit form approach to save the unsent xml in local db …
Dec 20, 2015
69d88f5
Merge branch 'dev' of git://github.com/projectbuendia/client into fea…
Jan 11, 2016
b3c704c
Renaming UnsyncForm model and its field to more meaningful names.
Jan 17, 2016
b7d323a
Adding check to not allow users to submit new forms prior to resent a…
Jan 18, 2016
87e476c
Enable multidex to temporarily avert the dexocalypse.
capnfabs Jan 19, 2016
ec77630
Commenting call to resent cached forms prior to submit the new one du…
Jan 19, 2016
16dea7c
Adding snackbar message to offline form submission
Jan 19, 2016
3e89deb
This fixes #225
llvasconcellos Jan 19, 2016
e370170
Merge pull request #220 from capnfabs/fix/avert-the-dexocalypse
capnfabs Jan 20, 2016
2c459bf
Creating AsyncTasks to avoid resend forms from Main Thread
Jan 20, 2016
e936762
Make start and stop (end) times for cell accessible via javascript
dancunningham Jan 20, 2016
d815972
Fixing english grammar error
Jan 21, 2016
1951087
Merging from remote/dev
Jan 21, 2016
c234d9e
Add a notes panel to the patient chart screen.
capnfabs Jan 19, 2016
17bfafe
Documenting the code
Jan 21, 2016
ae6c623
Merge pull request #228 from projectbuendia/feature/dan-fix-5g-line
llvasconcellos Jan 21, 2016
81e5abc
Merge pull request #229 from capnfabs/feature/notes-panel
llvasconcellos Jan 21, 2016
561a0cd
Merge pull request #226 from projectbuendia/fix/llvasconcellos-fix-or…
llvasconcellos Jan 21, 2016
4f44bab
this fixes #224
llvasconcellos Jan 21, 2016
38844c0
Merge pull request #231 from projectbuendia/fix/llvasconcellos-fix-ob…
llvasconcellos Jan 21, 2016
d197f90
This fixes #203
llvasconcellos Jan 21, 2016
477823f
Merge pull request #232 from projectbuendia/fix/llvasconcellos-fix-ob…
llvasconcellos Jan 21, 2016
045cd2f
Tweak notes panel to take up less space
capnfabs Jan 22, 2016
d8b3f88
Allow empty sections in ODK forms.
capnfabs Jan 22, 2016
1f3b4ce
Implementing and integrating unsent form helth check and integrating …
Jan 22, 2016
2cb7be9
Merge branch 'dev' of git://github.com/projectbuendia/client into fea…
Jan 22, 2016
8f3b811
Fix test compilation
capnfabs Jan 22, 2016
d2854fa
Refactoring AsyncTask implementations to chain submission calls
Jan 22, 2016
7c8e46e
This fixes #89
llvasconcellos Jan 24, 2016
125d7f2
Enable like search.
llvasconcellos Jan 25, 2016
7f19caf
Raising submission offline snackbar priority to higher than server i…
Jan 25, 2016
6c396a9
Merge pull request #237 from capnfabs/fix/199
capnfabs Jan 25, 2016
cd25dbf
Merge pull request #238 from capnfabs/fix/tests
capnfabs Jan 25, 2016
4aea7c8
Move function to chart.js
llvasconcellos Jan 25, 2016
714f8f4
Merge pull request #241 from projectbuendia/fix/llvasconcellos-fix-re…
llvasconcellos Jan 25, 2016
c320243
Merge pull request #243 from projectbuendia/fix/llvasconcellos-enable…
llvasconcellos Jan 25, 2016
d80a9e2
Fixes after discussion on PR.
capnfabs Jan 25, 2016
838f43d
Merge pull request #236 from capnfabs/feature/notes_tweaks
capnfabs Jan 25, 2016
529a8e4
Prevent chart from refreshing unless patient data has changed.
capnfabs Jan 26, 2016
eac1dc6
Merge pull request #239 from capnfabs/fix/chart-refreshes-too-agressi…
capnfabs Jan 26, 2016
7025ec2
Merge branch 'dev' of git://github.com/projectbuendia/client into fea…
Jan 27, 2016
ca970b8
UI support for setting custom start dates on Orders.
capnfabs Jan 27, 2016
8a7b444
Use BigToast to display the "note submit failed" toast.
capnfabs Jan 27, 2016
1c9609a
Tweaks to View Observations dialog
dancunningham Jan 27, 2016
cf2eb97
Fix string thing
dancunningham Jan 27, 2016
29bce56
Maybe fix
dancunningham Jan 27, 2016
29efe21
Temporarily disable the red network error toast
capnfabs Jan 27, 2016
73a09e2
Merge pull request #246 from projectbuendia/feature/dan-tweaks
capnfabs Jan 27, 2016
c386657
Merge pull request #250 from capnfabs/fix/disable-red-toast
llvasconcellos Jan 27, 2016
f173053
Merge pull request #249 from capnfabs/fix/📔✏️-notes-text-size
llvasconcellos Jan 27, 2016
99dbb4c
Merge pull request #248 from capnfabs/feature/backdate-orders
llvasconcellos Jan 27, 2016
3ec2c4f
Use dark, ancient magic to ensure that seconds are set for form entries.
capnfabs Jan 28, 2016
1c9d77f
Merge pull request #257 from capnfabs/fix/125-part-2
llvasconcellos Jan 28, 2016
997b933
Merge branch 'dev' of git://github.com/projectbuendia/client into fea…
Jan 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ android {
preDexLibraries = false
javaMaxHeapSize = '4g'
}

// Enable multidex support.
defaultConfig {
multiDexEnabled true
}
}
dependencies {
// Build plugins
Expand All @@ -44,10 +49,9 @@ dependencies {
compile project(':third_party:odkcollect')

// External dependencies
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.google.code.gson:gson:2.3' // JSON parser
compile 'com.google.guava:guava:18.0' // Google common libraries
compile 'com.jakewharton:butterknife:5.1.2' // View injection
compile 'com.mcxiaoke.volley:library:1.0.6' // HTTP framework
compile 'com.joanzapata.android:android-iconify:1.0.8' // Font-based icons
Expand All @@ -59,9 +63,14 @@ dependencies {
compile 'com.mitchellbosecke:pebble:1.5.1' // HTML templating
compile 'org.slf4j:slf4j-simple:1.7.12' // HTML templating dependency
compile 'org.apache.commons:commons-lang3:3.4'
// Magic sliding panel that we use for the notes view.
compile 'com.sothree.slidinguppanel:library:3.2.1'

// Testing
androidTestCompile 'com.android.support.test:runner:0.3'
// Explicitly add this dep at 23.1.1, because the above entry depends on 22.2.0, and the
// discrepancy can introduce differences in behaviour between prod and test.
androidTestCompile 'com.android.support:support-annotations:23.1.1'
// Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2'
Expand All @@ -71,6 +80,11 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
androidTestCompile 'org.mockito:mockito-core:1.9.5'

// Multidex.
// NOTE: This is temporary only! See https://slack-files.com/T02T5LNM4-F0JQ1UDRV-716ebe431f
// for more information.
compile 'com.android.support:multidex:1.0.1'
}

apply plugin: 'spoon'
Expand Down Expand Up @@ -170,8 +184,11 @@ logger.info("Default package server root URL: ${packageServerRootUrl}")
logger.info("Database encryption password: ${encryptionPassword}")

android {
compileSdkVersion 21
buildToolsVersion '19.1.0'
compileSdkVersion 23
buildToolsVersion '23.0.2'
// TODO: Port the various health checks to use HttpURLConnection instead and remove this
// dependency.
useLibrary 'org.apache.http.legacy'

sourceSets.main {
jniLibs.srcDir 'libs'
Expand Down Expand Up @@ -231,6 +248,8 @@ android {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}

lintOptions {
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/assets/chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
{% set class = summaryValue | format_values(row.item.cssClass) %}
{% set style = summaryValue | format_values(row.item.cssStyle) %}
<td id="cell-{{id}}-{{column.start.millis}}"
data-start="{{column.start.millis}}"
data-stop="{{column.stop.millis}}"
class="{{column.start == nowColumnStart ? 'now' : ''}} {{class}}"
style="{{style}}"
onclick="{% if points is not empty%}
Expand All @@ -97,6 +99,14 @@
{% endif %}
</td>
{% endfor %}
<script>
// Hides the row if not required and no observation is recorded.
if (!{{row.item.required}}) {
if (isRowEmpty(document.currentScript.parentNode)) {
document.currentScript.parentNode.style.display = 'none';
}
}
</script>
</tr>
{% endfor %}
</tbody>
Expand All @@ -118,7 +128,7 @@
<tr class="order">
<th scope="row" onclick="controller.onOrderHeadingPressed('{{order.uuid}}')">
<div class="medication">{{order.medication}}</div>
<div>{{order.dosage}}&nbsp;</div>
<div>{{order.dosage}}&nbsp;{{order.frequency != null ? order.frequency + 'x daily' : ''}}</div>
</th>
{% set previousActive = false %}
{% set future = false %}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/assets/chart.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
function isRowEmpty(parentNode) {
var rowEmpty = true;
$(parentNode).find('td').each(function(index, element) {
var innerHtml = element.innerHTML.trim();
if ( innerHtml != "" ) {
rowEmpty = false;
}
});
return rowEmpty;
}

function popup(name, pairs) {
// var dialog = document.getElementById('obs-dialog');
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/org/projectbuendia/client/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
package org.projectbuendia.client;

import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
import android.support.multidex.MultiDex;

import com.facebook.stetho.Stetho;

Expand Down Expand Up @@ -85,6 +87,13 @@ public static synchronized OpenMrsConnectionDetails getConnectionDetails() {
mHealthMonitor.start();
}

@Override
public void attachBaseContext(Context base) {
// Set up Multidex.
super.attachBaseContext(base);
MultiDex.install(this);
}

public void inject(Object obj) {
mObjectGraph.inject(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class DiagnosticsModule {
return ImmutableSet.of(
new WifiHealthCheck(application, settings),
new BuendiaApiHealthCheck(application, connectionDetails),
new PackageServerHealthCheck(application, settings));
new PackageServerHealthCheck(application, settings),
new UnsentFormHealthCheck(application));
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum HealthIssue {
SERVER_INTERNAL_ISSUE,
SERVER_NOT_RESPONDING,
PACKAGE_SERVER_HOST_UNREACHABLE,
PACKAGE_SERVER_INDEX_NOT_FOUND;
PACKAGE_SERVER_INDEX_NOT_FOUND,
PENDING_FORM_SUBMISSION;

/** The event to be posted when a health issue is discovered. */
public final DiscoveredEvent discovered = new DiscoveredEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ private Set<TroubleshootingAction> getNetworkConnectivityTroubleshootingActions(
return actions;
}

private Set<TroubleshootingAction> getSynchronizationTroubleshootingActions() {
Set<TroubleshootingAction> actions = new HashSet<>();

if (mActiveIssues.contains(HealthIssue.PENDING_FORM_SUBMISSION)) {
actions.add(TroubleshootingAction.RESUBMIT_PENDING_FORM);
}

return actions;
}

private Set<TroubleshootingAction> getConfigurationTroubleshootingActions() {
Set<TroubleshootingAction> actions = new HashSet<>();

Expand Down Expand Up @@ -118,7 +128,7 @@ private void postTroubleshootingEvents(HealthIssue solvedIssue) {
actionsBuilder.addAll(getNetworkConnectivityTroubleshootingActions());
actionsBuilder.addAll(getConfigurationTroubleshootingActions());
actionsBuilder.addAll(getPackageServerTroubleshootingActions());

actionsBuilder.addAll(getSynchronizationTroubleshootingActions());
ImmutableSet<TroubleshootingAction> actions = actionsBuilder.build();

if (mLastTroubleshootingActionsChangedEvent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public enum TroubleshootingAction {
CHECK_PACKAGE_SERVER_REACHABILITY,

CHECK_PACKAGE_SERVER_CONFIGURATION,

RESUBMIT_PENDING_FORM
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2015 The Project Buendia Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at: http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distrib-
// uted under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
// OR CONDITIONS OF ANY KIND, either express or implied. See the License for
// specific language governing permissions and limitations under the License.

package org.projectbuendia.client.diagnostics;

import android.app.Application;
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.impl.client.DefaultHttpClient;
import org.projectbuendia.client.App;
import org.projectbuendia.client.AppSettings;
import org.projectbuendia.client.models.UnsentForm;
import org.projectbuendia.client.ui.OdkActivityLauncher;
import org.projectbuendia.client.utils.Logger;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;

/** A {@link HealthCheck} that checks whether there are saved forms which are not submitted and need
* to be resubmitted to the server. */
public class UnsentFormHealthCheck extends HealthCheck {

private static final Logger LOG = Logger.create();

/** Check for issues with this frequency. */
private static final int CHECK_PERIOD_MS = 10000;

private final Object mLock = new Object();

private HandlerThread mHandlerThread;
private Handler mHandler;
private final Runnable mHealthCheckRunnable = new Runnable() {

@Override public void run() {
performCheck();

synchronized (mLock) {
if (mHandler != null) {
mHandler.postDelayed(this, CHECK_PERIOD_MS);
}
}
}

private void performCheck() {
final List<UnsentForm> forms = OdkActivityLauncher.getUnsetForms(App.getInstance()
.getContentResolver());

if(!forms.isEmpty()) {
LOG.w("There are %d unsent forms saved locally and need to be resent to the server",
forms.size());
reportIssue(HealthIssue.PENDING_FORM_SUBMISSION);
return;
} else {
resolveIssue(HealthIssue.PENDING_FORM_SUBMISSION);
}
}
};

UnsentFormHealthCheck(Application application) {
super(application);
}

@Override protected void startImpl() {
synchronized (mLock) {
if (mHandlerThread == null) {
mHandlerThread = new HandlerThread("Buendia Unsent Form Health Check");
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
mHandler.post(mHealthCheckRunnable);
}
}
}

@Override protected void stopImpl() {
synchronized (mLock) {
if (mHandlerThread != null) {
mHandlerThread.quit();
mHandlerThread = null;
mHandler = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public enum Reason {
SERVER_BAD_ENDPOINT,
SERVER_TIMEOUT,
SERVER_ERROR,
CLIENT_ERROR
CLIENT_ERROR,
PENDING_FORM_SUBMISSION
}

public SubmitXformFailedEvent(Reason reason, @Nullable Exception exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.projectbuendia.client.events.data;

import org.projectbuendia.client.events.DefaultCrudEventBus;
import org.projectbuendia.client.models.Encounter;

/**
* An event bus event indicating that adding an encounter failed.
Expand All @@ -21,6 +22,7 @@
public class EncounterAddFailedEvent {
public final Reason reason;
public final Exception exception;
public final Encounter encounter;

public enum Reason {
UNKNOWN,
Expand All @@ -33,7 +35,8 @@ public enum Reason {
FAILED_TO_FETCH_SAVED_OBSERVATION
}

public EncounterAddFailedEvent(Reason reason, Exception exception) {
public EncounterAddFailedEvent(Encounter encounter, Reason reason, Exception exception) {
this.encounter = encounter;
this.reason = reason;
this.exception = exception;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

import org.joda.time.DateTime;

import java.util.Map;
import java.util.List;

/** JSON representation of an OpenMRS Encounter; call Serializers.registerTo before use. */
public class JsonEncounter {
public String patient_uuid;
public String uuid;
public DateTime timestamp;
public String enterer_id;
/** A {conceptUuid: value} map, where value can be a number, string, or answer UUID. */
public Map<Object, Object> observations;
public List<JsonObservation> observations;
public String[] order_uuids; // orders executed during this encounter
}
15 changes: 0 additions & 15 deletions app/src/main/java/org/projectbuendia/client/json/JsonPatient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

package org.projectbuendia.client.json;

import com.google.common.base.MoreObjects;

import org.joda.time.LocalDate;

import java.io.Serializable;
Expand All @@ -34,17 +32,4 @@ public class JsonPatient implements Serializable {

public JsonPatient() {
}

@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("uuid", uuid)
.add("voided", voided)
.add("id", id)
.add("given_name", given_name)
.add("family_name", family_name)
.add("sex", sex)
.add("birthdate", birthdate.toString())
.add("assigned_location", assigned_location)
.toString();
}
}
Loading