Skip to content

Commit ea43912

Browse files
committed
[Pavithran] Add. contact permission and routing
1 parent c49f37a commit ea43912

File tree

5 files changed

+198
-1
lines changed

5 files changed

+198
-1
lines changed

demo-app/android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.READ_CONTACTS"/>
3+
<queries>
4+
<intent>
5+
<action android:name="android.intent.action.VIEW" />
6+
<data android:scheme="tel" />
7+
</intent>
8+
</queries>
29
<application
310
android:label="appium_testing_app"
411
android:name="${applicationName}"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import 'package:appium_testing_app/components/custom_app_bar.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:permission_handler/permission_handler.dart';
4+
import 'package:url_launcher/url_launcher.dart';
5+
6+
class ContactPermissionScreen extends StatefulWidget {
7+
final String title;
8+
9+
const ContactPermissionScreen({required this.title, super.key});
10+
11+
@override
12+
State<ContactPermissionScreen> createState() =>
13+
_ContactPermissionScreenState();
14+
}
15+
16+
class _ContactPermissionScreenState extends State<ContactPermissionScreen> {
17+
@override
18+
Widget build(BuildContext context) {
19+
return Scaffold(
20+
appBar: CustomAppBarWidget(title: widget.title),
21+
body: Center(
22+
child: Column(
23+
children: [
24+
ElevatedButton(
25+
onPressed: () async {
26+
PermissionStatus contactsStatus =
27+
await Permission.contacts.status;
28+
if (contactsStatus == PermissionStatus.granted) {
29+
await _launchContacts();
30+
} else if (contactsStatus == PermissionStatus.denied) {
31+
if (await Permission.contacts.request().isGranted) {
32+
// Open Contacts App
33+
await _launchContacts();
34+
}
35+
} else if (contactsStatus ==
36+
PermissionStatus.permanentlyDenied) {
37+
await openAppSettings();
38+
}
39+
},
40+
style: ElevatedButton.styleFrom(
41+
backgroundColor: Theme.of(context).colorScheme.primary,
42+
),
43+
child: const Text(
44+
"Ask Contact Permission",
45+
style: TextStyle(color: Colors.white),
46+
),
47+
),
48+
],
49+
),
50+
),
51+
);
52+
}
53+
54+
Future<void> _launchContacts() async {
55+
const url = 'content://contacts/people/';
56+
if (await canLaunchUrl(Uri.parse(url))) {
57+
await launchUrl(Uri.parse(url));
58+
} else {
59+
throw 'Could not launch $url';
60+
}
61+
}
62+
}

demo-app/lib/screens/home_screen.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:appium_testing_app/screens/wheel_picker_screen.dart';
1111
import 'package:flutter/material.dart';
1212

1313
import 'carousel_screen.dart';
14+
import 'contact_permission_screen.dart';
1415
import 'double_and_long_tap_screen.dart';
1516
import 'drag_and_drop_screen.dart';
1617
import 'forms_screen.dart';
@@ -60,6 +61,8 @@ class _HomeScreenState extends State<HomeScreen> {
6061
subtitle: "Page with horizontal and vertical scroll"));
6162
featureModels.add(FeatureModel(
6263
title: "Loader Screen", subtitle: "Page with loader and a button"));
64+
featureModels.add(FeatureModel(
65+
title: "Contact permission", subtitle: "Asks for contact permission with native popup"));
6366
}
6467

