@nativescript/core 9.0.0-next-09-24-2025-17985801416 → 9.0.0-next-10-06-2025-18277360121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/inspector_modules.js +74 -47
  2. package/inspector_modules.js.map +1 -1
  3. package/package.json +1 -1
  4. package/platforms/android/include.gradle +51 -0
  5. package/platforms/android/java/org/nativescript/Process.java +59 -0
  6. package/platforms/android/java/org/nativescript/widgets/AbsoluteLayout.java +88 -0
  7. package/platforms/android/java/org/nativescript/widgets/AnimatorHelper.java +61 -0
  8. package/platforms/android/java/org/nativescript/widgets/Async.java +1356 -0
  9. package/platforms/android/java/org/nativescript/widgets/BorderDrawable.java +936 -0
  10. package/platforms/android/java/org/nativescript/widgets/BottomNavigationBar.java +308 -0
  11. package/platforms/android/java/org/nativescript/widgets/BoxShadowDrawable.java +175 -0
  12. package/platforms/android/java/org/nativescript/widgets/CSSValue.java +34 -0
  13. package/platforms/android/java/org/nativescript/widgets/CommonLayoutParams.java +456 -0
  14. package/platforms/android/java/org/nativescript/widgets/ContentLayout.java +85 -0
  15. package/platforms/android/java/org/nativescript/widgets/CustomTransition.java +135 -0
  16. package/platforms/android/java/org/nativescript/widgets/CustomTypefaceSpan.java +44 -0
  17. package/platforms/android/java/org/nativescript/widgets/Dock.java +15 -0
  18. package/platforms/android/java/org/nativescript/widgets/DockLayout.java +185 -0
  19. package/platforms/android/java/org/nativescript/widgets/FileHelper.java +815 -0
  20. package/platforms/android/java/org/nativescript/widgets/FlexLine.java +177 -0
  21. package/platforms/android/java/org/nativescript/widgets/FlexboxLayout.java +2769 -0
  22. package/platforms/android/java/org/nativescript/widgets/FragmentBase.java +14 -0
  23. package/platforms/android/java/org/nativescript/widgets/GridLayout.java +1172 -0
  24. package/platforms/android/java/org/nativescript/widgets/GridUnitType.java +10 -0
  25. package/platforms/android/java/org/nativescript/widgets/HorizontalScrollView.java +256 -0
  26. package/platforms/android/java/org/nativescript/widgets/ImageView.java +423 -0
  27. package/platforms/android/java/org/nativescript/widgets/ItemSpec.java +56 -0
  28. package/platforms/android/java/org/nativescript/widgets/LayoutBase.java +98 -0
  29. package/platforms/android/java/org/nativescript/widgets/LinearGradientDefinition.java +46 -0
  30. package/platforms/android/java/org/nativescript/widgets/Orientation.java +9 -0
  31. package/platforms/android/java/org/nativescript/widgets/OriginPoint.java +74 -0
  32. package/platforms/android/java/org/nativescript/widgets/ScrollSavedState.java +63 -0
  33. package/platforms/android/java/org/nativescript/widgets/SegmentedBarColorDrawable.java +27 -0
  34. package/platforms/android/java/org/nativescript/widgets/StackLayout.java +231 -0
  35. package/platforms/android/java/org/nativescript/widgets/StyleableTextView.java +50 -0
  36. package/platforms/android/java/org/nativescript/widgets/TabIconRenderingMode.java +6 -0
  37. package/platforms/android/java/org/nativescript/widgets/TabItemSpec.java +15 -0
  38. package/platforms/android/java/org/nativescript/widgets/TabLayout.java +451 -0
  39. package/platforms/android/java/org/nativescript/widgets/TabStrip.java +294 -0
  40. package/platforms/android/java/org/nativescript/widgets/TabViewPager.java +64 -0
  41. package/platforms/android/java/org/nativescript/widgets/TabsBar.java +443 -0
  42. package/platforms/android/java/org/nativescript/widgets/Utils.java +546 -0
  43. package/platforms/android/java/org/nativescript/widgets/VerticalScrollView.java +258 -0
  44. package/platforms/android/java/org/nativescript/widgets/ViewHelper.java +564 -0
  45. package/platforms/android/java/org/nativescript/widgets/WrapLayout.java +252 -0
  46. package/platforms/android/java/org/nativescript/widgets/image/AsyncTask.java +679 -0
  47. package/platforms/android/java/org/nativescript/widgets/image/BitmapOwner.java +17 -0
  48. package/platforms/android/java/org/nativescript/widgets/image/Cache.java +471 -0
  49. package/platforms/android/java/org/nativescript/widgets/image/DiskLruCache.java +970 -0
  50. package/platforms/android/java/org/nativescript/widgets/image/Fetcher.java +747 -0
  51. package/platforms/android/java/org/nativescript/widgets/image/Utils.java +58 -0
  52. package/platforms/android/java/org/nativescript/widgets/image/Worker.java +571 -0
  53. package/platforms/ios/src/TNSWidgets/Info.plist +26 -0
  54. package/platforms/ios/src/TNSWidgets/NSData+Async.m +42 -0
  55. package/platforms/ios/src/TNSWidgets/NSFileHandle+Async.m +82 -0
  56. package/platforms/ios/src/TNSWidgets/NSObject+Swizzling.m +68 -0
  57. package/platforms/ios/src/TNSWidgets/NSString+Async.m +51 -0
  58. package/platforms/ios/src/TNSWidgets/TNSLabel.m +42 -0
  59. package/platforms/ios/src/TNSWidgets/UIImage+TNSBlocks.m +77 -0
  60. package/platforms/ios/src/TNSWidgets/UIView+PassThroughParent.m +53 -0
  61. package/platforms/ios/src/TNSWidgets/UIView+PropertyBag.m +72 -0
  62. package/platforms/ios/src/module.modulemap +5 -0
  63. package/platforms/android/widgets-release.aar +0 -0
  64. package/platforms/ios/TNSWidgets.xcframework/Info.plist +0 -102
  65. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
  66. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
  67. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
  68. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Modules/module.modulemap +0 -6
  69. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  70. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
  71. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  72. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
  73. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
  74. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
  75. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
  76. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
  77. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
  78. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
  79. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
  80. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
  81. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
  82. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Modules/module.modulemap +0 -6
  83. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
  84. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
  85. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +0 -52
  86. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSCCrypto.h +0 -60
  87. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSData+Async.h +0 -24
  88. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSFileHandle+Async.h +0 -22
  89. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSString+Async.h +0 -25
  90. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSLabel.h +0 -16
  91. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSProcess.h +0 -29
  92. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSWidgets.h +0 -25
  93. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIImage+TNSBlocks.h +0 -26
  94. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIView+PassThroughParent.h +0 -17
  95. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Modules/module.modulemap +0 -6
  96. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/NSObject+Swizzling.h +0 -17
  97. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/UIView+PropertyBag.h +0 -18
  98. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +0 -52
  99. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
  100. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSCCrypto.h +0 -60
  101. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSData+Async.h +0 -24
  102. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSFileHandle+Async.h +0 -22
  103. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSString+Async.h +0 -25
  104. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSLabel.h +0 -16
  105. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSProcess.h +0 -29
  106. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSWidgets.h +0 -25
  107. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIImage+TNSBlocks.h +0 -26
  108. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIView+PassThroughParent.h +0 -17
  109. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Modules/module.modulemap +0 -6
  110. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/NSObject+Swizzling.h +0 -17
  111. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/UIView+PropertyBag.h +0 -18
  112. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Resources/Info.plist +0 -52
  113. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
  114. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
  115. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  116. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
  117. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
  118. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
  119. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
  120. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
  121. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
  122. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
  123. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
  124. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
  125. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
  126. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
  127. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  128. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +0 -6
  129. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
  130. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
  131. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  132. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +0 -223
  133. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
  134. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  135. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
  136. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
  137. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
  138. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
  139. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
  140. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
  141. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
  142. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
  143. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
  144. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
  145. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
  146. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Info.plist +0 -0
  147. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Modules/module.modulemap +0 -6
  148. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
  149. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
  150. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  151. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
  152. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  153. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
  154. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
  155. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
  156. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
  157. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
  158. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
  159. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
  160. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
  161. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
  162. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
  163. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  164. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +0 -6
  165. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
  166. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
  167. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  168. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +0 -223
  169. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
  170. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  171. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
  172. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
  173. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSData+Async.h +0 -0
  174. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSFileHandle+Async.h +0 -0
  175. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders → src/TNSWidgets}/NSObject+Swizzling.h +0 -0
  176. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSString+Async.h +0 -0
  177. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/TNSLabel.h +0 -0
  178. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/TNSWidgets.h +0 -0
  179. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/UIImage+TNSBlocks.h +0 -0
  180. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/UIView+PassThroughParent.h +0 -0
  181. /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders → src/TNSWidgets}/UIView+PropertyBag.h +0 -0
