Skip to content

Commit

Permalink
Merge branch 'release-2.5.4'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AlvaroBrey committed Apr 2, 2018
2 parents c476575 + 4050147 commit 0a43f30
Show file tree
Hide file tree
Showing 63 changed files with 6,430 additions and 450 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Local configuration file (sdk path, etc)
/local.properties
/keystore.properties
/.idea/workspace.xml
.DS_Store

Expand Down Expand Up @@ -43,6 +42,8 @@ libraries/*.iml
Calendula/google-services/
Calendula/google-services.json

Calendula/keystore

# captures
captures/

Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Non-code contributions are also welcome!. You can do a lot of things:

* Comment on a issue or start your own to suggest ideas or give your opinion.
* Fix typos, comments or clarify language to improve the quality of the app.
* Propose an icon, a better drawable for an specific action, or even a new material app logo ;-).
* Propose [an icon](assets/icons), a better drawable for an specific action, or even a new material app logo ;-).
* 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!

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

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

6 changes: 3 additions & 3 deletions Calendula/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 34
versionName "2.5.3"
versionCode 35
versionName "2.5.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "es.usc.citius.servando.calendula"
multiDexEnabled true
Expand Down Expand Up @@ -153,7 +153,7 @@ android {

applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
outputFileName = "${project.name}-${variant.name}-${variant.versionName}.apk"
}
}
compileOptions.incremental = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import android.support.test.espresso.action.ViewActions;
import android.test.ActivityInstrumentationTestCase2;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -38,6 +40,7 @@
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

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

// select capsules presentation
onView(withId(R.id.med_presentation_2))
onView(withTagValue(new PresentationTagMatcher(Presentation.CAPSULES)))
.perform(click());

// click save
onView(withId(R.id.add_button))
.perform(click());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.junit.Before;
import org.junit.Test;

import es.usc.citius.servando.calendula.BuildConfig;
import es.usc.citius.servando.calendula.CalendulaApp;
import es.usc.citius.servando.calendula.R;
import es.usc.citius.servando.calendula.database.DB;
Expand All @@ -36,6 +35,7 @@
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;


public class MedicinesActivityEditTest extends ActivityInstrumentationTestCase2<MedicinesActivity> {
Expand Down Expand Up @@ -85,7 +85,7 @@ public void testEditMedicine() {

TestUtils.sleep(1500);
// select capsules presentation
onView(withId(R.id.med_presentation_2))
onView(withTagValue(new PresentationTagMatcher(Presentation.CAPSULES)))
.perform(click());
TestUtils.sleep(200);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Calendula - An assistant for personal medication management.
* Copyright (C) 2014-2018 CiTIUS - University of Santiago de Compostela
*
* Calendula is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/

package es.usc.citius.servando.calendula.activities;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;

import es.usc.citius.servando.calendula.persistence.Presentation;

class PresentationTagMatcher extends BaseMatcher {

Presentation p;

public PresentationTagMatcher(Presentation p) {
this.p = p;
}

@Override
public boolean matches(Object item) {
return item != null && item.equals(p);
}

@Override
public void describeTo(Description description) {

}
}
Binary file modified Calendula/src/main/assets/fonts/presentation_icons.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ public void onBindEmptyItemViewHolder(EmptyItemViewHolder viewHolder, DailyAgend
if (expanded) {
LocalDate d = viewHolder.stub.date;
if (d.equals(DateTime.now().toLocalDate())) {
viewHolder.hourText.setText(item.time != null ? item.time.toString("kk:mm") : "--");
viewHolder.hourText.setText(item.time != null ? item.time.toString("HH:mm") : "--");
} else {
viewHolder.hourText.setText(item.dateTime().toString("kk:mm"));
viewHolder.hourText.setText(item.dateTime().toString("HH:mm"));
}
}
viewHolder.itemView.setVisibility(expanded ? View.VISIBLE : View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public class ConfirmActivity extends CalendulaActivity {
private boolean stateChanged = false;
private ConfirmItemAdapter itemAdapter;
private DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("dd/MM/YYYY");
private DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("kk:mm");
private DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm");
private IconicsDrawable checkedIcon;
private IconicsDrawable uncheckedIcon;
private int color;
Expand Down Expand Up @@ -676,7 +676,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

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

h.med.setText(m.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void updateSchedule(final Schedule s, final Schedule current, List<Schedu
LogUtil.d(TAG, "Saving daily schedule item..."
+ dsi.getId()
+ " timeToday: "
+ timeToday.toString("kk:mm"));
+ timeToday.toString("HH:mm"));
}
}
// save and fire event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ public class MedicinesActivity extends CalendulaActivity implements MedicineCrea
FloatingActionButton fab;
int color;

private static final String STATE_STARTED_SEARCH = "STATE_STARTED_SEARCH";

private Prescription prescriptionToSet = null;
private String prescriptionNameToSet = null;
private String intentAction;
private String intentSearchText = null;
private boolean startedSearch = false;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down Expand Up @@ -172,6 +175,7 @@ public void showSearchView(@Nullable final String searchText) {
Intent i = new Intent(this, MedicinesSearchActivity.class);
i.putExtra(MedicinesSearchActivity.EXTRA_SEARCH_TERM, searchText);
startActivityForResult(i, REQUEST_CODE_GET_MED);
startedSearch = true;
}


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

title.setBackgroundColor(color);

if (mMedicineId == -1 || intentSearchText != null) {
mViewPager.post(new Runnable() {
@Override
public void run() {
showSearchView(intentSearchText);
}
});

if (savedInstanceState != null && savedInstanceState.getBoolean(STATE_STARTED_SEARCH)) {
LogUtil.d(TAG, "onCreate: search was started, ignoring search intents");
} else if (mMedicineId == -1 || intentSearchText != null) {
showSearchView(intentSearchText);
}

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean(STATE_STARTED_SEARCH, startedSearch);
super.onSaveInstanceState(outState);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
LogUtil.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]");
if (requestCode == REQUEST_CODE_GET_MED) {
if (resultCode == RESULT_OK) {
final String prescriptionName = data.getStringExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION_NAME);
if (prescriptionName != null) {
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setMedicineName(prescriptionName);
} else {
final Prescription p = data.getParcelableExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION);
if (p != null) {
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setPrescription(p);
} else {
LogUtil.e(TAG, "onActivityResult: result was OK but no prescription extras received ");
mViewPager.post(new Runnable() {
@Override
public void run() {
if (prescriptionName != null) {
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setMedicineName(prescriptionName);
} else {
final Prescription p = data.getParcelableExtra(MedicinesSearchActivity.RETURN_EXTRA_PRESCRIPTION);
if (p != null) {
((MedicineCreateOrEditFragment) getViewPagerFragment(0)).setPrescription(p);
} else {
LogUtil.e(TAG, "onActivityResult: result was OK but no prescription extras received ");
}
}
}
}
});
}
} else {
LogUtil.w(TAG, "onActivityResult: invalid request code " + requestCode + ", ignoring");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void onClick(View view) {
});

holder.prView.setImageDrawable(new IconicsDrawable(getContext())
.icon(expectedPresentation == null ? CommunityMaterial.Icon.cmd_help : Presentation.iconFor(expectedPresentation))
.icon(expectedPresentation == null ? CommunityMaterial.Icon.cmd_help : expectedPresentation.icon())
.color(ScreenUtils.equivalentNoAlpha(patientColor, 0.8f))
.paddingDp(10)
.sizeDp(72));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static Notification buildNotification(Context context, NotificationOptio
// add delay button and cancel button
builder.addAction(R.drawable.ic_history_white_24dp, res.getString(R.string.notification_delay), options.delayIntent)
.addAction(R.drawable.ic_alarm_off_white_24dp, res.getString(R.string.notification_cancel_now), options.cancelIntent)
.addAction(R.drawable.ic_done_white_36dp, res.getString(R.string.take), options.confirmAllIntent);
.addAction(R.drawable.ic_done_white_36dp, res.getString(R.string.notification_taken), options.confirmAllIntent);

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

if (delayMinutes > 0 && !lost) {
String repeatTime = DateTime.now().plusMinutes(delayMinutes).toString("kk:mm");
String repeatTime = DateTime.now().plusMinutes(delayMinutes).toString("HH:mm");
style.setSummaryText(context.getString(R.string.notification_repeat_message, repeatTime));
} else {
style.setSummaryText(med.getName() + "(" + context.getString(R.string.every) + " " + schedule.rule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,13 @@ public Object call() throws Exception {
for (PickupInfo p : pickups) {
DB.pickups().remove(p);
}
DB.medicines().remove(m);

//Remove alerts
final List<PatientAlert> alerts = DB.alerts().findBy(PatientAlert.COLUMN_MEDICINE, m);
for (PatientAlert alert : alerts) {
AlertManager.removeAlert(alert);
}

DB.medicines().remove(m);
return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ public Routine findByPatientAndName(String name, Patient p) {
public List<Routine> findInHour(int hour) {
try {
LocalTime time = new LocalTime(hour, 0);
// get one hour interval [h:00, h:59:]
String start = time.toString("kk:mm");
String end = time.plusMinutes(59).toString("kk:mm");


LocalTime endTime = time.plusMinutes(59);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@ private Presentation expectedPresentation(@NonNull final String presentationForm
return Presentation.PILLS;

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

case "45": // Polvo / Granulado liberación modificada
return Presentation.POWDER;

case "18": // Crema
return Presentation.CREAM;

case "23": // Emulsion
case "24": // Gel
case "25": // Gel oftalmico
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public List<DailyAgendaItemStub> buildItems() {
el.medName = medicine.getName();
el.dose = schedule.dose();
el.displayDose = schedule.displayDose();
el.res = medicine.getPresentation().getDrawable();
el.presentation = medicine.getPresentation();
el.minute = time.toString("mm");
el.taken = dailyScheduleItem.getTakenToday();
Expand Down Expand Up @@ -236,7 +235,6 @@ public List<DailyAgendaItemStub> buildItems() {
el.dose = scheduleItem.getDose();
el.scheduleItemId = scheduleItem.getId();
el.displayDose = scheduleItem.displayDose();
el.res = medicine.getPresentation().getDrawable();
el.presentation = medicine.getPresentation();
el.minute = time.toString("mm");
el.taken = dailyScheduleItem.getTakenToday();
Expand Down
Loading

0 comments on commit 0a43f30

Please sign in to comment.