1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 11:26:47 +01:00

Pebble: Preparations for taking screenshots

This commit also includes some cleanups and removal of unused code/strings
This commit is contained in:
Andreas Shimokawa 2015-06-24 00:23:38 +02:00
parent 4b241ca9eb
commit 07d59322bd
11 changed files with 85 additions and 46 deletions

View File

@ -23,10 +23,6 @@
android:name="android.hardware.bluetooth_le" android:name="android.hardware.bluetooth_le"
android:required="false" /> android:required="false" />
<android:uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<application <application
android:name=".GBApplication" android:name=".GBApplication"
android:allowBackup="true" android:allowBackup="true"
@ -186,12 +182,10 @@
</activity> </activity>
<activity <activity
android:name=".activities.AndroidPairingActivity" android:name=".activities.AndroidPairingActivity"
android:label="@string/title_activity_android_pairing" > android:label="@string/title_activity_android_pairing"></activity>
</activity>
<activity <activity
android:name=".miband.MiBandPairingActivity" android:name=".miband.MiBandPairingActivity"
android:label="@string/title_activity_mi_band_pairing" > android:label="@string/title_activity_mi_band_pairing"></activity>
</activity>
<activity <activity
android:name=".activities.ChartsActivity" android:name=".activities.ChartsActivity"
android:label="@string/title_activity_charts" android:label="@string/title_activity_charts"

View File

@ -167,4 +167,10 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
byte[] bytes = gbDeviceProtocol.encodeFindDevice(start); byte[] bytes = gbDeviceProtocol.encodeFindDevice(start);
sendToDevice(bytes); sendToDevice(bytes);
} }
@Override
public void onScreenshotReq() {
byte[] bytes = gbDeviceProtocol.encodeScreenshotReq();
sendToDevice(bytes);
}
} }

View File

@ -30,8 +30,6 @@ import nodomain.freeyourgadget.gadgetbridge.pebble.PebbleSupport;
public class BluetoothCommunicationService extends Service { public class BluetoothCommunicationService extends Service {
public static final String ACTION_START public static final String ACTION_START
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.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 public static final String ACTION_CONNECT
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.connect"; = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.connect";
public static final String ACTION_NOTIFICATION_GENERIC public static final String ACTION_NOTIFICATION_GENERIC
@ -50,6 +48,8 @@ public class BluetoothCommunicationService extends Service {
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.request_versioninfo"; = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.request_versioninfo";
public static final String ACTION_REQUEST_APPINFO public static final String ACTION_REQUEST_APPINFO
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.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 public static final String ACTION_STARTAPP
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.startapp"; = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.startapp";
public static final String ACTION_DELETEAPP public static final String ACTION_DELETEAPP
@ -243,6 +243,9 @@ public class BluetoothCommunicationService extends Service {
case ACTION_REQUEST_APPINFO: case ACTION_REQUEST_APPINFO:
mDeviceSupport.onAppInfoReq(); mDeviceSupport.onAppInfoReq();
break; break;
case ACTION_REQUEST_SCREENSHOT:
mDeviceSupport.onScreenshotReq();
break;
case ACTION_STARTAPP: case ACTION_STARTAPP:
UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid")); UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid"));
mDeviceSupport.onAppStart(uuid); mDeviceSupport.onAppStart(uuid);

View File

@ -176,6 +176,10 @@ public class ControlCenter extends Activity {
menu.removeItem(R.id.controlcenter_fetch_activity_data); 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()) { if (!selectedDevice.isConnected()) {
menu.removeItem(R.id.controlcenter_disconnect); menu.removeItem(R.id.controlcenter_disconnect);
menu.removeItem(R.id.controlcenter_find_device); menu.removeItem(R.id.controlcenter_find_device);
@ -214,7 +218,7 @@ public class ControlCenter extends Activity {
case R.id.controlcenter_find_device: case R.id.controlcenter_find_device:
if (selectedDevice != null) { if (selectedDevice != null) {
findDevice(true); findDevice(true);
ProgressDialog dialog = ProgressDialog.show( ProgressDialog.show(
this, this,
getString(R.string.control_center_find_lost_device), getString(R.string.control_center_find_lost_device),
getString(R.string.control_center_cancel_to_stop_vibration), 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: default:
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
} }

View File

@ -36,4 +36,6 @@ public interface EventHandler {
void onReboot(); void onReboot();
void onFindDevice(boolean start); void onFindDevice(boolean start);
void onScreenshotReq();
} }

View File

@ -218,4 +218,12 @@ public class ServiceDeviceSupport implements DeviceSupport {
} }
delegate.onFindDevice(start); delegate.onFindDevice(start);
} }
@Override
public void onScreenshotReq() {
if (checkBusy("request screenshot")) {
return;
}
delegate.onScreenshotReq();
}
} }

View File

@ -490,6 +490,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
// not supported // not supported
} }
@Override
public void onScreenshotReq() {
// not supported
}
@Override @Override
public void onCharacteristicChanged(BluetoothGatt gatt, public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) { BluetoothGattCharacteristic characteristic) {

View File

@ -112,11 +112,13 @@ public class PebbleProtocol extends GBDeviceProtocol {
static final byte PUTBYTES_TYPE_FILE = 6; static final byte PUTBYTES_TYPE_FILE = 6;
public static final byte PUTBYTES_TYPE_WORKER = 7; 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; static final byte SCREENSHOT_TAKE = 0;
private final byte SYSTEMMESSAGE_FIRMWARECOMPLETE = 2;
private final byte SYSTEMMESSAGE_FIRMWAREFAIL = 3; 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_REQUEST = 0;
static final byte PHONEVERSION_APPVERSION_MAGIC = 2; // increase this if pebble complains 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); return encodeSimpleMessage(ENDPOINT_RESET, RESET_REBOOT);
} }
@Override
public byte[] encodeScreenshotReq() {
return encodeSimpleMessage( ENDPOINT_SCREENSHOT, SCREENSHOT_TAKE );
}
/* pebble specific install methods */ /* pebble specific install methods */
public byte[] encodeUploadStart(byte type, byte index, int size) { public byte[] encodeUploadStart(byte type, byte index, int size) {
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_UPLOADSTART); ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_UPLOADSTART);

