AndroidPermissionsRequestResult.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using System.Text;
  12. /// <summary>
  13. /// Structure holding data summarizing the result of an Android permissions request. </summary>
  14. public struct AndroidPermissionsRequestResult
  15. {
  16. /// <summary> Constructs a new AndroidPermissionsRequestResult. </summary>
  17. /// <param name="permissionNames"> The value for PermissionNames.</param>
  18. /// <param name="grantResults"> The value for GrantResults.</param>
  19. public AndroidPermissionsRequestResult(
  20. string[] permissionNames, bool[] grantResults) : this()
  21. {
  22. PermissionNames = permissionNames;
  23. GrantResults = grantResults;
  24. }
  25. /// <summary> Gets or sets a collection of permissions requested. </summary>
  26. /// <value> A list of names of the permissions. </value>
  27. public string[] PermissionNames { get; private set; }
  28. /// <summary>
  29. /// Gets or sets a collection of results corresponding to <see cref="PermissionNames"/>. </summary>
  30. /// <value> The grant results. </value>
  31. public bool[] GrantResults { get; private set; }
  32. /// <summary> Gets a value indicating whether all permissions are granted. </summary>
  33. /// <value> True if all is granted, false if not. </value>
  34. public bool IsAllGranted
  35. {
  36. get
  37. {
  38. if (PermissionNames == null || GrantResults == null)
  39. {
  40. return false;
  41. }
  42. for (int i = 0; i < GrantResults.Length; i++)
  43. {
  44. if (!GrantResults[i])
  45. {
  46. return false;
  47. }
  48. }
  49. return true;
  50. }
  51. }
  52. /// <summary> Convert this object into a string representation. </summary>
  53. /// <returns> A string that represents this object. </returns>
  54. public override string ToString()
  55. {
  56. StringBuilder st = new StringBuilder();
  57. for (int i = 0; i < PermissionNames.Length; i++)
  58. {
  59. st.AppendLine("Name:" + PermissionNames[i] + " GrantResult:" + GrantResults[i]);
  60. }
  61. return st.ToString();
  62. }
  63. }
  64. }