Scrape Navigation info from Google Maps notifications, and add Navigation handling to Bangle.js #3136
|
@ -205,4 +205,9 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
|
|||
for (int i=0; i<settings.size(); i++) settingsInt[i] = settings.get(i);
|
||||
return settingsInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsNavigation() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilter;
|
|||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntry;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.NotificationFilterEntryDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.notifications.GoogleMapsNotificationHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.AppNotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
|
@ -128,6 +129,8 @@ public class NotificationListener extends NotificationListenerService {
|
|||
private Runnable mSetMusicInfoRunnable = null;
|
||||
private Runnable mSetMusicStateRunnable = null;
|
||||
|
||||
private GoogleMapsNotificationHandler googleMapsNotificationHandler = new GoogleMapsNotificationHandler();
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
|
@ -277,6 +280,9 @@ public class NotificationListener extends NotificationListenerService {
|
|||
|
||||
if (shouldIgnoreSource(sbn)) return;
|
||||
|
||||
/* Check for navigation notifications and ignore if we're handling them */
|
||||
if (googleMapsNotificationHandler.handle(getApplicationContext(), sbn)) return;
|
||||
|
||||
// If media notifications do NOT ignore app list, check them after
|
||||
if (!mediaIgnoresAppList && handleMediaSessionNotification(sbn)) return;
|
||||
|
||||
|
@ -730,6 +736,8 @@ public class NotificationListener extends NotificationListenerService {
|
|||
|
||||
notificationStack.remove(sbn.getPackageName());
|
||||
|
||||
googleMapsNotificationHandler.handleRemove(sbn);
|
||||
|
||||
if (isServiceNotRunningAndShouldIgnoreNotifications()) return;
|
||||
|
||||
final Prefs prefs = GBApplication.getPrefs();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -294,7 +294,8 @@ public class GBDeviceService implements DeviceService {
|
|||
Intent intent = createIntent().setAction(ACTION_SETNAVIGATIONINFO)
|
||||
.putExtra(EXTRA_NAVIGATION_INSTRUCTION, navigationInfoSpec.instruction)
|
||||
.putExtra(EXTRA_NAVIGATION_NEXT_ACTION, navigationInfoSpec.nextAction)
|
||||
.putExtra(EXTRA_NAVIGATION_DISTANCE_TO_TURN, navigationInfoSpec.distanceToTurn);
|
||||
.putExtra(EXTRA_NAVIGATION_DISTANCE_TO_TURN, navigationInfoSpec.distanceToTurn)
|
||||
.putExtra(EXTRA_NAVIGATION_ETA, navigationInfoSpec.ETA);
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ public interface DeviceService extends EventHandler {
|
|||
String EXTRA_NAVIGATION_INSTRUCTION = "navigation_instruction";
|
||||
String EXTRA_NAVIGATION_DISTANCE_TO_TURN = "navigation_distance_to_turn";
|
||||
String EXTRA_NAVIGATION_NEXT_ACTION = "navigation_next_action";
|
||||
String EXTRA_NAVIGATION_ETA = "navigation_eta";
|
||||
String EXTRA_APP_UUID = "app_uuid";
|
||||
String EXTRA_APP_START = "app_start";
|
||||
String EXTRA_APP_CONFIG = "app_config";
|
||||
|
|
|
@ -31,8 +31,12 @@ public class NavigationInfoSpec {
|
|||
public static final int ACTION_OFFROUTE = 12;
|
||||
public static final int ACTION_ROUNDABOUT_RIGHT = 13;
|
||||
public static final int ACTION_ROUNDABOUT_LEFT = 14;
|
||||
public static final int ACTION_ROUNDABOUT_STRAIGHT = 15;
|
||||
public static final int ACTION_FINISH = 16;
|
||||
|
||||
// ETA? Total Distance?
|
||||
public String instruction;
|
||||
public int distanceToTurn;
|
||||
public int nextAction;
|
||||
public int distanceToTurn; ///< Distance to turn (in metres?)
|
||||
public int nextAction; ///< One of the ACTION_ constants
|
||||
public String ETA; ///< Estimated time of Arrival
|
||||
}
|
||||
|
|
|
@ -186,6 +186,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUS
|
|||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NAVIGATION_DISTANCE_TO_TURN;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NAVIGATION_INSTRUCTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NAVIGATION_NEXT_ACTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NAVIGATION_ETA;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_ACTIONS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_BODY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_DNDSUPPRESSED;
|
||||
|
@ -890,6 +891,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||
navigationInfoSpec.instruction = intent.getStringExtra(EXTRA_NAVIGATION_INSTRUCTION);
|
||||
navigationInfoSpec.nextAction = intent.getIntExtra(EXTRA_NAVIGATION_NEXT_ACTION,0);
|
||||
navigationInfoSpec.distanceToTurn = intent.getIntExtra(EXTRA_NAVIGATION_DISTANCE_TO_TURN,0);
|
||||
navigationInfoSpec.ETA = intent.getStringExtra(EXTRA_NAVIGATION_ETA);
|
||||
deviceSupport.onSetNavigationInfo(navigationInfoSpec);
|
||||
break;
|
||||
case ACTION_REQUEST_APPINFO:
|
||||
|
|
|
@ -116,6 +116,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
|||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NavigationInfoSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
|
@ -1526,4 +1527,26 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
|
||||
try {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("t", "nav");
|
||||
if (navigationInfoSpec.instruction!=null)
|
||||
o.put("instr", navigationInfoSpec.instruction);
|
||||
o.put("distance", navigationInfoSpec.distanceToTurn);
|
||||
String[] navActions = {
|
||||
"","continue", "left", "left_sharp", "left_slight", "right", "right_slight",
|
||||
"right_sharp", "keep_left", "keep_right", "uturn_left", "uturn_right",
|
||||
"offroute", "roundabout_right", "roundabout_left", "roundabout_straight", "finish"};
|
||||
if (navigationInfoSpec.nextAction>0 && navigationInfoSpec.nextAction<navActions.length)
|
||||
o.put("action", navActions[navigationInfoSpec.nextAction]);
|
||||
if (navigationInfoSpec.ETA!=null)
|
||||
o.put("eta", navigationInfoSpec.ETA);
|
||||
uartTxJSON("onSetNavigationInfo", o);
|
||||
} catch (JSONException e) {
|
||||
LOG.info("JSONException: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue