diff --git a/app/build.gradle b/app/build.gradle
index 80db15028..159126200 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -213,6 +213,7 @@ dependencies {
implementation 'com.github.wax911:android-emojify:0.1.7'
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
implementation "androidx.multidex:multidex:2.0.1"
+ implementation 'com.android.volley:volley:1.2.1'
}
preBuild.dependsOn(":GBDaoGenerator:genSources")
diff --git a/app/src/banglejs/AndroidManifest.xml b/app/src/banglejs/AndroidManifest.xml
new file mode 100644
index 000000000..8478e0e63
--- /dev/null
+++ b/app/src/banglejs/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java
index 2b2e82205..e63c4d23e 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java
@@ -65,6 +65,7 @@ import java.util.Set;
import de.cketti.library.changelog.ChangeLog;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapterv2;
import nodomain.freeyourgadget.gadgetbridge.database.DBAccess;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
@@ -438,6 +439,12 @@ public class ControlCenterv2 extends AppCompatActivity
}
}
+ if (BuildConfig.INTERNET_ACCESS) {
+ if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) {
+ wantedPermissions.add(Manifest.permission.INTERNET);
+ }
+ }
+
if (!wantedPermissions.isEmpty()) {
Prefs prefs = GBApplication.getPrefs();
// If this is not the first run, we can rely on
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java
index eb0754e23..542fa5fbc 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java
@@ -31,6 +31,13 @@ import android.widget.Toast;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+import com.android.volley.Request;
+import com.android.volley.Response;
+import com.android.volley.RequestQueue;
+import com.android.volley.VolleyError;
+import com.android.volley.toolbox.StringRequest;
+import com.android.volley.toolbox.Volley;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -267,6 +274,39 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
}
} break;
+ case "http": {
+ // FIXME: This should be behind a default-off option in Gadgetbridge settings
+ RequestQueue queue = Volley.newRequestQueue(getContext());
+ String url = json.getString("url");
+ // Request a string response from the provided URL.
+ StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
+ new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ JSONObject o = new JSONObject();
+ try {
+ o.put("t", "http");
+ o.put("resp", response);
+ } catch (JSONException e) {
+ GB.toast(getContext(), "HTTP: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
+ }
+ uartTxJSON("http", o);
+ }
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ JSONObject o = new JSONObject();
+ try {
+ o.put("t", "http");
+ o.put("err", error.toString());
+ } catch (JSONException e) {
+ GB.toast(getContext(), "HTTP: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
+ }
+ uartTxJSON("http", o);
+ }
+ });
+ queue.add(stringRequest);
+ } break;
}
}