From a6d0362103212053da89fc01de10f608be0b2659 Mon Sep 17 00:00:00 2001
From: aringot <alexis.ringot@fhstp.ac.at>
Date: Thu, 30 Aug 2018 13:25:08 +0200
Subject: [PATCH] Show Toast on no location at the right place (on 0,0 location
 but only if the option chosen was an Always one)

---
 .../java/at/ac/fhstp/sonicontrol/MainActivity.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/SoniControl/app/src/main/java/at/ac/fhstp/sonicontrol/MainActivity.java b/SoniControl/app/src/main/java/at/ac/fhstp/sonicontrol/MainActivity.java
index e67ea27e..cd0b74b1 100644
--- a/SoniControl/app/src/main/java/at/ac/fhstp/sonicontrol/MainActivity.java
+++ b/SoniControl/app/src/main/java/at/ac/fhstp/sonicontrol/MainActivity.java
@@ -1142,10 +1142,16 @@ public class MainActivity extends BaseActivity implements Scan.DetectionListener
 
         if(saveJsonFile && locationTrack) {
             //Log.d("SearchForJson", "addWithLoc");
-            jsonMan.addJsonObject(locationFinder.getDetectedDBEntry(), sigType.toString(), spoofDecision, locationFinder.getDetectedDBEntryAddres()); //adding the found signal in the JSON file
+            double[] detectedSignalPosition = locationFinder.getDetectedDBEntry();
+            jsonMan.addJsonObject(detectedSignalPosition, sigType.toString(), spoofDecision, locationFinder.getDetectedDBEntryAddres()); //adding the found signal in the JSON file
+            if (detectedSignalPosition[0] == 0 && detectedSignalPosition[1] == 0) {
+                Toast toast = Toast.makeText(MainActivity.this, R.string.toast_no_location_text, Toast.LENGTH_LONG);
+                toast.setGravity(Gravity.CENTER, 0, 0);
+                toast.show();
+            }
         }
         if(saveJsonFile&&!locationTrack){
-            showToastOnNoLocation();
+            //showToastOnNoLocation(); NOTE: Already shown in the Always options
             double[] noLocation = new double[2];
             noLocation[0] = 0;
             noLocation[1] = 0;
-- 
GitLab