1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 08:52:58 +01:00

Send out SMS when replying with a canned response

Closes #121
This commit is contained in:
Andreas Shimokawa 2015-12-15 00:26:06 +01:00
parent 3961e32c2b
commit dfa85745e8
4 changed files with 31 additions and 27 deletions

View File

@ -1,6 +1,7 @@
###Changelog ###Changelog
####Next Version ####Next Version
* Pebble: Support replying to SMS form the watch (canned replies)
* Pebble: Allow installing apps compiled with SDK 2.x also on the basalt platform (Time, Time Steel) * Pebble: Allow installing apps compiled with SDK 2.x also on the basalt platform (Time, Time Steel)
* Pebble: Fix decoding strings in appmessages from the pebble (fixes sending SMS from "Dialer for Pebble") * Pebble: Fix decoding strings in appmessages from the pebble (fixes sending SMS from "Dialer for Pebble")
* Some new and updated icons * Some new and updated icons

View File

@ -2,16 +2,17 @@
<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">
<!-- <!--
Comment in for testing Pebble Emulator Comment in for testing Pebble Emulator
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
--> -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.fsck.k9.permission.READ_MESSAGES" /> <uses-permission android:name="com.fsck.k9.permission.READ_MESSAGES" />
@ -46,23 +47,19 @@
<activity <activity
android:name=".activities.SettingsActivity" android:name=".activities.SettingsActivity"
android:label="@string/title_activity_settings" android:label="@string/title_activity_settings"
android:parentActivityName=".activities.ControlCenter"> android:parentActivityName=".activities.ControlCenter"></activity>
</activity>
<activity <activity
android:name=".devices.miband.MiBandPreferencesActivity" android:name=".devices.miband.MiBandPreferencesActivity"
android:label="@string/preferences_miband_settings" android:label="@string/preferences_miband_settings"
android:parentActivityName=".activities.SettingsActivity"> android:parentActivityName=".activities.SettingsActivity"></activity>
</activity>
<activity <activity
android:name=".activities.AppManagerActivity" android:name=".activities.AppManagerActivity"
android:label="@string/title_activity_appmanager" android:label="@string/title_activity_appmanager"
android:parentActivityName=".activities.ControlCenter"> android:parentActivityName=".activities.ControlCenter"></activity>
</activity>
<activity <activity
android:name=".activities.AppBlacklistActivity" android:name=".activities.AppBlacklistActivity"
android:label="@string/title_activity_appblacklist" android:label="@string/title_activity_appblacklist"
android:parentActivityName=".activities.SettingsActivity"> android:parentActivityName=".activities.SettingsActivity"></activity>
</activity>
<activity <activity
android:name=".activities.FwAppInstallerActivity" android:name=".activities.FwAppInstallerActivity"
android:label="@string/title_activity_fw_app_insaller" android:label="@string/title_activity_fw_app_insaller"
@ -197,7 +194,8 @@
</intent-filter> </intent-filter>
</service> </service>
<service android:name=".service.DeviceCommunicationService" /> <service android:name=".service.DeviceCommunicationService" />
<receiver
<receiver
android:name=".externalevents.BluetoothStateChangeReceiver" android:name=".externalevents.BluetoothStateChangeReceiver"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
@ -223,13 +221,11 @@
android:name=".activities.DebugActivity" android:name=".activities.DebugActivity"
android:label="@string/title_activity_debug" android:label="@string/title_activity_debug"
android:parentActivityName=".activities.ControlCenter" android:parentActivityName=".activities.ControlCenter"
android:windowSoftInputMode="stateHidden"> android:windowSoftInputMode="stateHidden"></activity>
</activity>
<activity <activity
android:name=".activities.DiscoveryActivity" android:name=".activities.DiscoveryActivity"
android:label="@string/title_activity_discovery" android:label="@string/title_activity_discovery"
android:parentActivityName=".activities.ControlCenter"> android:parentActivityName=".activities.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" />
@ -239,18 +235,15 @@
<activity <activity
android:name=".activities.charts.ChartsActivity" android:name=".activities.charts.ChartsActivity"
android:label="@string/title_activity_charts" android:label="@string/title_activity_charts"
android:parentActivityName=".activities.ControlCenter"> android:parentActivityName=".activities.ControlCenter"></activity>
</activity>
<activity <activity
android:name=".activities.ConfigureAlarms" android:name=".activities.ConfigureAlarms"
android:label="@string/title_activity_set_alarm" android:label="@string/title_activity_set_alarm"
android:parentActivityName=".activities.SettingsActivity"> android:parentActivityName=".activities.SettingsActivity"></activity>
</activity>
<activity <activity
android:name=".activities.AlarmDetails" android:name=".activities.AlarmDetails"
android:label="@string/title_activity_alarm_details" android:label="@string/title_activity_alarm_details"
android:parentActivityName=".activities.ConfigureAlarms"> android:parentActivityName=".activities.ConfigureAlarms"></activity>
</activity>
</application> </application>
</manifest> </manifest>

View File

@ -10,6 +10,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.telephony.SmsManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -230,7 +231,8 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
case REPLY: case REPLY:
String phoneNumber = GBApplication.getIDSenderLookup().lookup(deviceEvent.handle); String phoneNumber = GBApplication.getIDSenderLookup().lookup(deviceEvent.handle);
if (phoneNumber != null) { if (phoneNumber != null) {
GB.toast(context, "got notfication reply for " + phoneNumber + " : " + deviceEvent.reply, 2, GB.INFO); LOG.info("got notfication reply for " + phoneNumber + " : " + deviceEvent.reply);
SmsManager.getDefault().sendTextMessage(phoneNumber, null, deviceEvent.reply, null, null);
} }
break; break;
} }

View File

@ -1512,6 +1512,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, "Muted"); sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, "Muted");
break; break;
case 0x05: case 0x05:
String caption = "";
byte attribute_count = buf.get(); byte attribute_count = buf.get();
if (attribute_count > 0) { if (attribute_count > 0) {
byte attribute = buf.get(); byte attribute = buf.get();
@ -1522,14 +1523,17 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.get(reply); buf.get(reply);
devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
devEvtNotificationControl.reply = new String(reply); devEvtNotificationControl.reply = new String(reply);
caption = "Sent";
} else { } else {
caption = "FAILED";
devEvtNotificationControl = null; // error devEvtNotificationControl = null; // error
} }
} else { } else {
caption = "FAILED";
devEvtNotificationControl = null; // error devEvtNotificationControl = null; // error
} }
sendBytesAck = new GBDeviceEventSendBytes(); sendBytesAck = new GBDeviceEventSendBytes();
sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, "NOT IMPLEMENTED"); sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, caption);
break; break;
default: default:
return null; return null;
@ -1589,14 +1593,18 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.get(reply); buf.get(reply);
devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
devEvtNotificationControl.reply = new String(reply); devEvtNotificationControl.reply = new String(reply);
caption = "SENT";
icon_id = PebbleIconID.RESULT_SENT;
} else { } else {
devEvtNotificationControl = null; // error devEvtNotificationControl = null; // error
caption = "FAILED";
icon_id = PebbleIconID.RESULT_FAILED;
} }
} else { } else {
caption = "FAILED";
icon_id = PebbleIconID.RESULT_FAILED;
devEvtNotificationControl = null; // error devEvtNotificationControl = null; // error
} }
caption = "NOT IMPLEMENTED";
icon_id = PebbleIconID.GENERIC_WARNING;
break; break;
} }
GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes(); GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes();