File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 3
3
using Android . Content . PM ;
4
4
using Android . Content . Res ;
5
5
using Android . Provider ;
6
+ #if __ANDROID_29__
7
+ using AndroidX . Core . Content . PM ;
8
+ #else
9
+ using Android . Support . V4 . Content . PM ;
10
+ #endif
6
11
7
12
namespace Xamarin . Essentials
8
13
{
@@ -33,7 +38,13 @@ static string PlatformGetBuild()
33
38
var packageName = Platform . AppContext . PackageName ;
34
39
using ( var info = pm . GetPackageInfo ( packageName , PackageInfoFlags . MetaData ) )
35
40
{
41
+ #if __ANDROID_28__
42
+ return PackageInfoCompat . GetLongVersionCode ( info ) . ToString ( CultureInfo . InvariantCulture ) ;
43
+ #else
44
+ #pragma warning disable CS0618 // Type or member is obsolete
36
45
return info . VersionCode . ToString ( CultureInfo . InvariantCulture ) ;
46
+ #pragma warning restore CS0618 // Type or member is obsolete
47
+ #endif
37
48
}
38
49
}
39
50
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ public override Task<PermissionStatus> CheckStatusAsync() =>
25
25
public override Task < PermissionStatus > RequestAsync ( ) =>
26
26
Task . FromResult ( PermissionStatus . Granted ) ;
27
27
28
+ public override bool ShouldShowRationale ( ) => false ;
29
+
28
30
public override void EnsureDeclared ( )
29
31
{
30
32
var plistKeys = RequiredInfoPlistKeys ? . Invoke ( ) ;
Original file line number Diff line number Diff line change @@ -221,7 +221,9 @@ internal static Java.Util.Locale GetLocale()
221
221
return config . Locales . Get ( 0 ) ;
222
222
#endif
223
223
224
+ #pragma warning disable CS0618 // Type or member is obsolete
224
225
return config . Locale ;
226
+ #pragma warning restore CS0618 // Type or member is obsolete
225
227
}
226
228
227
229
internal static void SetLocale ( Java . Util . Locale locale )
@@ -231,9 +233,15 @@ internal static void SetLocale(Java.Util.Locale locale)
231
233
var config = resources . Configuration ;
232
234
233
235
if ( HasApiLevelN )
236
+ {
234
237
config . SetLocale ( locale ) ;
238
+ }
235
239
else
240
+ {
241
+ #pragma warning disable CS0618 // Type or member is obsolete
236
242
config . Locale = locale ;
243
+ #pragma warning restore CS0618 // Type or member is obsolete
244
+ }
237
245
238
246
#pragma warning disable CS0618 // Type or member is obsolete
239
247
resources . UpdateConfiguration ( config , resources . DisplayMetrics ) ;
You can’t perform that action at this time.
0 commit comments