Skip to content

Commit

Permalink
chore: release 1.1.0+4
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuvssut committed Apr 6, 2023
2 parents e2c5aa8 + c46a405 commit ba371d9
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 41 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ An app dedicated towards woman safety. Keeping in view about the increasing case
Currently this app is compatible with Android only.

### Find it on
Play Store has the **old** v0.1.3 working version of this app. You can optionally download the [latest 1.0.0 version](https://github.com/ashuvssut/women-safety-app/releases/tag/1.0.0-rc.1) and try it out (It is not published on Play Store yet)

<a href="https://play.google.com/store/apps/details?id=com.ashuvssut.women_safety_app">
<img alt="Get it on Google Play" height="80" src="https://lh3.googleusercontent.com/q1k2l5CwMV31JdDXcpN4Ey7O43PxnjAuZBTmcHEwQxVuv_2wCE2gAAQMWxwNUC2FYEOnYgFPOpw6kmHJWuEGeIBLTj9CuxcOEeU8UXyzWJq4NJM3lg=s0" />
</a>
Expand Down
12 changes: 7 additions & 5 deletions lib/components/permission_manager/permission_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:women_safety_app/services/notification_controller.dart';
import 'permissions.dart';

class PermissionManager extends StatefulWidget {
const PermissionManager({super.key});
const PermissionManager({super.key, this.isCalledAsPopup = false});
final bool isCalledAsPopup;

@override
State<PermissionManager> createState() => _PermissionManagerState();
Expand Down Expand Up @@ -93,19 +94,19 @@ class _PermissionManagerState extends State<PermissionManager> {
}

Future<void> getPermission() async {
if (!hasContactsPerms) {
if (!hasContactsPerms && mounted) {
await ContactsPerms.request() //
.then((status) => contactsPermsHandler(status));
}
if (!hasNotificationsPerms) {
if (!hasNotificationsPerms && mounted) {
await NotificationPerms.request() //
.then((isAllowed) => notificationPermsHandler(isAllowed));
}
if (!hasLocPerms) {
if (!hasLocPerms && mounted) {
await GeolocationPerms.request() //
.then((status) => locationPermsHandler(status));
}
if (!hasSmsPerms) {
if (!hasSmsPerms && mounted) {
await SMSPerms.request() //
.then((status) => smsPermsHandler(status));
}
Expand All @@ -127,6 +128,7 @@ class _PermissionManagerState extends State<PermissionManager> {
GeolocationPerms.check().then((status) {
locationPermsHandler(status);
});
if (widget.isCalledAsPopup) Navigator.pop(context);
}

@override
Expand Down
19 changes: 19 additions & 0 deletions lib/components/permission_manager/permissions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import 'package:flutter/material.dart';
import 'package:women_safety_app/components/permission_manager/permission_manager.dart';
import 'package:women_safety_app/main.dart';

export 'permissions/geolocation.dart';
export 'permissions/notification.dart';
export 'permissions/sms.dart';
export 'permissions/contacts.dart';
export 'package:permission_handler/permission_handler.dart';

class PermissionMethods {
static Future<void> initiatePermissionManger() async {
final context = MyApp.navigatorKey.currentState?.context;
if (context == null) return;

return showDialog<void>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return const PermissionManager(isCalledAsPopup: true);
},
);
}
}
3 changes: 1 addition & 2 deletions lib/components/permission_manager/permissions/contacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/material.dart';

class ContactsPerms {
static String permanentDeniedFeedback =
'Enable SMS permissions from device settings else you will be unable to add trusted contacts.';
static String permanentDeniedFeedback = 'No Contact permissions. Unable to add trusted contacts.';

static Future<PermissionStatus> check() async {
return await Permission.contacts.status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:geolocator/geolocator.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/material.dart';

class GeolocationPerms {
static String permanentDeniedFeedback =
'Enable SMS location permission from device settings else App will be unable to add you cuurent location info in your SOS SMS';
'No location permission. Unable to add location info in your SOS message';

static Future<PermissionStatus> check() async {
return await Permission.location.status;
Expand All @@ -22,6 +23,10 @@ class GeolocationPerms {
);
}

static Future<bool> isLocationServiceEnabled() async {
return await Geolocator.isLocationServiceEnabled();
}

// You can can also directly ask the permission about its status.
// if (await Permission.location.isRestricted) {
// The OS restricts access, for example because of parental controls.
Expand Down
2 changes: 1 addition & 1 deletion lib/components/permission_manager/permissions/sms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';

class SMSPerms {
static String permanentDeniedFeedback =
'Enable SMS permissions from device settings else App will be unable to send SOS SMS to your added trusted contacts';
'No SMS permissions. Unable to send SOS SMS to your trusted contacts';

static Future<PermissionStatus> check() async {
return await Permission.sms.status;
Expand Down
24 changes: 5 additions & 19 deletions lib/services/sos_message_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,15 @@ class SosMethods {
}
}

static Future<bool> getLocationPermission() async {
bool serviceEnabled;
static Future<bool> checkLocationPermission() async {
LocationPermission permission;

serviceEnabled = await Geolocator.isLocationServiceEnabled();
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
Fluttertoast.showToast(msg: 'Please enable Your Location Service');
}

permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
Fluttertoast.showToast(msg: 'Location permissions are denied');
}
}

if (permission == LocationPermission.deniedForever) {
Fluttertoast.showToast(
msg: 'Location permissions are permanently denied, App cannot request permissions.');
}

if (permission == LocationPermission.denied || permission == LocationPermission.deniedForever) {
return false;
Expand All @@ -100,12 +88,10 @@ class SosMethods {

static Future<PositionDetails?> _determinePosition() async {
// check if location service is enabled using getLocationPermission()
bool locationPermission = await getLocationPermission();
await PermissionMethods.initiatePermissionManger();
bool locationPermission = await checkLocationPermission();
if (!locationPermission) {
// TODO: graciously handle this
Fluttertoast.showToast(
msg:
'Location Service is not enabled. SOS Failed. Please enable Location Service in your phone settings.');
Fluttertoast.showToast(msg: 'No Location data. SOS Failed.');
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/services/sos_notification_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SosNotificationMethods {
key: 'START',
label: 'Send SOS',
autoDismissible: false,
actionType: ActionType.KeepOnTop,
actionType: ActionType.Default,
enabled: true,
),
],
Expand All @@ -75,7 +75,7 @@ class SosNotificationMethods {
key: 'STOP',
label: 'Cancel SOS',
autoDismissible: false,
actionType: ActionType.KeepOnTop,
actionType: ActionType.Default,
enabled: true,
)
],
Expand Down
17 changes: 7 additions & 10 deletions lib/views/select_contact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:developer';
import 'package:contacts_service/contacts_service.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:women_safety_app/components/permission_manager/permission_manager.dart';
import 'package:women_safety_app/components/permission_manager/permissions.dart';
import 'package:women_safety_app/services/contacts.dart';
import 'package:women_safety_app/services/database_methods.dart';
Expand All @@ -24,18 +25,13 @@ class _SelectContactState extends State<SelectContact> {
@override
void initState() {
super.initState();
getContactsPermissions();
WidgetsBinding.instance.addPostFrameCallback((_) async {
initContactList();
});
}

getContactsPermissions() async {
initContactList() async {
try {
if (!await ContactsPerms.check().isGranted) {
final isGranted = await ContactsPerms.request().isGranted;
if (!isGranted) {
Fluttertoast.showToast(msg: "Please grant contacts permission to continue");
return;
}
}
if (await ContactsPerms.check().isGranted) {
getAllContacts();
searchController.addListener(() {
Expand Down Expand Up @@ -201,7 +197,8 @@ class _SelectContactState extends State<SelectContact> {
isSearching ? 'No search results to show' : 'No contacts found yet',
style: Theme.of(context).textTheme.titleLarge,
),
)
),
PermissionManager(key: UniqueKey()),
],
),
),
Expand Down
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.3"
crypto:
dependency: transitive
description:
name: crypto
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
url: "https://pub.dev"
source: hosted
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -158,6 +166,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_isolate:
dependency: "direct main"
description:
name: flutter_isolate
sha256: "994ddec596da4ca12ca52154fd59404077584643eb7e3f1008a55fda9fe0b76b"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -637,6 +653,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
uuid:
dependency: transitive
description:
name: uuid
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
url: "https://pub.dev"
source: hosted
version: "3.0.7"
vector_graphics:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+3
version: 1.1.0+4

environment:
sdk: ">=2.19.1 <3.0.0"
Expand All @@ -29,6 +29,7 @@ dependencies:
firebase_core: ^2.7.0
flutter:
sdk: flutter
flutter_isolate: ^2.0.4
flutter_svg: ^2.0.2
fluttertoast: ^8.2.1
geocoding: ^2.0.5
Expand Down

0 comments on commit ba371d9

Please sign in to comment.