diff --git a/Client/Android/app/src/main/java/com/neptune/app/DeviceActivity.java b/Client/Android/app/src/main/java/com/neptune/app/DeviceActivity.java
index 1d0676c..323842f 100644
--- a/Client/Android/app/src/main/java/com/neptune/app/DeviceActivity.java
+++ b/Client/Android/app/src/main/java/com/neptune/app/DeviceActivity.java
@@ -1,12 +1,14 @@
package com.neptune.app;//comment
import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
@@ -14,9 +16,11 @@
import android.content.Intent;
import android.view.View;
+import com.google.gson.JsonParseException;
import com.neptune.app.Backend.ConnectionManager;
import com.neptune.app.Backend.Server;
+import java.io.IOException;
import java.util.UUID;
@@ -29,6 +33,7 @@ public class DeviceActivity extends AppCompatActivity {
private TextView notificationsTextView;
private TextView clipboardTextView;
private TextView fileTextView;
+ private CheckBox notificationsCheckbox;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -55,6 +60,43 @@ protected void onCreate(Bundle savedInstanceState) {
fileTextView = findViewById(R.id.fileTextView);
fileTextView.setText("Allow " + serverFriendlyName + " to send files.");
+ notificationsCheckbox = findViewById(R.id.notificationsCheckbox);
+ if(server.syncNotifications) {
+ notificationsCheckbox.setChecked(true);
+ }
+ notificationsCheckbox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if(server.syncNotifications) {
+ server.syncNotifications = false;
+ }
+ else {
+ server.syncNotifications = true;
+ }
+
+ try {
+ server.save();
+ } catch (JsonParseException e) {
+ e.printStackTrace();
+ if (server != null)
+ server.delete();
+ runOnUiThread(() -> showErrorMessage("Failed to pair device", e.getMessage()));
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ if (server != null)
+ server.delete();
+ runOnUiThread(() -> showErrorMessage("Failed to pair device", e.getMessage()));
+
+ }/* catch (ConnectionManager.FailedToPair e) {
+ e.printStackTrace();
+ if (server != null)
+ server.delete();
+ runOnUiThread(() -> showErrorMessage("Failed to pair device", e.getMessage()));
+ }*/
+ }
+ });
+
//Sets the EditText containing the IP address of the server to the correct IP Address.
ipAddress = findViewById(R.id.editIPAddress);
ipAddress.setText(server.ipAddress.getIPAddress());
@@ -164,4 +206,14 @@ public boolean onSupportNavigateUp() {
return true;
}
+ public void showErrorMessage(String title, String message) {
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
+ alertBuilder.setTitle(title);
+ alertBuilder.setMessage(message);
+ alertBuilder.setPositiveButton("Ok", (dialog, which) -> {
+ // do stuff here?
+ });
+
+ alertBuilder.create().show();
+ }
}
diff --git a/Client/Android/app/src/main/res/layout/activity_device.xml b/Client/Android/app/src/main/res/layout/activity_device.xml
index 05d7d0c..76b60ce 100644
--- a/Client/Android/app/src/main/res/layout/activity_device.xml
+++ b/Client/Android/app/src/main/res/layout/activity_device.xml
@@ -68,7 +68,7 @@
app:layout_constraintVertical_bias="1.0" />
+ app:layout_constraintTop_toBottomOf="@+id/notificationsCheckbox" />