Skip to content

Commit 0a43f30

Browse files
committed
Merge branch 'release-2.5.4'
* release-2.5.4: build: Prepend project name to APK name Italian translation (#105) Translations: Squashed commit of the following: Notification: use 'taken' instead of 'take' to better reflect user action Add keystore.properties symlink for easier management Remove med alerts before removing med RoutineCreateOrEditFrag: Force using RadialTimePicker with SDK<21 MedicinesActivity: don't wait for layout inflation before starting search MedicinesActivity: avoid re-launching search activity when this activity is GCd Schedules: Don't show pill dose pickers for presentations other than pills Add icon asset folder link to the contributing guidelines Add drug presentation icon sources to the repo MedicineCreateOrEditFragm: don't hardcode tag for presentations Fix medicine activity tests with new presentation layout Presentation: simplify icon retrieval Add new medicine presentations. Fixes #54 and #98 Properly format 24h times Add default strings for new presentations build: update Kotlin version to 1.2.30 build: Update versionCode and versionName
2 parents c476575 + 4050147 commit 0a43f30

File tree

63 files changed

+6430
-450
lines changed

Some content is hidden

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

63 files changed

+6430
-450
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Local configuration file (sdk path, etc)
22
/local.properties
3-
/keystore.properties
43
/.idea/workspace.xml
54
.DS_Store
65

@@ -43,6 +42,8 @@ libraries/*.iml
4342
Calendula/google-services/
4443
Calendula/google-services.json
4544

45+
Calendula/keystore
46+
4647
# captures
4748
captures/
4849

CONTRIBUTING.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Non-code contributions are also welcome!. You can do a lot of things:
3333

3434
* Comment on a issue or start your own to suggest ideas or give your opinion.
3535
* Fix typos, comments or clarify language to improve the quality of the app.
36-
* Propose an icon, a better drawable for an specific action, or even a new material app logo ;-).
36+
* Propose [an icon](assets/icons), a better drawable for an specific action, or even a new material app logo ;-).
3737
* Be a member of the testing community by joining the testing group on Google Groups. You will automatically receive the updates from the BETA channel like normal updates from Google Play. This helps us find bugs before the public release!
3838

3939
> Join the BETA channel: [click here!](https://play.google.com/apps/testing/es.usc.citius.servando.calendula)
@@ -50,4 +50,3 @@ Alternatively, you can contribute translations via pull request:
5050
* Send a pull request.
5151

5252
You can also improve an existing `strings_translatable.xml` file and make a PR with that!
53-

Calendula/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ android {
7777
defaultConfig {
7878
minSdkVersion 16
7979
targetSdkVersion 25
80-
versionCode 34
81-
versionName "2.5.3"
80+
versionCode 35
81+
versionName "2.5.4"
8282
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
8383
applicationId "es.usc.citius.servando.calendula"
8484
multiDexEnabled true
@@ -153,7 +153,7 @@ android {
153153

154154
applicationVariants.all { variant ->
155155
variant.outputs.all {
156-
outputFileName = "${variant.name}-${variant.versionName}.apk"
156+
outputFileName = "${project.name}-${variant.name}-${variant.versionName}.apk"
157157
}
158158
}
159159
compileOptions.incremental = false

Calendula/src/androidTest/java/es/usc/citius/servando/calendula/activities/MedicinesActivityCreateTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import android.support.test.espresso.action.ViewActions;
2323
import android.test.ActivityInstrumentationTestCase2;
2424

25+
import org.hamcrest.BaseMatcher;
26+
import org.hamcrest.Description;
2527
import org.junit.Before;
2628
import org.junit.Test;
2729

@@ -38,6 +40,7 @@
3840
import static android.support.test.espresso.action.ViewActions.click;
3941
import static android.support.test.espresso.action.ViewActions.typeText;
4042
import static android.support.test.espresso.matcher.ViewMatchers.withId;
43+
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
4144
import static android.support.test.espresso.matcher.ViewMatchers.withText;
4245

4346
public class MedicinesActivityCreateTest extends ActivityInstrumentationTestCase2<MedicinesActivity> {
@@ -97,8 +100,9 @@ public void testCreateMedicine() {
97100
.perform(click());
98101

99102
// select capsules presentation
100-
onView(withId(R.id.med_presentation_2))
103+
onView(withTagValue(new PresentationTagMatcher(Presentation.CAPSULES)))
101104
.perform(click());
105+
102106
// click save
103107
onView(withId(R.id.add_button))
104108
.perform(click());

Calendula/src/androidTest/java/es/usc/citius/servando/calendula/activities/MedicinesActivityEditTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.junit.Before;
2626
import org.junit.Test;
2727

28-
import es.usc.citius.servando.calendula.BuildConfig;
2928
import es.usc.citius.servando.calendula.CalendulaApp;
3029
import es.usc.citius.servando.calendula.R;
3130
import es.usc.citius.servando.calendula.database.DB;
@@ -36,6 +35,7 @@
3635
import static android.support.test.espresso.Espresso.onView;
3736
import static android.support.test.espresso.action.ViewActions.click;
3837
import static android.support.test.espresso.matcher.ViewMatchers.withId;
38+
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
3939

4040

4141
public class MedicinesActivityEditTest extends ActivityInstrumentationTestCase2<MedicinesActivity> {
@@ -85,7 +85,7 @@ public void testEditMedicine() {
8585

8686
TestUtils.sleep(1500);
8787
// select capsules presentation
88-
onView(withId(R.id.med_presentation_2))
88+
onView(withTagValue(new PresentationTagMatcher(Presentation.CAPSULES)))
8989
.perform(click());
9090
TestUtils.sleep(200);
9191

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Calendula - An assistant for personal medication management.
3+
* Copyright (C) 2014-2018 CiTIUS - University of Santiago de Compostela
4+
*
5+
* Calendula is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this software. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package es.usc.citius.servando.calendula.activities;
20+
21+
import org.hamcrest.BaseMatcher;
22+
import org.hamcrest.Description;
23+
24+
import es.usc.citius.servando.calendula.persistence.Presentation;
25+
26+
class PresentationTagMatcher extends BaseMatcher {
27+
28+
Presentation p;
29+
30+
public PresentationTagMatcher(Presentation p) {
31+
this.p = p;
32+
}
33+
34+
@Override
35+
public boolean matches(Object item) {
36+
return item != null && item.equals(p);
37+
}
38+
39+
@Override
40+
public void describeTo(Description description) {
41+
42+
}
43+
}
Binary file not shown.

Calendula/src/main/java/es/usc/citius/servando/calendula/DailyAgendaRecyclerAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ public void onBindEmptyItemViewHolder(EmptyItemViewHolder viewHolder, DailyAgend
190190
if (expanded) {
191191
LocalDate d = viewHolder.stub.date;
192192
if (d.equals(DateTime.now().toLocalDate())) {
193-
viewHolder.hourText.setText(item.time != null ? item.time.toString("kk:mm") : "--");
193+
viewHolder.hourText.setText(item.time != null ? item.time.toString("HH:mm") : "--");
194194
} else {
195-
viewHolder.hourText.setText(item.dateTime().toString("kk:mm"));
195+
viewHolder.hourText.setText(item.dateTime().toString("HH:mm"));
196196
}
197197
}
198198
viewHolder.itemView.setVisibility(expanded ? View.VISIBLE : View.GONE);

Calendula/src/main/java/es/usc/citius/servando/calendula/activities/ConfirmActivity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public class ConfirmActivity extends CalendulaActivity {
134134
private boolean stateChanged = false;
135135
private ConfirmItemAdapter itemAdapter;
136136
private DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("dd/MM/YYYY");
137-
private DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("kk:mm");
137+
private DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm");
138138
private IconicsDrawable checkedIcon;
139139
private IconicsDrawable uncheckedIcon;
140140
private int color;
@@ -676,7 +676,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
676676

677677
String status = getString(R.string.med_not_taken);
678678
if (i.getTimeTaken() != null) {
679-
status = (i.getTakenToday() ? getString(R.string.med_taken_at) : getString(R.string.med_cancelled_at)) + " " + i.getTimeTaken().toString("kk:mm") + "h";
679+
status = (i.getTakenToday() ? getString(R.string.med_taken_at) : getString(R.string.med_cancelled_at)) + " " + i.getTimeTaken().toString("HH:mm") + "h";
680680
}
681681

682682
h.med.setText(m.getName());

Calendula/src/main/java/es/usc/citius/servando/calendula/activities/ConfirmSchedulesActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void updateSchedule(final Schedule s, final Schedule current, List<Schedu
250250
LogUtil.d(TAG, "Saving daily schedule item..."
251251
+ dsi.getId()
252252
+ " timeToday: "
253-
+ timeToday.toString("kk:mm"));
253+
+ timeToday.toString("HH:mm"));
254254
}
255255
}
256256
// save and fire event

Calendula/src/main/java/es/usc/citius/servando/calendula/activities/MedicinesActivity.java

+30-17
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ public class MedicinesActivity extends CalendulaActivity implements MedicineCrea
9292
FloatingActionButton fab;
9393
int color;
9494

95+
private static final String STATE_STARTED_SEARCH = "STATE_STARTED_SEARCH";
96+
9597
private Prescription prescriptionToSet = null;
9698
private String prescriptionNameToSet = null;
9799
private String intentAction;
98100
private String intentSearchText = null;
101+
private boolean startedSearch = false;
99102

100103
@Override
101104
public boolean onCreateOptionsMenu(Menu menu) {
@@ -172,6 +175,7 @@ public void showSearchView(@Nullable final String searchText) {
172175
Intent i = new Intent(this, MedicinesSearchActivity.class);
173176
i.putExtra(MedicinesSearchActivity.EXTRA_SEARCH_TERM, searchText);
174177
startActivityForResult(i, REQUEST_CODE_GET_MED);
178+
startedSearch = true;
175179
}
176180

177181

@@ -208,34 +212,43 @@ public void onClick(View v) {
208212

209213
title.setBackgroundColor(color);
210214

211-
if (mMedicineId == -1 || intentSearchText != null) {
212-
mViewPager.post(new Runnable() {
213-
@Override
214-
public void run() {
215-
showSearchView(intentSearchText);
216-
}
217-
});
215+
216+
if (savedInstanceState != null && savedInstanceState.getBoolean(STATE_STARTED_SEARCH)) {
217+
LogUtil.d(TAG, "onCreate: search was started, ignoring search intents");
218+
} else if (mMedicineId == -1 || intentSearchText != null) {
219+
showSearchView(intentSearchText);
218220
}
219221

220222
}
221223

222224
@Override
223-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
225+
protected void onSaveInstanceState(Bundle outState) {
226+
outState.putBoolean(STATE_STARTED_SEARCH, startedSearch);
227+
super.onSaveInstanceState(outState);
228+
}
229+
230+
@Override
231+
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
224232
super.onActivityResult(requestCode, resultCode, data);
225233
LogUtil.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
226234
if (requestCode == REQUEST_CODE_GET_MED) {
227235
if (resultCode == RESULT_OK) {
228236
final String prescriptionName = data.getStringExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION_NAME);
229-
if (prescriptionName != null) {
230-
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setMedicineName(prescriptionName);
231-
} else {
232-
final Prescription p = data.getParcelableExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION);
233-
if (p != null) {
234-
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setPrescription(p);
235-
} else {
236-
LogUtil.e(TAG, "onActivityResult: result was OK but no prescription extras received ");
237+
mViewPager.post(new Runnable() {
238+
@Override
239+
public void run() {
240+
if (prescriptionName != null) {
241+
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setMedicineName(prescriptionName);
242+
} else {
243+
final Prescription p = data.getParcelableExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION);
244+
if (p != null) {
245+
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setPrescription(p);
246+
} else {
247+
LogUtil.e(TAG, "onActivityResult: result was OK but no prescription extras received ");
248+
}
249+
}
237250
}
238-
}
251+
});
239252
}
240253
} else {
241254
LogUtil.w(TAG, "onActivityResult: invalid request code " + requestCode + ", ignoring");

Calendula/src/main/java/es/usc/citius/servando/calendula/activities/MedicinesSearchAutoCompleteAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void onClick(View view) {
153153
});
154154

155155
holder.prView.setImageDrawable(new IconicsDrawable(getContext())
156-
.icon(expectedPresentation == null ? CommunityMaterial.Icon.cmd_help : Presentation.iconFor(expectedPresentation))
156+
.icon(expectedPresentation == null ? CommunityMaterial.Icon.cmd_help : expectedPresentation.icon())
157157
.color(ScreenUtils.equivalentNoAlpha(patientColor, 0.8f))
158158
.paddingDp(10)
159159
.sizeDp(72));

Calendula/src/main/java/es/usc/citius/servando/calendula/activities/ReminderNotification.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private static Notification buildNotification(Context context, NotificationOptio
242242
// add delay button and cancel button
243243
builder.addAction(R.drawable.ic_history_white_24dp, res.getString(R.string.notification_delay), options.delayIntent)
244244
.addAction(R.drawable.ic_alarm_off_white_24dp, res.getString(R.string.notification_cancel_now), options.cancelIntent)
245-
.addAction(R.drawable.ic_done_white_36dp, res.getString(R.string.take), options.confirmAllIntent);
245+
.addAction(R.drawable.ic_done_white_36dp, res.getString(R.string.notification_taken), options.confirmAllIntent);
246246

247247
builder.extend((new NotificationCompat.WearableExtender()
248248
.addAction(new NotificationCompat.Action.Builder(
@@ -306,7 +306,7 @@ private static void styleForSchedule(Context context, NotificationCompat.InboxSt
306306
int delayMinutes = (int) Long.parseLong(delayMinutesStr);
307307

308308
if (delayMinutes > 0 && !lost) {
309-
String repeatTime = DateTime.now().plusMinutes(delayMinutes).toString("kk:mm");
309+
String repeatTime = DateTime.now().plusMinutes(delayMinutes).toString("HH:mm");
310310
style.setSummaryText(context.getString(R.string.notification_repeat_message, repeatTime));
311311
} else {
312312
style.setSummaryText(med.getName() + "(" + context.getString(R.string.every) + " " + schedule.rule()

Calendula/src/main/java/es/usc/citius/servando/calendula/database/MedicineDao.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,13 @@ public Object call() throws Exception {
129129
for (PickupInfo p : pickups) {
130130
DB.pickups().remove(p);
131131
}
132-
DB.medicines().remove(m);
133132

134133
//Remove alerts
135134
final List<PatientAlert> alerts = DB.alerts().findBy(PatientAlert.COLUMN_MEDICINE, m);
136135
for (PatientAlert alert : alerts) {
137136
AlertManager.removeAlert(alert);
138137
}
139-
138+
DB.medicines().remove(m);
140139
return null;
141140
}
142141
});

Calendula/src/main/java/es/usc/citius/servando/calendula/database/RoutineDao.java

-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ public Routine findByPatientAndName(String name, Patient p) {
107107
public List<Routine> findInHour(int hour) {
108108
try {
109109
LocalTime time = new LocalTime(hour, 0);
110-
// get one hour interval [h:00, h:59:]
111-
String start = time.toString("kk:mm");
112-
String end = time.plusMinutes(59).toString("kk:mm");
113-
114110

115111
LocalTime endTime = time.plusMinutes(59);
116112

Calendula/src/main/java/es/usc/citius/servando/calendula/drugdb/AEMPSPrescriptionDBMgr.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,14 @@ private Presentation expectedPresentation(@NonNull final String presentationForm
210210
return Presentation.PILLS;
211211

212212
case "44": // Solución / Suspensión oral efervescente
213-
case "45": // Polvo / Granulado liberación modificada
214213
return Presentation.EFFERVESCENT;
215214

215+
case "45": // Polvo / Granulado liberación modificada
216+
return Presentation.POWDER;
217+
216218
case "18": // Crema
219+
return Presentation.CREAM;
220+
217221
case "23": // Emulsion
218222
case "24": // Gel
219223
case "25": // Gel oftalmico

Calendula/src/main/java/es/usc/citius/servando/calendula/fragments/DailyAgendaFragment.java

-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ public List<DailyAgendaItemStub> buildItems() {
159159
el.medName = medicine.getName();
160160
el.dose = schedule.dose();
161161
el.displayDose = schedule.displayDose();
162-
el.res = medicine.getPresentation().getDrawable();
163162
el.presentation = medicine.getPresentation();
164163
el.minute = time.toString("mm");
165164
el.taken = dailyScheduleItem.getTakenToday();
@@ -236,7 +235,6 @@ public List<DailyAgendaItemStub> buildItems() {
236235
el.dose = scheduleItem.getDose();
237236
el.scheduleItemId = scheduleItem.getId();
238237
el.displayDose = scheduleItem.displayDose();
239-
el.res = medicine.getPresentation().getDrawable();
240238
el.presentation = medicine.getPresentation();
241239
el.minute = time.toString("mm");
242240
el.taken = dailyScheduleItem.getTakenToday();

0 commit comments

Comments
 (0)