@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.
- package/inspector_modules.js +74 -47
- package/inspector_modules.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/include.gradle +51 -0
- package/platforms/android/java/org/nativescript/Process.java +59 -0
- package/platforms/android/java/org/nativescript/widgets/AbsoluteLayout.java +88 -0
- package/platforms/android/java/org/nativescript/widgets/AnimatorHelper.java +61 -0
- package/platforms/android/java/org/nativescript/widgets/Async.java +1356 -0
- package/platforms/android/java/org/nativescript/widgets/BorderDrawable.java +936 -0
- package/platforms/android/java/org/nativescript/widgets/BottomNavigationBar.java +308 -0
- package/platforms/android/java/org/nativescript/widgets/BoxShadowDrawable.java +175 -0
- package/platforms/android/java/org/nativescript/widgets/CSSValue.java +34 -0
- package/platforms/android/java/org/nativescript/widgets/CommonLayoutParams.java +456 -0
- package/platforms/android/java/org/nativescript/widgets/ContentLayout.java +85 -0
- package/platforms/android/java/org/nativescript/widgets/CustomTransition.java +135 -0
- package/platforms/android/java/org/nativescript/widgets/CustomTypefaceSpan.java +44 -0
- package/platforms/android/java/org/nativescript/widgets/Dock.java +15 -0
- package/platforms/android/java/org/nativescript/widgets/DockLayout.java +185 -0
- package/platforms/android/java/org/nativescript/widgets/FileHelper.java +815 -0
- package/platforms/android/java/org/nativescript/widgets/FlexLine.java +177 -0
- package/platforms/android/java/org/nativescript/widgets/FlexboxLayout.java +2769 -0
- package/platforms/android/java/org/nativescript/widgets/FragmentBase.java +14 -0
- package/platforms/android/java/org/nativescript/widgets/GridLayout.java +1172 -0
- package/platforms/android/java/org/nativescript/widgets/GridUnitType.java +10 -0
- package/platforms/android/java/org/nativescript/widgets/HorizontalScrollView.java +256 -0
- package/platforms/android/java/org/nativescript/widgets/ImageView.java +423 -0
- package/platforms/android/java/org/nativescript/widgets/ItemSpec.java +56 -0
- package/platforms/android/java/org/nativescript/widgets/LayoutBase.java +98 -0
- package/platforms/android/java/org/nativescript/widgets/LinearGradientDefinition.java +46 -0
- package/platforms/android/java/org/nativescript/widgets/Orientation.java +9 -0
- package/platforms/android/java/org/nativescript/widgets/OriginPoint.java +74 -0
- package/platforms/android/java/org/nativescript/widgets/ScrollSavedState.java +63 -0
- package/platforms/android/java/org/nativescript/widgets/SegmentedBarColorDrawable.java +27 -0
- package/platforms/android/java/org/nativescript/widgets/StackLayout.java +231 -0
- package/platforms/android/java/org/nativescript/widgets/StyleableTextView.java +50 -0
- package/platforms/android/java/org/nativescript/widgets/TabIconRenderingMode.java +6 -0
- package/platforms/android/java/org/nativescript/widgets/TabItemSpec.java +15 -0
- package/platforms/android/java/org/nativescript/widgets/TabLayout.java +451 -0
- package/platforms/android/java/org/nativescript/widgets/TabStrip.java +294 -0
- package/platforms/android/java/org/nativescript/widgets/TabViewPager.java +64 -0
- package/platforms/android/java/org/nativescript/widgets/TabsBar.java +443 -0
- package/platforms/android/java/org/nativescript/widgets/Utils.java +546 -0
- package/platforms/android/java/org/nativescript/widgets/VerticalScrollView.java +258 -0
- package/platforms/android/java/org/nativescript/widgets/ViewHelper.java +564 -0
- package/platforms/android/java/org/nativescript/widgets/WrapLayout.java +252 -0
- package/platforms/android/java/org/nativescript/widgets/image/AsyncTask.java +679 -0
- package/platforms/android/java/org/nativescript/widgets/image/BitmapOwner.java +17 -0
- package/platforms/android/java/org/nativescript/widgets/image/Cache.java +471 -0
- package/platforms/android/java/org/nativescript/widgets/image/DiskLruCache.java +970 -0
- package/platforms/android/java/org/nativescript/widgets/image/Fetcher.java +747 -0
- package/platforms/android/java/org/nativescript/widgets/image/Utils.java +58 -0
- package/platforms/android/java/org/nativescript/widgets/image/Worker.java +571 -0
- package/platforms/ios/src/TNSWidgets/Info.plist +26 -0
- package/platforms/ios/src/TNSWidgets/NSData+Async.m +42 -0
- package/platforms/ios/src/TNSWidgets/NSFileHandle+Async.m +82 -0
- package/platforms/ios/src/TNSWidgets/NSObject+Swizzling.m +68 -0
- package/platforms/ios/src/TNSWidgets/NSString+Async.m +51 -0
- package/platforms/ios/src/TNSWidgets/TNSLabel.m +42 -0
- package/platforms/ios/src/TNSWidgets/UIImage+TNSBlocks.m +77 -0
- package/platforms/ios/src/TNSWidgets/UIView+PassThroughParent.m +53 -0
- package/platforms/ios/src/TNSWidgets/UIView+PropertyBag.m +72 -0
- package/platforms/ios/src/module.modulemap +5 -0
- package/platforms/android/widgets-release.aar +0 -0
- package/platforms/ios/TNSWidgets.xcframework/Info.plist +0 -102
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +0 -52
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +0 -52
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Resources/Info.plist +0 -52
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +0 -223
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +0 -60
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +0 -24
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +0 -22
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +0 -16
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +0 -29
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +0 -25
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +0 -26
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +0 -6
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +0 -17
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +0 -18
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +0 -223
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +0 -20
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +0 -82
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +0 -82
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSData+Async.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSFileHandle+Async.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders → src/TNSWidgets}/NSObject+Swizzling.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/NSString+Async.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/TNSLabel.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/TNSWidgets.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/UIImage+TNSBlocks.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers → src/TNSWidgets}/UIView+PassThroughParent.h +0 -0
- /package/platforms/ios/{TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders → src/TNSWidgets}/UIView+PropertyBag.h +0 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
package org.nativescript.widgets;
|
|
2
|
+
|
|
3
|
+
import android.content.ContentResolver;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.graphics.Bitmap;
|
|
6
|
+
import android.graphics.BitmapFactory;
|
|
7
|
+
import android.graphics.Canvas;
|
|
8
|
+
import android.graphics.Color;
|
|
9
|
+
import android.graphics.Matrix;
|
|
10
|
+
import android.graphics.Rect;
|
|
11
|
+
import android.graphics.drawable.BitmapDrawable;
|
|
12
|
+
import android.graphics.drawable.ColorDrawable;
|
|
13
|
+
import android.graphics.drawable.Drawable;
|
|
14
|
+
import android.net.Uri;
|
|
15
|
+
import android.os.Build;
|
|
16
|
+
import android.os.Handler;
|
|
17
|
+
import android.os.Looper;
|
|
18
|
+
import android.os.ParcelFileDescriptor;
|
|
19
|
+
import android.util.Base64OutputStream;
|
|
20
|
+
import android.util.Log;
|
|
21
|
+
import android.util.Pair;
|
|
22
|
+
import android.view.View;
|
|
23
|
+
import android.view.ViewGroup;
|
|
24
|
+
import android.view.ViewParent;
|
|
25
|
+
|
|
26
|
+
import androidx.appcompat.content.res.AppCompatResources;
|
|
27
|
+
import androidx.core.view.ViewCompat;
|
|
28
|
+
import androidx.exifinterface.media.ExifInterface;
|
|
29
|
+
|
|
30
|
+
import org.json.JSONException;
|
|
31
|
+
import org.json.JSONObject;
|
|
32
|
+
|
|
33
|
+
import java.io.BufferedOutputStream;
|
|
34
|
+
import java.io.ByteArrayOutputStream;
|
|
35
|
+
import java.io.FileDescriptor;
|
|
36
|
+
import java.io.FileNotFoundException;
|
|
37
|
+
import java.io.IOException;
|
|
38
|
+
import java.util.concurrent.Executor;
|
|
39
|
+
import java.util.concurrent.Executors;
|
|
40
|
+
|
|
41
|
+
public class Utils {
|
|
42
|
+
|
|
43
|
+
public static Drawable getDrawable(String uri, Context context) {
|
|
44
|
+
int resId = 0;
|
|
45
|
+
int resPrefixLength = "res://".length();
|
|
46
|
+
|
|
47
|
+
if (uri.length() > resPrefixLength) {
|
|
48
|
+
String resPath = uri.substring(resPrefixLength);
|
|
49
|
+
resId = context.getResources().getIdentifier(resPath, "drawable", context.getPackageName());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (resId > 0) {
|
|
53
|
+
return AppCompatResources.getDrawable(context, resId);
|
|
54
|
+
} else {
|
|
55
|
+
Log.v("JS", "Missing Image with resourceID: " + uri);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private static Bitmap drawBitmap(View view) {
|
|
61
|
+
int width = view.getWidth();
|
|
62
|
+
int height = view.getHeight();
|
|
63
|
+
Bitmap bitmap;
|
|
64
|
+
if (view.getAlpha() < 1F) {
|
|
65
|
+
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
66
|
+
} else {
|
|
67
|
+
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
|
|
68
|
+
}
|
|
69
|
+
Canvas canvas = new Canvas(bitmap);
|
|
70
|
+
if (!ViewCompat.isLaidOut(view)) {
|
|
71
|
+
view.layout(0, 0, width, height);
|
|
72
|
+
}
|
|
73
|
+
view.draw(canvas);
|
|
74
|
+
return bitmap;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@SuppressWarnings("deprecation")
|
|
78
|
+
public static Bitmap getBitmapFromView(View view) {
|
|
79
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
80
|
+
return drawBitmap(view);
|
|
81
|
+
} else {
|
|
82
|
+
|
|
83
|
+
view.setDrawingCacheEnabled(true);
|
|
84
|
+
Bitmap drawCache = view.getDrawingCache();
|
|
85
|
+
Bitmap bitmap = Bitmap.createBitmap(drawCache);
|
|
86
|
+
view.setDrawingCacheEnabled(false);
|
|
87
|
+
|
|
88
|
+
if (bitmap == null) {
|
|
89
|
+
bitmap = drawBitmap(view);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return bitmap;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public static Bitmap getBitmapFromDrawable(Drawable drawable) {
|
|
97
|
+
if (drawable instanceof BitmapDrawable) {
|
|
98
|
+
return ((BitmapDrawable) drawable).getBitmap();
|
|
99
|
+
} else {
|
|
100
|
+
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
101
|
+
Canvas canvas = new Canvas(bitmap);
|
|
102
|
+
Rect previousBounds = null;
|
|
103
|
+
|
|
104
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
105
|
+
previousBounds = drawable.getBounds();
|
|
106
|
+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
drawable.draw(canvas);
|
|
110
|
+
|
|
111
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
112
|
+
drawable.setBounds(previousBounds);
|
|
113
|
+
}
|
|
114
|
+
return bitmap;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public static void drawBoxShadow(View view, String value) {
|
|
119
|
+
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
Log.d("BoxShadowDrawable", "drawBoxShadow");
|
|
123
|
+
|
|
124
|
+
Drawable currentBg = view.getBackground();
|
|
125
|
+
|
|
126
|
+
if (currentBg != null) {
|
|
127
|
+
Log.d("BoxShadowDrawable", "current BG is: " + currentBg.getClass().getName());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (currentBg == null) {
|
|
131
|
+
Log.d("BoxShadowDrawable", "view had no background!");
|
|
132
|
+
currentBg = new ColorDrawable(Color.TRANSPARENT);
|
|
133
|
+
} else if (currentBg instanceof BoxShadowDrawable) {
|
|
134
|
+
currentBg = ((BoxShadowDrawable) view.getBackground()).getWrappedDrawable();
|
|
135
|
+
Log.d("BoxShadowDrawable", "already a BoxShadowDrawable, getting wrapped drawable:" + currentBg.getClass().getName());
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// replace background
|
|
139
|
+
Log.d("BoxShadowDrawable", "replacing background with new BoxShadowDrawable...");
|
|
140
|
+
view.setBackground(new BoxShadowDrawable(currentBg, value));
|
|
141
|
+
|
|
142
|
+
Drawable bg = view.getBackground();
|
|
143
|
+
if (bg != null) {
|
|
144
|
+
Log.d("BoxShadowDrawable", "new current bg: " + bg.getClass().getName());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int count = 0;
|
|
148
|
+
while (view.getParent() != null && view.getParent() instanceof ViewGroup) {
|
|
149
|
+
count++;
|
|
150
|
+
ViewGroup parent = (ViewGroup) view.getParent();
|
|
151
|
+
parent.setClipChildren(false);
|
|
152
|
+
parent.setClipToPadding(false);
|
|
153
|
+
// removing clipping from all breaks the ui
|
|
154
|
+
if (count == 1) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public interface AsyncImageCallback {
|
|
161
|
+
void onSuccess(Object bitmap);
|
|
162
|
+
|
|
163
|
+
void onError(Exception exception);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static class ImageAssetOptions {
|
|
167
|
+
int width;
|
|
168
|
+
int height;
|
|
169
|
+
boolean keepAspectRatio;
|
|
170
|
+
boolean autoScaleFactor;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private static final Executor executors = Executors.newCachedThreadPool();
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
private static Pair<Integer, Integer> getAspectSafeDimensions(float sourceWidth, float sourceHeight, float reqWidth, float reqHeight) {
|
|
177
|
+
float widthCoef = sourceWidth / reqWidth;
|
|
178
|
+
float heightCoef = sourceHeight / reqHeight;
|
|
179
|
+
float aspectCoef = Math.min(widthCoef, heightCoef);
|
|
180
|
+
|
|
181
|
+
return new Pair<>((int) Math.floor(sourceWidth / aspectCoef), (int) Math.floor(sourceHeight / aspectCoef));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
private static Pair<Integer, Integer> getRequestedImageSize(Pair<Integer, Integer> src, Pair<Integer, Integer> maxSize, ImageAssetOptions options) {
|
|
186
|
+
int reqWidth = options.width;
|
|
187
|
+
if (reqWidth <= 0) {
|
|
188
|
+
reqWidth = Math.min(src.first, maxSize.first);
|
|
189
|
+
}
|
|
190
|
+
int reqHeight = options.height;
|
|
191
|
+
if (reqHeight <= 0) {
|
|
192
|
+
reqHeight = Math.min(src.second, maxSize.second);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (options.keepAspectRatio) {
|
|
196
|
+
Pair<Integer, Integer> safeAspectSize = getAspectSafeDimensions(src.first, src.second, reqWidth, reqHeight);
|
|
197
|
+
reqWidth = safeAspectSize.first;
|
|
198
|
+
reqHeight = safeAspectSize.second;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return new Pair<>(reqWidth, reqHeight);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
private static void closePfd(ParcelFileDescriptor pfd) {
|
|
206
|
+
if (pfd != null) {
|
|
207
|
+
try {
|
|
208
|
+
pfd.close();
|
|
209
|
+
} catch (IOException ignored) {
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private static int calculateAngleFromFile(String filename) {
|
|
215
|
+
int rotationAngle = 0;
|
|
216
|
+
ExifInterface ei;
|
|
217
|
+
try {
|
|
218
|
+
ei = new ExifInterface(filename);
|
|
219
|
+
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
|
220
|
+
|
|
221
|
+
switch (orientation) {
|
|
222
|
+
case ExifInterface.ORIENTATION_ROTATE_90:
|
|
223
|
+
rotationAngle = 90;
|
|
224
|
+
break;
|
|
225
|
+
case ExifInterface.ORIENTATION_ROTATE_180:
|
|
226
|
+
rotationAngle = 180;
|
|
227
|
+
break;
|
|
228
|
+
case ExifInterface.ORIENTATION_ROTATE_270:
|
|
229
|
+
rotationAngle = 270;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
} catch (IOException ignored) {
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return rotationAngle;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
private static int calculateAngleFromFileDescriptor(FileDescriptor fd) {
|
|
240
|
+
int rotationAngle = 0;
|
|
241
|
+
ExifInterface ei;
|
|
242
|
+
try {
|
|
243
|
+
ei = new ExifInterface(fd);
|
|
244
|
+
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
|
245
|
+
|
|
246
|
+
switch (orientation) {
|
|
247
|
+
case ExifInterface.ORIENTATION_ROTATE_90:
|
|
248
|
+
rotationAngle = 90;
|
|
249
|
+
break;
|
|
250
|
+
case ExifInterface.ORIENTATION_ROTATE_180:
|
|
251
|
+
rotationAngle = 180;
|
|
252
|
+
break;
|
|
253
|
+
case ExifInterface.ORIENTATION_ROTATE_270:
|
|
254
|
+
rotationAngle = 270;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
} catch (IOException ignored) {
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return rotationAngle;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public static void loadImageAsync(final Context context, final String src, final String options, final int maxWidth, final int maxHeight, final AsyncImageCallback callback) {
|
|
264
|
+
final Handler mHandler = new Handler(Looper.myLooper());
|
|
265
|
+
executors.execute(new Runnable() {
|
|
266
|
+
@Override
|
|
267
|
+
public void run() {
|
|
268
|
+
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
|
|
269
|
+
bitmapOptions.inJustDecodeBounds = true;
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
Bitmap bitmap;
|
|
273
|
+
ParcelFileDescriptor pfd = null;
|
|
274
|
+
if (src.startsWith("content://")) {
|
|
275
|
+
Uri uri = android.net.Uri.parse(src);
|
|
276
|
+
ContentResolver resolver = context.getContentResolver();
|
|
277
|
+
try {
|
|
278
|
+
pfd = resolver.openFileDescriptor(uri, "r");
|
|
279
|
+
} catch (final FileNotFoundException e) {
|
|
280
|
+
mHandler.post(new Runnable() {
|
|
281
|
+
@Override
|
|
282
|
+
public void run() {
|
|
283
|
+
callback.onError(e);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
closePfd(pfd);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
android.graphics.BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, bitmapOptions);
|
|
290
|
+
} else {
|
|
291
|
+
android.graphics.BitmapFactory.decodeFile(src, bitmapOptions);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
ImageAssetOptions opts = new ImageAssetOptions();
|
|
295
|
+
opts.keepAspectRatio = true;
|
|
296
|
+
opts.autoScaleFactor = true;
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
JSONObject object = new JSONObject(options);
|
|
300
|
+
opts.width = object.optInt("width", 0);
|
|
301
|
+
opts.height = object.optInt("height", 0);
|
|
302
|
+
opts.keepAspectRatio = object.optBoolean("keepAspectRatio", true);
|
|
303
|
+
opts.autoScaleFactor = object.optBoolean("autoScaleFactor", true);
|
|
304
|
+
} catch (JSONException ignored) {
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
Pair<Integer, Integer> sourceSize = new Pair<>(bitmapOptions.outWidth, bitmapOptions.outHeight);
|
|
309
|
+
Pair<Integer, Integer> maxSize = new Pair<>(maxWidth, maxHeight);
|
|
310
|
+
Pair<Integer, Integer> requestedSize = getRequestedImageSize(sourceSize, maxSize, opts);
|
|
311
|
+
int sampleSize = org.nativescript.widgets.image.Fetcher.calculateInSampleSize(bitmapOptions.outWidth, bitmapOptions.outHeight, requestedSize.first, requestedSize.second);
|
|
312
|
+
BitmapFactory.Options finalBitmapOptions = new BitmapFactory.Options();
|
|
313
|
+
finalBitmapOptions.inSampleSize = sampleSize;
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
String error = null;
|
|
317
|
+
// read as minimum bitmap as possible (slightly bigger than the requested size)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
if (pfd != null) {
|
|
321
|
+
bitmap = BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, finalBitmapOptions);
|
|
322
|
+
} else {
|
|
323
|
+
bitmap = android.graphics.BitmapFactory.decodeFile(src, finalBitmapOptions);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
if (bitmap != null) {
|
|
328
|
+
if (requestedSize.first != bitmap.getWidth() || requestedSize.second != bitmap.getHeight()) {
|
|
329
|
+
// scale to exact size
|
|
330
|
+
bitmap = android.graphics.Bitmap.createScaledBitmap(bitmap, requestedSize.first, requestedSize.second, true);
|
|
331
|
+
}
|
|
332
|
+
int rotationAngle;
|
|
333
|
+
|
|
334
|
+
if (pfd != null) {
|
|
335
|
+
rotationAngle = calculateAngleFromFileDescriptor(pfd.getFileDescriptor());
|
|
336
|
+
closePfd(pfd);
|
|
337
|
+
} else {
|
|
338
|
+
rotationAngle = calculateAngleFromFile(src);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (rotationAngle != 0) {
|
|
342
|
+
Matrix matrix = new android.graphics.Matrix();
|
|
343
|
+
matrix.postRotate(rotationAngle);
|
|
344
|
+
bitmap = android.graphics.Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (bitmap == null) {
|
|
348
|
+
error = "Asset '" + src + "' cannot be found.";
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
final String finalError = error;
|
|
352
|
+
final Bitmap finalBitmap = bitmap;
|
|
353
|
+
mHandler.post(new Runnable() {
|
|
354
|
+
@Override
|
|
355
|
+
public void run() {
|
|
356
|
+
if (finalError != null) {
|
|
357
|
+
callback.onError(new Exception(finalError));
|
|
358
|
+
} else {
|
|
359
|
+
callback.onSuccess(finalBitmap);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
} catch (final Exception ex) {
|
|
364
|
+
mHandler.post(new Runnable() {
|
|
365
|
+
@Override
|
|
366
|
+
public void run() {
|
|
367
|
+
callback.onError(ex);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
static Bitmap.CompressFormat getTargetFormat(String format) {
|
|
376
|
+
switch (format) {
|
|
377
|
+
case "jpeg":
|
|
378
|
+
case "jpg":
|
|
379
|
+
return Bitmap.CompressFormat.JPEG;
|
|
380
|
+
default:
|
|
381
|
+
return Bitmap.CompressFormat.PNG;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
public static void saveToFileAsync(final Bitmap bitmap, final String path, final String format, final int quality, final AsyncImageCallback callback) {
|
|
387
|
+
final Handler mHandler = new Handler(Looper.myLooper());
|
|
388
|
+
executors.execute(new Runnable() {
|
|
389
|
+
@Override
|
|
390
|
+
public void run() {
|
|
391
|
+
boolean isSuccess = false;
|
|
392
|
+
Exception exception = null;
|
|
393
|
+
if (bitmap != null) {
|
|
394
|
+
Bitmap.CompressFormat targetFormat = getTargetFormat(format);
|
|
395
|
+
try (BufferedOutputStream outputStream = new BufferedOutputStream(new java.io.FileOutputStream(path))) {
|
|
396
|
+
isSuccess = bitmap.compress(targetFormat, quality, outputStream);
|
|
397
|
+
} catch (Exception e) {
|
|
398
|
+
exception = e;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
final Exception finalException = exception;
|
|
403
|
+
final boolean finalIsSuccess = isSuccess;
|
|
404
|
+
mHandler.post(new Runnable() {
|
|
405
|
+
@Override
|
|
406
|
+
public void run() {
|
|
407
|
+
if (finalException != null) {
|
|
408
|
+
callback.onError(finalException);
|
|
409
|
+
} else {
|
|
410
|
+
callback.onSuccess(finalIsSuccess);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
public static void toBase64StringAsync(final Bitmap bitmap, final String format, final int quality, final AsyncImageCallback callback) {
|
|
419
|
+
final Handler mHandler = new Handler(Looper.myLooper());
|
|
420
|
+
executors.execute(new Runnable() {
|
|
421
|
+
@Override
|
|
422
|
+
public void run() {
|
|
423
|
+
String result = null;
|
|
424
|
+
Exception exception = null;
|
|
425
|
+
if (bitmap != null) {
|
|
426
|
+
|
|
427
|
+
Bitmap.CompressFormat targetFormat = getTargetFormat(format);
|
|
428
|
+
|
|
429
|
+
try (
|
|
430
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
431
|
+
Base64OutputStream base64Stream = new Base64OutputStream(outputStream, android.util.Base64.NO_WRAP)
|
|
432
|
+
) {
|
|
433
|
+
bitmap.compress(targetFormat, quality, base64Stream);
|
|
434
|
+
result = outputStream.toString();
|
|
435
|
+
} catch (Exception e) {
|
|
436
|
+
exception = e;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
final Exception finalException = exception;
|
|
441
|
+
final String finalResult = result;
|
|
442
|
+
mHandler.post(new Runnable() {
|
|
443
|
+
@Override
|
|
444
|
+
public void run() {
|
|
445
|
+
if (finalException != null) {
|
|
446
|
+
callback.onError(finalException);
|
|
447
|
+
} else {
|
|
448
|
+
callback.onSuccess(finalResult);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
static Pair<Integer, Integer> getScaledDimensions(float width, float height, float maxSize) {
|
|
457
|
+
if (height >= width) {
|
|
458
|
+
if (height <= maxSize) {
|
|
459
|
+
// if image already smaller than the required height
|
|
460
|
+
return new Pair<>((int) width, (int) height);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return new Pair<>(
|
|
464
|
+
Math.round((maxSize * width) / height)
|
|
465
|
+
, (int) maxSize);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (width <= maxSize) {
|
|
469
|
+
// if image already smaller than the required width
|
|
470
|
+
return new Pair<>((int) width, (int) height);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return new Pair<>((int) maxSize, Math.round((maxSize * height) / width));
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
public static void resizeAsync(final Bitmap bitmap, final float maxSize, final String options, final AsyncImageCallback callback) {
|
|
478
|
+
final Handler mHandler = new Handler(Looper.myLooper());
|
|
479
|
+
executors.execute(new Runnable() {
|
|
480
|
+
@Override
|
|
481
|
+
public void run() {
|
|
482
|
+
Bitmap result = null;
|
|
483
|
+
Exception exception = null;
|
|
484
|
+
if (bitmap != null) {
|
|
485
|
+
Pair<Integer, Integer> dim = getScaledDimensions(bitmap.getWidth(), bitmap.getHeight(), maxSize);
|
|
486
|
+
boolean filter = false;
|
|
487
|
+
if (options != null) {
|
|
488
|
+
try {
|
|
489
|
+
JSONObject json = new JSONObject(options);
|
|
490
|
+
filter = json.optBoolean("filter", false);
|
|
491
|
+
} catch (JSONException ignored) {
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
result = android.graphics.Bitmap.createScaledBitmap(bitmap, dim.first, dim.second, filter);
|
|
496
|
+
} catch (Exception e) {
|
|
497
|
+
exception = e;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
final Exception finalException = exception;
|
|
502
|
+
final Bitmap finalResult = result;
|
|
503
|
+
mHandler.post(new Runnable() {
|
|
504
|
+
@Override
|
|
505
|
+
public void run() {
|
|
506
|
+
if (finalException != null) {
|
|
507
|
+
callback.onError(finalException);
|
|
508
|
+
} else {
|
|
509
|
+
callback.onSuccess(finalResult);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Return true if child is a descendant of parent, (or equal to the parent).
|
|
519
|
+
*/
|
|
520
|
+
static boolean isViewDescendantOf(View child, View parent) {
|
|
521
|
+
if (child == parent) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
final ViewParent childParent = child.getParent();
|
|
526
|
+
return (childParent instanceof ViewGroup) && isViewDescendantOf((View) childParent, parent);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// public static void clearBoxShadow(View view) {
|
|
530
|
+
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
|
|
531
|
+
// return;
|
|
532
|
+
// }
|
|
533
|
+
// Log.d("BoxShadowDrawable", "clearBoxShadow.");
|
|
534
|
+
//
|
|
535
|
+
// Drawable bg = view.getBackground();
|
|
536
|
+
// if(bg != null) {
|
|
537
|
+
// Log.d("BoxShadowDrawable", "current bg: " + bg.getClass().getName());
|
|
538
|
+
// }
|
|
539
|
+
// if(bg instanceof BoxShadowDrawable) {
|
|
540
|
+
// Drawable original = ((BoxShadowDrawable) view.getBackground()).getWrappedDrawable();
|
|
541
|
+
// Log.d("BoxShadowDrawable", "BoxShadowDrawable found, resetting to original: " + original.getClass().getName());
|
|
542
|
+
// view.setBackground(null);
|
|
543
|
+
//// view.setBackground(original);
|
|
544
|
+
// }
|
|
545
|
+
// }
|
|
546
|
+
}
|