diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6cafeebdd..7df4110df 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="nodomain.freeyourgadget.gadgetbridge"> - - + android:theme="@style/GadgetbridgeTheme"> + android:label="@string/title_activity_controlcenter"> @@ -44,35 +40,35 @@ + android:label="@string/title_activity_settings"> + android:label="@string/preferences_miband_settings"> + android:label="@string/title_activity_appmanager"> + android:label="@string/title_activity_sleepmonitor"> + android:label="@string/title_activity_appinstaller"> @@ -92,7 +88,7 @@ + android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> @@ -101,7 +97,7 @@ + android:enabled="false"> @@ -111,14 +107,14 @@ + android:enabled="false"> + android:enabled="false"> @@ -126,7 +122,7 @@ + android:enabled="false"> @@ -135,14 +131,14 @@ + android:enabled="false"> + android:enabled="false"> @@ -150,21 +146,21 @@ + android:exported="false"> + android:exported="false"> + android:exported="false"> @@ -172,30 +168,28 @@ + android:label="@string/title_activity_debug"> + android:label="@string/title_activity_discovery"> - + android:label="@string/title_activity_android_pairing"> - + android:label="@string/title_activity_mi_band_pairing"> + android:parentActivityName=".ControlCenter"> diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java index d8ea32288..29d4ffeb8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/AbstractBTDeviceSupport.java @@ -167,4 +167,10 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport { byte[] bytes = gbDeviceProtocol.encodeFindDevice(start); sendToDevice(bytes); } + + @Override + public void onScreenshotReq() { + byte[] bytes = gbDeviceProtocol.encodeScreenshotReq(); + sendToDevice(bytes); + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java index 52da0a439..e4d39b00e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java @@ -30,8 +30,6 @@ import nodomain.freeyourgadget.gadgetbridge.pebble.PebbleSupport; public class BluetoothCommunicationService extends Service { public static final String ACTION_START = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.start"; - public static final String ACTION_PAIR - = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.pair"; public static final String ACTION_CONNECT = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.connect"; public static final String ACTION_NOTIFICATION_GENERIC @@ -50,6 +48,8 @@ public class BluetoothCommunicationService extends Service { = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.request_versioninfo"; public static final String ACTION_REQUEST_APPINFO = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.request_appinfo"; + public static final String ACTION_REQUEST_SCREENSHOT + = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.request_screenshot"; public static final String ACTION_STARTAPP = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.startapp"; public static final String ACTION_DELETEAPP @@ -243,6 +243,9 @@ public class BluetoothCommunicationService extends Service { case ACTION_REQUEST_APPINFO: mDeviceSupport.onAppInfoReq(); break; + case ACTION_REQUEST_SCREENSHOT: + mDeviceSupport.onScreenshotReq(); + break; case ACTION_STARTAPP: UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid")); mDeviceSupport.onAppStart(uuid); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java index a78a8a8a5..c2f332782 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java @@ -176,6 +176,10 @@ public class ControlCenter extends Activity { menu.removeItem(R.id.controlcenter_fetch_activity_data); } + if (!selectedDevice.isConnected() || selectedDevice.getType() == DeviceType.MIBAND) { + menu.removeItem(R.id.controlcenter_take_screenshot); + } + if (!selectedDevice.isConnected()) { menu.removeItem(R.id.controlcenter_disconnect); menu.removeItem(R.id.controlcenter_find_device); @@ -214,7 +218,7 @@ public class ControlCenter extends Activity { case R.id.controlcenter_find_device: if (selectedDevice != null) { findDevice(true); - ProgressDialog dialog = ProgressDialog.show( + ProgressDialog.show( this, getString(R.string.control_center_find_lost_device), getString(R.string.control_center_cancel_to_stop_vibration), @@ -226,6 +230,14 @@ public class ControlCenter extends Activity { } }); } + return true; + case R.id.controlcenter_take_screenshot: + if (selectedDevice != null) { + Intent startIntent = new Intent(this, BluetoothCommunicationService.class); + startIntent.setAction(BluetoothCommunicationService.ACTION_REQUEST_SCREENSHOT); + startService(startIntent); + } + return true; default: return super.onContextItemSelected(item); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java index 8dbcf63c6..3f4e76533 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/EventHandler.java @@ -36,4 +36,6 @@ public interface EventHandler { void onReboot(); void onFindDevice(boolean start); + + void onScreenshotReq(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ServiceDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ServiceDeviceSupport.java index 1574a5d79..9a17893b8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ServiceDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ServiceDeviceSupport.java @@ -218,4 +218,12 @@ public class ServiceDeviceSupport implements DeviceSupport { } delegate.onFindDevice(start); } + + @Override + public void onScreenshotReq() { + if (checkBusy("request screenshot")) { + return; + } + delegate.onScreenshotReq(); + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java index 5ada8a408..40a03fb27 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java @@ -490,6 +490,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { // not supported } + @Override + public void onScreenshotReq() { + // not supported + } + @Override public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java index 1e3b34a77..84881f95c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java @@ -112,11 +112,13 @@ public class PebbleProtocol extends GBDeviceProtocol { static final byte PUTBYTES_TYPE_FILE = 6; public static final byte PUTBYTES_TYPE_WORKER = 7; - public static final byte RESET_REBOOT = 0; + static final byte RESET_REBOOT = 0; - private final byte SYSTEMMESSAGE_FIRMWARESTART = 1; - private final byte SYSTEMMESSAGE_FIRMWARECOMPLETE = 2; - private final byte SYSTEMMESSAGE_FIRMWAREFAIL = 3; + static final byte SCREENSHOT_TAKE = 0; + + static final byte SYSTEMMESSAGE_FIRMWARESTART = 1; + static final byte SYSTEMMESSAGE_FIRMWARECOMPLETE = 2; + static final byte SYSTEMMESSAGE_FIRMWAREFAIL = 3; static final byte PHONEVERSION_REQUEST = 0; static final byte PHONEVERSION_APPVERSION_MAGIC = 2; // increase this if pebble complains @@ -529,6 +531,11 @@ public class PebbleProtocol extends GBDeviceProtocol { return encodeSimpleMessage(ENDPOINT_RESET, RESET_REBOOT); } + @Override + public byte[] encodeScreenshotReq() { + return encodeSimpleMessage( ENDPOINT_SCREENSHOT, SCREENSHOT_TAKE ); + } + /* pebble specific install methods */ public byte[] encodeUploadStart(byte type, byte index, int size) { ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_UPLOADSTART); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java index 7370caa73..86c990afc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/GBDeviceProtocol.java @@ -43,6 +43,10 @@ public abstract class GBDeviceProtocol { return null; } + public byte[] encodeScreenshotReq() { + return null; + } + public byte[] encodeAppDelete(UUID uuid) { return null; } diff --git a/app/src/main/res/menu/controlcenter_context.xml b/app/src/main/res/menu/controlcenter_context.xml index cbfd60100..4002869d4 100644 --- a/app/src/main/res/menu/controlcenter_context.xml +++ b/app/src/main/res/menu/controlcenter_context.xml @@ -8,7 +8,10 @@ android:title="@string/controlcenter_start_sleepmonitor"/> + android:title="@string/controlcenter_find_device"/> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c1561ae8..e9bfccd75 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,7 +6,11 @@ Settings Debug Quit + Fetch Activity Data Sleep Monitor (ALPHA) + Find Device… + Take Screenshot + Disconnect Debug @@ -113,8 +117,6 @@ Write Log Files (needs restart) initializing Fetching Activity Data - Fetch Activity Data - Disconnect From %1$s to %2$s Wearing left or right? Vibration Profile @@ -133,15 +135,8 @@ Pebble Notification K9 Mail Notification Incoming Call Notification - Find Device… Find lost Device Cancel to stop vibration. ChartsActivity - Section 1 - Section 2 - Section 3 - - Hello world! -