1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 13:26:50 +01:00

add onSetNavigationInfo() to device interface

This commit is contained in:
Andreas Shimokawa 2021-10-20 22:37:23 +02:00
parent 6379036559
commit 48dee7486f
6 changed files with 45 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
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.Reminder;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
@ -71,6 +72,8 @@ public interface EventHandler {
*/
void onSetPhoneVolume(final float volume);
void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec);
void onEnableRealtimeSteps(boolean enable);
void onInstallApp(Uri uri);

View File

@ -43,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.Contact;
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.Reminder;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
@ -288,6 +289,15 @@ public class GBDeviceService implements DeviceService {
invokeService(intent);
}
@Override
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
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);
invokeService(intent);
}
@Override
public void onInstallApp(Uri uri) {
Intent intent = createIntent().setAction(ACTION_INSTALL)

View File

@ -40,6 +40,7 @@ public interface DeviceService extends EventHandler {
String ACTION_SETMUSICINFO = PREFIX + ".action.setmusicinfo";
String ACTION_SETMUSICSTATE = PREFIX + ".action.setmusicstate";
String ACTION_SET_PHONE_VOLUME = PREFIX + ".action.set_phone_volume";
String ACTION_SETNAVIGATIONINFO = PREFIX + ".action.setnavigationinfo";
String ACTION_REQUEST_DEVICEINFO = PREFIX + ".action.request_deviceinfo";
String ACTION_REQUEST_APPINFO = PREFIX + ".action.request_appinfo";
String ACTION_REQUEST_SCREENSHOT = PREFIX + ".action.request_screenshot";
@ -110,6 +111,9 @@ public interface DeviceService extends EventHandler {
String EXTRA_MUSIC_POSITION = "music_position";
String EXTRA_MUSIC_RATE = "music_rate";
String EXTRA_PHONE_VOLUME = "phone_volume";
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_APP_UUID = "app_uuid";
String EXTRA_APP_START = "app_start";
String EXTRA_APP_CONFIG = "app_config";

View File

@ -91,6 +91,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
import nodomain.freeyourgadget.gadgetbridge.model.NavigationInfoSpec;
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver;
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBMusicControlReceiver;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
@ -548,6 +549,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
return inputString;
}
<<<<<<< HEAD
// Empty functions following, leaving optional implementation up to child classes
@ -950,4 +952,9 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
public void onTestNewFunction() {
}
@Override
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
}
}

View File

@ -81,6 +81,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
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.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
@ -125,6 +126,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SE
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETCANNEDMESSAGES;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICSTATE;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETNAVIGATIONINFO;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETTIME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_ALARMS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_CONSTANT_VIBRATION;
@ -181,6 +183,9 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUS
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_TRACK;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_TRACKCOUNT;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_TRACKNR;
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_NOTIFICATION_ACTIONS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_BODY;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_DNDSUPPRESSED;
@ -868,6 +873,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte) 0);
deviceSupport.onSetMusicState(stateSpec);
break;
case ACTION_SETNAVIGATIONINFO:
NavigationInfoSpec navigationInfoSpec = new NavigationInfoSpec();
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);
mDeviceSupport.onSetNavigationInfo(navigationInfoSpec);
break;
case ACTION_REQUEST_APPINFO:
deviceSupport.onAppInfoReq();
break;

View File

@ -39,6 +39,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
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.Reminder;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
@ -228,6 +229,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
delegate.onSetPhoneVolume(volume);
}
@Override
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
if (checkBusy("set navigation info")) {
return;
}
delegate.onSetNavigationInfo(navigationInfoSpec);
}
@Override
public void onInstallApp(Uri uri) {
if (checkBusy("install app")) {