mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Pebble: support setting the other non-metric system crap for the pebble
(pebble health has to be activated again in app manager after changing the option) This also moves the fake:// uri handling code from PebbleIoThread to PebbleSupport
This commit is contained in:
parent
6d8ffad55c
commit
486596b1a8
@ -543,20 +543,6 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
}
|
||||
|
||||
void installApp(Uri uri, int appId) {
|
||||
if (uri.equals(Uri.parse("fake://health"))) {
|
||||
write(mPebbleProtocol.encodeActivateHealth(true));
|
||||
write(mPebbleProtocol.encodeSetSaneDistanceUnit(true));
|
||||
return;
|
||||
}
|
||||
if (uri.equals(Uri.parse("fake://hrm"))) {
|
||||
write(mPebbleProtocol.encodeActivateHRM(true));
|
||||
return;
|
||||
}
|
||||
if (uri.equals(Uri.parse("fake://weather"))) {
|
||||
write(mPebbleProtocol.encodeActivateWeather(true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsInstalling) {
|
||||
return;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
@ -67,7 +68,30 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onInstallApp(Uri uri) {
|
||||
getDeviceIOThread().installApp(uri, 0);
|
||||
PebbleProtocol pebbleProtocol = (PebbleProtocol) getDeviceProtocol();
|
||||
PebbleIoThread pebbleIoThread = getDeviceIOThread();
|
||||
// catch fake urls first
|
||||
if (uri.equals(Uri.parse("fake://health"))) {
|
||||
getDeviceIOThread().write(pebbleProtocol.encodeActivateHealth(true));
|
||||
String units = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
if (units.equals(getContext().getString(R.string.p_unit_metric))) {
|
||||
pebbleIoThread.write(pebbleProtocol.encodeSetSaneDistanceUnit(true));
|
||||
} else {
|
||||
pebbleIoThread.write(pebbleProtocol.encodeSetSaneDistanceUnit(false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (uri.equals(Uri.parse("fake://hrm"))) {
|
||||
getDeviceIOThread().write(pebbleProtocol.encodeActivateHRM(true));
|
||||
return;
|
||||
}
|
||||
if (uri.equals(Uri.parse("fake://weather"))) {
|
||||
getDeviceIOThread().write(pebbleProtocol.encodeActivateWeather(true));
|
||||
return;
|
||||
}
|
||||
|
||||
// it is a real app
|
||||
pebbleIoThread.installApp(uri, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user