mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Moyoung: Fixes for settings, sync, logging, weather, live activity
This commit is contained in:
parent
33664d1e83
commit
b8d036c6bc
@ -105,6 +105,11 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractDeviceCoo
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSpo2(GBDevice device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
return new MoyoungActivitySampleProvider(device, session);
|
||||
@ -185,7 +190,6 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractDeviceCoo
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_personalinfo,
|
||||
//R.xml.devicesettings_steplength, // TODO is this needed? does it work? write-only so hard to tell
|
||||
R.xml.devicesettings_moyoung_device_version,
|
||||
R.xml.devicesettings_moyoung_language,
|
||||
@ -195,8 +199,9 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractDeviceCoo
|
||||
//R.xml.devicesettings_moyoung_othermessage, // not implemented because this doesn't really do anything on the watch side, only enables/disables sending of "other" notifications in the app (no idea why they store the setting on the watch)
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_moyoung_sedentary_reminder,
|
||||
R.xml.devicesettings_donotdisturb_no_auto_v2,
|
||||
R.xml.devicesettings_donotdisturb_no_auto,
|
||||
//R.xml.devicesettings_moyoung_breathinglight, // No idea what this does but it doesn't seem to change anything
|
||||
R.xml.devicesettings_world_clocks,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -267,6 +267,8 @@ public class MoyoungConstants {
|
||||
public static final byte CMD_QUERY_BREATHING_LIGHT = -120; // {} -> {value}
|
||||
public static final byte CMD_SET_BREATHING_LIGHT = 120; // {enabled ? 1 : 0}
|
||||
|
||||
public static final byte CMD_QUERY_STOCKS = (byte) 0xb9;
|
||||
public static final byte CMD_DAGPT = (byte) 0xbb;
|
||||
|
||||
public static final byte TRAINING_TYPE_WALK = 0;
|
||||
public static final byte TRAINING_TYPE_RUN = 1;
|
||||
|
@ -185,7 +185,7 @@ public class FetchDataOperation extends AbstractBTLEOperation<MoyoungDeviceSuppo
|
||||
private void updateProgressAndCheckFinish()
|
||||
{
|
||||
int count = 0;
|
||||
int total = receivedSteps.length + receivedSleep.length + 1;
|
||||
int total = receivedSteps.length + receivedSleep.length;
|
||||
for(int i = 0; i < receivedSteps.length; i++)
|
||||
if (receivedSteps[i])
|
||||
++count;
|
||||
@ -195,6 +195,7 @@ public class FetchDataOperation extends AbstractBTLEOperation<MoyoungDeviceSuppo
|
||||
if (receivedTrainingData)
|
||||
++count;
|
||||
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 100 * count / total, getContext());
|
||||
LOG.debug("Fetching activity data status: {} out of {}", count, total);
|
||||
if (count == total)
|
||||
operationFinished();
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
byte packetType = packet.first;
|
||||
byte[] payload = packet.second;
|
||||
|
||||
LOG.info("Response for: " + packetType);
|
||||
LOG.info("Response for: " + Logging.formatBytes(new byte[]{packetType}));
|
||||
|
||||
if (handlePacket(packetType, payload))
|
||||
return true;
|
||||
@ -253,7 +253,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setUserId(userId);
|
||||
|
||||
sampleProvider.addSample(sample);
|
||||
// broadcastSample(sample);
|
||||
broadcastSample(sample);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error acquiring database for recording heart rate samples", e);
|
||||
}
|
||||
@ -362,6 +362,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW)
|
||||
{
|
||||
// TODO: trigger camera photo
|
||||
LOG.info("Camera shutter triggered from watch");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -389,7 +390,31 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG.warn("Unhandled packet " + packetType + ": " + Logging.formatBytes(payload));
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_DISPLAY_WATCH_FACE)
|
||||
{
|
||||
LOG.info("Watchface changed on watch to nr {}", payload[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_STOCKS)
|
||||
{
|
||||
LOG.info("Stocks queried from watch");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (packetType == MoyoungConstants.CMD_DAGPT)
|
||||
{
|
||||
LOG.info("Da GPT started on watch");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (packetType == MoyoungConstants.CMD_FIND_MY_PHONE)
|
||||
{
|
||||
LOG.info("Find my phone started on watch");
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG.warn("Unhandled packet " + Logging.formatBytes(new byte[]{packetType}) + ": " + Logging.formatBytes(payload));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -424,6 +449,16 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void broadcastSample(MoyoungHeartRateSample sample) {
|
||||
MoyoungActivitySample genericSample = new MoyoungActivitySample();
|
||||
genericSample.setTimestamp((int) (sample.getTimestamp() / 1000));
|
||||
genericSample.setHeartRate(sample.getHeartRate());
|
||||
Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES)
|
||||
.putExtra(DeviceService.EXTRA_REALTIME_SAMPLE, genericSample)
|
||||
.putExtra(DeviceService.EXTRA_TIMESTAMP, genericSample.getTimestamp());
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void handleDeviceInfo(DeviceInfo info) {
|
||||
LOG.warn("Device info: " + info);
|
||||
versionCmd.hwVersion = info.getHardwareRevision();
|
||||
@ -1452,8 +1487,8 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
packetWeatherToday.put(weatherToday.city.getBytes("unicodebigunmarked"));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_WEATHER_TODAY, packetWeatherToday.array()));
|
||||
|
||||
ByteBuffer packetWeatherForecast = ByteBuffer.allocate(7 * 3);
|
||||
for(int i = 0; i < 7; i++)
|
||||
ByteBuffer packetWeatherForecast = ByteBuffer.allocate(6 * 3);
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
MoyoungWeatherForecast forecast;
|
||||
if (weatherSpec.forecasts.size() > i)
|
||||
|
@ -2638,12 +2638,26 @@
|
||||
<item>Watch face 1</item>
|
||||
<item>Watch face 2</item>
|
||||
<item>Watch face 3</item>
|
||||
<item>Watch face 4</item>
|
||||
<item>Watch face 5</item>
|
||||
<item>Watch face 6</item>
|
||||
<item>Watch face 7</item>
|
||||
<item>Watch face 8</item>
|
||||
<item>Watch face 9</item>
|
||||
<item>Watch face 10</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_moyoung_watch_face_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_moyoung_device_version">
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- FIXME: A better version of _no_auto because the other one changes the IDs so the change notification does not work... -->
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_block"
|
||||
android:key="screen_do_not_disturb"
|
||||
android:persistent="false"
|
||||
android:summary="@string/mi2_prefs_do_not_disturb_summary"
|
||||
android:title="@string/mi2_prefs_do_not_disturb">
|
||||
|
||||
<!-- workaround for missing toolbar -->
|
||||
<PreferenceCategory android:title="@string/mi2_prefs_do_not_disturb" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XListPreference
|
||||
android:defaultValue="@string/p_off"
|
||||
android:entries="@array/do_not_disturb_no_auto"
|
||||
android:entryValues="@array/do_not_disturb_no_auto_values"
|
||||
android:key="do_not_disturb"
|
||||
android:summary="%s"
|
||||
android:title="@string/mi2_prefs_do_not_disturb" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="01:00"
|
||||
android:key="do_not_disturb_start"
|
||||
android:dependency="do_not_disturb"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="06:00"
|
||||
android:key="do_not_disturb_end"
|
||||
android:dependency="do_not_disturb"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
@ -7,10 +7,7 @@
|
||||
android:persistent="false"
|
||||
android:title="@string/pref_sedentary_reminder">
|
||||
|
||||
<!-- workaround for missing toolbar -->
|
||||
<PreferenceCategory android:title="@string/pref_sedentary_reminder" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XListPreference
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_off"
|
||||
android:entries="@array/sedentary_reminder"
|
||||
android:entryValues="@array/sedentary_reminder_values"
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference
|
||||
android:icon="@drawable/ic_person"
|
||||
android:key="personal_info"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
<intent
|
||||
android:targetPackage="nodomain.freeyourgadget.gadgetbridge"
|
||||
android:targetClass="nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity" />
|
||||
<!-- TODO: link this to proper subscreen -->
|
||||
</Preference>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user