mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 03:55:47 +02:00
Pebble: move a bunch of preferences to device specific settings
This commit is contained in:
parent
c3d76477ec
commit
795ffde0e1
@ -44,6 +44,7 @@ import java.util.UUID;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
@ -51,7 +52,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.webview.GBChromeClient;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.webview.GBWebClient;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.webview.JSInterface;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.WebViewSingleton;
|
||||
@ -120,14 +120,14 @@ public class ExternalPebbleJSActivity extends AbstractGBActivity {
|
||||
currentDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
|
||||
currentUUID = (UUID) extras.getSerializable(DeviceService.EXTRA_APP_UUID);
|
||||
|
||||
if (extras.getBoolean(START_BG_WEBVIEW, false)) {
|
||||
if (currentDevice != null && extras.getBoolean(START_BG_WEBVIEW, false) && ((PebbleCoordinator) currentDevice.getDeviceCoordinator()).isBackgroundJsEnabled(currentDevice)) {
|
||||
startBackgroundWebViewAndFinish();
|
||||
return;
|
||||
}
|
||||
showConfig = extras.getBoolean(SHOW_CONFIG, false);
|
||||
}
|
||||
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (currentDevice != null && ((PebbleCoordinator) currentDevice.getDeviceCoordinator()).isBackgroundJsEnabled(currentDevice)) {
|
||||
if (showConfig) {
|
||||
Objects.requireNonNull(currentDevice, "Must provide a device when invoking this activity");
|
||||
Objects.requireNonNull(currentUUID, "Must provide a uuid when invoking this activity");
|
||||
@ -144,11 +144,7 @@ public class ExternalPebbleJSActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
private void startBackgroundWebViewAndFinish() {
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
WebViewSingleton.ensureCreated(this);
|
||||
} else {
|
||||
LOG.warn("BGJs disabled, not starting webview");
|
||||
}
|
||||
WebViewSingleton.ensureCreated(this);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLClassicDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
@ -47,14 +49,16 @@ import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySampleD
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMisfitSampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMorpheuzSampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
private static final String BG_JS_ENABLED = "pebble_enable_background_javascript";
|
||||
private static final boolean BG_JS_ENABLED_DEFAULT = false;
|
||||
|
||||
public PebbleCoordinator() {
|
||||
}
|
||||
|
||||
@ -83,7 +87,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends AbstractActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
DevicePrefs prefs = GBApplication.getDevicePrefs(device.getAddress());
|
||||
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH);
|
||||
switch (activityTracker) {
|
||||
case SampleProvider.PROVIDER_PEBBLE_HEALTH:
|
||||
@ -223,15 +227,30 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
// return new int[]{
|
||||
// ,
|
||||
// R.xml.devicesettings_transliteration
|
||||
// };
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_autoremove_notifications,
|
||||
R.xml.devicesettings_canned_reply_16,
|
||||
R.xml.devicesettings_canned_dismisscall_16,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_transliteration
|
||||
};
|
||||
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
|
||||
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
|
||||
|
||||
final List<Integer> notifications = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
|
||||
notifications.add(R.xml.devicesettings_autoremove_notifications);
|
||||
notifications.add(R.xml.devicesettings_canned_reply_16);
|
||||
notifications.add(R.xml.devicesettings_canned_dismisscall_16);
|
||||
notifications.add(R.xml.devicesettings_transliteration);
|
||||
|
||||
final List<Integer> calendar = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALENDAR);
|
||||
calendar.add(R.xml.devicesettings_sync_calendar);
|
||||
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_pebble_preferences);
|
||||
|
||||
return deviceSpecificSettings;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -259,4 +278,10 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
public int getDisabledIconResource() {
|
||||
return R.drawable.ic_device_pebble_disabled;
|
||||
}
|
||||
|
||||
public boolean isBackgroundJsEnabled(final GBDevice device) {
|
||||
DevicePrefs deviceSpecificPreferences = GBApplication.getDevicePrefs(device.getAddress());
|
||||
return deviceSpecificPreferences.getBoolean(BG_JS_ENABLED, BG_JS_ENABLED_DEFAULT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,21 +29,26 @@ import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
class AppMessageHandler {
|
||||
final PebbleProtocol mPebbleProtocol;
|
||||
final UUID mUUID;
|
||||
Map<String, Integer> messageKeys;
|
||||
protected final DevicePrefs devicePrefs;
|
||||
|
||||
|
||||
AppMessageHandler(UUID uuid, PebbleProtocol pebbleProtocol) {
|
||||
mUUID = uuid;
|
||||
mPebbleProtocol = pebbleProtocol;
|
||||
devicePrefs = GBApplication.getDevicePrefs(pebbleProtocol.getDevice().getAddress());
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
|
@ -37,7 +37,6 @@ import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMisfitSamplePro
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMisfitSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
|
||||
@ -59,8 +58,7 @@ class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
return prefs.getBoolean("pebble_sync_misfit", true);
|
||||
return devicePrefs.getBoolean("pebble_sync_misfit", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +38,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMorpheuzSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMorpheuzSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
private Integer keyPoint;
|
||||
@ -100,8 +99,7 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
return prefs.getBoolean("pebble_sync_morpheuz", true);
|
||||
return devicePrefs.getBoolean("pebble_sync_morpheuz", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,15 +21,17 @@ import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
abstract class DatalogSessionPebbleHealth extends DatalogSession {
|
||||
|
||||
private final GBDevice mDevice;
|
||||
private final DevicePrefs devicePrefs;
|
||||
|
||||
DatalogSessionPebbleHealth(byte id, UUID uuid, int timestamp, int tag, byte itemType, short itemSize, GBDevice device) {
|
||||
super(id, uuid, timestamp, tag, itemType, itemSize);
|
||||
mDevice = device;
|
||||
devicePrefs = GBApplication.getDevicePrefs(mDevice.getAddress());
|
||||
}
|
||||
|
||||
public GBDevice getDevice() {
|
||||
@ -37,12 +39,10 @@ abstract class DatalogSessionPebbleHealth extends DatalogSession {
|
||||
}
|
||||
|
||||
boolean isPebbleHealthEnabled() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
return prefs.getBoolean("pebble_sync_health", true);
|
||||
return devicePrefs.getBoolean("pebble_sync_health", true);
|
||||
}
|
||||
|
||||
boolean storePebbleHealthRawRecord() {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
return prefs.getBoolean("pebble_health_store_raw", true);
|
||||
return devicePrefs.getBoolean("pebble_health_store_raw", true);
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelUuid;
|
||||
import android.webkit.ValueCallback;
|
||||
@ -59,6 +58,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppMessage
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.pebble.GBDeviceEventDataLogging;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PBWReader;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleInstallable;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
@ -69,11 +69,13 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.WebViewSingleton;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
class PebbleIoThread extends GBDeviceIoThread {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PebbleIoThread.class);
|
||||
|
||||
private final Prefs prefs = GBApplication.getPrefs();
|
||||
private final DevicePrefs devicePrefs;
|
||||
|
||||
private final PebbleProtocol mPebbleProtocol;
|
||||
private final PebbleSupport mPebbleSupport;
|
||||
@ -147,12 +149,12 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
|
||||
super(gbDevice, context);
|
||||
final SharedPreferences deviceSpecificSharedPrefsrefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||
devicePrefs = GBApplication.getDevicePrefs(gbDevice.getAddress());
|
||||
mPebbleProtocol = (PebbleProtocol) gbDeviceProtocol;
|
||||
mBtAdapter = btAdapter;
|
||||
mPebbleSupport = pebbleSupport;
|
||||
mEnablePebblekit = deviceSpecificSharedPrefsrefs.getBoolean("third_party_apps_set_settings", false);
|
||||
mPebbleProtocol.setAlwaysACKPebbleKit(prefs.getBoolean("pebble_always_ack_pebblekit", false));
|
||||
mEnablePebblekit = devicePrefs.getBoolean("third_party_apps_set_settings", false);
|
||||
mPebbleProtocol.setAlwaysACKPebbleKit(devicePrefs.getBoolean("pebble_always_ack_pebblekit", false));
|
||||
mPebbleProtocol.setEnablePebbleKit(mEnablePebblekit);
|
||||
|
||||
mPebbleActiveAppTracker = new PebbleActiveAppTracker();
|
||||
@ -183,7 +185,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
mOutStream = mTCPSocket.getOutputStream();
|
||||
} else {
|
||||
mIsTCP = false;
|
||||
if (gbDevice.getVolatileAddress() != null && prefs.getBoolean("pebble_force_le", false)) {
|
||||
if (gbDevice.getVolatileAddress() != null && devicePrefs.getBoolean("pebble_force_le", false)) {
|
||||
deviceAddress = gbDevice.getVolatileAddress();
|
||||
}
|
||||
BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(deviceAddress);
|
||||
@ -211,9 +213,10 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
mOutStream = mBtSocket.getOutputStream();
|
||||
}
|
||||
}
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (((PebbleCoordinator) gbDevice.getDeviceCoordinator()).isBackgroundJsEnabled(gbDevice)) {
|
||||
Intent startIntent = new Intent(getContext(), ExternalPebbleJSActivity.class);
|
||||
startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, gbDevice);
|
||||
startIntent.putExtra(ExternalPebbleJSActivity.START_BG_WEBVIEW, true);
|
||||
getContext().startActivity(startIntent);
|
||||
} else {
|
||||
@ -230,7 +233,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
return false;
|
||||
}
|
||||
|
||||
mPebbleProtocol.setForceProtocol(prefs.getBoolean("pebble_force_protocol", false));
|
||||
mPebbleProtocol.setForceProtocol(devicePrefs.getBoolean("pebble_force_protocol", false));
|
||||
|
||||
mIsConnected = true;
|
||||
write(mPebbleProtocol.encodeFirmwareVersionReq());
|
||||
@ -414,7 +417,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
gbDevice.setState(GBDevice.State.WAITING_FOR_RECONNECT);
|
||||
}
|
||||
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (((PebbleCoordinator) gbDevice.getDeviceCoordinator()).isBackgroundJsEnabled(gbDevice)) {
|
||||
WebViewSingleton.getInstance().disposeWebView();
|
||||
}
|
||||
|
||||
@ -478,7 +481,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
LOG.info("syncing time");
|
||||
write(mPebbleProtocol.encodeSetTime());
|
||||
}
|
||||
write(mPebbleProtocol.encodeEnableAppLogs(prefs.getBoolean("pebble_enable_applogs", false)));
|
||||
write(mPebbleProtocol.encodeEnableAppLogs(devicePrefs.getBoolean("pebble_enable_applogs", false)));
|
||||
write(mPebbleProtocol.encodeReportDataLogSessions());
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
return false;
|
||||
@ -542,7 +545,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
break;
|
||||
case START:
|
||||
LOG.info("got GBDeviceEventAppManagement START event for uuid: " + appMgmt.uuid);
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (((PebbleCoordinator) gbDevice.getDeviceCoordinator()).isBackgroundJsEnabled(gbDevice)) {
|
||||
if (mPebbleProtocol.hasAppMessageHandler(appMgmt.uuid)) {
|
||||
WebViewSingleton.getInstance().stopJavascriptInterface();
|
||||
} else {
|
||||
@ -565,7 +568,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
setInstallSlot(appInfoEvent.freeSlot);
|
||||
return false;
|
||||
} else if (deviceEvent instanceof GBDeviceEventAppMessage) {
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (((PebbleCoordinator) gbDevice.getDeviceCoordinator()).isBackgroundJsEnabled(gbDevice)) {
|
||||
sendAppMessageJS((GBDeviceEventAppMessage) deviceEvent);
|
||||
}
|
||||
if (mEnablePebblekit) {
|
||||
|
@ -28,8 +28,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
@ -55,6 +53,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.pebble.GBDeviceEventDataLogging;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleIconID;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
@ -69,7 +68,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class PebbleProtocol extends GBDeviceProtocol {
|
||||
@ -423,7 +421,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
super(device);
|
||||
mAppMessageHandlers.put(UUID_MORPHEUZ, new AppMessageHandlerMorpheuz(UUID_MORPHEUZ, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_MISFIT, new AppMessageHandlerMisfit(UUID_MISFIT, PebbleProtocol.this));
|
||||
if (!GBApplication.getPrefs().isBackgroundJsEnabled()) {
|
||||
if (!((PebbleCoordinator) device.getDeviceCoordinator()).isBackgroundJsEnabled(device)) {
|
||||
mAppMessageHandlers.put(UUID_PEBBLE_TIMESTYLE, new AppMessageHandlerTimeStylePebble(UUID_PEBBLE_TIMESTYLE, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_PEBSTYLE, new AppMessageHandlerPebStyle(UUID_PEBSTYLE, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_MARIOTIME, new AppMessageHandlerMarioTime(UUID_MARIOTIME, PebbleProtocol.this));
|
||||
|
@ -35,7 +35,6 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
@ -153,7 +152,7 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onNotification(NotificationSpec notificationSpec) {
|
||||
String currentPrivacyMode = GBApplication.getPrefs().getString("pebble_pref_privacy_mode", getContext().getString(R.string.p_pebble_privacy_mode_off));
|
||||
String currentPrivacyMode = GBApplication.getDevicePrefs(gbDevice.getAddress()).getString("pebble_pref_privacy_mode", getContext().getString(R.string.p_pebble_privacy_mode_off));
|
||||
if (getContext().getString(R.string.p_pebble_privacy_mode_complete).equals(currentPrivacyMode)) {
|
||||
notificationSpec.body = null;
|
||||
notificationSpec.sender = null;
|
||||
@ -177,7 +176,7 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (reconnect()) {
|
||||
if ((callSpec.command != CallSpec.CALL_OUTGOING) || GBApplication.getPrefs().getBoolean("pebble_enable_outgoing_call", true)) {
|
||||
if ((callSpec.command != CallSpec.CALL_OUTGOING) || GBApplication.getDevicePrefs(gbDevice.getAddress()).getBoolean("pebble_enable_outgoing_call", true)) {
|
||||
super.onSetCallState(callSpec);
|
||||
}
|
||||
}
|
||||
|
@ -60,11 +60,11 @@ public class PebbleLESupport {
|
||||
mWriteHandlerThread.start();
|
||||
mWriteHandler = new Handler(mWriteHandlerThread.getLooper());
|
||||
|
||||
mMTULimit = GBApplication.getPrefs().getInt("pebble_mtu_limit", 512);
|
||||
mMTULimit = GBApplication.getDevicePrefs(mBtDevice.getAddress()).getInt("pebble_mtu_limit", 512);
|
||||
mMTULimit = Math.max(mMTULimit, 20);
|
||||
mMTULimit = Math.min(mMTULimit, 512);
|
||||
|
||||
clientOnly = GBApplication.getPrefs().getBoolean("pebble_gatt_clientonly", false);
|
||||
clientOnly = GBApplication.getDevicePrefs(mBtDevice.getAddress()).getBoolean("pebble_gatt_clientonly", false);
|
||||
|
||||
if (!clientOnly) {
|
||||
mPebbleGATTServer = new PebbleGATTServer(this, context, mBtDevice);
|
||||
|
@ -44,6 +44,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.WebViewSingleton;
|
||||
|
||||
@ -79,7 +80,7 @@ public class GBWebClient extends WebViewClient {
|
||||
|
||||
private WebResourceResponse mimicReply(Uri requestedUri) {
|
||||
if (requestedUri.getHost() != null && (StringUtils.indexOfAny(requestedUri.getHost(), AllowedDomains) != -1)) {
|
||||
if (GBApplication.getPrefs().isBackgroundJsEnabled() && WebViewSingleton.getInstance().internetHelperBound) {
|
||||
if (WebViewSingleton.getInstance().internetHelperBound) {
|
||||
LOG.debug("WEBVIEW forwarding request to the internet helper");
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("URL", requestedUri.toString());
|
||||
|
@ -54,8 +54,6 @@ public class GBPrefs extends Prefs {
|
||||
public static final String PING_TONE = "ping_tone";
|
||||
public static final String AUTO_EXPORT_INTERVAL = "auto_export_interval";
|
||||
private static final boolean AUTO_START_DEFAULT = true;
|
||||
private static final String BG_JS_ENABLED = "pebble_enable_background_javascript";
|
||||
private static final boolean BG_JS_ENABLED_DEFAULT = false;
|
||||
public static final String RTL_SUPPORT = "rtl";
|
||||
public static final String RTL_CONTEXTUAL_ARABIC = "contextualArabic";
|
||||
public static boolean AUTO_RECONNECT_DEFAULT = true;
|
||||
@ -96,10 +94,6 @@ public class GBPrefs extends Prefs {
|
||||
return getBoolean(AUTO_START, AUTO_START_DEFAULT);
|
||||
}
|
||||
|
||||
public boolean isBackgroundJsEnabled() {
|
||||
return getBoolean(BG_JS_ENABLED, BG_JS_ENABLED_DEFAULT);
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return getString(USER_NAME, USER_NAME_DEFAULT);
|
||||
}
|
||||
|
163
app/src/main/res/xml/devicesettings_pebble_preferences.xml
Normal file
163
app/src/main/res/xml/devicesettings_pebble_preferences.xml
Normal file
@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_general"
|
||||
app:iconSpaceReserved="false">
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_pebble_privacy_mode_off"
|
||||
android:entries="@array/pebble_privacymode"
|
||||
android:entryValues="@array/pebble_privacymode_values"
|
||||
android:key="pebble_pref_privacy_mode"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_pebble_privacy_mode"
|
||||
app:iconSpaceReserved="false" />
|
||||
<!--
|
||||
<EditTextPreference
|
||||
android:defaultValue="12"
|
||||
android:inputType="number"
|
||||
android:key="pebble_reconnect_attempts"
|
||||
android:maxLength="4"
|
||||
android:title="@string/pref_title_pebble_reconnect_attempts"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
-->
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_enable_outgoing_call"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_enable_outgoing_call"
|
||||
android:title="@string/pref_title_enable_outgoing_call"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
<!--
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_pebble_timeline"
|
||||
app:iconSpaceReserved="false">
|
||||
<SwitchPreferenceCompat
|
||||
android:key="send_sunrise_sunset"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_sunrise_sunset"
|
||||
android:title="@string/pref_title_sunrise_sunset"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
-->
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_activitytrackers"
|
||||
app:iconSpaceReserved="false">
|
||||
<ListPreference
|
||||
android:defaultValue="4"
|
||||
android:entries="@array/pebble_activitytracker"
|
||||
android:entryValues="@array/pebble_activitytracker_values"
|
||||
android:key="pebble_activitytracker"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_pebble_activitytracker"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_health"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_health"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:dependency="pebble_sync_health"
|
||||
android:key="pebble_health_store_raw"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_health_store_raw"
|
||||
android:title="@string/pref_title_pebble_health_store_raw"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_misfit"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_misfit"
|
||||
app:iconSpaceReserved="false" />>
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_morpheuz"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_morpheuz"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_development"
|
||||
app:iconSpaceReserved="false">
|
||||
<EditTextPreference
|
||||
android:defaultValue="512"
|
||||
android:inputType="number"
|
||||
android:key="pebble_mtu_limit"
|
||||
android:maxLength="3"
|
||||
android:summary="@string/pref_summary_pebble_mtu_limit"
|
||||
android:title="@string/pref_title_pebble_mtu_limit"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_untested"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_forceuntested"
|
||||
android:title="@string/pref_title_pebble_forceuntested"
|
||||
app:iconSpaceReserved="false" />
|
||||
<!--
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_le"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_forcele"
|
||||
android:title="@string/pref_title_pebble_forcele"
|
||||
app:iconSpaceReserved="false" />
|
||||
-->
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_protocol"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_forceprotocol"
|
||||
android:title="@string/pref_title_pebble_forceprotocol"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_gatt_clientonly"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_gatt_clientonly"
|
||||
android:title="@string/pref_title_pebble_gatt_clientonly"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_enable_applogs"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_enable_applogs"
|
||||
android:title="@string/pref_title_pebble_enable_applogs"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_always_ack_pebblekit"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_always_ack_pebblekit"
|
||||
android:title="@string/pref_title_pebble_always_ack_pebblekit"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:dependency="pebble_force_untested"
|
||||
android:key="pebble_enable_background_javascript"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_enable_bgjs"
|
||||
android:title="@string/pref_title_pebble_enable_bgjs"
|
||||
app:iconSpaceReserved="false" />
|
||||
<!--
|
||||
<EditTextPreference
|
||||
android:digits="0123456789."
|
||||
android:key="pebble_emu_addr"
|
||||
android:maxLength="15"
|
||||
android:title="Emulator IP"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="pebble_emu_port"
|
||||
android:maxLength="5"
|
||||
android:title="Emulator Port"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
</androidx.preference.PreferenceScreen>
|
@ -1,16 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_general"
|
||||
app:iconSpaceReserved="false">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_enable_outgoing_call"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_enable_outgoing_call"
|
||||
android:title="@string/pref_title_enable_outgoing_call"
|
||||
app:iconSpaceReserved="false" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="12"
|
||||
android:inputType="number"
|
||||
@ -19,14 +12,6 @@
|
||||
android:title="@string/pref_title_pebble_reconnect_attempts"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_pebble_privacy_mode_off"
|
||||
android:entries="@array/pebble_privacymode"
|
||||
android:entryValues="@array/pebble_privacymode_values"
|
||||
android:key="pebble_pref_privacy_mode"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_pebble_privacy_mode"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_pebble_timeline"
|
||||
@ -38,54 +23,9 @@
|
||||
android:title="@string/pref_title_sunrise_sunset"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_activitytrackers"
|
||||
app:iconSpaceReserved="false">
|
||||
<ListPreference
|
||||
android:defaultValue="4"
|
||||
android:entries="@array/pebble_activitytracker"
|
||||
android:entryValues="@array/pebble_activitytracker_values"
|
||||
android:key="pebble_activitytracker"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_pebble_activitytracker"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_health"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_health"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:dependency="pebble_sync_health"
|
||||
android:key="pebble_health_store_raw"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_health_store_raw"
|
||||
android:title="@string/pref_title_pebble_health_store_raw"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_misfit"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_misfit"
|
||||
app:iconSpaceReserved="false" />>
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="pebble_sync_morpheuz"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_pebble_sync_morpheuz"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_development"
|
||||
app:iconSpaceReserved="false">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_protocol"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_forceprotocol"
|
||||
android:title="@string/pref_title_pebble_forceprotocol"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_untested"
|
||||
@ -100,43 +40,6 @@
|
||||
android:summary="@string/pref_summary_pebble_forcele"
|
||||
android:title="@string/pref_title_pebble_forcele"
|
||||
app:iconSpaceReserved="false" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="512"
|
||||
android:inputType="number"
|
||||
android:key="pebble_mtu_limit"
|
||||
android:maxLength="3"
|
||||
android:summary="@string/pref_summary_pebble_mtu_limit"
|
||||
android:title="@string/pref_title_pebble_mtu_limit"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_gatt_clientonly"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_gatt_clientonly"
|
||||
android:title="@string/pref_title_pebble_gatt_clientonly"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_enable_applogs"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_enable_applogs"
|
||||
android:title="@string/pref_title_pebble_enable_applogs"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_always_ack_pebblekit"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_always_ack_pebblekit"
|
||||
android:title="@string/pref_title_pebble_always_ack_pebblekit"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:dependency="pebble_force_untested"
|
||||
android:key="pebble_enable_background_javascript"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_pebble_enable_bgjs"
|
||||
android:title="@string/pref_title_pebble_enable_bgjs"
|
||||
app:iconSpaceReserved="false" />
|
||||
<EditTextPreference
|
||||
android:digits="0123456789."
|
||||
android:key="pebble_emu_addr"
|
||||
@ -152,4 +55,4 @@
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user