@@ -388,11 +388,79 @@ public void SetShowWhen(AndroidJavaObject builder, bool showTimestamp)
388
388
}
389
389
}
390
390
391
+ struct BundleJni
392
+ {
393
+ JniMethodID containsKey ;
394
+ JniMethodID getBoolean ;
395
+ JniMethodID getInt ;
396
+ JniMethodID getLong ;
397
+ JniMethodID getString ;
398
+ JniMethodID putInt ;
399
+ JniMethodID putLong ;
400
+ JniMethodID putString ;
401
+
402
+ public void CollectJni ( )
403
+ {
404
+ using ( var clazz = new AndroidJavaClass ( "android/os/Bundle" ) )
405
+ {
406
+ containsKey = JniApi . FindMethod ( clazz , "containsKey" , "(Ljava/lang/String;)Z" , false ) ;
407
+ getBoolean = JniApi . FindMethod ( clazz , "getBoolean" , "(Ljava/lang/String;Z)Z" , false ) ;
408
+ getInt = JniApi . FindMethod ( clazz , "getInt" , "(Ljava/lang/String;I)I" , false ) ;
409
+ getLong = JniApi . FindMethod ( clazz , "getLong" , "(Ljava/lang/String;J)J" , false ) ;
410
+ getString = JniApi . FindMethod ( clazz , "getString" , "(Ljava/lang/String;)Ljava/lang/String;" , false ) ;
411
+ putInt = JniApi . FindMethod ( clazz , "putInt" , "(Ljava/lang/String;I)V" , false ) ;
412
+ putLong = JniApi . FindMethod ( clazz , "putLong" , "(Ljava/lang/String;J)V" , false ) ;
413
+ putString = JniApi . FindMethod ( clazz , "putString" , "(Ljava/lang/String;Ljava/lang/String;)V" , false ) ;
414
+ }
415
+ }
416
+
417
+ public bool ContainsKey ( AndroidJavaObject bundle , AndroidJavaObject key )
418
+ {
419
+ return bundle . Call < bool > ( containsKey , key ) ;
420
+ }
421
+
422
+ public bool GetBoolean ( AndroidJavaObject bundle , AndroidJavaObject key , bool defaultValue )
423
+ {
424
+ return bundle . Call < bool > ( getBoolean , key , defaultValue ) ;
425
+ }
426
+
427
+ public int GetInt ( AndroidJavaObject bundle , AndroidJavaObject key , int defaultValue )
428
+ {
429
+ return bundle . Call < int > ( getInt , key , defaultValue ) ;
430
+ }
431
+
432
+ public long GetLong ( AndroidJavaObject bundle , AndroidJavaObject key , long defaultValue )
433
+ {
434
+ return bundle . Call < long > ( getLong , key , defaultValue ) ;
435
+ }
436
+
437
+ public string GetString ( AndroidJavaObject bundle , AndroidJavaObject key )
438
+ {
439
+ return bundle . Call < string > ( getString , key ) ;
440
+ }
441
+
442
+ public void PutInt ( AndroidJavaObject bundle , AndroidJavaObject key , int value )
443
+ {
444
+ bundle . Call ( putInt , key , value ) ;
445
+ }
446
+
447
+ public void PutLong ( AndroidJavaObject bundle , AndroidJavaObject key , long value )
448
+ {
449
+ bundle . Call ( putLong , key , value ) ;
450
+ }
451
+
452
+ public void PutString ( AndroidJavaObject bundle , AndroidJavaObject key , string value )
453
+ {
454
+ bundle . Call ( putString , key , value ) ;
455
+ }
456
+ }
457
+
391
458
struct JniApi
392
459
{
393
460
public NotificationManagerJni NotificationManager ;
394
461
public NotificationJni Notification ;
395
462
public NotificationBuilderJni NotificationBuilder ;
463
+ public BundleJni Bundle ;
396
464
397
465
public JniApi ( AndroidJavaClass notificationManagerClass , AndroidJavaObject notificationManager )
398
466
{
@@ -401,7 +469,8 @@ public JniApi(AndroidJavaClass notificationManagerClass, AndroidJavaObject notif
401
469
Notification . CollectJni ( ) ;
402
470
NotificationBuilder = default ;
403
471
NotificationBuilder . CollectJni ( ) ;
404
- JniApi . Bundle . CollectJni ( ) ;
472
+ Bundle = default ;
473
+ Bundle . CollectJni ( ) ;
405
474
}
406
475
407
476
public static JniMethodID FindMethod ( AndroidJavaClass clazz , string name , string signature , bool isStatic )
@@ -415,73 +484,6 @@ public static JniMethodID FindMethod(AndroidJavaClass clazz, string name, string
415
484
return name ;
416
485
#endif
417
486
}
418
-
419
- public static class Bundle
420
- {
421
- static JniMethodID containsKey ;
422
- static JniMethodID getBoolean ;
423
- static JniMethodID getInt ;
424
- static JniMethodID getLong ;
425
- static JniMethodID getString ;
426
- static JniMethodID putInt ;
427
- static JniMethodID putLong ;
428
- static JniMethodID putString ;
429
-
430
- public static void CollectJni ( )
431
- {
432
- using ( var clazz = new AndroidJavaClass ( "android/os/Bundle" ) )
433
- {
434
- containsKey = JniApi . FindMethod ( clazz , "containsKey" , "(Ljava/lang/String;)Z" , false ) ;
435
- getBoolean = JniApi . FindMethod ( clazz , "getBoolean" , "(Ljava/lang/String;Z)Z" , false ) ;
436
- getInt = JniApi . FindMethod ( clazz , "getInt" , "(Ljava/lang/String;I)I" , false ) ;
437
- getLong = JniApi . FindMethod ( clazz , "getLong" , "(Ljava/lang/String;J)J" , false ) ;
438
- getString = JniApi . FindMethod ( clazz , "getString" , "(Ljava/lang/String;)Ljava/lang/String;" , false ) ;
439
- putInt = JniApi . FindMethod ( clazz , "putInt" , "(Ljava/lang/String;I)V" , false ) ;
440
- putLong = JniApi . FindMethod ( clazz , "putLong" , "(Ljava/lang/String;J)V" , false ) ;
441
- putString = JniApi . FindMethod ( clazz , "putString" , "(Ljava/lang/String;Ljava/lang/String;)V" , false ) ;
442
- }
443
- }
444
-
445
- public static bool ContainsKey ( AndroidJavaObject bundle , AndroidJavaObject key )
446
- {
447
- return bundle . Call < bool > ( containsKey , key ) ;
448
- }
449
-
450
- public static bool GetBoolean ( AndroidJavaObject bundle , AndroidJavaObject key , bool defaultValue )
451
- {
452
- return bundle . Call < bool > ( getBoolean , key , defaultValue ) ;
453
- }
454
-
455
- public static int GetInt ( AndroidJavaObject bundle , AndroidJavaObject key , int defaultValue )
456
- {
457
- return bundle . Call < int > ( getInt , key , defaultValue ) ;
458
- }
459
-
460
- public static long GetLong ( AndroidJavaObject bundle , AndroidJavaObject key , long defaultValue )
461
- {
462
- return bundle . Call < long > ( getLong , key , defaultValue ) ;
463
- }
464
-
465
- public static string GetString ( AndroidJavaObject bundle , AndroidJavaObject key )
466
- {
467
- return bundle . Call < string > ( getString , key ) ;
468
- }
469
-
470
- public static void PutInt ( AndroidJavaObject bundle , AndroidJavaObject key , int value )
471
- {
472
- bundle . Call ( putInt , key , value ) ;
473
- }
474
-
475
- public static void PutLong ( AndroidJavaObject bundle , AndroidJavaObject key , long value )
476
- {
477
- bundle . Call ( putLong , key , value ) ;
478
- }
479
-
480
- public static void PutString ( AndroidJavaObject bundle , AndroidJavaObject key , string value )
481
- {
482
- bundle . Call ( putString , key , value ) ;
483
- }
484
- }
485
487
}
486
488
487
489
/// <summary>
@@ -868,11 +870,11 @@ public static AndroidJavaObject CreateNotificationBuilder(int id, AndroidNotific
868
870
869
871
using ( var extras = s_Jni . NotificationBuilder . GetExtras ( notificationBuilder ) )
870
872
{
871
- JniApi . Bundle . PutInt ( extras , s_Jni . NotificationManager . KEY_ID , id ) ;
872
- JniApi . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , notification . RepeatInterval . ToLong ( ) ) ;
873
- JniApi . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , fireTime ) ;
873
+ s_Jni . Bundle . PutInt ( extras , s_Jni . NotificationManager . KEY_ID , id ) ;
874
+ s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , notification . RepeatInterval . ToLong ( ) ) ;
875
+ s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , fireTime ) ;
874
876
if ( ! string . IsNullOrEmpty ( notification . IntentData ) )
875
- JniApi . Bundle . PutString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA , notification . IntentData ) ;
877
+ s_Jni . Bundle . PutString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA , notification . IntentData ) ;
876
878
}
877
879
878
880
return notificationBuilder ;
@@ -882,36 +884,36 @@ internal static AndroidNotificationIntentData GetNotificationData(AndroidJavaObj
882
884
{
883
885
using ( var extras = s_Jni . Notification . Extras ( notificationObj ) )
884
886
{
885
- var id = JniApi . Bundle . GetInt ( extras , s_Jni . NotificationManager . KEY_ID , - 1 ) ;
887
+ var id = s_Jni . Bundle . GetInt ( extras , s_Jni . NotificationManager . KEY_ID , - 1 ) ;
886
888
if ( id == - 1 )
887
889
return null ;
888
890
889
891
var channelId = s_Jni . NotificationManager . GetNotificationChannelId ( notificationObj ) ;
890
892
int flags = s_Jni . Notification . Flags ( notificationObj ) ;
891
893
892
894
var notification = new AndroidNotification ( ) ;
893
- notification . Title = JniApi . Bundle . GetString ( extras , s_Jni . Notification . EXTRA_TITLE ) ;
894
- notification . Text = JniApi . Bundle . GetString ( extras , s_Jni . Notification . EXTRA_TEXT ) ;
895
- notification . SmallIcon = JniApi . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_SMALL_ICON ) ;
896
- notification . LargeIcon = JniApi . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_LARGE_ICON ) ;
895
+ notification . Title = s_Jni . Bundle . GetString ( extras , s_Jni . Notification . EXTRA_TITLE ) ;
896
+ notification . Text = s_Jni . Bundle . GetString ( extras , s_Jni . Notification . EXTRA_TEXT ) ;
897
+ notification . SmallIcon = s_Jni . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_SMALL_ICON ) ;
898
+ notification . LargeIcon = s_Jni . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_LARGE_ICON ) ;
897
899
notification . ShouldAutoCancel = 0 != ( flags & s_Jni . Notification . FLAG_AUTO_CANCEL ) ;
898
- notification . UsesStopwatch = JniApi . Bundle . GetBoolean ( extras , s_Jni . Notification . EXTRA_SHOW_CHRONOMETER , false ) ;
899
- notification . FireTime = JniApi . Bundle . GetLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , - 1L ) . ToDatetime ( ) ;
900
- notification . RepeatInterval = JniApi . Bundle . GetLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , - 1L ) . ToTimeSpan ( ) ;
900
+ notification . UsesStopwatch = s_Jni . Bundle . GetBoolean ( extras , s_Jni . Notification . EXTRA_SHOW_CHRONOMETER , false ) ;
901
+ notification . FireTime = s_Jni . Bundle . GetLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , - 1L ) . ToDatetime ( ) ;
902
+ notification . RepeatInterval = s_Jni . Bundle . GetLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , - 1L ) . ToTimeSpan ( ) ;
901
903
902
- if ( JniApi . Bundle . ContainsKey ( extras , s_Jni . Notification . EXTRA_BIG_TEXT ) )
904
+ if ( s_Jni . Bundle . ContainsKey ( extras , s_Jni . Notification . EXTRA_BIG_TEXT ) )
903
905
notification . Style = NotificationStyle . BigTextStyle ;
904
906
else
905
907
notification . Style = NotificationStyle . None ;
906
908
907
909
notification . Color = s_Jni . NotificationManager . GetNotificationColor ( notificationObj ) ;
908
910
notification . Number = s_Jni . Notification . Number ( notificationObj ) ;
909
- notification . IntentData = JniApi . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA ) ;
911
+ notification . IntentData = s_Jni . Bundle . GetString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA ) ;
910
912
notification . Group = s_Jni . Notification . GetGroup ( notificationObj ) ;
911
913
notification . GroupSummary = 0 != ( flags & s_Jni . Notification . FLAG_GROUP_SUMMARY ) ;
912
914
notification . SortKey = s_Jni . Notification . GetSortKey ( notificationObj ) ;
913
915
notification . GroupAlertBehaviour = s_Jni . NotificationManager . GetNotificationGroupAlertBehavior ( notificationObj ) . ToGroupAlertBehaviours ( ) ;
914
- var showTimestamp = JniApi . Bundle . GetBoolean ( extras , s_Jni . Notification . EXTRA_SHOW_WHEN , false ) ;
916
+ var showTimestamp = s_Jni . Bundle . GetBoolean ( extras , s_Jni . Notification . EXTRA_SHOW_WHEN , false ) ;
915
917
notification . ShowTimestamp = showTimestamp ;
916
918
if ( showTimestamp )
917
919
notification . CustomTimestamp = s_Jni . Notification . When ( notificationObj ) . ToDatetime ( ) ;
0 commit comments