This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 501
/
Copy pathPermissions.shared.cs
140 lines (106 loc) · 2.93 KB
/
Permissions.shared.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System.Threading.Tasks;
namespace Xamarin.Essentials
{
public static partial class Permissions
{
public static Task<PermissionStatus> CheckStatusAsync<TPermission>()
where TPermission : BasePermission, new() =>
new TPermission().CheckStatusAsync();
public static Task<PermissionStatus> RequestAsync<TPermission>()
where TPermission : BasePermission, new() =>
new TPermission().RequestAsync();
public static bool ShouldShowRationale<TPermission>()
where TPermission : BasePermission, new() =>
new TPermission().ShouldShowRationale();
internal static void EnsureDeclared<TPermission>()
where TPermission : BasePermission, new() =>
new TPermission().EnsureDeclared();
internal static async Task EnsureGrantedAsync<TPermission>()
where TPermission : BasePermission, new()
{
var status = await RequestAsync<TPermission>();
if (status != PermissionStatus.Granted)
throw new PermissionException($"{typeof(TPermission).Name} permission was not granted: {status}");
}
public abstract partial class BasePermission
{
[Preserve]
public BasePermission()
{
}
public abstract Task<PermissionStatus> CheckStatusAsync();
public abstract Task<PermissionStatus> RequestAsync();
public abstract void EnsureDeclared();
public abstract bool ShouldShowRationale();
}
public partial class Battery
{
}
public partial class CalendarRead
{
}
public partial class CalendarWrite
{
}
public partial class Camera
{
}
public partial class ContactsRead
{
}
public partial class ContactsWrite
{
}
public partial class Flashlight
{
}
public partial class LaunchApp
{
}
public partial class LocationWhenInUse
{
}
public partial class LocationAlways
{
}
public partial class Maps
{
}
public partial class Media
{
}
public partial class Microphone
{
}
public partial class NetworkState
{
}
public partial class Phone
{
}
public partial class Photos
{
}
public partial class Reminders
{
}
public partial class Sensors
{
}
public partial class Sms
{
}
public partial class Speech
{
}
public partial class StorageRead
{
}
public partial class StorageWrite
{
}
public partial class Vibrate
{
}
}
}