diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/MainActivity.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/MainActivity.kt
index e5a99f8b..a9119098 100644
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/MainActivity.kt
+++ b/ui/digural/src/main/kotlin/de/cyface/app/digural/MainActivity.kt
@@ -44,6 +44,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import de.cyface.app.digural.auth.LoginActivity
import de.cyface.app.digural.button.ExternalCameraController
+import de.cyface.app.digural.capturing.settings.CustomPreferences
import de.cyface.app.digural.databinding.ActivityMainBinding
import de.cyface.app.digural.notification.CameraEventHandler
import de.cyface.app.digural.notification.DataCapturingEventHandler
@@ -164,7 +165,6 @@ class MainActivity : AppCompatActivity(), ServiceProvider, CameraServiceProvider
override fun onCreate(savedInstanceState: Bundle?) {
preferences = AppPreferences(this)
cameraPreferences = CameraPreferences(this)
- val diguralPreferences = DiGuRaLPreferences(this)
// Location permissions are requested by MainFragment which needs to react to results
diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/button/DiGuRaLCameraSystemTriggerer.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/button/DiGuRaLCameraSystemTriggerer.kt
deleted file mode 100644
index c4896fb7..00000000
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/button/DiGuRaLCameraSystemTriggerer.kt
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2023 Cyface GmbH
- *
- * This file is part of the Cyface App for Android.
- *
- * The Cyface App for Android is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Cyface App for Android is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with the Cyface App for Android. If not, see .
- */
-package de.cyface.app.digural.button
-
-import android.location.Location
-import de.cyface.app.digural.capturing.DiguralApi.diguralService
-import de.cyface.camera_service.background.CapturingProcessListener
-import android.util.Log
-import de.cyface.camera_service.background.ParcelableCapturingProcessListener
-import de.cyface.utils.Validate
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.withContext
-import kotlinx.parcelize.Parcelize
-import retrofit2.awaitResponse
-import java.net.HttpURLConnection
-import java.net.URL
-import java.nio.charset.Charset
-import kotlin.concurrent.thread
-
-/**
- * Calls the API that triggers external cameras to trigger in sync with this smartphones camera.
- *
- * @author Klemens Muthmann
- * @since 4.2.0
- * @constructor Create a new triggerer from the world wide unique device identifier of this device.
- */
-@Parcelize
-class DiGuRaLCameraSystemTriggerer(val deviceId: String, val address: URL) :
- ParcelableCapturingProcessListener {
- private val TAG = "de.cyface.app.digural"
-
- init {
- Validate.notEmpty(deviceId)
- Log.d(TAG, "Setting digural Server address to: ${address}!")
- baseUrl = address
- }
-
- override fun onCameraAccessLost() {}
- override fun onPictureCaptured() {}
- override fun onRecordingStarted() {}
- override fun onRecordingStopped() {}
- override fun onCameraError(reason: String) {}
- override fun onAboutToCapture(measurementId: Long, location: Location?) {
- Log.d(TAG, "######## On About to Capture $location")
- val payload = de.cyface.app.digural.capturing.Location(
- deviceId,
- measurementId,
- 50.0,
- 13.0,
- 10_000
- )
-
- /*runBlocking {
- withContext(Dispatchers.IO) {*/
-
- thread {
- //Log.d(TAG, "###########Sending Payload ${payload.toJson()}")
- with(URL("http://192.168.113.154:5000/PanAiCam/Trigger").openConnection() as HttpURLConnection) {
- try {
- requestMethod = "POST"
- //requestMethod = "GET"
- setRequestProperty("Accept", "*/*")
- setRequestProperty("Content-Type", "application/json")
- doOutput = true
- //doInput = true
-
- outputStream.use { os ->
- val input: ByteArray =
- payload.toJson().toByteArray(Charset.defaultCharset())
- os.write(input, 0, input.size)
- }
- outputStream.flush()
- outputStream.close()
-
- Log.d(TAG, "$responseCode")
- } finally {
- disconnect()
- }
- //}
- //}
-
- /*Log.d(TAG,"#############Triggering")
- val response = diguralService.trigger().awaitResponse()//(payload)
-
- Log.d(TAG, "##### Response Code: ${response.code()}")
- Log.d(TAG, "#### Body: ${response.body()}")
- Log.d(TAG, "########Triggered")*/
- }
- }
-
- /*if(location == null) {
- return
- }*/
-
- /*val payload = de.cyface.app.digural.capturing.Location(
- deviceId,
- measurementId,
- location.latitude,
- location.longitude,
- location.time
- )*/
-
-
- }
-
- override fun shallStop() {
- TODO("Not yet implemented")
- }
- }
diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/button/ExternalCameraController.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/button/ExternalCameraController.kt
index faeeb901..7de90b94 100644
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/button/ExternalCameraController.kt
+++ b/ui/digural/src/main/kotlin/de/cyface/app/digural/button/ExternalCameraController.kt
@@ -30,6 +30,10 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.parcelize.Parcelize
+import java.net.HttpURLConnection
+import java.net.URL
+import java.nio.charset.Charset
+import kotlin.concurrent.thread
/**
* Calls the API that triggers external cameras to trigger in sync with this smartphones camera.
@@ -62,7 +66,8 @@ class ExternalCameraController(private val deviceId: String) : ParcelableCapturi
override fun onRecordingStopped() {}
override fun onCameraError(reason: String) {}
override fun onAboutToCapture(measurementId: Long, location: Location?) {
- if(location == null) {
+ Log.d(TAG, "On About to Capture $location")
+ if (location == null) {
return
}
@@ -74,12 +79,40 @@ class ExternalCameraController(private val deviceId: String) : ParcelableCapturi
location.time
)
- runBlocking {
+ /* Begin Retrofit Variant */
+ /*runBlocking {
withContext(Dispatchers.IO) {
Log.d(TAG, "###########Sending Payload $payload to ${DiguralApi.baseUrl}")
DiguralApi.diguralService.trigger(payload)
}
+ }*/
+ /* End Retrofit Variant */
+
+ /* Begin Classic Variant */
+ thread {
+ Log.d(TAG, "Sending Payload ${payload.toJson()}")
+ with(URL("http://192.168.113.154:5000/PanAiCam/Trigger").openConnection() as HttpURLConnection) {
+ try {
+ requestMethod = "POST"
+ setRequestProperty("Accept", "*/*")
+ setRequestProperty("Content-Type", "application/json")
+ doOutput = true
+
+ outputStream.use { os ->
+ val input: ByteArray =
+ payload.toJson().toByteArray(Charset.defaultCharset())
+ os.write(input, 0, input.size)
+ }
+ outputStream.flush()
+ outputStream.close()
+
+ Log.d(TAG, "$responseCode")
+ } finally {
+ disconnect()
+ }
+ }
}
+ /* End Classic Variant */
}
override fun shallStop() {
diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLPreferences.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLPreferences.kt
deleted file mode 100644
index 61080406..00000000
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLPreferences.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package de.cyface.app.digural.capturing.settings
-
-import android.content.Context
-import androidx.core.content.edit
-import java.net.MalformedURLException
-import java.net.URL
-
-private const val DIGURAL_SERVER_ADDRESS = "de.cyface.digural.server"
-/**
- * This class is responsible for storing and retrieving preferences specific to the DiGuRaL project.
- */
-class DiGuRaLPreferences(context: Context) {
- private val preferences = context.getSharedPreferences("DiGuRaL", Context.MODE_PRIVATE)
-
- fun saveDiGuRaLApiAddress(address: URL) {
- preferences.edit {
- putString(DIGURAL_SERVER_ADDRESS, address.toExternalForm())
- apply()
- }
- }
-
- fun getDiGuRaLApiAddress(): URL {
- try {
- val addressString = preferences.getString(
- DIGURAL_SERVER_ADDRESS,
- "http://localhost:33553/PanAiCam/"
- )
- return URL(addressString)
- // TODO: Add proper Error handling here before merging.
- } catch (e: MalformedURLException) {
- return URL("http://localhost:33553/PanAiCam/")
- }
- }
-}
diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLServerAddress.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLServerAddress.kt
deleted file mode 100644
index 8ed1c010..00000000
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/DiGuRaLServerAddress.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package de.cyface.app.digural.capturing.settings
-
-import android.text.Editable
-import android.text.TextWatcher
-import java.net.URL
-
-class DiGuRaLServerAddress(
- private val viewModel: SettingsViewModel
-)
- : TextWatcher {
- override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
- // Nothing to do here!
- }
-
- override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
- // Nothing to do here!
- }
-
- override fun afterTextChanged(s: Editable?) {
- if(s != null) {
- viewModel.setDiGuRaLServerAddressValue(URL(s.toString()))
- }
- }
-
-}
\ No newline at end of file
diff --git a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/SettingsFragment.kt b/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/SettingsFragment.kt
index e4bfe9ae..29ae283c 100644
--- a/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/SettingsFragment.kt
+++ b/ui/digural/src/main/kotlin/de/cyface/app/digural/capturing/settings/SettingsFragment.kt
@@ -726,6 +726,7 @@ class SettingsFragment : Fragment() {
final boolean bluetoothIsConfigured = preferences.getString(BLUETOOTHLE_DEVICE_MAC_KEY, null) != null
&& preferences.getFloat(BLUETOOTHLE_WHEEL_CIRCUMFERENCE, 0.0F) > 0.0F;
connectToExternalSpeedSensorToggle.setChecked(bluetoothIsConfigured);
+*/
// connectToExternalSpeedSensorToggle.setOnClickListener(new ConnectToExternalSpeedSensorToggleListener());
diff --git a/ui/digural/src/main/res/layout/fragment_settings.xml b/ui/digural/src/main/res/layout/fragment_settings.xml
index dd450802..f1caad9a 100644
--- a/ui/digural/src/main/res/layout/fragment_settings.xml
+++ b/ui/digural/src/main/res/layout/fragment_settings.xml
@@ -614,15 +614,5 @@
-
-