Skip to content

Commit

Permalink
fix permission on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ghassenbenzahra123 committed Jul 9, 2024
1 parent 9e1a896 commit bc2f74c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions lib/src/pages/SplashScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:mawaqit/src/helpers/PerformanceHelper.dart';
import 'package:mawaqit/src/helpers/RelativeSizes.dart';
import 'package:mawaqit/src/helpers/SharedPref.dart';
import 'package:mawaqit/src/helpers/StreamGenerator.dart';
import 'package:mawaqit/src/helpers/TimeShiftManager.dart';
import 'package:mawaqit/src/models/settings.dart';
import 'package:mawaqit/src/pages/ErrorScreen.dart';
import 'package:mawaqit/src/pages/home/OfflineHomeScreen.dart';
Expand Down Expand Up @@ -101,7 +102,21 @@ class _SplashScreen extends State<Splash> {

return res == null;
}
Future<void> addLocationPermission() async {
try {
await platform.invokeMethod('addLocationPermission');
} on PlatformException catch (e) {
logger.e("kiosk mode: location permission: error: $e");
}
}

Future<void> addFineLocationPermission() async {
try {
await platform.invokeMethod('grantFineLocationPermission');
} on PlatformException catch (e) {
logger.e("kiosk mode: location permission: error: $e");
}
}
/// navigates to first screen
Future<void> _initApplication() async {
try {
Expand All @@ -110,7 +125,12 @@ class _SplashScreen extends State<Splash> {
var goBoarding = await loadBoarding();
var mosqueManager = context.read<MosqueManager>();
bool hasNoMosque = mosqueManager.mosqueUUID == null;
final TimeShiftManager _timeManager = TimeShiftManager();

if (_timeManager.deviceModel == "MAWAQITBOX V2") {
await addLocationPermission();
await addFineLocationPermission();
}
/// waite for the animation if it is not loaded yet
await animationFuture.future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class WifiScanNotifier extends AsyncNotifier<WifiScanState> {
Future<void> _scan() async {
state = AsyncLoading();
try {
if (_timeManager.deviceModel != "MAWAQITBOX V2") {
final can = await WiFiScan.instance.canStartScan();
if (can != CanStartScan.yes) {
logger.e("kiosk mode: wifi_scan: can't start scan");
Expand All @@ -38,7 +37,7 @@ class WifiScanNotifier extends AsyncNotifier<WifiScanState> {
logger.e("kiosk mode: wifi_scan: can't get scanned results");
return;
}
}

final results = await WiFiScan.instance.getScannedResults();
state = AsyncData(
state.value!.copyWith(
Expand Down

0 comments on commit bc2f74c

Please sign in to comment.