diff --git a/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/RequireLocationForWifi.kt b/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/RequireLocationForWifi.kt
index 38a7d2ce..b4fbbb3b 100644
--- a/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/RequireLocationForWifi.kt
+++ b/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/RequireLocationForWifi.kt
@@ -38,6 +38,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import no.nordicsemi.android.common.permissions.wifi.utils.WifiPermissionNotAvailableReason
import no.nordicsemi.android.common.permissions.wifi.utils.WifiPermissionState
+import no.nordicsemi.android.common.permissions.wifi.view.LocationDisabledView
import no.nordicsemi.android.common.permissions.wifi.view.LocationPermissionRequiredView
import no.nordicsemi.android.common.permissions.wifi.viewmodel.PermissionViewModel
@@ -60,7 +61,7 @@ fun RequireLocationForWifi(
when (val s = state) {
WifiPermissionState.Available -> content(false)
is WifiPermissionState.NotAvailable -> when (s.reason) {
- WifiPermissionNotAvailableReason.DISABLED -> content(true)
+ WifiPermissionNotAvailableReason.DISABLED -> LocationDisabledView()
else -> contentWithoutLocation()
}
}
diff --git a/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/view/LocationDisabledView.kt b/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/view/LocationDisabledView.kt
new file mode 100644
index 00000000..f6da4973
--- /dev/null
+++ b/permissions-wifi/src/main/java/no/nordicsemi/android/common/permissions/wifi/view/LocationDisabledView.kt
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2024, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package no.nordicsemi.android.common.permissions.wifi.view
+
+import android.content.Context
+import android.content.Intent
+import android.provider.Settings
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.LocationOff
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.tooling.preview.Preview
+import no.nordicsemi.android.common.permissions.wifi.R
+import no.nordicsemi.android.common.theme.NordicTheme
+import no.nordicsemi.android.common.theme.view.WarningView
+
+@Composable
+internal fun LocationDisabledView() {
+ WarningView(
+ imageVector = Icons.Default.LocationOff,
+ title = stringResource(id = R.string.location_disabled),
+ hint = stringResource(id = R.string.location_disabled_des),
+ modifier = Modifier
+ .fillMaxSize()
+ .verticalScroll(rememberScrollState())
+ ) {
+ val context = LocalContext.current
+ Button(onClick = { enableLocation(context) }) {
+ Text(text = stringResource(id = R.string.enable_location))
+ }
+ }
+}
+
+private fun enableLocation(context: Context) {
+ context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
+}
+
+@Preview
+@Composable
+private fun LocationDisabledViewPreview() {
+ NordicTheme {
+ LocationDisabledView()
+ }
+}
\ No newline at end of file
diff --git a/permissions-wifi/src/main/res/values/strings.xml b/permissions-wifi/src/main/res/values/strings.xml
index c49b56f0..e0922fdd 100644
--- a/permissions-wifi/src/main/res/values/strings.xml
+++ b/permissions-wifi/src/main/res/values/strings.xml
@@ -40,6 +40,10 @@
WI-FI NOT AVAILABLE
Wi-Fi is not available on this device.
+ LOCATION DISABLED
+ Location is disabled. Please enable location to scan for Wi-Fi networks.
+ Enable Location
+
Grant Permission
Settings