mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Resolve issues from review
This commit is contained in:
committed by
Arjan Schrijver
parent
775d064262
commit
77f0dbbad8
+1
-1
@@ -28,7 +28,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.PermissionsUtils.PACKAGE_INTERN
|
||||
class InternetHelperPreferencesActivity : AbstractGBActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_internet_helper_preferences)
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
|
||||
-2
@@ -33,7 +33,6 @@ public class GBDeviceEventAppMessage extends GBDeviceEvent {
|
||||
public UUID appUUID;
|
||||
public int id;
|
||||
public String message;
|
||||
public GBDevice device;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -43,7 +42,6 @@ public class GBDeviceEventAppMessage extends GBDeviceEvent {
|
||||
", appUUID=" + appUUID +
|
||||
", message='" + message + '\'' +
|
||||
", id=" + id +
|
||||
", device=" + device +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -105,20 +105,20 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
private int mBytesWritten = -1;
|
||||
|
||||
private void sendAppMessageJS(GBDeviceEventAppMessage appMessage) {
|
||||
sendAppMessage(appMessage);
|
||||
sendAppMessage(gbDevice, appMessage);
|
||||
if (appMessage.type == GBDeviceEventAppMessage.TYPE_APPMESSAGE) {
|
||||
write(mPebbleProtocol.encodeApplicationMessageAck(appMessage.appUUID, (byte) appMessage.id));
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendAppMessage(GBDeviceEventAppMessage message) {
|
||||
if (! ((PebbleCoordinator) message.device.getDeviceCoordinator()).isBackgroundJsEnabled(message.device)) {
|
||||
private static void sendAppMessage(GBDevice device, GBDeviceEventAppMessage message) {
|
||||
if (! ((PebbleCoordinator) device.getDeviceCoordinator()).isBackgroundJsEnabled(device)) {
|
||||
LOG.info("App message received but Pebble JS Service not running");
|
||||
return;
|
||||
}
|
||||
final String jsEvent;
|
||||
try {
|
||||
PebbleJsService.Companion.getInstance().checkAppRunning(message.device, message.appUUID);
|
||||
PebbleJsService.Companion.getInstance().checkAppRunning(device, message.appUUID);
|
||||
} catch (NullPointerException | IllegalStateException ex) {
|
||||
LOG.warn("Unable to send app message: {}", message, ex);
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
final String appMessage = PebbleUtils.parseIncomingAppMessage(message.message, message.appUUID, message.id);
|
||||
LOG.debug("to WEBVIEW: event: {} message: {}", jsEvent, appMessage);
|
||||
PebbleJsService.Companion.getInstance().evaluateJsForDevice(message.device, "if (typeof Pebble == 'object') Pebble.evaluate('" + jsEvent + "',[" + appMessage + "]);", s -> {
|
||||
PebbleJsService.Companion.getInstance().evaluateJsForDevice(device, "if (typeof Pebble == 'object') Pebble.evaluate('" + jsEvent + "',[" + appMessage + "]);", s -> {
|
||||
//TODO: the message should be acked here instead of in PebbleIoThread
|
||||
LOG.debug("Callback from appmessage: {}", s);
|
||||
});
|
||||
|
||||
-2
@@ -1782,7 +1782,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
appMessage.appUUID = uuid;
|
||||
appMessage.id = last_id & 0xff;
|
||||
appMessage.message = jsonArray.toString();
|
||||
appMessage.device = getDevice();
|
||||
return new GBDeviceEvent[]{appMessage, sendBytesAck};
|
||||
}
|
||||
|
||||
@@ -2563,7 +2562,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
}
|
||||
evtAppMessage.id = idLookup[last_id & 0xff];
|
||||
evtAppMessage.appUUID = currentRunningApp;
|
||||
evtAppMessage.device = getDevice();
|
||||
}
|
||||
devEvts = new GBDeviceEvent[]{evtAppMessage};
|
||||
break;
|
||||
|
||||
@@ -43,12 +43,9 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
|
||||
@@ -208,10 +208,12 @@ public class PebbleUtils {
|
||||
// Delay start until service is ready
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
PebbleJsService s = PebbleJsService.Companion.getInstance();
|
||||
if (s != null) {
|
||||
if (s == null) {
|
||||
LOG.warn("Couldn't start PebbleJsService");
|
||||
} else {
|
||||
s.startJsForDevice(device, uuid);
|
||||
}
|
||||
}, 600);
|
||||
}, 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/root_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/settings_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
Reference in New Issue
Block a user