110 lines
3.8 KiB
Java
110 lines
3.8 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.devices.garmin;
|
|
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import java.util.List;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
|
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.GarminSupport;
|
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
|
|
|
public abstract class GarminCoordinator extends AbstractBLEDeviceCoordinator {
|
|
@Override
|
|
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
|
|
|
}
|
|
|
|
@Override
|
|
public String getManufacturer() {
|
|
return "Garmin";
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public Class<? extends DeviceSupport> getDeviceSupportClass() {
|
|
return GarminSupport.class;
|
|
}
|
|
|
|
@Override
|
|
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
|
|
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
|
|
|
|
final List<Integer> notifications = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
|
|
|
|
notifications.add(R.xml.devicesettings_send_app_notifications);
|
|
|
|
if (getCannedRepliesSlotCount(device) > 0) {
|
|
notifications.add(R.xml.devicesettings_garmin_default_reply_suffix);
|
|
notifications.add(R.xml.devicesettings_canned_reply_16);
|
|
notifications.add(R.xml.devicesettings_canned_dismisscall_16);
|
|
}
|
|
|
|
final List<Integer> location = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.LOCATION);
|
|
location.add(R.xml.devicesettings_workout_send_gps_to_band);
|
|
|
|
final List<Integer> connection = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CONNECTION);
|
|
connection.add(R.xml.devicesettings_high_mtu);
|
|
|
|
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
|
|
developer.add(R.xml.devicesettings_keep_activity_data_on_device);
|
|
|
|
return deviceSpecificSettings;
|
|
}
|
|
|
|
@Override
|
|
public boolean supportsActivityDataFetching() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean supportsFindDevice() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean supportsWeather() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getCannedRepliesSlotCount(final GBDevice device) {
|
|
if (getPrefs(device).getBoolean(GarminPreferences.PREF_FEAT_CANNED_MESSAGES, false)) {
|
|
return 16;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
protected static Prefs getPrefs(final GBDevice device) {
|
|
return new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
|
}
|
|
|
|
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
|
|
if (supportsAgpsUpdates()) {
|
|
final GarminAgpsInstallHandler agpsInstallHandler = new GarminAgpsInstallHandler(uri, context);
|
|
if (agpsInstallHandler.isValid()) {
|
|
return agpsInstallHandler;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public boolean supportsAgpsUpdates() {
|
|
return false;
|
|
}
|
|
}
|