1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nodomain.freeyourgadget.gadgetbridge" > package="nodomain.freeyourgadget.gadgetbridge">
<uses-sdk <uses-sdk
android:minSdkVersion="19" android:minSdkVersion="19"
@ -23,19 +23,15 @@
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"
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/GadgetbridgeTheme" > android:theme="@style/GadgetbridgeTheme">
<activity <activity
android:name=".ControlCenter" android:name=".ControlCenter"
android:label="@string/title_activity_controlcenter" > android:label="@string/title_activity_controlcenter">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -44,35 +40,35 @@
</activity> </activity>
<activity <activity
android:name=".SettingsActivity" android:name=".SettingsActivity"
android:label="@string/title_activity_settings" > android:label="@string/title_activity_settings">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ControlCenter" /> android:value=".ControlCenter" />
</activity> </activity>
<activity <activity
android:name=".miband.MiBandPreferencesActivity" android:name=".miband.MiBandPreferencesActivity"
android:label="@string/preferences_miband_settings" > android:label="@string/preferences_miband_settings">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".SettingsActivity" /> android:value=".SettingsActivity" />
</activity> </activity>
<activity <activity
android:name=".AppManagerActivity" android:name=".AppManagerActivity"
android:label="@string/title_activity_appmanager" > android:label="@string/title_activity_appmanager">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ControlCenter" /> android:value=".ControlCenter" />
</activity> </activity>
<activity <activity
android:name=".activities.SleepChartActivity" android:name=".activities.SleepChartActivity"
android:label="@string/title_activity_sleepmonitor" > android:label="@string/title_activity_sleepmonitor">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ControlCenter" /> android:value=".ControlCenter" />
</activity> </activity>
<activity <activity
android:name=".pebble.PebbleAppInstallerActivity" android:name=".pebble.PebbleAppInstallerActivity"
android:label="@string/title_activity_appinstaller" > android:label="@string/title_activity_appinstaller">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".AppManagerActivity" /> android:value=".AppManagerActivity" />
@ -92,7 +88,7 @@
<service <service
android:name=".externalevents.NotificationListener" android:name=".externalevents.NotificationListener"
android:label="@string/app_name" android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter> <intent-filter>
<action android:name="android.service.notification.NotificationListenerService" /> <action android:name="android.service.notification.NotificationListenerService" />
</intent-filter> </intent-filter>
@ -101,7 +97,7 @@
<receiver <receiver
android:name=".externalevents.PhoneCallReceiver" android:name=".externalevents.PhoneCallReceiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.PHONE_STATE" /> <action android:name="android.intent.action.PHONE_STATE" />
</intent-filter> </intent-filter>
@ -111,14 +107,14 @@
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.SMSReceiver" android:name=".externalevents.SMSReceiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" /> <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.TimeChangeReceiver" android:name=".externalevents.TimeChangeReceiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" /> <action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.TIME_SET" /> <action android:name="android.intent.action.TIME_SET" />
@ -126,7 +122,7 @@
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.K9Receiver" android:name=".externalevents.K9Receiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<data android:scheme="email" /> <data android:scheme="email" />
@ -135,14 +131,14 @@
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.PebbleReceiver" android:name=".externalevents.PebbleReceiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<action android:name="com.getpebble.action.SEND_NOTIFICATION" /> <action android:name="com.getpebble.action.SEND_NOTIFICATION" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.MusicPlaybackReceiver" android:name=".externalevents.MusicPlaybackReceiver"
android:enabled="false" > android:enabled="false">
<intent-filter> <intent-filter>
<action android:name="com.andrew.apollo.metachanged" /> <action android:name="com.andrew.apollo.metachanged" />
<action android:name="com.cyanogenmod.eleven.metachanged" /> <action android:name="com.cyanogenmod.eleven.metachanged" />
@ -150,21 +146,21 @@
</receiver> </receiver>
<receiver <receiver
android:name=".externalevents.BluetoothStateChangeReceiver" android:name=".externalevents.BluetoothStateChangeReceiver"
android:exported="false" > android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" /> <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".GBMusicControlReceiver" android:name=".GBMusicControlReceiver"
android:exported="false" > android:exported="false">
<intent-filter> <intent-filter>
<action android:name="nodomain.freeyourgadget.gadgetbridge.musiccontrol" /> <action android:name="nodomain.freeyourgadget.gadgetbridge.musiccontrol" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".GBCallControlReceiver" android:name=".GBCallControlReceiver"
android:exported="false" > android:exported="false">
<intent-filter> <intent-filter>
<action android:name="nodomain.freeyourgadget.gadgetbridge.callcontrol" /> <action android:name="nodomain.freeyourgadget.gadgetbridge.callcontrol" />
</intent-filter> </intent-filter>
@ -172,30 +168,28 @@
<activity <activity
android:name=".DebugActivity" android:name=".DebugActivity"
android:label="@string/title_activity_debug" > android:label="@string/title_activity_debug">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ControlCenter" /> android:value=".ControlCenter" />
</activity> </activity>
<activity <activity
android:name=".discovery.DiscoveryActivity" android:name=".discovery.DiscoveryActivity"
android:label="@string/title_activity_discovery" > android:label="@string/title_activity_discovery">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ControlCenter" /> android:value=".ControlCenter" />
</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"
android:parentActivityName=".ControlCenter" > android:parentActivityName=".ControlCenter">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="nodomain.freeyourgadget.gadgetbridge.ControlCenter" /> android:value="nodomain.freeyourgadget.gadgetbridge.ControlCenter" />

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>