@akylas/nativescript 8.9.9 → 8.9.11

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