Skip to content

Commit

Permalink
Merge branch 'release-2.5.7'
Browse files Browse the repository at this point in the history
* release-2.5.7:
  build: Update version code and version name
  Increase compileSDK and support libs to api 27
  Translations: squashed commit
  InstallDatabaseService: fix comment
  Delete WakeIntentService.java, since it's of no use anymore
  Make InstallDatabaseService a JobIntentService as well
  Add optional intake item name decorator
  Update unit test dependencies and minor changes in tests for api 26
  AlarmIntentService: Fix typo
  Transform AlarmIntentService into a JobIntentService
  Use NotificationManagerCompat for all notification purposes
  NotificationHelper: use default importance for default channel
  Use notification channels for all notifications
  Create notification channels on app startup
  Update targetSdk to 26
  ci: Fix OOM errors in CircleCI
  build: Make kotlinc treat warnings as errors
  Update Kotlin version to 1.2.51
  PrivacyPrefsPresenter: correctly rename argument to match interface
  • Loading branch information
AlvaroBrey committed Aug 7, 2018
2 parents 3803d6b + b230aae commit 6f0dcf6
Show file tree
Hide file tree
Showing 31 changed files with 398 additions and 308 deletions.
29 changes: 18 additions & 11 deletions Calendula/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ apply from: 'config.gradle'
repositories {
mavenCentral()
jcenter()
maven { url "https://maven.google.com" }
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://jitpack.io' }
}
Expand Down Expand Up @@ -72,13 +72,13 @@ task copyTestClasses(type: Copy) {
}

android {
compileSdkVersion 26
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 37
versionName "2.5.6"
targetSdkVersion 26
versionCode 38
versionName "2.5.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "es.usc.citius.servando.calendula"
multiDexEnabled true
Expand Down Expand Up @@ -159,6 +159,13 @@ android {
compileOptions.incremental = false
}


tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
allWarningsAsErrors = true
}
}