@@ -0,0 +1,815 @@
1
+ package org.nativescript.widgets;
2
+
3
+ import android.content.ContentValues;
4
+ import android.content.Context;
5
+ import android.database.Cursor;
6
+ import android.net.Uri;
7
+ import android.os.Build;
8
+ import android.os.Environment;
9
+ import android.os.Handler;
10
+ import android.os.Looper;
11
+ import android.provider.DocumentsContract;
12
+ import android.provider.MediaStore;
13
+ import android.webkit.MimeTypeMap;
14
+ import android.util.Log;
15
+
16
+ import androidx.annotation.Nullable;
17
+ import androidx.documentfile.provider.DocumentFile;
18
+
19
+ import java.io.BufferedReader;
20
+ import java.io.File;
21
+ import java.io.FileInputStream;
22
+ import java.io.FileNotFoundException;
23
+ import java.io.FileOutputStream;
24
+ import java.io.InputStream;
25
+ import java.io.InputStreamReader;
26
+ import java.io.OutputStream;
27
+ import java.io.OutputStreamWriter;
28
+ import java.lang.ref.WeakReference;
29
+ import java.nio.ByteBuffer;
30
+ import java.nio.channels.Channels;
31
+ import java.nio.channels.FileChannel;
32
+ import java.nio.channels.ReadableByteChannel;
33
+ import java.nio.channels.WritableByteChannel;
34
+ import java.util.concurrent.ExecutorService;
35
+ import java.util.concurrent.Executors;
36
+
37
+ public class FileHelper {
38
+ static final String TAG = "FileHelper";
39
+ private Uri uri;
40
+ private final ExecutorService executor = Executors.newSingleThreadExecutor();
41
+ private final Handler handler;
42
+
43
+
44
+ private DocumentFile documentFile;
45
+
46
+ private WeakReference<Context> context;
47
+
48
+ public interface Callback {
49
+ void onError(Exception exception);
50
+
51
+ void onSuccess(@Nullable Object result);
52
+ }
53
+
54
+ FileHelper(Context context, Uri uri) {
55
+ handler = new Handler(Looper.myLooper());
56
+ this.context = new WeakReference<>(context);
57
+ this.uri = uri;
58
+ if (DocumentFile.isDocumentUri(context, uri)) {
59
+ documentFile = DocumentFile.fromSingleUri(context, uri);
60
+ }
61
+ }
62
+
63
+ private static boolean isExternalStorageDocument(Uri uri) {
64
+ return "com.android.externalstorage.documents".equals(uri
65
+ .getAuthority());
66
+ }
67
+
68
+ private static @Nullable
69
+ Cursor getCursor(Context context, Uri uri) {
70
+ return getCursor(context, uri, new String[]{
71
+ MediaStore.MediaColumns.DISPLAY_NAME,
72
+ MediaStore.MediaColumns.DATE_MODIFIED,
73
+ MediaStore.MediaColumns.SIZE
74
+ });
75
+ }
76
+
77
+ private static @Nullable
78
+ Cursor getCursor(Context context, Uri uri, String[] projections) {
79
+ Cursor cursor = null;
80
+ try {
81
+ if (Build.VERSION.SDK_INT >= 19) {
82
+ if (DocumentsContract.isDocumentUri(context, uri)) {
83
+ if (Build.VERSION.SDK_INT >= 29) {
84
+ if (!uri.toString().startsWith("content://com.android.providers.downloads.documents")) {
85
+ cursor = context.getContentResolver().query(
86
+ MediaStore.getMediaUri(context, uri), projections, null, null, null, null
87
+ );
88
+ }
89
+ }
90
+ }
91
+ }
92
+ if (cursor == null) {
93
+ cursor = context.getContentResolver().query(uri, projections, null, null, null);
94
+ }
95
+ } catch (Exception ignored) {
96
+ }
97
+
98
+ return cursor;
99
+
100
+ }
101
+
102
+ public static boolean exists(Context context, String string) {
103
+ try {
104
+ return exists(context, Uri.parse(string));
105
+ } catch (Exception ignored) {
106
+ return false;
107
+ }
108
+ }
109
+
110
+ static File getDocumentFile(Context context, Uri uri) {
111
+ if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context, uri)) {
112
+ return getFile(context, uri);
113
+ }
114
+ return null;
115
+ }
116
+
117
+ public static boolean exists(Context context, Uri uri) {
118
+ if (Build.VERSION.SDK_INT >= 19) {
119
+ if (DocumentsContract.isDocumentUri(context, uri)) {
120
+ DocumentFile file = DocumentFile.fromSingleUri(context, uri);
121
+ if (file != null) {
122
+ return file.exists();
123
+ }
124
+ }
125
+ File file = getDocumentFile(context, uri);
126
+ if (file != null) {
127
+ return file.exists();
128
+ }
129
+ return false;
130
+ }
131
+ Cursor cursor = getCursor(context, uri);
132
+ if (cursor == null) {
133
+ return false;
134
+ }
135
+ boolean exists = cursor.moveToFirst();
136
+ cursor.close();
137
+ return exists;
138
+ }
139
+
140
+ public static @Nullable
141
+ FileHelper fromString(Context context, String string) {
142
+ return fromUri(context, Uri.parse(string));
143
+ }
144
+
145
+ @SuppressWarnings("deprecation")
146
+ private static @Nullable
147
+ File getFile(Context context, Uri uri) {
148
+ if (Build.VERSION.SDK_INT >= 19) {
149
+ if (isExternalStorageDocument(uri)) {
150
+ String docId = DocumentsContract.getDocumentId(uri);
151
+ String[] split = docId.split(":");
152
+ String type = split[0];
153
+ String path = split[1];
154
+
155
+ if ("primary".equals(type)) {
156
+ int nameIndex = path.lastIndexOf("/");
157
+ String seg = path.substring(0, nameIndex);
158
+ String[] parts = Uri.decode(uri.toString()).split(":" + seg);
159
+ String file = Environment.getExternalStorageDirectory() + "/" + path + "/" + parts[1];
160
+ return new File(file);
161
+ } else {
162
+ File[] cacheDirs = context.getExternalCacheDirs();
163
+ String storageDir = null;
164
+ for (File cacheDir : cacheDirs) {
165
+ final String cachePath = cacheDir.getPath();
166
+ int index = cachePath.indexOf(type);
167
+ if (index >= 0) {
168
+ storageDir = cachePath.substring(0, index + type.length());
169
+ }
170
+ }
171
+
172
+ if (storageDir != null) {
173
+ return new File(storageDir + "/" + path);
174
+ }
175
+ }
176
+ }
177
+ }
178
+ return null;
179
+ }
180
+
181
+ public static @Nullable
182
+ FileHelper fromUri(Context context, Uri contentUri) {
183
+ return new FileHelper(context, contentUri);
184
+ }
185
+
186
+ private long getFileSize() {
187
+ if (documentFile != null) {
188
+ return documentFile.length();
189
+ }
190
+ Context context = this.context.get();
191
+ if (context == null) {
192
+ return 0;
193
+ }
194
+ if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context, uri)) {
195
+ File file = getDocumentFile(context, uri);
196
+ if (file == null) {
197
+ return 0;
198
+ }
199
+ return file.length();
200
+ }
201
+
202
+ Cursor cursor = getCursor(context, uri, null);
203
+
204
+ if (cursor == null) {
205
+ return 0;
206
+ }
207
+
208
+ long size = 0;
209
+
210
+ boolean moved = cursor.moveToFirst();
211
+ if (moved) {
212
+ int sizeIndex = cursor.getColumnIndex(
213
+ MediaStore.MediaColumns.SIZE
214
+ );
215
+
216
+ size = cursor.getLong(sizeIndex);
217
+
218
+ }
219
+ cursor.close();
220
+
221
+ return size;
222
+ }
223
+
224
+ private void updateInternal(Context context) {
225
+ updateInternal(context, true);
226
+ }
227
+
228
+
229
+ private void updateValue(Context context, Uri uri, ContentValues values) {
230
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
231
+ context.getContentResolver().update(uri, values, null);
232
+ } else {
233
+ context.getContentResolver().update(uri, values, null, null);
234
+ }
235
+ }
236
+
237
+ private void updateInternal(Context context, boolean force) {
238
+
239
+ if (force) {
240
+ // trigger db update
241
+ ContentValues values = new ContentValues();
242
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
243
+ if (isExternalStorageDocument(uri)) {
244
+ return;
245
+ }
246
+ if (DocumentsContract.isDocumentUri(context, uri)) {
247
+ DocumentFile file = DocumentFile.fromSingleUri(context, uri);
248
+ if (file != null) {
249
+ updateValue(context, file.getUri(), values);
250
+ }
251
+ } else {
252
+ updateValue(context, uri, values);
253
+ }
254
+ } else {
255
+ updateValue(context, uri, values);
256
+ }
257
+ }
258
+ }
259
+
260
+ public long getSize() {
261
+ return getFileSize();
262
+ }
263
+
264
+ public String getName() {
265
+ if (documentFile != null) {
266
+ return documentFile.getName();
267
+ }
268
+
269
+ String name = null;
270
+
271
+ Context context = this.context.get();
272
+ if (context != null) {
273
+ if (DocumentFile.isDocumentUri(context, uri)) {
274
+ File file = getDocumentFile(context, uri);
275
+ if (file != null) {
276
+ name = file.getName();
277
+ }
278
+ } else {
279
+
280
+ Cursor cursor = getCursor(context, uri, null);
281
+
282
+ if (cursor == null) {
283
+ return null;
284
+ }
285
+
286
+ boolean moved = cursor.moveToFirst();
287
+ if (moved) {
288
+ int nameIndex = cursor.getColumnIndex(
289
+ MediaStore.MediaColumns.DISPLAY_NAME
290
+ );
291
+
292
+ name = cursor.getString(nameIndex);
293
+
294
+ }
295
+ cursor.close();
296
+
297
+ return name;
298
+ }
299
+ }
300
+
301
+ return name;
302
+ }
303
+
304
+ public String getMime() {
305
+ String mime = null;
306
+
307
+ Context context = this.context.get();
308
+ if (context != null) {
309
+ mime = context.getContentResolver().getType(uri);
310
+ }
311
+
312
+ if (mime == null) {
313
+ return "application/octet-stream";
314
+ }
315
+ return mime;
316
+ }
317
+
318
+ public String getExtension() {
319
+ String mime = getMime();
320
+ if (mime == null) {
321
+ return "";
322
+ }
323
+ return MimeTypeMap.getSingleton().getExtensionFromMimeType(mime);
324
+ }
325
+
326
+ public long getLastModified() {
327
+ long lastModified = 0;
328
+ if (documentFile != null) {
329
+ return documentFile.lastModified();
330
+ }
331
+ Context context = this.context.get();
332
+ if (context != null) {
333
+ if (DocumentFile.isDocumentUri(context, uri)) {
334
+ File file = getDocumentFile(context, uri);
335
+ if (file != null) {
336
+ lastModified = file.lastModified() / 1000;
337
+ }
338
+ } else {
339
+ Cursor cursor = getCursor(context, uri, null);
340
+
341
+ if (cursor == null) {
342
+ return 0;
343
+ }
344
+
345
+ boolean moved = cursor.moveToFirst();
346
+ if (moved) {
347
+ int sizeIndex = cursor.getColumnIndex(
348
+ MediaStore.MediaColumns.DATE_MODIFIED
349
+ );
350
+
351
+ lastModified = cursor.getLong(sizeIndex);
352
+
353
+ }
354
+ cursor.close();
355
+ }
356
+ }
357
+
358
+ return lastModified;
359
+ }
360
+
361
+ private InputStream getInputStream(Context context, Uri uri) throws Exception {
362
+ if (Build.VERSION.SDK_INT >= 19) {
363
+ if (DocumentsContract.isDocumentUri(context, uri)) {
364
+ return context.getContentResolver().openInputStream(DocumentFile.fromSingleUri(context, uri).getUri());
365
+ }
366
+ if (isExternalStorageDocument(uri)) {
367
+ File file = getFile(context, uri);
368
+ return new FileInputStream(file);
369
+ }
370
+ }
371
+ return context.getContentResolver().openInputStream(uri);
372
+ }
373
+
374
+ private OutputStream getOutputStream(Context context, Uri uri) throws Exception {
375
+ return getOutputStream(context, uri, false);
376
+ }
377
+
378
+ private OutputStream getOutputStream(Context context, Uri uri, boolean append) throws Exception {
379
+ if (Build.VERSION.SDK_INT >= 19) {
380
+ if (DocumentsContract.isDocumentUri(context, uri)) {
381
+ return context.getContentResolver().openOutputStream(DocumentFile.fromSingleUri(context, uri).getUri(), append ? "wa" : "w");
382
+ }
383
+ if (isExternalStorageDocument(uri)) {
384
+ File file = getFile(context, uri);
385
+ return new FileOutputStream(file, append);
386
+ }
387
+ }
388
+ return context.getContentResolver().openOutputStream(uri, append ? "wa" : "w");
389
+ }
390
+
391
+ public void appendSync(Context context, byte[] content, @Nullable Callback callback) {
392
+ try {
393
+ writeSyncInternal(context, content, true);
394
+ } catch (Exception e) {
395
+ if (callback != null) {
396
+ callback.onError(e);
397
+ }
398
+ }
399
+ }
400
+
401
+ public void append(Context context, byte[] content, Callback callback) {
402
+ executor.execute(() -> {
403
+ try {
404
+ writeSyncInternal(context, content, true);
405
+ handler.post(() -> callback.onSuccess(null));
406
+ } catch (Exception e) {
407
+ handler.post(() -> callback.onError(e));
408
+ }
409
+ });
410
+ }
411
+
412
+ public void appendBufferSync(Context context, ByteBuffer content, @Nullable Callback callback) {
413
+ try {
414
+ writeBufferSyncInternal(context, content, true);
415
+ } catch (Exception e) {
416
+ if (callback != null) {
417
+ callback.onError(e);
418
+ }
419
+ }
420
+ }
421
+
422
+ public void appendBuffer(Context context, ByteBuffer content, Callback callback) {
423
+ executor.execute(() -> {
424
+ try {
425
+ writeBufferSyncInternal(context, content, true);
426
+ handler.post(() -> callback.onSuccess(null));
427
+ } catch (Exception e) {
428
+ handler.post(() -> callback.onError(e));
429
+ }
430
+ });
431
+ }
432
+
433
+ public void appendTextSync(Context context, String content, @Nullable String encoding, @Nullable Callback callback) {
434
+ try {
435
+ writeTextSyncInternal(context, content, encoding, true);
436
+ } catch (Exception e) {
437
+ if (callback != null) {
438
+ callback.onError(e);
439
+ }
440
+ }
441
+ }
442
+
443
+ public void appendText(Context context, String content, @Nullable String encoding, Callback callback) {
444
+ executor.execute(() -> {
445
+ try {
446
+ writeTextSyncInternal(context, content, encoding, true);
447
+ handler.post(() -> callback.onSuccess(null));
448
+ } catch (Exception e) {
449
+ handler.post(() -> callback.onError(e));
450
+ }
451
+ });
452
+ }
453
+
454
+ private byte[] readSyncInternal(Context context) throws Exception {
455
+ InputStream is = getInputStream(context, uri);
456
+
457
+ Async.Http.RequestResult.ByteArrayOutputStream2 ret = new Async.Http.RequestResult.ByteArrayOutputStream2();
458
+
459
+ byte[] buff = new byte[4096];
460
+ int read;
461
+ while ((read = is.read(buff, 0, buff.length)) != -1) {
462
+ ret.write(buff, 0, read);
463
+ }
464
+
465
+ is.close();
466
+ return ret.buf();
467
+ }
468
+
469
+ private ByteBuffer readBufferSyncInternal(Context context) throws Exception {
470
+ InputStream is = getInputStream(context, uri);
471
+
472
+ ReadableByteChannel channel = Channels.newChannel(is);
473
+ ByteBuffer buffer = ByteBuffer.allocateDirect(is.available());
474
+ channel.read(buffer);
475
+
476
+ return buffer;
477
+ }
478
+
479
+ public @Nullable
480
+ byte[] readSync(Context context, @Nullable Callback callback) {
481
+ try {
482
+ return readSyncInternal(context);
483
+ } catch (Exception e) {
484
+ if (callback != null) {
485
+ callback.onError(e);
486
+ }
487
+ }
488
+ return null;
489
+ }
490
+
491
+ public void read(Context context, Callback callback) {
492
+ executor.execute(() -> {
493
+ try {
494
+ byte[] result = readSyncInternal(context);
495
+ handler.post(() -> callback.onSuccess(result));
496
+ } catch (Exception e) {
497
+ handler.post(() -> callback.onError(e));
498
+ }
499
+ });
500
+ }
501
+
502
+ public @Nullable
503
+ ByteBuffer readBufferSync(Context context, @Nullable Callback callback) {
504
+ try {
505
+ return readBufferSyncInternal(context);
506
+ } catch (Exception e) {
507
+ if (callback != null) {
508
+ callback.onError(e);
509
+ }
510
+ }
511
+ return null;
512
+ }
513
+
514
+ public void readBuffer(Context context, Callback callback) {
515
+ executor.execute(() -> {
516
+ try {
517
+ ByteBuffer result = readBufferSyncInternal(context);
518
+ handler.post(() -> callback.onSuccess(result));
519
+ } catch (Exception e) {
520
+ handler.post(() -> callback.onError(e));
521
+ }
522
+ });
523
+ }
524
+
525
+ private String readTextSyncInternal(Context context, @Nullable String encoding) throws Exception {
526
+ String characterSet = encoding;
527
+ if (characterSet == null) {
528
+ characterSet = "UTF-8";
529
+ }
530
+
531
+ InputStream is = getInputStream(context, uri);
532
+ InputStreamReader isr = new InputStreamReader(is, characterSet);
533
+ BufferedReader reader = new BufferedReader(isr);
534
+ char[] buf = new char[is.available()];
535
+ reader.read(buf);
536
+ reader.close();
537
+ return new String(buf);
538
+ }
539
+
540
+ public String readTextSync(Context context, @Nullable String encoding, @Nullable Callback callback) {
541
+ try {
542
+ return readTextSyncInternal(context, encoding);
543
+ } catch (Exception e) {
544
+ if (callback != null) {
545
+ callback.onError(e);
546
+ }
547
+ }
548
+ return null;
549
+ }
550
+
551
+ public void readText(Context context, @Nullable String encoding, Callback callback) {
552
+ executor.execute(() -> {
553
+ try {
554
+ String result = readTextSyncInternal(context, encoding);
555
+ handler.post(() -> callback.onSuccess(result));
556
+ } catch (Exception e) {
557
+ handler.post(() -> callback.onError(e));
558
+ }
559
+ });
560
+ }
561
+
562
+ private void writeSyncInternal(Context context, byte[] content) throws Exception {
563
+ writeSyncInternal(context, content, false);
564
+ }
565
+
566
+ private void writeSyncInternal(Context context, byte[] content, boolean append) throws Exception {
567
+ OutputStream os = getOutputStream(context, uri, append);
568
+ os.write(content, 0, content.length);
569
+ os.flush();
570
+ os.close();
571
+ try {
572
+ updateInternal(context);
573
+ } catch (Exception exception){
574
+ Log.e(TAG, "Failed to updateValue: " + exception.getMessage());
575
+ }
576
+ }
577
+
578
+ private void writeBufferSyncInternal(Context context, ByteBuffer content) throws Exception {
579
+ writeBufferSyncInternal(context, content, false);
580
+ }
581
+
582
+ private void writeBufferSyncInternal(Context context, ByteBuffer content, boolean append) throws Exception {
583
+ OutputStream os = getOutputStream(context, uri, append);
584
+ WritableByteChannel channel = Channels.newChannel(os);
585
+ channel.write(content);
586
+ os.flush();
587
+ os.close();
588
+ try {
589
+ updateInternal(context);
590
+ } catch (Exception exception){
591
+ Log.e(TAG, "Failed to updateValue: " + exception.getMessage());
592
+ }
593
+ }
594
+
595
+ public void writeSync(Context context, byte[] content, @Nullable Callback callback) {
596
+ try {
597
+ writeSyncInternal(context, content);
598
+ } catch (Exception e) {
599
+ if (callback != null) {
600
+ callback.onError(e);
601
+ }
602
+ }
603
+ }
604
+
605
+ public void write(Context context, byte[] content, Callback callback) {
606
+ executor.execute(() -> {
607
+ try {
608
+ writeSyncInternal(context, content);
609
+ handler.post(() -> callback.onSuccess(null));
610
+ } catch (Exception e) {
611
+ handler.post(() -> callback.onError(e));
612
+ }
613
+ });
614
+ }
615
+
616
+ public void writeBufferSync(Context context, ByteBuffer content, @Nullable Callback callback) {
617
+ try {
618
+ writeBufferSyncInternal(context, content);
619
+ } catch (Exception e) {
620
+ if (callback != null) {
621
+ callback.onError(e);
622
+ }
623
+ }
624
+ }
625
+
626
+ public void writeBuffer(Context context, ByteBuffer content, Callback callback) {
627
+ executor.execute(() -> {
628
+ try {
629
+ writeBufferSyncInternal(context, content);
630
+ handler.post(() -> callback.onSuccess(null));
631
+ } catch (Exception e) {
632
+ handler.post(() -> callback.onError(e));
633
+ }
634
+ });
635
+ }
636
+
637
+ private void writeTextSyncInternal(Context context, String content, @Nullable String encoding) throws Exception {
638
+ writeTextSyncInternal(context, content, encoding, false);
639
+ }
640
+
641
+ private void writeTextSyncInternal(Context context, String content, @Nullable String encoding, boolean append) throws Exception {
642
+ OutputStream os = getOutputStream(context, uri, append);
643
+ String characterSet = encoding;
644
+ if (characterSet == null) {
645
+ characterSet = "UTF-8";
646
+ }
647
+ OutputStreamWriter osw = new OutputStreamWriter(os, characterSet);
648
+ osw.write(content);
649
+ osw.flush();
650
+ osw.close();
651
+ try {
652
+ updateInternal(context);
653
+ } catch (Exception exception){
654
+ Log.e(TAG, "Failed to updateValue: " + exception.getMessage());
655
+ }
656
+ }
657
+
658
+ public void writeTextSync(Context context, String content, @Nullable String encoding, @Nullable Callback callback) {
659
+ try {
660
+ writeTextSyncInternal(context, content, encoding);
661
+ } catch (Exception e) {
662
+ if (callback != null) {
663
+ callback.onError(e);
664
+ }
665
+ }
666
+ }
667
+
668
+ public void writeText(Context context, String content, @Nullable String encoding, Callback callback) {
669
+ executor.execute(() -> {
670
+ try {
671
+ writeTextSyncInternal(context, content, encoding);
672
+ handler.post(() -> callback.onSuccess(null));
673
+ } catch (Exception e) {
674
+ handler.post(() -> callback.onError(e));
675
+ }
676
+ });
677
+ }
678
+
679
+ private void copyToFileInternal(InputStream is, OutputStream os) throws Exception {
680
+ int read;
681
+ byte[] buf = new byte[1024];
682
+ while ((read = is.read(buf)) != -1) {
683
+ os.write(buf, 0, read);
684
+ }
685
+ is.close();
686
+ os.flush();
687
+ os.close();
688
+ }
689
+
690
+ private void copyToFileInternal(Context context, File file) throws Exception {
691
+ InputStream is = getInputStream(context, uri);
692
+ FileOutputStream os = new FileOutputStream(file);
693
+ copyToFileInternal(is, os);
694
+ }
695
+
696
+ public boolean copyToFileSync(Context context, File file, @Nullable Callback callback) {
697
+ boolean completed = false;
698
+ try {
699
+ copyToFileInternal(context, file);
700
+ completed = true;
701
+ } catch (Exception e) {
702
+ if (callback != null) {
703
+ callback.onError(e);
704
+ }
705
+ }
706
+ return completed;
707
+ }
708
+
709
+ public void copyToFile(Context context, File file, Callback callback) {
710
+ executor.execute(() -> {
711
+ try {
712
+ copyToFileInternal(context, file);
713
+ handler.post(() -> callback.onSuccess(true));
714
+ } catch (Exception e) {
715
+ handler.post(() -> callback.onError(e));
716
+ }
717
+ });
718
+ }
719
+
720
+ public boolean delete(Context context) {
721
+ try {
722
+ if (Build.VERSION.SDK_INT >= 19) {
723
+ if (isExternalStorageDocument(uri)) {
724
+ File file = getFile(context, uri);
725
+ if (file != null) {
726
+ return file.delete();
727
+ }
728
+ return false;
729
+ } else {
730
+ if (DocumentsContract.isDocumentUri(context, uri)) {
731
+ if (Build.VERSION.SDK_INT >= 29) {
732
+ if (!uri.toString().startsWith("content://com.android.providers.downloads.documents")) {
733
+ return context.getContentResolver().delete(
734
+ MediaStore.getMediaUri(context, uri), null, null
735
+ ) > 0;
736
+ }
737
+
738
+ } else {
739
+ return DocumentsContract.deleteDocument(context.getContentResolver(), uri);
740
+ }
741
+ }
742
+ }
743
+ }
744
+ return context.getContentResolver().delete(uri, null, null) > 0;
745
+ } catch (SecurityException | FileNotFoundException e) {
746
+ return false;
747
+ }
748
+ }
749
+
750
+
751
+ private void renameInternal(Context context, String newName) throws Exception {
752
+ ContentValues values = new ContentValues();
753
+ values.put(MediaStore.MediaColumns.DISPLAY_NAME, newName);
754
+
755
+ if (Build.VERSION.SDK_INT >= 19) {
756
+ if (isExternalStorageDocument(uri)) {
757
+ File file = getFile(context, uri);
758
+ if (file != null) {
759
+ file.renameTo(new File(file.getParentFile(), newName));
760
+ return;
761
+ }
762
+ return;
763
+ }
764
+
765
+ if (DocumentsContract.isDocumentUri(context, uri)) {
766
+ if (Build.VERSION.SDK_INT >= 29) {
767
+ if (!uri.toString().startsWith("content://com.android.providers.downloads.documents")) {
768
+ context.getContentResolver().update(
769
+ uri, values, null, null
770
+ );
771
+ return;
772
+ }
773
+ DocumentsContract.renameDocument(context.getContentResolver(), uri, newName);
774
+ } else if (Build.VERSION.SDK_INT >= 21) {
775
+ DocumentsContract.renameDocument(context.getContentResolver(), uri, newName);
776
+ return;
777
+ }
778
+ }
779
+
780
+ }
781
+ try {
782
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
783
+ context.getContentResolver().update(uri, values, null);
784
+ } else {
785
+ context.getContentResolver().update(uri, values, null, null);
786
+ }
787
+ updateInternal(context, false);
788
+ } catch (Exception exception){
789
+ Log.e(TAG, "Failed to updateValue: " + exception.getMessage());
790
+ }
791
+
792
+ }
793
+
794
+ public void renameSync(Context context, String newName, @Nullable Callback callback) {
795
+ try {
796
+ renameInternal(context, newName);
797
+ } catch (Exception e) {
798
+ if (callback != null) {
799
+ callback.onError(e);
800
+ }
801
+ }
802
+ }
803
+
804
+ public void rename(Context context, String newName, Callback callback) {
805
+ executor.execute(() -> {
806
+ try {
807
+ renameInternal(context, newName);
808
+ handler.post(() -> callback.onSuccess(null));
809
+ } catch (Exception e) {
810
+ handler.post(() -> callback.onError(e));
811
+ }
812
+ });
813
+ }
814
+
815
+ }