diff --git a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java
index a31e41e..fc356f4 100644
--- a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java
+++ b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java
@@ -13,10 +13,12 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.location.LocationManager;
import android.os.Build;
import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.SystemClock;
+import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.view.View;
@@ -160,10 +162,16 @@ public class PodsService extends Service {
private static final long TIMEOUT_CONNECTED=30000;
private static boolean maybeConnected =true;
private class NotificationThread extends Thread{
+ private boolean isLocationEnabled(){
+ LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
+ return service!=null&&service.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+ }
public void run(){
boolean notificationShowing=false;
RemoteViews notificationBig=new RemoteViews(getPackageName(),R.layout.status_big);
RemoteViews notificationSmall=new RemoteViews(getPackageName(),R.layout.status_small);
+ RemoteViews locationDisabledBig=new RemoteViews(getPackageName(),R.layout.location_disabled_big);
+ RemoteViews locationDisabledSmall=new RemoteViews(getPackageName(),R.layout.location_disabled_small);
NotificationManager mNotifyManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(PodsService.this,TAG);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //on oreo and newer, create a notification channel
@@ -173,8 +181,6 @@ public class PodsService extends Service {
channel.setShowBadge(true);
mNotifyManager.createNotificationChannel(channel);
}
- mBuilder.setCustomContentView(notificationSmall);
- mBuilder.setCustomBigContentView(notificationBig);
mBuilder.setShowWhen(false);
mBuilder.setOngoing(true);
mBuilder.setSmallIcon(R.drawable.left_pod);
@@ -192,6 +198,13 @@ public class PodsService extends Service {
mNotifyManager.cancel(1);
}
}
+ if(isLocationEnabled()) {
+ mBuilder.setCustomContentView(notificationSmall);
+ mBuilder.setCustomBigContentView(notificationBig);
+ }else{
+ mBuilder.setCustomContentView(locationDisabledSmall);
+ mBuilder.setCustomBigContentView(locationDisabledBig);
+ }
if(notificationShowing){
if(ENABLE_LOGGING) Log.d(TAG,"Left: "+leftStatus+(chargeL?"+":"")+" "+"Right: "+rightStatus+(chargeR?"+":"")+" "+"Case: "+caseStatus+(chargeCase?"+":""));
notificationBig.setImageViewResource(R.id.leftPodImg,leftStatus<=10?R.drawable.left_pod:R.drawable.left_pod_disconnected);
diff --git a/OpenPods/app/src/main/res/layout/location_disabled_big.xml b/OpenPods/app/src/main/res/layout/location_disabled_big.xml
new file mode 100644
index 0000000..6e60591
--- /dev/null
+++ b/OpenPods/app/src/main/res/layout/location_disabled_big.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/OpenPods/app/src/main/res/layout/location_disabled_small.xml b/OpenPods/app/src/main/res/layout/location_disabled_small.xml
new file mode 100644
index 0000000..3f2b0eb
--- /dev/null
+++ b/OpenPods/app/src/main/res/layout/location_disabled_small.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/OpenPods/app/src/main/res/layout/status_big.xml b/OpenPods/app/src/main/res/layout/status_big.xml
index 832ea61..2e333c2 100644
--- a/OpenPods/app/src/main/res/layout/status_big.xml
+++ b/OpenPods/app/src/main/res/layout/status_big.xml
@@ -6,6 +6,7 @@
android:gravity="center"
>
+
Nascondi app
L\'icona sarĂ rimossa presto
Questo dispositivo non supporta Bluetooth LE
+ Attiva la posizione per permttere a OpenPods di leggere lo stato
\ No newline at end of file
diff --git a/OpenPods/app/src/main/res/values/strings.xml b/OpenPods/app/src/main/res/values/strings.xml
index 5c08bbb..d9469b1 100644
--- a/OpenPods/app/src/main/res/values/strings.xml
+++ b/OpenPods/app/src/main/res/values/strings.xml
@@ -8,4 +8,5 @@
Hide app
The icon will disappear soon
It looks like this device doesn\'t have Bluetooth LE
+ You need to turn on Location to allow OpenPods to read the status