diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
index d52f41dacf..19a4e3a841 100644
--- a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
+++ b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
@@ -53,9 +53,15 @@ class TestPushFromPushGateway @Inject constructor(private val context: AppCompat
}
override fun onSuccess(data: Unit) {
+ // Wait for user to click on the notification
description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_success)
- status = TestStatus.SUCCESS
+ status = TestStatus.RUNNING
}
})
}
+
+ override fun onNotificationClicked() {
+ description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_notification_clicked)
+ status = TestStatus.SUCCESS
+ }
}
diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index 3f178a3d20..d8ae90a33c 100644
--- a/vector/src/main/AndroidManifest.xml
+++ b/vector/src/main/AndroidManifest.xml
@@ -252,6 +252,10 @@
android:name=".features.call.service.CallHeadsUpActionReceiver"
android:exported="false" />
+
+
{
// check if there are quick fixes
+ // TODO Rewrite using firstOrNull
var hasQuickFix = false
testManager?.testList?.let {
for (test in it) {
@@ -161,6 +172,25 @@ class VectorSettingsNotificationsTroubleshootFragment @Inject constructor(
override fun onResume() {
super.onResume()
(activity as? VectorBaseActivity)?.supportActionBar?.setTitle(R.string.settings_notification_troubleshoot)
+
+ tryOrNull("Unable to register the receiver") {
+ LocalBroadcastManager.getInstance(requireContext())
+ .registerReceiver(broadcastReceiver, IntentFilter(NotificationUtils.DIAGNOSTIC_ACTION))
+ }
+ }
+
+ override fun onPause() {
+ super.onPause()
+ tryOrNull {
+ LocalBroadcastManager.getInstance(requireContext())
+ .unregisterReceiver(broadcastReceiver)
+ }
+ }
+
+ private val broadcastReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ testManager?.onDiagnosticNotificationClicked()
+ }
}
override fun onAttach(context: Context) {
diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootTestManager.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootTestManager.kt
index e977dc5963..0c77caf635 100644
--- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootTestManager.kt
+++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootTestManager.kt
@@ -94,4 +94,10 @@ class NotificationTroubleshootTestManager(val fragment: Fragment) {
test.cancel()
}
}
+
+ fun onDiagnosticNotificationClicked() {
+ testList.forEach {
+ it.onNotificationClicked()
+ }
+ }
}
diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestNotificationReceiver.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestNotificationReceiver.kt
new file mode 100644
index 0000000000..7dec870d3d
--- /dev/null
+++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestNotificationReceiver.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 New Vector Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package im.vector.app.features.settings.troubleshoot
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import androidx.localbroadcastmanager.content.LocalBroadcastManager
+
+class TestNotificationReceiver : BroadcastReceiver() {
+
+ override fun onReceive(context: Context, intent: Intent) {
+ // Internal broadcast to any one interested
+ LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
+ }
+}
diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TroubleshootTest.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TroubleshootTest.kt
index f894fcc0ef..aedca5e356 100644
--- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TroubleshootTest.kt
+++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TroubleshootTest.kt
@@ -51,4 +51,7 @@ abstract class TroubleshootTest(@StringRes val titleResId: Int) {
open fun cancel() {
}
+
+ open fun onNotificationClicked() {
+ }
}
diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml
index d5e590375c..004da5e15e 100644
--- a/vector/src/main/res/values/strings.xml
+++ b/vector/src/main/res/values/strings.xml
@@ -750,9 +750,10 @@
Failed to register FCM token to HomeServer:\n%1$s
Test Push
- The application is receiving PUSH, you should see a notification.
+ The application is receiving PUSH, please click on the test notification you just receive.
+ The notification has been clicked!
Failed to receive push. Solution could be to reinstall the application.
- You are receiving PUSH!
+ You are receiving PUSH! Click me!
Notifications Service
Notifications Service is running.