Skip to content

Commit 998a19e

Browse files
Merge pull request #39 from OpenSRP/35-make-views-mobile-friendly
Make views mobile friendly
2 parents 54243b6 + d10b9fe commit 998a19e

File tree

61 files changed

+1272
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1272
-443
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION_NAME=1.2.8-SNAPSHOT
1+
VERSION_NAME=1.2.9-SNAPSHOT
22
VERSION_CODE=2
33
GROUP=org.smartregister
44
POM_SETTING_DESCRIPTION=OpenSRP Client Immunization

opensrp-immunization/jacoco.exec

-340 KB
Binary file not shown.

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/ServiceDialogFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.smartregister.immunization.listener.ServiceActionListener;
3232
import org.smartregister.immunization.service.intent.RecurringIntentService;
3333
import org.smartregister.immunization.util.ImageUtils;
34+
import org.smartregister.immunization.util.Utils;
3435
import org.smartregister.immunization.util.VaccinatorUtils;
3536
import org.smartregister.util.DatePickerUtils;
3637
import org.smartregister.util.OpenSRPImageLoader;
@@ -529,7 +530,9 @@ public void run() {
529530

530531
int width = size.x;
531532

532-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
533+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
534+
535+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
533536
window.setGravity(Gravity.CENTER);
534537

535538
}

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/ServiceEditDialogFragment.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.smartregister.immunization.domain.ServiceWrapper;
3131
import org.smartregister.immunization.listener.ServiceActionListener;
3232
import org.smartregister.immunization.util.ImageUtils;
33+
import org.smartregister.immunization.util.Utils;
3334
import org.smartregister.immunization.util.VaccinatorUtils;
3435
import org.smartregister.util.DatePickerUtils;
3536
import org.smartregister.util.OpenSRPImageLoader;
@@ -240,11 +241,11 @@ private void updateDateRanges(DatePicker datePicker, Button set) {
240241
}
241242

242243
if (maxDate.getMillis() >= minDate.getMillis()) {
243-
set.setVisibility(View.INVISIBLE);
244+
set.setVisibility(View.GONE);
244245
datePicker.setMinDate(minDate.getMillis());
245246
datePicker.setMaxDate(maxDate.getMillis());
246247
} else {
247-
set.setVisibility(View.INVISIBLE);
248+
set.setVisibility(View.GONE);
248249
Toast.makeText(getActivity(), R.string.problem_applying_vaccine_constraints, Toast.LENGTH_LONG).show();
249250
}
250251
}
@@ -330,7 +331,9 @@ public void run() {
330331

331332
int width = size.x;
332333

333-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
334+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
335+
336+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
334337
window.setGravity(Gravity.CENTER);
335338

336339
}

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/UndoServiceDialogFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.smartregister.immunization.domain.ServiceWrapper;
2323
import org.smartregister.immunization.listener.ServiceActionListener;
2424
import org.smartregister.immunization.util.ImageUtils;
25+
import org.smartregister.immunization.util.Utils;
2526
import org.smartregister.util.OpenSRPImageLoader;
2627
import org.smartregister.view.activity.DrishtiApplication;
2728

@@ -150,8 +151,9 @@ public void run() {
150151
display.getSize(size);
151152

152153
int width = size.x;
154+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
153155

154-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
156+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
155157
window.setGravity(Gravity.CENTER);
156158
}
157159
});

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/UndoVaccinationDialogFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.smartregister.immunization.domain.VaccineWrapper;
2424
import org.smartregister.immunization.listener.VaccinationActionListener;
2525
import org.smartregister.immunization.util.ImageUtils;
26+
import org.smartregister.immunization.util.Utils;
2627
import org.smartregister.util.OpenSRPImageLoader;
2728
import org.smartregister.view.activity.DrishtiApplication;
2829

