From 6e3f3c44af60e501ffb0624cc1364beb5d49fc56 Mon Sep 17 00:00:00 2001 From: raphael Date: Wed, 29 Dec 2021 23:22:12 +0100 Subject: [PATCH] adds stub for notifications --- .../com/example/bump/MessageProcessorTest.kt | 12 ++- .../java/com/example/bump/RestCryptTest.kt | 12 +++ app/src/main/AndroidManifest.xml | 4 +- app/src/main/java/com/example/bump/Message.kt | 5 - .../example/bump/receiver/AlarmReceiver.kt | 28 ++++++ .../example/bump/receiver/SnoozeReceiver.kt | 42 +++++++++ .../example/bump/{ => ui}/CameraFragment.kt | 7 +- .../example/bump/{ => ui}/FirstFragment.kt | 50 ++++++++-- .../com/example/bump/{ => ui}/MainActivity.kt | 3 +- .../example/bump/{ => ui}/MainApplication.kt | 4 +- .../example/bump/{ => ui}/SecondFragment.kt | 2 +- .../example/bump/{ => util}/BumpProcessor.kt | 6 +- .../bump/{ => util}/CameraXViewModel.kt | 2 +- .../com/example/bump/{ => util}/LocalData.kt | 2 +- .../java/com/example/bump/util/Message.kt | 10 ++ .../bump/{ => util}/MessageProcessor.kt | 6 +- .../com/example/bump/util/NotificationUtil.kt | 91 +++++++++++++++++++ .../example/bump/{ => util}/RestSingleton.kt | 4 +- app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/fragment_camera.xml | 2 +- app/src/main/res/layout/fragment_first.xml | 2 +- app/src/main/res/layout/fragment_second.xml | 2 +- app/src/main/res/menu/menu_main.xml | 2 +- app/src/main/res/navigation/nav_graph.xml | 6 +- app/src/main/res/values/strings.xml | 4 + 25 files changed, 267 insertions(+), 43 deletions(-) delete mode 100644 app/src/main/java/com/example/bump/Message.kt create mode 100644 app/src/main/java/com/example/bump/receiver/AlarmReceiver.kt create mode 100644 app/src/main/java/com/example/bump/receiver/SnoozeReceiver.kt rename app/src/main/java/com/example/bump/{ => ui}/CameraFragment.kt (97%) rename app/src/main/java/com/example/bump/{ => ui}/FirstFragment.kt (50%) rename app/src/main/java/com/example/bump/{ => ui}/MainActivity.kt (97%) rename app/src/main/java/com/example/bump/{ => ui}/MainApplication.kt (87%) rename app/src/main/java/com/example/bump/{ => ui}/SecondFragment.kt (97%) rename app/src/main/java/com/example/bump/{ => util}/BumpProcessor.kt (94%) rename app/src/main/java/com/example/bump/{ => util}/CameraXViewModel.kt (98%) rename app/src/main/java/com/example/bump/{ => util}/LocalData.kt (95%) create mode 100644 app/src/main/java/com/example/bump/util/Message.kt rename app/src/main/java/com/example/bump/{ => util}/MessageProcessor.kt (97%) create mode 100644 app/src/main/java/com/example/bump/util/NotificationUtil.kt rename app/src/main/java/com/example/bump/{ => util}/RestSingleton.kt (97%) diff --git a/app/src/androidTest/java/com/example/bump/MessageProcessorTest.kt b/app/src/androidTest/java/com/example/bump/MessageProcessorTest.kt index dedba27..72f29d5 100644 --- a/app/src/androidTest/java/com/example/bump/MessageProcessorTest.kt +++ b/app/src/androidTest/java/com/example/bump/MessageProcessorTest.kt @@ -1,8 +1,9 @@ package com.example.bump import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.internal.runner.InstrumentationConnection import androidx.test.platform.app.InstrumentationRegistry +import com.example.bump.util.LocalData +import com.example.bump.util.MessageProcessor import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -15,8 +16,9 @@ class MessageProcessorTest { val code = "dydoes-unknowledgeable-indiscretion-househusbands-pot-walloper-indiscretion-discophorous-transcriptions-dydoes-poodle-faker-transcriptions-budlike" // val messageRaw = "M1dEAxKZ5HUHCJoRkgGOvAABhqCAAAAAAGG2eKTSlKXWLDQx5B_wssZsNwsanzQID2UyUm4KKuKYKgfwH5MG2N-qzt6K4mg3pfZmWPaiDB9PiqlX236k6zo9Yvvq" val messageRaw = "M1dEAxKZ5HUHCJoRkgGOvAABhqCAAAAAAGG8afPPk380EzwcbGzNoTr_I4y6YT8hnUYcToinlgsVkaUx5K-JicdS5epZenOX4u8vVhhMvR0ebeWm_mgp6LZvTw8S" - val data = decryptMessage(code, messageRaw) - Assert.assertEquals(data, "hello") + val processor = MessageProcessor(code) + val decrypted = processor.decrypt(messageRaw) + Assert.assertEquals(decrypted, "hello") } @Test @@ -26,7 +28,9 @@ class MessageProcessorTest { val test = getRandomString(32) val encrypted = message.encrypt(test) - val decrypted = decryptMessage(code, encrypted) + + val processor = MessageProcessor(code) + val decrypted = processor.decrypt(encrypted) Assert.assertEquals(test, decrypted) } diff --git a/app/src/androidTest/java/com/example/bump/RestCryptTest.kt b/app/src/androidTest/java/com/example/bump/RestCryptTest.kt index 7b3f724..7b6f042 100644 --- a/app/src/androidTest/java/com/example/bump/RestCryptTest.kt +++ b/app/src/androidTest/java/com/example/bump/RestCryptTest.kt @@ -2,6 +2,9 @@ package com.example.bump import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.example.bump.util.Message +import com.example.bump.util.MessageProcessor +import com.example.bump.util.RestSingleton import org.json.JSONArray import org.json.JSONObject @@ -27,6 +30,13 @@ class ExampleInstrumentedTest { } } +class NotificationTest { + @Test + fun showNotification() { + + } +} + class RestCryptTest{ @Test @@ -46,6 +56,8 @@ class RestCryptTest{ assertEquals(messageData, encrypted) val data = message.decrypt(messageData) assertEquals(data, testMessage) + + val m = Message(code, data, messageEncrypted.get("timestamp").toString()) lock.countDown() } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index baf73e4..a4014c9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ + tools:context="com.example.bump.ui.MainActivity"> + tools:context="com.example.bump.ui.SecondFragment">