Skip to content

Commit

Permalink
fix QA bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bennsimon committed Jan 28, 2021
1 parent 300a859 commit 78de6a7
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 76 deletions.
22 changes: 1 addition & 21 deletions opensrp-eusm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,6 @@ android {

buildTypes {

release {
resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"'
buildConfigField "int", "DATABASE_VERSION", '1'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
buildConfigField "long", "SYNC_INTERVAL_IN_MINUTES", '15'
buildConfigField "long", "PULL_UNIQUE_IDS_MINUTES", '15'
buildConfigField "String", "ADMIN_PASSWORD_NOT_NEAR_STRUCTURES", '"AdminPass1"'
buildConfigField "float", "MY_LOCATION_BUFFER", '25'
buildConfigField "boolean", "VALIDATE_FAR_STRUCTURES", 'false'
buildConfigField "int", "RESOLVE_LOCATION_TIMEOUT_IN_SECONDS", '60'
buildConfigField "boolean", "DISPLAY_OUTSIDE_OPERATIONAL_AREA_MASK", 'false'
buildConfigField "boolean", "DISPLAY_DISTANCE_SCALE", 'true'
buildConfigField "String[]", "FACILITY_LEVELS", '{"Country", "Region", "District"}'
buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Region", "District"}'

testCoverageEnabled true
}

debug {
resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"'
buildConfigField "int", "DATABASE_VERSION", '1'
Expand Down Expand Up @@ -243,7 +223,7 @@ dependencies {
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
}

api('org.smartregister:opensrp-client-stock:1.2.2-SNAPSHOT') {
api('org.smartregister:opensrp-client-stock:1.2.3-SNAPSHOT') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.smartregister.tasking.presenter.ValidateUserLocationPresenter;
import org.smartregister.util.Utils;

import timber.log.Timber;

public class EusmTaskingMapActivity extends TaskingMapActivity {

private CardView eusmCardView;
Expand Down Expand Up @@ -181,6 +183,11 @@ public void displaySelectedFeature(Feature feature, LatLng clickedPoint, double

@Override
public Location getUserCurrentLocation() {
return super.getUserCurrentLocation();
try {
return super.getUserCurrentLocation();
} catch (NullPointerException e) {
Timber.e(e);
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void onNextButtonClick() {
if ((totalCount - ((currentPageNo) * pageSize)) > pageSize) {
getFragment().clientsView.scrollToPosition(0);
getFragment().getNextButton().setVisibility(View.VISIBLE);
getFragment().getPreviousButton().setVisibility(View.VISIBLE);
} else {
getFragment().getNextButton().setVisibility(View.INVISIBLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.sqlcipher.SQLException;
import net.sqlcipher.database.SQLiteDatabase;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.smartregister.domain.Geometry;
import org.smartregister.eusm.application.EusmApplication;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void addOrUpdate(org.smartregister.domain.Location location) {

public int countOfStructures(String nameFilter, String locationParentId, String planId) {
SQLiteDatabase sqLiteDatabase = getReadableDatabase();
String query = "SELECT count(1) from " + STRUCTURE_TABLE;
String query = "SELECT count(DISTINCT structure._id) from " + STRUCTURE_TABLE;

String[] args = StringUtils.stripAll(locationParentId, planId);

Expand All @@ -105,15 +106,15 @@ public int countOfStructures(String nameFilter, String locationParentId, String
query += " where location.parent_id = ? AND task.plan_id = ?";

if (StringUtils.isNotBlank(nameFilter)) {
args = StringUtils.stripAll(locationParentId, planId, nameFilter);
args = StringUtils.stripAll(locationParentId, planId, "%" + nameFilter + "%");

query += " and " + STRUCTURE_TABLE + "." + NAME + " like '%?%'";
query += " and " + STRUCTURE_TABLE + "." + NAME + " like ? ";
}

int count = 0;
try (Cursor cursor = sqLiteDatabase.rawQuery(query, args)) {
if (cursor != null) {
count = cursor.getCount();
if (cursor != null && cursor.moveToNext()) {
count = cursor.getInt(0);
}
} catch (SQLException w) {
Timber.e(w);
Expand All @@ -127,6 +128,9 @@ public List<StructureDetail> fetchStructureDetails(int pageNo, String locationPa

public List<StructureDetail> fetchStructureDetails(Integer pageNo, String locationParentId,
String nameFilter, boolean isForMapping, String planId) {

Location location = EusmApplication.getInstance().getUserLocation();

List<StructureDetail> structureDetails = new ArrayList<>();
SQLiteDatabase sqLiteDatabase = getReadableDatabase();
String[] columns = new String[]{
Expand All @@ -139,7 +143,7 @@ public List<StructureDetail> fetchStructureDetails(Integer pageNo, String locati
STRUCTURE_TABLE + "." + "geojson as structureGeoJson",
LOCATION_TABLE + "." + "name as locationName",
LOCATION_TABLE + "." + "parent_id as locationParentId",
"(((? - longitude)*(? - longitude)) + ((? - latitude)*(? - latitude))) as dist",
location == null ? "0 as dist " : "(((? - longitude)*(? - longitude)) + ((? - latitude)*(? - latitude))) as dist",
"case \n" +
"\twhen (sum(task.status = 'COMPLETED')*1.0/sum(task.status= 'READY')*1.0) = 0.0 \n" +
"\t\tthen sum(task.status= 'READY')\n" +
Expand All @@ -155,34 +159,28 @@ public List<StructureDetail> fetchStructureDetails(Integer pageNo, String locati
+ " join task on task.structure_id = " + StructureRepository.STRUCTURE_TABLE + "._id "
+ " join location on location._id = " + StructureRepository.STRUCTURE_TABLE + ".parent_id ";


Location location = EusmApplication.getInstance().getUserLocation();
if (location == null) {
location = new Location("temp");
location.setLongitude(0.000);
location.setLatitude(0.000);
}

String[] args = StringUtils.stripAll(
String.valueOf(location.getLongitude()),
String.valueOf(location.getLongitude()),
String.valueOf(location.getLatitude()),
String.valueOf(location.getLatitude()),
planId,
locationParentId);

query += " where task.plan_id = ? AND locationParentId = ? ";

if (StringUtils.isNotBlank(nameFilter)) {
args = StringUtils.stripAll(
planId,
locationParentId,
"%" + nameFilter + "%");
query += " and structureName like ? ";
}

if (location != null) {
String[] locationArgsArray = new String[]{
String.valueOf(location.getLongitude()),
String.valueOf(location.getLongitude()),
String.valueOf(location.getLatitude()),
String.valueOf(location.getLatitude()),
planId,
locationParentId,
nameFilter);
query += " and structureName like '%?%'";
};
args = ArrayUtils.addAll(locationArgsArray, args);
}

query += " group by " + STRUCTURE_TABLE + "." + "_id" + " order by case when dist is null then 1 else 0 end, dist"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.smartregister.eusm.service;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;

import androidx.core.app.ActivityCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import org.jetbrains.annotations.NotNull;
Expand All @@ -19,6 +22,8 @@
import java.util.List;
import java.util.Set;

import timber.log.Timber;

import static org.smartregister.tasking.util.Constants.Action.STRUCTURE_TASK_SYNCED;

public class AppLocationTaskIntentService extends LocationTaskIntentService {
Expand Down Expand Up @@ -46,7 +51,13 @@ protected List<Location> syncStructures(LocationServiceHelper locationServiceHel

//initiate Stock And StockType sync after structures have been fetched
SyncStockServiceJob.scheduleJobImmediately(SyncStockServiceJob.TAG);
SyncStockTypeServiceJob.scheduleJobImmediately(SyncStockTypeServiceJob.TAG);
if ((ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) +
ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE))
== PackageManager.PERMISSION_GRANTED) {
SyncStockTypeServiceJob.scheduleJobImmediately(SyncStockTypeServiceJob.TAG);
} else {
Timber.e("Read and Write Permission Not Granted");
}
}
return locationList;
}
Expand Down
4 changes: 2 additions & 2 deletions opensrp-eusm/src/main/res/drawable/rounded_blue_outline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<corners android:radius="30dp" />
<padding
android:bottom="@dimen/status_label_vertical_padding"
android:left="70dp"
android:right="70dp"
android:left="50dp"
android:right="50dp"
android:top="@dimen/status_label_vertical_padding"/>
</shape>
2 changes: 1 addition & 1 deletion opensrp-eusm/src/main/res/layout/activity_product_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
android:paddingEnd="3dp"
android:text="@string/back"
android:textColor="@color/customAppThemeBlue"
android:textSize="16dp"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
Expand Down
42 changes: 21 additions & 21 deletions opensrp-eusm/src/main/res/layout/card_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_height="wrap_content"
android:text="Alabsdos sdwewe"
android:textColor="@color/text_black"
android:textSize="20dp"
android:textSize="20sp"
android:textStyle="bold" />

<TextView
Expand All @@ -75,31 +75,31 @@
android:layout_marginTop="10dp"
android:text="4 items"
android:textColor="@color/text_black"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
android:textSize="20sp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="center"
android:orientation="horizontal">

<Button
android:id="@+id/btn_view_inventory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="@dimen/change_spray_status_btn_bottom_margin"
android:layout_weight="2"
android:background="@drawable/rounded_blue_outline"
android:text="@string/view_inventory"
android:textAllCaps="false"
android:textColor="#1892D4"
android:textSize="@dimen/structure_info_card_text_size" />
<Button
android:id="@+id/btn_view_inventory"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/change_spray_status_btn_bottom_margin"
android:background="@drawable/rounded_blue_outline"
android:text="@string/view_inventory"
android:textAllCaps="false"
android:textColor="#1892D4"
android:textSize="@dimen/activity_title_size" />


</LinearLayout>
</LinearLayout>
</LinearLayout>


</LinearLayout>
</androidx.cardview.widget.CardView>
2 changes: 1 addition & 1 deletion opensrp-eusm/src/main/res/layout/generic_empty_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
android:padding="13dp"
android:text="@string/no_items_checked_yet"
android:textColor="#747474"
android:textSize="17dp" />
android:textSize="17sp" />
</LinearLayout>
2 changes: 1 addition & 1 deletion opensrp-eusm/src/main/res/layout/generic_title_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:text="@string/nearby_within_n_m"
android:textSize="15dp" />
android:textSize="15sp" />
</LinearLayout>
2 changes: 1 addition & 1 deletion opensrp-eusm/src/main/res/layout/gps_unknown_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
android:paddingStart="0dp"
android:text="@string/gps_unknown"
android:textColor="@android:color/white"
android:textSize="14dp" />
android:textSize="14sp" />
</LinearLayout>
7 changes: 4 additions & 3 deletions opensrp-eusm/src/main/res/layout/task_register_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<FrameLayout
android:id="@+id/layout_product_image"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_width="85dp"
android:layout_height="85dp"
android:paddingTop="1dp"
android:paddingEnd="2dp"
android:paddingStart="1dp"
Expand Down Expand Up @@ -78,7 +78,8 @@
android:paddingEnd="5dp"
android:text="Serial # 3423423"
android:textColor="@color/text_black"
android:textSize="15dp"
android:textSize="15sp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/txt_product_name"
app:layout_constraintStart_toEndOf="@+id/layout_product_image"
Expand Down
2 changes: 1 addition & 1 deletion opensrp-eusm/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<dimen name="drawer_icon_margin">40dp</dimen>

<dimen name="structure_info_card_text_size">16sp</dimen>
<dimen name="structure_info_card_text_size">15sp</dimen>
<dimen name="structure_info_card_status_text_size">22sp</dimen>
<dimen name="mosquito_collection_card_view_title_text_size">20sp</dimen>
<dimen name="mosquito_collection_card_view_title_left_margin">25dp</dimen>
Expand Down
1 change: 1 addition & 0 deletions opensrp-eusm/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@
<string name="select_campaign_operational_area_title">Mission and District not set</string>
<string name="select_campaign_operational_area">Mission and District not set. Select from the hamburger menu</string>
<string name="revoked_plan_operational_area">Previously selected Mission and/or District revoked. Select from the hamburger menu</string>
<string name="read_and_write_permission_not_granted">Read And Write Storage Permission Not Granted</string>
</resources>
Loading

0 comments on commit 78de6a7

Please sign in to comment.