Converted to target SDK Level 28 - had to change how we did notifications, and specify a style to get back to black background. Still a problem with the 'ok' notification not displaying properly - background showing white for some reason.
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 28
|
||||||
useLibrary 'org.apache.http.legacy'
|
useLibrary 'org.apache.http.legacy'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "uk.org.openseizuredetector"
|
applicationId "uk.org.openseizuredetector"
|
||||||
minSdkVersion 14
|
minSdkVersion 19
|
||||||
targetSdkVersion 14
|
targetSdkVersion 28
|
||||||
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -32,8 +33,8 @@ dependencies {
|
|||||||
testImplementation 'org.mockito:mockito-core:1.10.19'
|
testImplementation 'org.mockito:mockito-core:1.10.19'
|
||||||
// Set this dependency if you want to use Hamcrest matching
|
// Set this dependency if you want to use Hamcrest matching
|
||||||
testImplementation 'org.hamcrest:hamcrest-library:1.1'
|
testImplementation 'org.hamcrest:hamcrest-library:1.1'
|
||||||
implementation 'com.android.support:appcompat-v7:22.2.1'
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||||
implementation 'com.android.support:support-v4:22.2.1'
|
implementation 'com.android.support:support-v4:28.0.0'
|
||||||
//compile files('libs/JTransforms-3.1-with-dependencies.jar')
|
//compile files('libs/JTransforms-3.1-with-dependencies.jar')
|
||||||
implementation 'org.apache.commons:commons-math3:3.6.1'
|
implementation 'org.apache.commons:commons-math3:3.6.1'
|
||||||
// google play services used for location finding for SMS alerts.
|
// google play services used for location finding for SMS alerts.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:theme="@style/Theme.AppCompat"
|
||||||
android:icon="@drawable/star_of_life_48x48"
|
android:icon="@drawable/star_of_life_48x48"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<activity android:name=".StartupActivity">
|
<activity android:name=".StartupActivity">
|
||||||
|
|||||||
@@ -28,12 +28,10 @@ package uk.org.openseizuredetector;
|
|||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import fi.iki.elonen.NanoHTTPD;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@@ -42,29 +40,24 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.RingtoneManager;
|
|
||||||
import android.media.ToneGenerator;
|
import android.media.ToneGenerator;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.location.Location;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -72,13 +65,9 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import android.text.format.Time;
|
import android.text.format.Time;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on example at:
|
* Based on example at:
|
||||||
@@ -89,9 +78,12 @@ import org.json.JSONArray;
|
|||||||
public class SdServer extends Service implements SdDataReceiver, SdLocationReceiver {
|
public class SdServer extends Service implements SdDataReceiver, SdLocationReceiver {
|
||||||
// Notification ID
|
// Notification ID
|
||||||
private int NOTIFICATION_ID = 1;
|
private int NOTIFICATION_ID = 1;
|
||||||
|
private String mNotChId = "OSD Notification Channel";
|
||||||
|
private CharSequence mNotChName = "OSD Notification Chennel";
|
||||||
|
private String mNotChDesc = "OSD Notification Channel Description";
|
||||||
|
|
||||||
private NotificationManager mNM;
|
private NotificationManager mNM;
|
||||||
|
private NotificationCompat.Builder mNotificationBuilder;
|
||||||
private SdWebServer webServer = null;
|
private SdWebServer webServer = null;
|
||||||
private final static String TAG = "SdServer";
|
private final static String TAG = "SdServer";
|
||||||
private Timer dataLogTimer = null;
|
private Timer dataLogTimer = null;
|
||||||
@@ -151,7 +143,6 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
Log.v(TAG, "sdServer.onBind()");
|
Log.v(TAG, "sdServer.onBind()");
|
||||||
@@ -237,6 +228,18 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
mUtil.writeToSysLogFile("SdServer.onStartCommand() - starting SdDataSource");
|
mUtil.writeToSysLogFile("SdServer.onStartCommand() - starting SdDataSource");
|
||||||
mSdDataSource.start();
|
mSdDataSource.start();
|
||||||
|
|
||||||
|
// Initialise Notification channel for API level 26 and over
|
||||||
|
// from https://stackoverflow.com/questions/44443690/notificationcompat-with-api-26
|
||||||
|
mNM= (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
mNotificationBuilder = new NotificationCompat.Builder(this,mNotChId);
|
||||||
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
|
NotificationChannel channel = new NotificationChannel(mNotChId,
|
||||||
|
mNotChName,
|
||||||
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
|
channel.setDescription(mNotChDesc);
|
||||||
|
mNM.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Display a notification icon in the status bar of the phone to
|
// Display a notification icon in the status bar of the phone to
|
||||||
// show the service is running.
|
// show the service is running.
|
||||||
@@ -372,16 +375,16 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
PendingIntent contentIntent =
|
PendingIntent contentIntent =
|
||||||
PendingIntent.getActivity(this,
|
PendingIntent.getActivity(this,
|
||||||
0, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
0, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
Notification notification = mNotificationBuilder.setContentIntent(contentIntent)
|
||||||
Notification notification = builder.setContentIntent(contentIntent)
|
|
||||||
.setSmallIcon(iconId)
|
.setSmallIcon(iconId)
|
||||||
|
.setColor(0xff000000)
|
||||||
.setTicker("OpenSeizureDetector")
|
.setTicker("OpenSeizureDetector")
|
||||||
.setAutoCancel(false)
|
.setAutoCancel(false)
|
||||||
.setContentTitle("OpenSeizureDetector")
|
.setContentTitle("OpenSeizureDetector")
|
||||||
.setContentText(mSdDataSourceName + " Data Source")
|
.setContentText(mSdDataSourceName + " Data Source")
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
mNM.notify(NOTIFICATION_ID, notification);
|
mNM.notify(NOTIFICATION_ID, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
Reference in New Issue
Block a user