Pebble: Implement call dismissal with canned messages
This also moved the canned replies setting to pebble settings (we will change that if we have another device supporting this)
This commit is contained in:
parent
7ed867a88d
commit
b77f3ad3bf
|
@ -21,6 +21,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -28,8 +29,10 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
||||||
|
@ -155,6 +158,25 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pref = findPreference("canned_messages_dismisscall_send");
|
||||||
|
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= 16; i++) {
|
||||||
|
String message = prefs.getString("canned_message_dismisscall_" + i, null);
|
||||||
|
if (message != null && !message.equals("")) {
|
||||||
|
messages.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CannedMessagesSpec cannedMessagesSpec = new CannedMessagesSpec();
|
||||||
|
cannedMessagesSpec.type = CannedMessagesSpec.TYPE_MISSEDCALLS;
|
||||||
|
cannedMessagesSpec.cannedMessages = messages.toArray(new String[messages.size()]);
|
||||||
|
GBApplication.deviceService().onSetCannedMessages(cannedMessagesSpec);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Get all receivers of Media Buttons
|
// Get all receivers of Media Buttons
|
||||||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||||
|
|
||||||
|
@ -206,6 +228,22 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||||
"canned_reply_14",
|
"canned_reply_14",
|
||||||
"canned_reply_15",
|
"canned_reply_15",
|
||||||
"canned_reply_16",
|
"canned_reply_16",
|
||||||
|
"canned_message_dismisscall_1",
|
||||||
|
"canned_message_dismisscall_2",
|
||||||
|
"canned_message_dismisscall_3",
|
||||||
|
"canned_message_dismisscall_4",
|
||||||
|
"canned_message_dismisscall_5",
|
||||||
|
"canned_message_dismisscall_6",
|
||||||
|
"canned_message_dismisscall_7",
|
||||||
|
"canned_message_dismisscall_8",
|
||||||
|
"canned_message_dismisscall_9",
|
||||||
|
"canned_message_dismisscall_10",
|
||||||
|
"canned_message_dismisscall_11",
|
||||||
|
"canned_message_dismisscall_12",
|
||||||
|
"canned_message_dismisscall_13",
|
||||||
|
"canned_message_dismisscall_14",
|
||||||
|
"canned_message_dismisscall_15",
|
||||||
|
"canned_message_dismisscall_16",
|
||||||
PREF_USER_YEAR_OF_BIRTH,
|
PREF_USER_YEAR_OF_BIRTH,
|
||||||
PREF_USER_HEIGHT_CM,
|
PREF_USER_HEIGHT_CM,
|
||||||
PREF_USER_WEIGHT_KG,
|
PREF_USER_WEIGHT_KG,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.UUID;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
@ -26,6 +27,8 @@ public interface EventHandler {
|
||||||
|
|
||||||
void onSetCallState(CallSpec callSpec);
|
void onSetCallState(CallSpec callSpec);
|
||||||
|
|
||||||
|
void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec);
|
||||||
|
|
||||||
void onSetMusicState(MusicStateSpec stateSpec);
|
void onSetMusicState(MusicStateSpec stateSpec);
|
||||||
|
|
||||||
void onSetMusicInfo(MusicSpec musicSpec);
|
void onSetMusicInfo(MusicSpec musicSpec);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.UUID;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
|
@ -30,8 +31,7 @@ public class GBDeviceService implements DeviceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Intent createIntent() {
|
protected Intent createIntent() {
|
||||||
Intent startIntent = new Intent(mContext, mServiceClass);
|
return new Intent(mContext, mServiceClass);
|
||||||
return startIntent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invokeService(Intent intent) {
|
protected void invokeService(Intent intent) {
|
||||||
|
@ -128,6 +128,14 @@ public class GBDeviceService implements DeviceService {
|
||||||
invokeService(intent);
|
invokeService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
Intent intent = createIntent().setAction(ACTION_SETCANNEDMESSAGES)
|
||||||
|
.putExtra(EXTRA_CANNEDMESSAGES_TYPE, cannedMessagesSpec.type)
|
||||||
|
.putExtra(EXTRA_CANNEDMESSAGES, cannedMessagesSpec.cannedMessages);
|
||||||
|
invokeService(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||||
Intent intent = createIntent().setAction(ACTION_SETMUSICSTATE)
|
Intent intent = createIntent().setAction(ACTION_SETMUSICSTATE)
|
||||||
|
|
|
@ -16,6 +16,7 @@ public interface DeviceService extends EventHandler {
|
||||||
String ACTION_CONNECT = PREFIX + ".action.connect";
|
String ACTION_CONNECT = PREFIX + ".action.connect";
|
||||||
String ACTION_NOTIFICATION = PREFIX + ".action.notification";
|
String ACTION_NOTIFICATION = PREFIX + ".action.notification";
|
||||||
String ACTION_CALLSTATE = PREFIX + ".action.callstate";
|
String ACTION_CALLSTATE = PREFIX + ".action.callstate";
|
||||||
|
String ACTION_SETCANNEDMESSAGES = PREFIX + ".action.setcannedmessages";
|
||||||
String ACTION_SETTIME = PREFIX + ".action.settime";
|
String ACTION_SETTIME = PREFIX + ".action.settime";
|
||||||
String ACTION_SETMUSICINFO = PREFIX + ".action.setmusicinfo";
|
String ACTION_SETMUSICINFO = PREFIX + ".action.setmusicinfo";
|
||||||
String ACTION_SETMUSICSTATE = PREFIX + ".action.setmusicstate";
|
String ACTION_SETMUSICSTATE = PREFIX + ".action.setmusicstate";
|
||||||
|
@ -53,6 +54,8 @@ public interface DeviceService extends EventHandler {
|
||||||
String EXTRA_FIND_START = "find_start";
|
String EXTRA_FIND_START = "find_start";
|
||||||
String EXTRA_CALL_COMMAND = "call_command";
|
String EXTRA_CALL_COMMAND = "call_command";
|
||||||
String EXTRA_CALL_PHONENUMBER = "call_phonenumber";
|
String EXTRA_CALL_PHONENUMBER = "call_phonenumber";
|
||||||
|
String EXTRA_CANNEDMESSAGES = "cannedmessages";
|
||||||
|
String EXTRA_CANNEDMESSAGES_TYPE = "cannedmessages_type";
|
||||||
String EXTRA_MUSIC_ARTIST = "music_artist";
|
String EXTRA_MUSIC_ARTIST = "music_artist";
|
||||||
String EXTRA_MUSIC_ALBUM = "music_album";
|
String EXTRA_MUSIC_ALBUM = "music_album";
|
||||||
String EXTRA_MUSIC_TRACK = "music_track";
|
String EXTRA_MUSIC_TRACK = "music_track";
|
||||||
|
|
|
@ -37,6 +37,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
@ -66,6 +67,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_RE
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_APPINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_APPINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_DEVICEINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_DEVICEINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_SCREENSHOT;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_SCREENSHOT;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETCANNEDMESSAGES;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICSTATE;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICSTATE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETTIME;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETTIME;
|
||||||
|
@ -85,6 +87,8 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAL
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_TYPE;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_TYPE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_COMMAND;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_COMMAND;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES_TYPE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_DEVICE_ADDRESS;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_DEVICE_ADDRESS;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
|
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
|
||||||
|
@ -346,6 +350,15 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||||
callSpec.name = callerName;
|
callSpec.name = callerName;
|
||||||
mDeviceSupport.onSetCallState(callSpec);
|
mDeviceSupport.onSetCallState(callSpec);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_SETCANNEDMESSAGES:
|
||||||
|
int type = intent.getIntExtra(EXTRA_CANNEDMESSAGES_TYPE, -1);
|
||||||
|
String[] cannedMessages = intent.getStringArrayExtra(EXTRA_CANNEDMESSAGES);
|
||||||
|
|
||||||
|
CannedMessagesSpec cannedMessagesSpec = new CannedMessagesSpec();
|
||||||
|
cannedMessagesSpec.type = type;
|
||||||
|
cannedMessagesSpec.cannedMessages = cannedMessages;
|
||||||
|
mDeviceSupport.onSetCannedMessages(cannedMessagesSpec);
|
||||||
|
break;
|
||||||
case ACTION_SETTIME:
|
case ACTION_SETTIME:
|
||||||
mDeviceSupport.onSetTime();
|
mDeviceSupport.onSetTime();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
@ -151,6 +152,14 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||||
delegate.onSetCallState(callSpec);
|
delegate.onSetCallState(callSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
if (checkBusy("set canned messages")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delegate.onSetCannedMessages(cannedMessagesSpec);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||||
if (checkBusy("set music state")) {
|
if (checkBusy("set music state")) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEvents;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEvents;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
|
@ -595,6 +596,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isTelephoneRinging() {
|
private boolean isTelephoneRinging() {
|
||||||
// don't synchronize, this is not really important
|
// don't synchronize, this is not really important
|
||||||
return telephoneRinging;
|
return telephoneRinging;
|
||||||
|
|
|
@ -35,6 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||||
|
@ -85,7 +86,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
static final byte BLOBDB_APP = 2;
|
static final byte BLOBDB_APP = 2;
|
||||||
static final byte BLOBDB_REMINDER = 3;
|
static final byte BLOBDB_REMINDER = 3;
|
||||||
static final byte BLOBDB_NOTIFICATION = 4;
|
static final byte BLOBDB_NOTIFICATION = 4;
|
||||||
|
static final byte BLOBDB_CANNED_MESSAGES = 6;
|
||||||
static final byte BLOBDB_PREFERENCES = 7;
|
static final byte BLOBDB_PREFERENCES = 7;
|
||||||
|
static final byte BLOBDB_APPGLANCE = 11;
|
||||||
|
|
||||||
static final byte BLOBDB_SUCCESS = 1;
|
static final byte BLOBDB_SUCCESS = 1;
|
||||||
static final byte BLOBDB_GENERALFAILURE = 2;
|
static final byte BLOBDB_GENERALFAILURE = 2;
|
||||||
static final byte BLOBDB_INVALIDOPERATION = 3;
|
static final byte BLOBDB_INVALIDOPERATION = 3;
|
||||||
|
@ -1318,6 +1322,53 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
return buf.array();
|
return buf.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] encodeSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
|
||||||
|
if (cannedMessagesSpec.cannedMessages == null || cannedMessagesSpec.cannedMessages.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String blobDBKey;
|
||||||
|
switch (cannedMessagesSpec.type) {
|
||||||
|
case CannedMessagesSpec.TYPE_MISSEDCALLS:
|
||||||
|
blobDBKey = "com.pebble.android.phone";
|
||||||
|
break;
|
||||||
|
case CannedMessagesSpec.TYPE_NEWSMS:
|
||||||
|
blobDBKey = "com.pebble.sendText";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int replies_length = -1;
|
||||||
|
|
||||||
|
for (String reply : cannedMessagesSpec.cannedMessages) {
|
||||||
|
replies_length += reply.getBytes().length + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuffer buf = ByteBuffer.allocate(12 + replies_length);
|
||||||
|
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
buf.putInt(0x00000000); // unknown
|
||||||
|
buf.put((byte) 0x00); // atributes count?
|
||||||
|
buf.put((byte) 0x01); // actions count?
|
||||||
|
|
||||||
|
// action
|
||||||
|
buf.put((byte) 0x00); // action id
|
||||||
|
buf.put((byte) 0x03); // action type = reply
|
||||||
|
buf.put((byte) 0x01); // attributes count
|
||||||
|
buf.put((byte) 0x08); // canned messages
|
||||||
|
buf.putShort((short) replies_length);
|
||||||
|
for (int i = 0; i < cannedMessagesSpec.cannedMessages.length - 1; i++) {
|
||||||
|
buf.put(cannedMessagesSpec.cannedMessages[i].getBytes());
|
||||||
|
buf.put((byte) 0x00);
|
||||||
|
}
|
||||||
|
// last one must not be zero terminated, else we get an additional empty reply
|
||||||
|
buf.put(cannedMessagesSpec.cannedMessages[cannedMessagesSpec.cannedMessages.length - 1].getBytes());
|
||||||
|
|
||||||
|
return encodeBlobdb(blobDBKey, BLOBDB_INSERT, BLOBDB_CANNED_MESSAGES, buf.array());
|
||||||
|
}
|
||||||
|
|
||||||
/* pebble specific install methods */
|
/* pebble specific install methods */
|
||||||
public byte[] encodeUploadStart(byte type, int app_id, int size, String filename) {
|
public byte[] encodeUploadStart(byte type, int app_id, int size, String filename) {
|
||||||
short length;
|
short length;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.serial;
|
package nodomain.freeyourgadget.gadgetbridge.service.serial;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
|
@ -10,6 +7,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.EventHandler;
|
import nodomain.freeyourgadget.gadgetbridge.devices.EventHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
@ -29,9 +27,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.AbstractDeviceSupport;
|
||||||
* to create the device specific message for the respective events and sends them to the device via {@link #sendToDevice(byte[])}.
|
* to create the device specific message for the respective events and sends them to the device via {@link #sendToDevice(byte[])}.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport {
|
public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceSupport.class);
|
|
||||||
|
|
||||||
protected GBDeviceProtocol gbDeviceProtocol;
|
protected GBDeviceProtocol gbDeviceProtocol;
|
||||||
protected GBDeviceIoThread gbDeviceIOThread;
|
protected GBDeviceIoThread gbDeviceIOThread;
|
||||||
|
|
||||||
|
@ -124,6 +119,12 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
|
||||||
sendToDevice(bytes);
|
sendToDevice(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
byte[] bytes = gbDeviceProtocol.encodeSetCannedMessages(cannedMessagesSpec);
|
||||||
|
sendToDevice(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||||
byte[] bytes = gbDeviceProtocol.encodeSetMusicState(stateSpec.state, stateSpec.position, stateSpec.playRate, stateSpec.shuffle, stateSpec.repeat);
|
byte[] bytes = gbDeviceProtocol.encodeSetMusicState(stateSpec.state, stateSpec.position, stateSpec.playRate, stateSpec.shuffle, stateSpec.repeat);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
|
||||||
public abstract class GBDeviceProtocol {
|
public abstract class GBDeviceProtocol {
|
||||||
|
@ -27,6 +28,10 @@ public abstract class GBDeviceProtocol {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] encodeSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] encodeSetMusicInfo(String artist, String album, String track, int duration, int trackCount, int trackNr) {
|
public byte[] encodeSetMusicInfo(String artist, String album, String track, int duration, int trackCount, int trackNr) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,11 @@
|
||||||
|
|
||||||
<string name="pref_blacklist">Blacklist Apps</string>
|
<string name="pref_blacklist">Blacklist Apps</string>
|
||||||
|
|
||||||
<string name="pref_title_canned_replies">Canned Replies</string>
|
<string name="pref_header_cannned_messages">Canned Messages</string>
|
||||||
|
<string name="pref_title_canned_replies">Replies</string>
|
||||||
<string name="pref_title_canned_reply_suffix">Common suffix</string>
|
<string name="pref_title_canned_reply_suffix">Common suffix</string>
|
||||||
|
<string name="pref_title_canned_messages_dismisscall">Call Dismissal</string>
|
||||||
|
<string name="pref_title_canned_messages_set">Update on Pebble</string>
|
||||||
|
|
||||||
<string name="pref_header_development">Developer Options</string>
|
<string name="pref_header_development">Developer Options</string>
|
||||||
<string name="pref_title_development_miaddr">Mi Band address</string>
|
<string name="pref_title_development_miaddr">Mi Band address</string>
|
||||||
|
|
|
@ -94,63 +94,6 @@
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_key_blacklist"
|
android:key="pref_key_blacklist"
|
||||||
android:title="@string/pref_blacklist" />
|
android:title="@string/pref_blacklist" />
|
||||||
<PreferenceScreen
|
|
||||||
android:key="pref_key_canned_replies"
|
|
||||||
android:title="@string/pref_title_canned_replies">
|
|
||||||
<EditTextPreference
|
|
||||||
android:defaultValue=" (canned reply)"
|
|
||||||
android:key="canned_reply_suffix"
|
|
||||||
android:maxLength="64"
|
|
||||||
android:title="@string/pref_title_canned_reply_suffix" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_1"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_2"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_3"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_4"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_5"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_6"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_7"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_8"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_9"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_10"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_11"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_12"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_13"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_14"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_15"
|
|
||||||
android:maxLength="64" />
|
|
||||||
<EditTextPreference
|
|
||||||
android:key="canned_reply_16"
|
|
||||||
android:maxLength="64" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
@ -192,7 +135,6 @@
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_key_device_specific_category"
|
|
||||||
android:title="@string/preferences_category_device_specific_settings">
|
android:title="@string/preferences_category_device_specific_settings">
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/ic_device_miband"
|
android:icon="@drawable/ic_device_miband"
|
||||||
|
@ -259,6 +201,117 @@
|
||||||
android:key="location_longitude"
|
android:key="location_longitude"
|
||||||
android:title="@string/pref_title_location_longitude" />
|
android:title="@string/pref_title_location_longitude" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/pref_header_cannned_messages">
|
||||||
|
<PreferenceScreen android:title="@string/pref_title_canned_replies">
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue=" (canned reply)"
|
||||||
|
android:key="canned_reply_suffix"
|
||||||
|
android:maxLength="64"
|
||||||
|
android:title="@string/pref_title_canned_reply_suffix" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_1"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_2"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_3"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_4"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_5"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_6"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_7"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_8"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_9"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_10"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_11"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_12"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_13"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_14"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_15"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_reply_16"
|
||||||
|
android:maxLength="64" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
<PreferenceScreen android:title="@string/pref_title_canned_messages_dismisscall">
|
||||||
|
<Preference
|
||||||
|
android:key="canned_messages_dismisscall_send"
|
||||||
|
android:title="@string/pref_title_canned_messages_set" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_1"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_2"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_3"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_4"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_5"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_6"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_7"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_8"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_9"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_10"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_11"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_12"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_13"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_14"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_15"
|
||||||
|
android:maxLength="64" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="canned_message_dismisscall_16"
|
||||||
|
android:maxLength="64" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_header_development">
|
android:title="@string/pref_header_development">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
|
@ -11,6 +11,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
|
@ -67,6 +68,11 @@ public class TestDeviceSupport extends AbstractDeviceSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue