1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

Bangle.js: Add screenshot support

This commit is contained in:
José Rebelo 2024-03-17 14:47:21 +00:00 committed by José Rebelo
parent 705651e5f6
commit 1e2a561dfd
56 changed files with 73 additions and 57 deletions

View File

@ -443,7 +443,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
//take screenshot
holder.takeScreenshotView.setVisibility((device.isInitialized() && coordinator.supportsScreenshots()) ? View.VISIBLE : View.GONE);
holder.takeScreenshotView.setVisibility((device.isInitialized() && coordinator.supportsScreenshots(device)) ? View.VISIBLE : View.GONE);
holder.takeScreenshotView.setOnClickListener(new View.OnClickListener()
{

View File

@ -310,7 +310,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -332,7 +332,7 @@ public interface DeviceCoordinator {
*
* @return
*/
boolean supportsScreenshots();
boolean supportsScreenshots(GBDevice device);
/**
* Returns the number of alarms this device/coordinator supports

View File

@ -142,7 +142,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -147,7 +147,7 @@ public class AsteroidOSDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -113,8 +113,8 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
return false;
public boolean supportsScreenshots(final GBDevice device) {
return device.getModel() != null && device.getModel().equals("2");
}
@Override

View File

@ -109,7 +109,7 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -102,7 +102,7 @@ public class CasioGB6900DeviceCoordinator extends CasioDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -133,7 +133,7 @@ public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -111,7 +111,7 @@ public class CasioGWB5600DeviceCoordinator extends CasioDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -71,7 +71,7 @@ public class DomyosT540Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -96,7 +96,7 @@ public class FitProDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -81,7 +81,7 @@ public class FlipperZeroCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -71,7 +71,7 @@ public abstract class GalaxyBudsGenericCoordinator extends AbstractBLClassicDevi
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -127,7 +127,7 @@ public class HPlusCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -526,7 +526,7 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -55,7 +55,7 @@ public class MiBand7Coordinator extends ZeppOsCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -126,7 +126,7 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return true;
}

View File

@ -107,7 +107,7 @@ public abstract class HuaweiBRCoordinator extends AbstractBLClassicDeviceCoordin
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -107,7 +107,7 @@ public abstract class HuaweiLECoordinator extends AbstractBLEDeviceCoordinator i
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -96,7 +96,7 @@ public class ID115Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -93,7 +93,7 @@ public class ITagCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -184,7 +184,7 @@ public class BFH16DeviceCoordinator extends AbstractBLEDeviceCoordinator
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -131,7 +131,7 @@ public class TeclastH30Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -82,7 +82,7 @@ public class Y5Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -99,7 +99,7 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -131,7 +131,7 @@ public class WatchXPlusDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -71,7 +71,7 @@ public class LiveviewCoordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -214,7 +214,7 @@ public class MakibesHR3Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -129,7 +129,7 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -106,7 +106,7 @@ public class MiScale2DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -92,7 +92,7 @@ public class No1F1Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -100,7 +100,7 @@ public class NutCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -117,7 +117,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return true;
}

View File

@ -75,7 +75,7 @@ public class PineTimeJFCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -90,7 +90,7 @@ public class QC35Coordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -127,7 +127,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
public boolean supportsFlashing() { return false; }
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -80,7 +80,7 @@ public abstract class RoidmiCoordinator extends AbstractBLClassicDeviceCoordinat
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -98,7 +98,7 @@ public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -70,7 +70,7 @@ public class SoFlowCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -94,7 +94,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -203,7 +203,7 @@ public class SonyWena3Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -83,7 +83,7 @@ public class SonySWR12DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -104,7 +104,7 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -197,7 +197,7 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return supports(getTestDevice(), TestFeature.SCREENSHOTS);
}

View File

@ -79,7 +79,7 @@ public class TLW64Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -109,7 +109,7 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -116,7 +116,7 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -72,7 +72,7 @@ public class VibratissimoCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -85,7 +85,7 @@ public class VivomoveHrCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -100,7 +100,7 @@ public class WaspOSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -107,7 +107,7 @@ public class Watch9DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -111,7 +111,7 @@ public class WithingsSteelHRDeviceCoordinator extends AbstractDeviceCoordinator
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -78,7 +78,7 @@ public class XWatchCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -60,7 +60,7 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public boolean supportsScreenshots() {
public boolean supportsScreenshots(final GBDevice device) {
return false;
}

View File

@ -109,6 +109,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicContr
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
import nodomain.freeyourgadget.gadgetbridge.devices.banglejs.BangleJSConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.banglejs.BangleJSSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.BangleJSActivitySample;
@ -509,7 +510,11 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
LOG.error("UART RX JSON parse failure: "+ e.getLocalizedMessage());
GB.toast(getContext(), "Malformed JSON from Bangle.js: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
}
} else if (line.startsWith("data:image/bmp;base64,")) {
LOG.debug("Got screenshot bmp");
final byte[] screenshotBytes = Base64.decode(line.substring(21), Base64.DEFAULT);
final GBDeviceEventScreenshot gbDeviceEventScreenshot = new GBDeviceEventScreenshot(screenshotBytes);
evaluateGBDeviceEvent(gbDeviceEventScreenshot);
} else {
LOG.info("UART RX line started with "+(int)line.charAt(0)+" - ignoring");
}
@ -1520,6 +1525,17 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
}
}
@Override
public void onScreenshotReq() {
try {
final TransactionBuilder builder = performInitialized("screenshot");
uartTx(builder, "\u0010g.dump()\n");
builder.queue(getQueue());
} catch (final IOException e) {
GB.toast(getContext(), "Failed to get screenshot: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
}
}
@Override
public void onSetHeartRateMeasurementInterval(int seconds) {
realtimeHRMInterval = seconds;