1
1
using Android . App ;
2
- using Android . Content ;
3
2
using Android . Content . PM ;
4
3
using Android . OS ;
5
- using Android . Runtime ;
6
4
using Avalonia ;
7
5
using Avalonia . Android ;
8
6
using Avalonia . ReactiveUI ;
11
9
using Pixed . Application . DependencyInjection ;
12
10
using Pixed . Application . IO ;
13
11
using Pixed . Application . Platform ;
14
- using System . Threading . Tasks ;
15
12
16
13
namespace Pixed . Android ;
17
14
@@ -22,8 +19,7 @@ namespace Pixed.Android;
22
19
ConfigurationChanges = ConfigChanges . Orientation | ConfigChanges . ScreenSize | ConfigChanges . UiMode ) ]
23
20
public class MainActivity : AvaloniaMainActivity < App >
24
21
{
25
- private TaskCompletionSource < Permission > _permissionTcs ;
26
- protected override async void OnCreate ( Bundle ? savedInstanceState )
22
+ protected override void OnCreate ( Bundle ? savedInstanceState )
27
23
{
28
24
AndroidX . Core . SplashScreen . SplashScreen . InstallSplashScreen ( this ) ;
29
25
PlatformSettings . MainActivity = this ;
@@ -34,13 +30,6 @@ protected override async void OnCreate(Bundle? savedInstanceState)
34
30
IPlatformSettings . Instance = new PlatformSettings ( ) ;
35
31
36
32
base . OnCreate ( savedInstanceState ) ;
37
- var permissions = await CheckPermissions ( ) ;
38
-
39
- if ( permissions != Permission . Granted )
40
- {
41
- Process . KillProcess ( Process . MyPid ( ) ) ;
42
- return ;
43
- }
44
33
}
45
34
protected override AppBuilder CustomizeAppBuilder ( AppBuilder builder )
46
35
{
@@ -50,42 +39,5 @@ protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
50
39
. UseReactiveUI ( )
51
40
. UseShell ( ) ;
52
41
}
53
-
54
- private Task < Permission > CheckPermissions ( )
55
- {
56
- if ( Environment . IsExternalStorageManager )
57
- {
58
- return Task . FromResult ( Permission . Granted ) ;
59
- }
60
-
61
- if ( _permissionTcs != null && _permissionTcs . Task . IsCompleted )
62
- {
63
- _permissionTcs . SetCanceled ( ) ;
64
- _permissionTcs = null ;
65
- }
66
-
67
- Intent intent = new ( global ::Android . Provider . Settings . ActionManageAppAllFilesAccessPermission ) ;
68
- intent . AddCategory ( "android.intent.category.DEFAULT" ) ;
69
- intent . SetData ( global ::Android . Net . Uri . Parse ( "package:" + PackageName ) ) ;
70
- StartActivityForResult ( intent , 1 ) ;
71
- _permissionTcs = new TaskCompletionSource < Permission > ( ) ;
72
- return _permissionTcs . Task ;
73
- }
74
-
75
- protected override void OnActivityResult ( int requestCode , [ GeneratedEnum ] Result resultCode , Intent ? data )
76
- {
77
- base . OnActivityResult ( requestCode , resultCode , data ) ;
78
-
79
- if ( requestCode == 1 )
80
- {
81
- if ( Environment . IsExternalStorageManager )
82
- {
83
- _permissionTcs . TrySetResult ( Permission . Granted ) ;
84
- return ;
85
- }
86
-
87
- _permissionTcs . TrySetResult ( Permission . Denied ) ;
88
- }
89
- }
90
42
}
91
43
0 commit comments