diff --git a/ClimateGoApp/app/src/main/AndroidManifest.xml b/ClimateGoApp/app/src/main/AndroidManifest.xml
index 715dbe8..7372be3 100644
--- a/ClimateGoApp/app/src/main/AndroidManifest.xml
+++ b/ClimateGoApp/app/src/main/AndroidManifest.xml
@@ -2,6 +2,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java
index c319435..021733d 100644
--- a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java
+++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/DebugFragment.java
@@ -1,10 +1,18 @@
package de.cdaut.climategoapp;
+import static android.app.Activity.RESULT_OK;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Toast;
+
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
@@ -14,6 +22,22 @@ public class DebugFragment extends Fragment {
private FragmentDebugBinding binding;
+ //this is the Launcher that will make the request to
+ // enable Bluetooth and handle the result callback
+ private final ActivityResultLauncher mBtEnable = registerForActivityResult(
+ new ActivityResultContracts.StartActivityForResult(),
+ result -> {
+ if (result.getResultCode() != RESULT_OK) {
+ //make an error toast if the user denys enabling bluetooth
+ Toast.makeText(
+ getActivity().getApplicationContext(),
+ R.string.bt_required,
+ Toast.LENGTH_LONG
+ ).show();
+ }
+ }
+ );
+
@Override
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
@@ -22,20 +46,15 @@ public class DebugFragment extends Fragment {
binding = FragmentDebugBinding.inflate(inflater, container, false);
- //TODO: Add proper Function when button is pressed here
this.binding.buttonTest.setOnClickListener(view -> {
- this.binding.debugView.setText("NewText");
+ //make request to enable bluetooth
+ mBtEnable.launch(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));
});
return binding.getRoot();
}
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- }
-
@Override
public void onDestroyView() {
super.onDestroyView();
diff --git a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java
index fd52678..9f4cf3e 100644
--- a/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java
+++ b/ClimateGoApp/app/src/main/java/de/cdaut/climategoapp/sensor/SensorDebugUtils.java
@@ -8,9 +8,11 @@ public final class SensorDebugUtils {
throw new IllegalAccessError("Utility Class");
}
- public static List readSensorData(){
+ public static List readSensorData() {
ArrayList data = new ArrayList<>();
data.add("Test");
+ data.add("a");
+ data.add("b");
return data;
}
}
diff --git a/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml b/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml
index 136c5e5..e66b45b 100644
--- a/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml
+++ b/ClimateGoApp/app/src/main/res/layout/fragment_debug.xml
@@ -21,7 +21,6 @@
android:id="@+id/debugView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/ClimateGoApp/app/src/main/res/values/strings.xml b/ClimateGoApp/app/src/main/res/values/strings.xml
index 747d565..e43380c 100644
--- a/ClimateGoApp/app/src/main/res/values/strings.xml
+++ b/ClimateGoApp/app/src/main/res/values/strings.xml
@@ -4,9 +4,10 @@
Main Fragment
Debug Fragment
- Test
+ Enable Bluetooth
Main
Debug view
Open
Close
+ Bluetooth is required to connect to the sensor
\ No newline at end of file