View File

@ -43,6 +43,10 @@ public abstract class GBDeviceProtocol {
return null; return null;
} }
public byte[] encodeScreenshotReq() {
return null;
}
public byte[] encodeAppDelete(UUID uuid) { public byte[] encodeAppDelete(UUID uuid) {
return null; return null;
} }

View File

@ -8,7 +8,10 @@
android:title="@string/controlcenter_start_sleepmonitor"/> android:title="@string/controlcenter_start_sleepmonitor"/>
<item <item
android:id="@+id/controlcenter_find_device" android:id="@+id/controlcenter_find_device"
android:title="@string/control_center_find_device"/> android:title="@string/controlcenter_find_device"/>
<item
android:id="@+id/controlcenter_take_screenshot"
android:title="@string/controlcenter_take_screenshot"/>
<item <item
android:id="@+id/controlcenter_disconnect" android:id="@+id/controlcenter_disconnect"
android:title="@string/controlcenter_disconnect"/> android:title="@string/controlcenter_disconnect"/>

View File

@ -6,7 +6,11 @@
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_debug">Debug</string> <string name="action_debug">Debug</string>
<string name="action_quit">Quit</string> <string name="action_quit">Quit</string>
<string name="controlcenter_fetch_activity_data">Fetch Activity Data</string>
<string name="controlcenter_start_sleepmonitor">Sleep Monitor (ALPHA)</string> <string name="controlcenter_start_sleepmonitor">Sleep Monitor (ALPHA)</string>
<string name="controlcenter_find_device">Find Device…</string>
<string name="controlcenter_take_screenshot">Take Screenshot</string>
<string name="controlcenter_disconnect">Disconnect</string>
<string name="title_activity_debug">Debug</string> <string name="title_activity_debug">Debug</string>
@ -113,8 +117,6 @@
<string name="pref_write_logfiles">Write Log Files (needs restart)</string> <string name="pref_write_logfiles">Write Log Files (needs restart)</string>
<string name="initializing">initializing</string> <string name="initializing">initializing</string>
<string name="busy_task_fetch_activity_data">Fetching Activity Data</string> <string name="busy_task_fetch_activity_data">Fetching Activity Data</string>
<string name="controlcenter_fetch_activity_data">Fetch Activity Data</string>
<string name="controlcenter_disconnect">Disconnect</string>
<string name="sleep_activity_date_range">From %1$s to %2$s</string> <string name="sleep_activity_date_range">From %1$s to %2$s</string>
<string name="miband_prefs_wearside">Wearing left or right?</string> <string name="miband_prefs_wearside">Wearing left or right?</string>
<string name="pref_screen_vibration_profile">Vibration Profile</string> <string name="pref_screen_vibration_profile">Vibration Profile</string>
@ -133,15 +135,8 @@
<string name="pref_screen_notification_profile_pebblemsg">Pebble Notification</string> <string name="pref_screen_notification_profile_pebblemsg">Pebble Notification</string>
<string name="pref_screen_notification_profile_k9mail">K9 Mail Notification</string> <string name="pref_screen_notification_profile_k9mail">K9 Mail Notification</string>
<string name="pref_screen_notification_profile_incoming_call">Incoming Call Notification</string> <string name="pref_screen_notification_profile_incoming_call">Incoming Call Notification</string>
<string name="control_center_find_device">Find Device…</string>
<string name="control_center_find_lost_device">Find lost Device</string> <string name="control_center_find_lost_device">Find lost Device</string>
<string name="control_center_cancel_to_stop_vibration">Cancel to stop vibration.</string> <string name="control_center_cancel_to_stop_vibration">Cancel to stop vibration.</string>
<string name="title_activity_charts">ChartsActivity</string> <string name="title_activity_charts">ChartsActivity</string>
<string name="title_section1">Section 1</string>
<string name="title_section2">Section 2</string>
<string name="title_section3">Section 3</string>
<string name="hello_world">Hello world!</string>
</resources> </resources>