6568
@override
@@ -147,6 +150,9 @@ class _HomeScreenState extends State<HomeScreen> {
147150
case 13:
148151
page = LoaderScreen(title: featureModels[index].title);
149152
break;
153+
case 14:
154+
page = ContactPermissionScreen(title: featureModels[index].title,);
155+
break;
150156
default:
151157
page = NativeScreen(title: featureModels[index].title);
152158
break;

demo-app/pubspec.lock

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ packages:
2323
path: "../server"
2424
relative: true
2525
source: path
26-
version: "0.0.6"
26+
version: "0.0.11"
2727
args:
2828
dependency: transitive
2929
description:
@@ -454,6 +454,54 @@ packages:
454454
url: "https://pub.dev"
455455
source: hosted
456456
version: "2.2.1"
457+
permission_handler:
458+
dependency: "direct main"
459+
description:
460+
name: permission_handler
461+
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
462+
url: "https://pub.dev"
463+
source: hosted
464+
version: "11.3.1"
465+
permission_handler_android:
466+
dependency: transitive
467+
description:
468+
name: permission_handler_android
469+
sha256: b29a799ca03be9f999aa6c39f7de5209482d638e6f857f6b93b0875c618b7e54
470+
url: "https://pub.dev"
471+
source: hosted
472+
version: "12.0.7"
473+
permission_handler_apple:
474+
dependency: transitive
475+
description:
476+
name: permission_handler_apple
477+
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
478+
url: "https://pub.dev"
479+
source: hosted
480+
version: "9.4.5"
481+
permission_handler_html:
482+
dependency: transitive
483+
description:
484+
name: permission_handler_html
485+
sha256: "54bf176b90f6eddd4ece307e2c06cf977fb3973719c35a93b85cc7093eb6070d"
486+
url: "https://pub.dev"
487+
source: hosted
488+
version: "0.1.1"
489+
permission_handler_platform_interface:
490+
dependency: transitive
491+
description:
492+
name: permission_handler_platform_interface
493+
sha256: "48d4fcf201a1dad93ee869ab0d4101d084f49136ec82a8a06ed9cfeacab9fd20"
494+
url: "https://pub.dev"
495+
source: hosted
496+
version: "4.2.1"
497+
permission_handler_windows:
498+
dependency: transitive
499+
description:
500+
name: permission_handler_windows
501+
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
502+
url: "https://pub.dev"
503+
source: hosted
504+
version: "0.2.1"
457505
platform:
458506
dependency: transitive
459507
description:
@@ -502,6 +550,14 @@ packages:
502550
url: "https://pub.dev"
503551
source: hosted
504552
version: "1.3.0"
553+
quiver:
554+
dependency: transitive
555+
description:
556+
name: quiver
557+
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
558+
url: "https://pub.dev"
559+
source: hosted
560+
version: "3.2.1"
505561
sembast:
506562
dependency: transitive
507563
description:
@@ -675,6 +731,70 @@ packages:
675731
url: "https://pub.dev"
676732
source: hosted
677733
version: "2.2.2"
734+
url_launcher:
735+
dependency: "direct main"
736+
description:
737+
name: url_launcher
738+
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
739+
url: "https://pub.dev"
740+
source: hosted
741+
version: "6.3.0"
742+
url_launcher_android:
743+
dependency: transitive
744+
description:
745+
name: url_launcher_android
746+
sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf
747+
url: "https://pub.dev"
748+
source: hosted
749+
version: "6.3.3"
750+
url_launcher_ios:
751+
dependency: transitive
752+
description:
753+
name: url_launcher_ios
754+
sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89"
755+
url: "https://pub.dev"
756+
source: hosted
757+
version: "6.3.0"
758+
url_launcher_linux:
759+
dependency: transitive
760+
description:
761+
name: url_launcher_linux
762+
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
763+
url: "https://pub.dev"
764+
source: hosted
765+
version: "3.1.1"
766+
url_launcher_macos:
767+
dependency: transitive
768+
description:
769+
name: url_launcher_macos
770+
sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
771+
url: "https://pub.dev"
772+
source: hosted
773+
version: "3.2.0"
774+
url_launcher_platform_interface:
775+
dependency: transitive
776+
description:
777+
name: url_launcher_platform_interface
778+
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
779+
url: "https://pub.dev"
780+
source: hosted
781+
version: "2.3.2"
782+
url_launcher_web:
783+
dependency: transitive
784+
description:
785+
name: url_launcher_web
786+
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
787+
url: "https://pub.dev"
788+
source: hosted
789+
version: "2.3.1"
790+
url_launcher_windows:
791+
dependency: transitive
792+
description:
793+
name: url_launcher_windows
794+
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
795+
url: "https://pub.dev"
796+
source: hosted
797+
version: "3.1.1"
678798
uuid:
679799
dependency: transitive
680800
description:

demo-app/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ environment:
2121
dependencies:
2222
webview_flutter: ^4.5.0
2323
carousel_slider: ^4.2.1
24+
permission_handler: ^11.3.1
25+
url_launcher: ^6.3.0
2426
flutter:
2527
sdk: flutter
2628

0 commit comments

Comments
 (0)