From 18f24b0104005ccf36686724fec23c79241abb5c Mon Sep 17 00:00:00 2001 From: Aitor Viana Date: Tue, 29 Mar 2022 14:48:48 +0100 Subject: [PATCH] Address review comments --- .../feature/remote/VpnRemoteFeatureReceiver.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vpn-internal/src/main/java/com/duckduckgo/vpn/internal/feature/remote/VpnRemoteFeatureReceiver.kt b/vpn-internal/src/main/java/com/duckduckgo/vpn/internal/feature/remote/VpnRemoteFeatureReceiver.kt index 6877a6f03f8a..c4971f3326ae 100644 --- a/vpn-internal/src/main/java/com/duckduckgo/vpn/internal/feature/remote/VpnRemoteFeatureReceiver.kt +++ b/vpn-internal/src/main/java/com/duckduckgo/vpn/internal/feature/remote/VpnRemoteFeatureReceiver.kt @@ -47,6 +47,9 @@ import javax.inject.Inject import kotlin.reflect.KClass private const val REMOTE_FEATURE = "remote-feature" +private const val ON = "on" +private const val OFF = "off" +private const val TYPE = "type" class VpnRemoteFeatureReceiver( context: Context, @@ -59,28 +62,28 @@ class VpnRemoteFeatureReceiver( fun enableIntent(type: KClass): Intent { return Intent(REMOTE_FEATURE).apply { - putExtra("type", type.nestedClassQualifiedName()) - putExtra(type.qualifiedName, "on") + putExtra(TYPE, type.nestedClassQualifiedName()) + putExtra(type.qualifiedName, ON) } } fun disableIntent(type: KClass): Intent { return Intent(REMOTE_FEATURE).apply { - putExtra("type", type.nestedClassQualifiedName()) - putExtra(type.qualifiedName, "off") + putExtra(TYPE, type.nestedClassQualifiedName()) + putExtra(type.qualifiedName, OFF) } } fun isOnIntent(intent: Intent): Boolean { - return intent.getStringExtra(getType(intent).qualifiedName)?.lowercase() == "on" + return intent.getStringExtra(getType(intent).qualifiedName)?.lowercase() == ON } fun isOffIntent(intent: Intent): Boolean { - return intent.getStringExtra(getType(intent).qualifiedName)?.lowercase() == "off" + return intent.getStringExtra(getType(intent).qualifiedName)?.lowercase() == OFF } fun getType(intent: Intent): KClass { - return Class.forName(intent.getStringExtra("type")!!).kotlin as KClass + return Class.forName(intent.getStringExtra(TYPE)!!).kotlin as KClass } private fun KClass<*>.nestedClassQualifiedName(): String {