dependencies {

/********** DEBUGGING **********/
Expand Down Expand Up @@ -207,14 +214,14 @@ dependencies {
androidTestImplementation "org.mockito:mockito-android:2.13.0"

// Support testing
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'

// Roboelectric
testImplementation "org.robolectric:robolectric:3.6.1"
testImplementation "org.robolectric:shadows-multidex:3.6.1"
testImplementation "org.robolectric:robolectric:3.8"
testImplementation "org.robolectric:shadows-multidex:3.8"

/********** UTILITIES **********/
// HTML parsing
Expand Down
6 changes: 4 additions & 2 deletions Calendula/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@

<service
android:name=".scheduling.AlarmIntentService"
android:label="AlarmIntentService"/>
android:label="AlarmIntentService"
android:permission="android.permission.BIND_JOB_SERVICE"/>

<service
android:name=".drugdb.download.InstallDatabaseService"
android:exported="false"/>
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>

<service
android:name=".drugdb.download.UpdateDatabaseService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,16 @@ private boolean addMeds(NormalItemViewHolder viewHolder, DailyAgendaItemStub ite
TextView medName = (TextView) intakeView.findViewById(R.id.med_item_name);
TextView medDose = (TextView) intakeView.findViewById(R.id.med_item_dose);
ImageView image = (ImageView) intakeView.findViewById(R.id.imageView);

ImageView nameDecorator = (ImageView) intakeView.findViewById(R.id.name_decorator);
String units = element.presentation.units(viewHolder.context.getResources(), element.dose);
image.setImageDrawable(medIcon(element.presentation.icon(), intakeView.getContext()));
medDose.setText(element.displayDose + " " + units);
medName.setText(element.medName);
if (element.medNameDecorator != null) {
nameDecorator.setImageDrawable(element.medNameDecorator);
} else {
nameDecorator.setVisibility(View.GONE);
}

if (element.taken) {
intakeView.findViewById(R.id.ic_done).setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
Expand All @@ -29,18 +28,13 @@
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;

import es.usc.citius.servando.calendula.R;
import es.usc.citius.servando.calendula.notifications.NotificationHelper;
import es.usc.citius.servando.calendula.util.PreferenceKeys;
import es.usc.citius.servando.calendula.util.PreferenceUtils;

/**
* Helper class for showing and canceling message
* notifications.
* <p/>
* This class makes heavy use of the {@link android.support.v4.app.NotificationCompat.Builder} helper
* class to create notifications in a backward-compatible way.
*/
public class PickupNotification {

private static final String TAG = "PickupNotification";
Expand Down Expand Up @@ -78,7 +72,7 @@ public static void notify(final Context context, final String title, final Strin
intent,
PendingIntent.FLAG_CANCEL_CURRENT);

final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationHelper.CHANNEL_DEFAULT_ID)

// Set appropriate defaults for the notification light, sound,
// and vibration.
Expand Down Expand Up @@ -111,15 +105,12 @@ public static void notify(final Context context, final String title, final Strin
*/
@TargetApi(Build.VERSION_CODES.ECLAIR)
public static void cancel(final Context context) {
final NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(NOTIFICATION_TAG, 0);
NotificationManagerCompat.from(context).cancel(NOTIFICATION_TAG, 0);
}

@TargetApi(Build.VERSION_CODES.ECLAIR)
private static void notify(final Context context, final Notification notification) {
final NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NOTIFICATION_TAG, 0, notification);
NotificationManagerCompat.from(context)
.notify(NOTIFICATION_TAG, 0, notification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
Expand All @@ -32,6 +31,7 @@
import android.os.Build;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.util.Pair;
import android.text.SpannableStringBuilder;

Expand All @@ -45,6 +45,7 @@
import es.usc.citius.servando.calendula.CalendulaApp;
import es.usc.citius.servando.calendula.R;
import es.usc.citius.servando.calendula.notifications.LockScreenAlarmActivity;
import es.usc.citius.servando.calendula.notifications.NotificationHelper;
import es.usc.citius.servando.calendula.persistence.Medicine;
import es.usc.citius.servando.calendula.persistence.Patient;
import es.usc.citius.servando.calendula.persistence.Routine;
Expand Down Expand Up @@ -140,15 +141,9 @@ public static void notify(final Context context, final String title, Schedule sc
*/
@TargetApi(Build.VERSION_CODES.ECLAIR)
public static void cancel(final Context context, int id) {
final NotificationManager nm =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
nm.cancel(NOTIFICATION_ROUTINE_TAG, id);
nm.cancel(NOTIFICATION_SCHEDULE_TAG, id);
} else {
nm.cancel(id);
nm.cancel(id);
}
final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
nm.cancel(NOTIFICATION_ROUTINE_TAG, id);
nm.cancel(NOTIFICATION_SCHEDULE_TAG, id);
}

private static void showInsistentScreen(Context context, Intent i) {
Expand Down Expand Up @@ -208,7 +203,7 @@ private static Notification buildNotification(Context context, NotificationOptio
Resources res = context.getResources();
boolean insistentNotifications = PreferenceUtils.getBoolean(PreferenceKeys.SETTINGS_ALARM_INSISTENT, false);

final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationHelper.CHANNEL_MEDS_ID)

// Set appropriate defaults for the notification light, sound, and vibration.
.setDefaults(Notification.DEFAULT_ALL)
Expand Down Expand Up @@ -362,13 +357,8 @@ private static Bitmap getLargeIcon(Resources r, Patient p) {
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static void notify(final Context context, int id, final Notification notification, String tag) {
//int id = Math.abs(tag.hashCode());
final NotificationManager nm =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
nm.notify(tag, id, notification);
} else {
nm.notify(id, notification);
}
final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
nm.notify(tag, id, notification);
}

private static class NotificationOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -29,6 +28,7 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.support.v4.app.NotificationManagerCompat;
import android.util.Pair;
import android.widget.Toast;

Expand Down Expand Up @@ -192,7 +192,7 @@ protected Boolean doInBackground(String... params) {
PrescriptionDBMgr mgr = DBRegistry.instance().db(database);
if (mgr != null) {
InstallDatabaseService.isRunning = true;
NotificationManager mNotifyManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationManagerCompat mNotifyManager = NotificationManagerCompat.from(ctx);
final DownloadManager manager = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE);


Expand Down
Loading

0 comments on commit 6f0dcf6

Please sign in to comment.