up pr: code reviewed

This commit is contained in:
S1m 2021-07-07 01:49:39 +02:00
parent 6c153d04da
commit 4ac4755868
7 changed files with 18 additions and 17 deletions

View file

@ -444,8 +444,9 @@ dependencies {
implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
// Unifiedpush
implementation 'com.github.UnifiedPush:android-connector:1.1.3'
// UnifiedPush
implementation 'com.github.UnifiedPush:android-connector:1.2.0'
// UnifiedPush gplay flavor only
gplayImplementation 'com.github.UnifiedPush:android-embedded_fcm_distributor:1.1.0'
// OSS License, gplay flavor only

View file

@ -35,7 +35,6 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
private val testSystemSettings: TestSystemSettings,
private val testAccountSettings: TestAccountSettings,
private val testDeviceSettings: TestDeviceSettings,
private val testBingRulesSettings: TestPushRulesSettings,
private val testNewEndpoint: TestNewEndpoint,
private val testTokenRegistration: TestTokenRegistration,
private val testPushFromPushGateway: TestPushFromPushGateway,
@ -51,13 +50,12 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
mgr.addTest(testSystemSettings)
mgr.addTest(testAccountSettings)
mgr.addTest(testDeviceSettings)
mgr.addTest(testPushRulesSettings)
if (UPHelper.distributorExists(fragment.requireContext())) {
mgr.addTest(testBingRulesSettings)
mgr.addTest(testNewEndpoint)
mgr.addTest(testTokenRegistration)
mgr.addTest(testPushFromPushGateway)
} else {
mgr.addTest(testPushRulesSettings)
mgr.addTest(testAutoStartBoot)
mgr.addTest(testBackgroundRestrictions)
mgr.addTest(testBatteryOptimization)

View file

@ -36,7 +36,6 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
private val testSystemSettings: TestSystemSettings,
private val testAccountSettings: TestAccountSettings,
private val testDeviceSettings: TestDeviceSettings,
private val testBingRulesSettings: TestPushRulesSettings,
private val testPlayServices: TestPlayServices,
private val testNewEndpoint: TestNewEndpoint,
private val testTokenRegistration: TestTokenRegistration,
@ -53,14 +52,13 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
mgr.addTest(testSystemSettings)
mgr.addTest(testAccountSettings)
mgr.addTest(testDeviceSettings)
mgr.addTest(testPushRulesSettings)
if (UPHelper.distributorExists(fragment.requireContext())) {
mgr.addTest(testBingRulesSettings)
mgr.addTest(testPlayServices)
mgr.addTest(testNewEndpoint)
mgr.addTest(testTokenRegistration)
mgr.addTest(testPushFromPushGateway)
} else {
mgr.addTest(testPushRulesSettings)
mgr.addTest(testAutoStartBoot)
mgr.addTest(testBackgroundRestrictions)
mgr.addTest(testBatteryOptimization)

View file

@ -71,8 +71,9 @@ class PushersManager @Inject constructor(
val appId = stringProvider.getString(R.string.pusher_app_id)
return if (UPHelper.isEmbeddedDistributor(context)) {
appId
} else
"${appId}.up"
} else {
"$appId.up"
}
}
companion object {

View file

@ -19,6 +19,7 @@ import android.content.Context
import android.content.pm.PackageManager
import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.push.fcm.FcmHelper
@ -104,7 +105,7 @@ object UPHelper {
up.registerApp(context)
}
else -> {
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
val builder: AlertDialog.Builder = MaterialAlertDialogBuilder(context)
builder.setTitle(context.getString(R.string.unifiedpush_getdistributors_dialog_title))
val distributorsArray = distributors.toTypedArray()
@ -142,8 +143,9 @@ object UPHelper {
// register app_id type upfcm on sygnal
// the pushkey if FCM key
val up = Registration()
if (up.getDistributor(context) == context.packageName)
if (up.getDistributor(context) == context.packageName) {
return context.getString(R.string.pusher_http_url)
}
// else, unifiedpush, and pushkey is an endpoint
val default = context.getString(R.string.default_push_gateway_http_url)
endpoint?.let {
@ -175,5 +177,4 @@ object UPHelper {
val up = Registration()
return up.getDistributor(context) == context.packageName
}
}

View file

@ -38,9 +38,9 @@ class TestNewEndpoint @Inject constructor(private val context: AppCompatActivity
if (!endpoint.isNullOrEmpty()) {
status = TestStatus.SUCCESS
description = stringProvider.getString(R.string.settings_troubleshoot_test_endpoint_success, endpoint)
return
}
} else {
status = TestStatus.FAILED
description = stringProvider.getString(R.string.settings_troubleshoot_test_endpoint_failed)
}
}
}

View file

@ -14,8 +14,10 @@
-->
<!-- Note: pusher_http_url should have path '/_matrix/push/v1/notify' -->
<!-- It is the push gateway for FCM embedded distributor -->
<string name="pusher_http_url" translatable="false">https://matrix.org/_matrix/push/v1/notify</string>
<!-- Note: pusher_http_url should have path '/_matrix/push/v1/notify' -->
<!-- Note: default_push_gateway_http_url should have path '/_matrix/push/v1/notify' -->
<!-- It is the push gateway for UnifiedPush -->
<string name="default_push_gateway_http_url" translatable="false">https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify</string>
<!-- Note: pusher_app_id cannot exceed 64 chars -->
<string name="pusher_app_id" translatable="false">im.vector.app.android</string>