@@ -152,8 +153,8 @@ public void run() {
152153
display.getSize(size);
153154

154155
int width = size.x;
155-
156-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
156+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
157+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
157158
window.setGravity(Gravity.CENTER);
158159

159160
}

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/VaccinationDialogFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.smartregister.immunization.domain.VaccineWrapper;
3535
import org.smartregister.immunization.listener.VaccinationActionListener;
3636
import org.smartregister.immunization.util.ImageUtils;
37+
import org.smartregister.immunization.util.Utils;
3738
import org.smartregister.util.DatePickerUtils;
3839
import org.smartregister.util.OpenSRPImageLoader;
3940
import org.smartregister.view.activity.DrishtiApplication;
@@ -573,8 +574,9 @@ public void run() {
573574
display.getSize(size);
574575

575576
int width = size.x;
577+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
576578

577-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
579+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
578580
window.setGravity(Gravity.CENTER);
579581
}
580582
});

opensrp-immunization/src/main/java/org/smartregister/immunization/fragment/VaccinationEditDialogFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.smartregister.immunization.domain.VaccineWrapper;
3333
import org.smartregister.immunization.listener.VaccinationActionListener;
3434
import org.smartregister.immunization.util.ImageUtils;
35+
import org.smartregister.immunization.util.Utils;
3536
import org.smartregister.util.DatePickerUtils;
3637
import org.smartregister.util.OpenSRPImageLoader;
3738
import org.smartregister.view.activity.DrishtiApplication;
@@ -300,6 +301,9 @@ public void onClick(View view) {
300301
@Override
301302
public void onClick(View view) {
302303
CheckBox childSelect = (CheckBox) view.findViewById(R.id.select);
304+
if (childSelect == null) {
305+
return;
306+
}
303307
childSelect.toggle();
304308
}
305309
});
@@ -507,7 +511,9 @@ public void run() {
507511

508512
int width = size.x;
509513

510-
window.setLayout((int) (width * 0.7), FrameLayout.LayoutParams.WRAP_CONTENT);
514+
double widthFactor = Utils.calculateDialogWidthFactor(getActivity());
515+
516+
window.setLayout((int) (width * widthFactor), FrameLayout.LayoutParams.WRAP_CONTENT);
511517
window.setGravity(Gravity.CENTER);
512518
}
513519
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.smartregister.immunization.util;
2+
3+
import android.app.Activity;
4+
import android.content.res.Configuration;
5+
6+
/**
7+
* Created by vkaruri on 29/03/2018.
8+
*/
9+
10+
public class Utils {
11+
public static double calculateDialogWidthFactor(Activity activity) {
12+
double widthFactor = 0.7;
13+
int screenSize = activity.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
14+
if (screenSize >= Configuration.SCREENLAYOUT_SIZE_NORMAL && screenSize < Configuration.SCREENLAYOUT_SIZE_LARGE) {
15+
widthFactor = 0.9;
16+
}
17+
return widthFactor;
18+
}
19+
}

opensrp-immunization/src/main/java/org/smartregister/immunization/view/ImmunizationRowCard.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class ImmunizationRowCard extends LinearLayout {
3232
private Button undoB;
3333
private State state;
3434
private VaccineWrapper vaccineWrapper;
35-
public boolean editmode;
35+
private boolean editmode;
36+
private boolean statusForMoreThanThreeMonths = false;
3637

3738
public ImmunizationRowCard(Context context, boolean editmode) {
3839
super(context);
@@ -128,7 +129,6 @@ public void setState(State state) {
128129
}
129130

130131
private void updateStateUi() {
131-
boolean statusForMoreThanThreeMonths = false;
132132
if (getDbKey() != null) {
133133
statusForMoreThanThreeMonths = VaccinateActionUtils.moreThanThreeMonths(getCreatedAt());
134134
}
@@ -259,4 +259,12 @@ private Long getDbKey() {
259259
public Button getUndoB() {
260260
return undoB;
261261
}
262+
263+
public boolean isEditmode() {
264+
return editmode;
265+
}
266+
267+
public boolean isStatusForMoreThanThreeMonths() {
268+
return statusForMoreThanThreeMonths;
269+
}
262270
}

0 commit comments

Comments
 (0)