Merged
feat: add harmony support #3
feat: add harmony support #3
Merged
Frank_SummerAdd on Nov 6, 2025
Total: 60 files changed+561-2922
@@ -1,6 +0,0 @@
1- 
2-[android]
3- target = Google Inc.:Google APIs:23
4- 
5-[maven_repositories]
6- central = https://repo1.maven.org/maven2
@@ -1,96 +0,0 @@
1-[ignore]
2- 
3-# We fork some components by platform.
4-.*/*.web.js
5-.*/*.android.js
6- 
7-# Some modules have their own node_modules with overlap
8-.*/node_modules/node-haste/.*
9- 
10-# Ugh
11-.*/node_modules/babel.*
12-.*/node_modules/babylon.*
13-.*/node_modules/invariant.*
14- 
15-# Ignore react and fbjs where there are overlaps, but don't ignore
16-# anything that react-native relies on
17-.*/node_modules/fbjs/lib/Map.js
18-.*/node_modules/fbjs/lib/fetch.js
19-.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20-.*/node_modules/fbjs/lib/ErrorUtils.js
21- 
22-# Flow has a built-in definition for the 'react' module which we prefer to use
23-# over the currently-untyped source
24-.*/node_modules/react/react.js
25-.*/node_modules/react/lib/React.js
26-.*/node_modules/react/lib/ReactDOM.js
27- 
28-.*/__mocks__/.*
29-.*/__tests__/.*
30- 
31-.*/commoner/test/source/widget/share.js
32- 
33-# Ignore commoner tests
34-.*/node_modules/commoner/test/.*
35- 
36-# See https://github.com/facebook/flow/issues/442
37-.*/react-tools/node_modules/commoner/lib/reader.js
38- 
39-# Ignore jest
40-.*/node_modules/jest-cli/.*
41- 
42-# Ignore Website
43-.*/website/.*
44- 
45-# Ignore generators
46-.*/local-cli/generator.*
47- 
48-# Ignore BUCK generated folders
49-.*\.buckd/
50- 
51-.*/node_modules/is-my-json-valid/test/.*\.json
52-.*/node_modules/iconv-lite/encodings/tables/.*\.json
53-.*/node_modules/y18n/test/.*\.json
54-.*/node_modules/spdx-license-ids/spdx-license-ids.json
55-.*/node_modules/spdx-exceptions/index.json
56-.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
57-.*/node_modules/resolve/lib/core.json
58-.*/node_modules/jsonparse/samplejson/.*\.json
59-.*/node_modules/json5/test/.*\.json
60-.*/node_modules/ua-parser-js/test/.*\.json
61-.*/node_modules/builtin-modules/builtin-modules.json
62-.*/node_modules/binary-extensions/binary-extensions.json
63-.*/node_modules/url-regex/tlds.json
64-.*/node_modules/joi/.*\.json
65-.*/node_modules/isemail/.*\.json
66-.*/node_modules/tr46/.*\.json
67- 
68- 
69-[include]
70- 
71-[libs]
72-node_modules/react-native/Libraries/react-native/react-native-interface.js
73-node_modules/react-native/flow
74-flow/
75- 
76-[options]
77-module.system=haste
78- 
79-esproposal.class_static_fields=enable
80-esproposal.class_instance_fields=enable
81- 
82-munge_underscores=true
83- 
84-module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
85-module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
86- 
87-suppress_type=$FlowIssue
88-suppress_type=$FlowFixMe
89-suppress_type=$FixMe
90- 
91-suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
92-suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
93-suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
94- 
95-[version]
96-0.23.0
@@ -1 +0,0 @@
1-{}
@@ -1,66 +0,0 @@
1-import re
2- 
3-# To learn about Buck see [Docs](https://buckbuild.com/).
4-# To run your application with Buck:
5-# - install Buck
6-# - `npm start` - to start the packager
7-# - `cd android`
8-# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
9-# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10-# - `buck install -r android/app` - compile, install and run application
11-#
12- 
13-lib_deps = []
14-for jarfile in glob(['libs/*.jar']):
15- name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16- lib_deps.append(':' + name)
17- prebuilt_jar(
18- name = name,
19- binary_jar = jarfile,
20- )
21- 
22-for aarfile in glob(['libs/*.aar']):
23- name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24- lib_deps.append(':' + name)
25- android_prebuilt_aar(
26- name = name,
27- aar = aarfile,
28- )
29- 
30-android_library(
31- name = 'all-libs',
32- exported_deps = lib_deps
33-)
34- 
35-android_library(
36- name = 'app-code',
37- srcs = glob([
38- 'src/main/java/**/*.java',
39- ]),
40- deps = [
41- ':all-libs',
42- ':build_config',
43- ':res',
44- ],
45-)
46- 
47-android_build_config(
48- name = 'build_config',
49- package = 'com.imagerotateexample',
50-)
51- 
52-android_resource(
53- name = 'res',
54- res = 'src/main/res',
55- package = 'com.imagerotateexample',
56-)
57- 
58-android_binary(
59- name = 'app',
60- package_type = 'debug',
61- manifest = 'src/main/AndroidManifest.xml',
62- keystore = '//android/keystores:debug',
63- deps = [
64- ':app-code',
65- ],
66-)
@@ -1,134 +0,0 @@
1-apply plugin: "com.android.application"
2- 
3-import com.android.build.OutputFile
4- 
5-/**
6- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7- * and bundleReleaseJsAndAssets).
8- * These basically call `react-native bundle` with the correct arguments during the Android build
9- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10- * bundle directly from the development server. Below you can see all the possible configurations
11- * and their defaults. If you decide to add a configuration block, make sure to add it before the
12- * `apply from: "../../node_modules/react-native/react.gradle"` line.
13- *
14- * project.ext.react = [
15- * // the name of the generated asset file containing your JS bundle
16- * bundleAssetName: "index.android.bundle",
17- *
18- * // the entry file for bundle generation
19- * entryFile: "index.android.js",
20- *
21- * // whether to bundle JS and assets in debug mode
22- * bundleInDebug: false,
23- *
24- * // whether to bundle JS and assets in release mode
25- * bundleInRelease: true,
26- *
27- * // whether to bundle JS and assets in another build variant (if configured).
28- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29- * // The configuration property can be in the following formats
30- * // 'bundleIn${productFlavor}${buildType}'
31- * // 'bundleIn${buildType}'
32- * // bundleInFreeDebug: true,
33- * // bundleInPaidRelease: true,
34- * // bundleInBeta: true,
35- *
36- * // the root of your project, i.e. where "package.json" lives
37- * root: "../../",
38- *
39- * // where to put the JS bundle asset in debug mode
40- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
41- *
42- * // where to put the JS bundle asset in release mode
43- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
44- *
45- * // where to put drawable resources / React Native assets, e.g. the ones you use via
46- * // require('./image.png')), in debug mode
47- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
48- *
49- * // where to put drawable resources / React Native assets, e.g. the ones you use via
50- * // require('./image.png')), in release mode
51- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
52- *
53- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
54- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
55- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
56- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57- * // for example, you might want to remove it from here.
58- * inputExcludes: ["android/**", "ios/**"]
59- * ]
60- */
61- 
62-apply from: "../../node_modules/react-native/react.gradle"
63- 
64-/**
65- * Set this to true to create two separate APKs instead of one:
66- * - An APK that only works on ARM devices
67- * - An APK that only works on x86 devices
68- * The advantage is the size of the APK is reduced by about 4MB.
69- * Upload all the APKs to the Play Store and people will download
70- * the correct one based on the CPU architecture of their device.
71- */
72-def enableSeparateBuildPerCPUArchitecture = false
73- 
74-/**
75- * Run Proguard to shrink the Java bytecode in release builds.
76- */
77-def enableProguardInReleaseBuilds = false
78- 
79-android {
80- compileSdkVersion 23
81- buildToolsVersion "23.0.1"
82- 
83- defaultConfig {
84- applicationId "com.imagerotateexample"
85- minSdkVersion 16
86- targetSdkVersion 22
87- versionCode 1
88- versionName "1.0"
89- ndk {
90- abiFilters "armeabi-v7a", "x86"
91- }
92- }
93- splits {
94- abi {
95- reset()
96- enable enableSeparateBuildPerCPUArchitecture
97- universalApk false // If true, also generate a universal APK
98- include "armeabi-v7a", "x86"
99- }
100- }
101- buildTypes {
102- release {
103- minifyEnabled enableProguardInReleaseBuilds
104- proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
105- }
106- }
107- // applicationVariants are e.g. debug, release
108- applicationVariants.all { variant ->
109- variant.outputs.each { output ->
110- // For each separate APK per architecture, set a unique version code as described here:
111- // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112- def versionCodes = ["armeabi-v7a":1, "x86":2]
113- def abi = output.getFilter(OutputFile.ABI)
114- if (abi != null) { // null for the universal-debug, universal-release variants
115- output.versionCodeOverride =
116- versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
117- }
118- }
119- }
120-}
121- 
122-dependencies {
123- compile fileTree(dir: "libs", include: ["*.jar"])
124- compile "com.android.support:appcompat-v7:23.0.1"
125- compile "com.facebook.react:react-native:+" // From node_modules
126- compile(project(':react-native-image-rotate'))
127-}
128- 
129-// Run this once to be able to run the application with BUCK
130-// puts all compile dependencies into folder libs for BUCK to use
131-task copyDownloadableDepsToLibs(type: Copy) {
132- from configurations.compile
133- into 'libs'
134-}
@@ -1,63 +0,0 @@
1-# Add project specific ProGuard rules here.
2-# By default, the flags in this file are appended to flags specified
3-# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4-# You can edit the include path and order by changing the proguardFiles
5-# directive in build.gradle.
6-#
7-# For more details, see
8-# http://developer.android.com/guide/developing/tools/proguard.html
9- 
10-# Add any project specific keep options here:
11- 
12-# If your project uses WebView with JS, uncomment the following
13-# and specify the fully qualified class name to the JavaScript interface
14-# class:
15-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-# public *;
17-#}
18- 
19-# Disabling obfuscation is useful if you collect stack traces from production crashes
20-# (unless you are using a system that supports de-obfuscate the stack traces).
21--dontobfuscate
22- 
23-# React Native
24- 
25-# Keep our interfaces so they can be used by other ProGuard rules.
26-# See http://sourceforge.net/p/proguard/bugs/466/
27--keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28--keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29- 
30-# Do not strip any method/class that is annotated with @DoNotStrip
31--keep @com.facebook.proguard.annotations.DoNotStrip class *
32--keepclassmembers class * {
33- @com.facebook.proguard.annotations.DoNotStrip *;
34-}
35- 
36--keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
37- void set*(***);
38- *** get*();
39-}
40- 
41--keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
42--keep class * extends com.facebook.react.bridge.NativeModule { *; }
43--keepclassmembers,includedescriptorclasses class * { native <methods>; }
44--keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
45--keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
46--keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
47- 
48--dontwarn com.facebook.react.**
49- 
50-# okhttp
51- 
52--keepattributes Signature
53--keepattributes *Annotation*
54--keep class com.squareup.okhttp.** { *; }
55--keep interface com.squareup.okhttp.** { *; }
56--dontwarn com.squareup.okhttp.**
57- 
58-# okio
59- 
60--keep class sun.misc.Unsafe { *; }
61--dontwarn java.nio.file.*
62--dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
63--dontwarn okio.**
@@ -1,30 +0,0 @@
1-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2- package="com.imagerotateexample"
3- android:versionCode="1"
4- android:versionName="1.0">
5- 
6- <uses-permission android:name="android.permission.INTERNET" />
7- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
8- 
9- <uses-sdk
10- android:minSdkVersion="16"
11- android:targetSdkVersion="22" />
12- 
13- <application
14- android:allowBackup="true"
15- android:label="@string/app_name"
16- android:icon="@mipmap/ic_launcher"
17- android:theme="@style/AppTheme">
18- <activity
19- android:name=".MainActivity"
20- android:label="@string/app_name"
21- android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
22- <intent-filter>
23- <action android:name="android.intent.action.MAIN" />
24- <category android:name="android.intent.category.LAUNCHER" />
25- </intent-filter>
26- </activity>
27- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
28- </application>
29- 
30-</manifest>
@@ -1,43 +0,0 @@
1-package com.imagerotateexample;
2- 
3-import io.codebakery.imagerotate.ImageRotatePackage;
4- 
5-import com.facebook.react.ReactActivity;
6-import com.facebook.react.ReactPackage;
7-import com.facebook.react.shell.MainReactPackage;
8- 
9-import java.util.Arrays;
10-import java.util.List;
11- 
12-public class MainActivity extends ReactActivity {
13- 
14- /**
15- * Returns the name of the main component registered from JavaScript.
16- * This is used to schedule rendering of the component.
17- */
18- @Override
19- protected String getMainComponentName() {
20- return "ImageRotateExample";
21- }
22- 
23- /**
24- * Returns whether dev mode should be enabled.
25- * This enables e.g. the dev menu.
26- */
27- @Override
28- protected boolean getUseDeveloperSupport() {
29- return BuildConfig.DEBUG;
30- }
31- 
32- /**
33- * A list of packages used by the app. If the app uses additional views
34- * or modules besides the default ones, add more packages here.
35- */
36- @Override
37- protected List<ReactPackage> getPackages() {
38- return Arrays.<ReactPackage>asList(
39- new MainReactPackage(),
40- new ImageRotatePackage()
41- );
42- }
43-}
@@ -1,3 +0,0 @@
1-<resources>
2- <string name="app_name">ImageRotateExample</string>
3-</resources>
@@ -1,8 +0,0 @@
1-<resources>
2- 
3- <!-- Base application theme. -->
4- <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5- <!-- Customize your theme here. -->
6- </style>
7- 
8-</resources>
@@ -1,24 +0,0 @@
1-// Top-level build file where you can add configuration options common to all sub-projects/modules.
2- 
3-buildscript {
4- repositories {
5- jcenter()
6- }
7- dependencies {
8- classpath 'com.android.tools.build:gradle:1.3.1'
9- 
10- // NOTE: Do not place your application dependencies here; they belong
11- // in the individual module build.gradle files
12- }
13-}
14- 
15-allprojects {
16- repositories {
17- mavenLocal()
18- jcenter()
19- maven {
20- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21- url "$projectDir/../../node_modules/react-native/android"
22- }
23- }
24-}
@@ -1,20 +0,0 @@
1-# Project-wide Gradle settings.
2- 
3-# IDE (e.g. Android Studio) users:
4-# Gradle settings configured through the IDE *will override*
5-# any settings specified in this file.
6- 
7-# For more details on how to configure your build environment visit
8-# http://www.gradle.org/docs/current/userguide/build_environment.html
9- 
10-# Specifies the JVM arguments used for the daemon process.
11-# The setting is particularly useful for tweaking memory settings.
12-# Default value: -Xmx10248m -XX:MaxPermSize=256m
13-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14- 
15-# When configured, Gradle will run in incubating parallel mode.
16-# This option should only be used with decoupled projects. More details, visit
17-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-# org.gradle.parallel=true
19- 
20-android.useDeprecatedNdk=true
Binary files do not support preview
@@ -1,5 +0,0 @@
1-distributionBase=GRADLE_USER_HOME
2-distributionPath=wrapper/dists
3-zipStoreBase=GRADLE_USER_HOME
4-zipStorePath=wrapper/dists
5-distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
@@ -1,164 +0,0 @@
1-#!/usr/bin/env bash
2- 
3-##############################################################################
4-##
5-## Gradle start up script for UN*X
6-##
7-##############################################################################
8- 
9-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10-DEFAULT_JVM_OPTS=""
11- 
12-APP_NAME="Gradle"
13-APP_BASE_NAME=`basename "$0"`
14- 
15-# Use the maximum available, or set MAX_FD != -1 to use that value.
16-MAX_FD="maximum"
17- 
18-warn ( ) {
19- echo "$*"
20-}
21- 
22-die ( ) {
23- echo
24- echo "$*"
25- echo
26- exit 1
27-}
28- 
29-# OS specific support (must be 'true' or 'false').
30-cygwin=false
31-msys=false
32-darwin=false
33-case "`uname`" in
34- CYGWIN* )
35- cygwin=true
36- ;;
37- Darwin* )
38- darwin=true
39- ;;
40- MINGW* )
41- msys=true
42- ;;
43-esac
44- 
45-# For Cygwin, ensure paths are in UNIX format before anything is touched.
46-if $cygwin ; then
47- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48-fi
49- 
50-# Attempt to set APP_HOME
51-# Resolve links: $0 may be a link
52-PRG="$0"
53-# Need this for relative symlinks.
54-while [ -h "$PRG" ] ; do
55- ls=`ls -ld "$PRG"`
56- link=`expr "$ls" : '.*-> \(.*\)$'`
57- if expr "$link" : '/.*' > /dev/null; then
58- PRG="$link"
59- else
60- PRG=`dirname "$PRG"`"/$link"
61- fi
62-done
63-SAVED="`pwd`"
64-cd "`dirname \"$PRG\"`/" >&-
65-APP_HOME="`pwd -P`"
66-cd "$SAVED" >&-
67- 
68-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69- 
70-# Determine the Java command to use to start the JVM.
71-if [ -n "$JAVA_HOME" ] ; then
72- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73- # IBM's JDK on AIX uses strange locations for the executables
74- JAVACMD="$JAVA_HOME/jre/sh/java"
75- else
76- JAVACMD="$JAVA_HOME/bin/java"
77- fi
78- if [ ! -x "$JAVACMD" ] ; then
79- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80- 
81-Please set the JAVA_HOME variable in your environment to match the
82-location of your Java installation."
83- fi
84-else
85- JAVACMD="java"
86- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87- 
88-Please set the JAVA_HOME variable in your environment to match the
89-location of your Java installation."
90-fi
91- 
92-# Increase the maximum file descriptors if we can.
93-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94- MAX_FD_LIMIT=`ulimit -H -n`
95- if [ $? -eq 0 ] ; then
96- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97- MAX_FD="$MAX_FD_LIMIT"
98- fi
99- ulimit -n $MAX_FD
100- if [ $? -ne 0 ] ; then
101- warn "Could not set maximum file descriptor limit: $MAX_FD"
102- fi
103- else
104- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105- fi
106-fi
107- 
108-# For Darwin, add options to specify how the application appears in the dock
109-if $darwin; then
110- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111-fi
112- 
113-# For Cygwin, switch paths to Windows format before running java
114-if $cygwin ; then
115- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117- 
118- # We build the pattern for arguments to be converted via cygpath
119- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120- SEP=""
121- for dir in $ROOTDIRSRAW ; do
122- ROOTDIRS="$ROOTDIRS$SEP$dir"
123- SEP="|"
124- done
125- OURCYGPATTERN="(^($ROOTDIRS))"
126- # Add a user-defined pattern to the cygpath arguments
127- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129- fi
130- # Now convert the arguments - kludge to limit ourselves to /bin/sh
131- i=0
132- for arg in "$@" ; do
133- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135- 
136- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138- else
139- eval `echo args$i`="\"$arg\""
140- fi
141- i=$((i+1))
142- done
143- case $i in
144- (0) set -- ;;
145- (1) set -- "$args0" ;;
146- (2) set -- "$args0" "$args1" ;;
147- (3) set -- "$args0" "$args1" "$args2" ;;
148- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154- esac
155-fi
156- 
157-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-function splitJvmOpts() {
159- JVM_OPTS=("$@")
160-}
161-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163- 
164-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@@ -1,90 +0,0 @@
1-@if "%DEBUG%" == "" @echo off
2-@rem ##########################################################################
3-@rem
4-@rem Gradle startup script for Windows
5-@rem
6-@rem ##########################################################################
7- 
8-@rem Set local scope for the variables with windows NT shell
9-if "%OS%"=="Windows_NT" setlocal
10- 
11-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12-set DEFAULT_JVM_OPTS=
13- 
14-set DIRNAME=%~dp0
15-if "%DIRNAME%" == "" set DIRNAME=.
16-set APP_BASE_NAME=%~n0
17-set APP_HOME=%DIRNAME%
18- 
19-@rem Find java.exe
20-if defined JAVA_HOME goto findJavaFromJavaHome
21- 
22-set JAVA_EXE=java.exe
23-%JAVA_EXE% -version >NUL 2>&1
24-if "%ERRORLEVEL%" == "0" goto init
25- 
26-echo.
27-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28-echo.
29-echo Please set the JAVA_HOME variable in your environment to match the
30-echo location of your Java installation.
31- 
32-goto fail
33- 
34-:findJavaFromJavaHome
35-set JAVA_HOME=%JAVA_HOME:"=%
36-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37- 
38-if exist "%JAVA_EXE%" goto init
39- 
40-echo.
41-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42-echo.
43-echo Please set the JAVA_HOME variable in your environment to match the
44-echo location of your Java installation.
45- 
46-goto fail
47- 
48-:init
49-@rem Get command-line arguments, handling Windowz variants
50- 
51-if not "%OS%" == "Windows_NT" goto win9xME_args
52-if "%@eval[2+2]" == "4" goto 4NT_args
53- 
54-:win9xME_args
55-@rem Slurp the command line arguments.
56-set CMD_LINE_ARGS=
57-set _SKIP=2
58- 
59-:win9xME_args_slurp
60-if "x%~1" == "x" goto execute
61- 
62-set CMD_LINE_ARGS=%*
63-goto execute
64- 
65-:4NT_args
66-@rem Get arguments from the 4NT Shell from JP Software
67-set CMD_LINE_ARGS=%$
68- 
69-:execute
70-@rem Setup the command line
71- 
72-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73- 
74-@rem Execute Gradle
75-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76- 
77-:end
78-@rem End local scope for the variables with windows NT shell
79-if "%ERRORLEVEL%"=="0" goto mainEnd
80- 
81-:fail
82-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83-rem the _cmd.exe /c_ return code!
84-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85-exit /b 1
86- 
87-:mainEnd
88-if "%OS%"=="Windows_NT" endlocal
89- 
90-:omega
@@ -1,8 +0,0 @@
1-keystore(
2- name = 'debug',
3- store = 'debug.keystore',
4- properties = 'debug.keystore.properties',
5- visibility = [
6- 'PUBLIC',
7- ],
8-)
@@ -1,4 +0,0 @@
1-key.store=debug.keystore
2-key.alias=androiddebugkey
3-key.store.password=android
4-key.alias.password=android
@@ -1,5 +0,0 @@
1-rootProject.name = 'ImageRotateExample'
2- 
3-include ':app'
4-include ':react-native-image-rotate'
5-project(':react-native-image-rotate').projectDir = new File(rootProject.projectDir, '../../android')
@@ -1,4 +0,0 @@
1-import { AppRegistry } from 'react-native';
2-import App from './src';
3- 
4-AppRegistry.registerComponent('ImageRotateExample', () => App);
@@ -1,4 +0,0 @@
1-import { AppRegistry } from 'react-native';
2-import App from './src';
3- 
4-AppRegistry.registerComponent('ImageRotateExample', () => App);
@@ -1,112 +0,0 @@
1-<?xml version="1.0" encoding="UTF-8"?>
2-<Scheme
3- LastUpgradeVersion = "0620"
4- version = "1.3">
5- <BuildAction
6- parallelizeBuildables = "YES"
7- buildImplicitDependencies = "YES">
8- <BuildActionEntries>
9- <BuildActionEntry
10- buildForTesting = "YES"
11- buildForRunning = "YES"
12- buildForProfiling = "YES"
13- buildForArchiving = "YES"
14- buildForAnalyzing = "YES">
15- <BuildableReference
16- BuildableIdentifier = "primary"
17- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
18- BuildableName = "ImageRotateExample.app"
19- BlueprintName = "ImageRotateExample"
20- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
21- </BuildableReference>
22- </BuildActionEntry>
23- <BuildActionEntry
24- buildForTesting = "YES"
25- buildForRunning = "YES"
26- buildForProfiling = "NO"
27- buildForArchiving = "NO"
28- buildForAnalyzing = "YES">
29- <BuildableReference
30- BuildableIdentifier = "primary"
31- BlueprintIdentifier = "00E356ED1AD99517003FC87E"
32- BuildableName = "ImageRotateExampleTests.xctest"
33- BlueprintName = "ImageRotateExampleTests"
34- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
35- </BuildableReference>
36- </BuildActionEntry>
37- </BuildActionEntries>
38- </BuildAction>
39- <TestAction
40- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
41- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
42- shouldUseLaunchSchemeArgsEnv = "YES"
43- buildConfiguration = "Debug">
44- <Testables>
45- <TestableReference
46- skipped = "NO">
47- <BuildableReference
48- BuildableIdentifier = "primary"
49- BlueprintIdentifier = "00E356ED1AD99517003FC87E"
50- BuildableName = "ImageRotateExampleTests.xctest"
51- BlueprintName = "ImageRotateExampleTests"
52- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
53- </BuildableReference>
54- </TestableReference>
55- </Testables>
56- <MacroExpansion>
57- <BuildableReference
58- BuildableIdentifier = "primary"
59- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
60- BuildableName = "ImageRotateExample.app"
61- BlueprintName = "ImageRotateExample"
62- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
63- </BuildableReference>
64- </MacroExpansion>
65- </TestAction>
66- <LaunchAction
67- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
68- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
69- launchStyle = "0"
70- useCustomWorkingDirectory = "NO"
71- buildConfiguration = "Debug"
72- ignoresPersistentStateOnLaunch = "NO"
73- debugDocumentVersioning = "YES"
74- allowLocationSimulation = "YES">
75- <BuildableProductRunnable
76- runnableDebuggingMode = "0">
77- <BuildableReference
78- BuildableIdentifier = "primary"
79- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
80- BuildableName = "ImageRotateExample.app"
81- BlueprintName = "ImageRotateExample"
82- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
83- </BuildableReference>
84- </BuildableProductRunnable>
85- <AdditionalOptions>
86- </AdditionalOptions>
87- </LaunchAction>
88- <ProfileAction
89- shouldUseLaunchSchemeArgsEnv = "YES"
90- savedToolIdentifier = ""
91- useCustomWorkingDirectory = "NO"
92- buildConfiguration = "Release"
93- debugDocumentVersioning = "YES">
94- <BuildableProductRunnable
95- runnableDebuggingMode = "0">
96- <BuildableReference
97- BuildableIdentifier = "primary"
98- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
99- BuildableName = "ImageRotateExample.app"
100- BlueprintName = "ImageRotateExample"
101- ReferencedContainer = "container:ImageRotateExample.xcodeproj">
102- </BuildableReference>
103- </BuildableProductRunnable>
104- </ProfileAction>
105- <AnalyzeAction
106- buildConfiguration = "Debug">
107- </AnalyzeAction>
108- <ArchiveAction
109- buildConfiguration = "Release"
110- revealArchiveInOrganizer = "YES">
111- </ArchiveAction>
112-</Scheme>
@@ -1,16 +0,0 @@
1-/**
2- * Copyright (c) 2015-present, Facebook, Inc.
3- * All rights reserved.
4- *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
8- */
9- 
10-#import <UIKit/UIKit.h>
11- 
12-@interface AppDelegate : UIResponder <UIApplicationDelegate>
13- 
14-@property (nonatomic, strong) UIWindow *window;
15- 
16-@end
@@ -1,59 +0,0 @@
1-/**
2- * Copyright (c) 2015-present, Facebook, Inc.
3- * All rights reserved.
4- *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
8- */
9- 
10-#import "AppDelegate.h"
11- 
12-#import "RCTRootView.h"
13- 
14-@implementation AppDelegate
15- 
16-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17-{
18- NSURL *jsCodeLocation;
19- 
20- /**
21- * Loading JavaScript code - uncomment the one you want.
22- *
23- * OPTION 1
24- * Load from development server. Start the server from the repository root:
25- *
26- * $ npm start
27- *
28- * To run on device, change `localhost` to the IP address of your computer
29- * (you can get this by typing `ifconfig` into the terminal and selecting the
30- * `inet` value under `en0:`) and make sure your computer and iOS device are
31- * on the same Wi-Fi network.
32- */
33- 
34- jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
35- 
36- /**
37- * OPTION 2
38- * Load from pre-bundled file on disk. The static bundle is automatically
39- * generated by the "Bundle React Native code and images" build step when
40- * running the project on an actual device or running the project on the
41- * simulator in the "Release" build configuration.
42- */
43- 
44-// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
45- 
46- RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
47- moduleName:@"ImageRotateExample"
48- initialProperties:nil
49- launchOptions:launchOptions];
50- 
51- self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
52- UIViewController *rootViewController = [UIViewController new];
53- rootViewController.view = rootView;
54- self.window.rootViewController = rootViewController;
55- [self.window makeKeyAndVisible];
56- return YES;
57-}
58- 
59-@end
@@ -1,42 +0,0 @@
1-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
3- <dependencies>
4- <deployment identifier="iOS"/>
5- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
6- <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
7- </dependencies>
8- <objects>
9- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
10- <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
11- <view contentMode="scaleToFill" id="iN0-l3-epB">
12- <rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
13- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
14- <subviews>
15- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
16- <rect key="frame" x="20" y="439" width="441" height="21"/>
17- <fontDescription key="fontDescription" type="system" pointSize="17"/>
18- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
19- <nil key="highlightedColor"/>
20- </label>
21- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ImageRotateExample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
22- <rect key="frame" x="20" y="140" width="441" height="43"/>
23- <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
24- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
25- <nil key="highlightedColor"/>
26- </label>
27- </subviews>
28- <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
29- <constraints>
30- <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
31- <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
32- <constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
33- <constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
34- <constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
35- <constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
36- </constraints>
37- <nil key="simulatedStatusBarMetrics"/>
38- <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
39- <point key="canvasLocation" x="548" y="455"/>
40- </view>
41- </objects>
42-</document>
@@ -1,38 +0,0 @@
1-{
2- "images" : [
3- {
4- "idiom" : "iphone",
5- "size" : "29x29",
6- "scale" : "2x"
7- },
8- {
9- "idiom" : "iphone",
10- "size" : "29x29",
11- "scale" : "3x"
12- },
13- {
14- "idiom" : "iphone",
15- "size" : "40x40",
16- "scale" : "2x"
17- },
18- {
19- "idiom" : "iphone",
20- "size" : "40x40",
21- "scale" : "3x"
22- },
23- {
24- "idiom" : "iphone",
25- "size" : "60x60",
26- "scale" : "2x"
27- },
28- {
29- "idiom" : "iphone",
30- "size" : "60x60",
31- "scale" : "3x"
32- }
33- ],
34- "info" : {
35- "version" : 1,
36- "author" : "xcode"
37- }
38-}
@@ -1,48 +0,0 @@
1-<?xml version="1.0" encoding="UTF-8"?>
2-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3-<plist version="1.0">
4-<dict>
5- <key>CFBundleDevelopmentRegion</key>
6- <string>en</string>
7- <key>CFBundleExecutable</key>
8- <string>$(EXECUTABLE_NAME)</string>
9- <key>CFBundleIdentifier</key>
10- <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
11- <key>CFBundleInfoDictionaryVersion</key>
12- <string>6.0</string>
13- <key>CFBundleName</key>
14- <string>$(PRODUCT_NAME)</string>
15- <key>CFBundlePackageType</key>
16- <string>APPL</string>
17- <key>CFBundleShortVersionString</key>
18- <string>1.0</string>
19- <key>CFBundleSignature</key>
20- <string>????</string>
21- <key>CFBundleVersion</key>
22- <string>1</string>
23- <key>LSRequiresIPhoneOS</key>
24- <true/>
25- <key>UILaunchStoryboardName</key>
26- <string>LaunchScreen</string>
27- <key>UIRequiredDeviceCapabilities</key>
28- <array>
29- <string>armv7</string>
30- </array>
31- <key>UISupportedInterfaceOrientations</key>
32- <array>
33- <string>UIInterfaceOrientationPortrait</string>
34- <string>UIInterfaceOrientationLandscapeLeft</string>
35- <string>UIInterfaceOrientationLandscapeRight</string>
36- </array>
37- <key>UIViewControllerBasedStatusBarAppearance</key>
38- <false/>
39- <key>NSLocationWhenInUseUsageDescription</key>
40- <string></string>
41- <key>NSAppTransportSecurity</key>
42- <dict>
43- <!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
44- <key>NSAllowsArbitraryLoads</key>
45- <true/>
46- </dict>
47-</dict>
48-</plist>
@@ -1,18 +0,0 @@
1-/**
2- * Copyright (c) 2015-present, Facebook, Inc.
3- * All rights reserved.
4- *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
8- */
9- 
10-#import <UIKit/UIKit.h>
11- 
12-#import "AppDelegate.h"
13- 
14-int main(int argc, char * argv[]) {
15- @autoreleasepool {
16- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17- }
18-}
@@ -1,70 +0,0 @@
1-/**
2- * Copyright (c) 2015-present, Facebook, Inc.
3- * All rights reserved.
4- *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
8- */
9- 
10-#import <UIKit/UIKit.h>
11-#import <XCTest/XCTest.h>
12- 
13-#import "RCTLog.h"
14-#import "RCTRootView.h"
15- 
16-#define TIMEOUT_SECONDS 600
17-#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
18- 
19-@interface ImageRotateExampleTests : XCTestCase
20- 
21-@end
22- 
23-@implementation ImageRotateExampleTests
24- 
25-- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
26-{
27- if (test(view)) {
28- return YES;
29- }
30- for (UIView *subview in [view subviews]) {
31- if ([self findSubviewInView:subview matching:test]) {
32- return YES;
33- }
34- }
35- return NO;
36-}
37- 
38-- (void)testRendersWelcomeScreen
39-{
40- UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
41- NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
42- BOOL foundElement = NO;
43- 
44- __block NSString *redboxError = nil;
45- RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
46- if (level >= RCTLogLevelError) {
47- redboxError = message;
48- }
49- });
50- 
51- while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
52- [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
53- [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
54- 
55- foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
56- if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
57- return YES;
58- }
59- return NO;
60- }];
61- }
62- 
63- RCTSetLogFunction(RCTDefaultLogFunction);
64- 
65- XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
66- XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
67-}
68- 
69- 
70-@end
@@ -1,24 +0,0 @@
1-<?xml version="1.0" encoding="UTF-8"?>
2-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3-<plist version="1.0">
4-<dict>
5- <key>CFBundleDevelopmentRegion</key>
6- <string>en</string>
7- <key>CFBundleExecutable</key>
8- <string>$(EXECUTABLE_NAME)</string>
9- <key>CFBundleIdentifier</key>
10- <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
11- <key>CFBundleInfoDictionaryVersion</key>
12- <string>6.0</string>
13- <key>CFBundleName</key>
14- <string>$(PRODUCT_NAME)</string>
15- <key>CFBundlePackageType</key>
16- <string>BNDL</string>
17- <key>CFBundleShortVersionString</key>
18- <string>1.0</string>
19- <key>CFBundleSignature</key>
20- <string>????</string>
21- <key>CFBundleVersion</key>
22- <string>1</string>
23-</dict>
24-</plist>
@@ -1,13 +0,0 @@
1-{
2- "name": "ImageRotateExample",
3- "version": "0.0.1",
4- "private": true,
5- "scripts": {
6- "start": "node node_modules/react-native/local-cli/cli.js start"
7- },
8- "dependencies": {
9- "react": "^0.14.8",
10- "react-native": "^0.25.1",
11- "react-native-image-rotate": "file:../"
12- }
13-}
@@ -1,90 +0,0 @@
1-import React, { Component } from 'react';
2-import {
3- Image,
4- StyleSheet,
5- Text,
6- TouchableHighlight,
7- View
8-} from 'react-native';
9- 
10-import ImageRotate from 'react-native-image-rotate';
11- 
12-const SOURCE_IMAGE = 'https://upload.wikimedia.org/wikipedia/en/5/56/Warcraft_Teaser_Poster.jpg';
13- 
14-export default class App extends Component {
15- 
16- constructor() {
17- super();
18- this.state = {
19- image: SOURCE_IMAGE,
20- currentAngle: 0,
21- width: 150,
22- height: 240,
23- };
24- 
25- this.rotate = this.rotate.bind(this);
26- }
27- 
28- rotate(angle) {
29- const nextAngle = this.state.currentAngle + angle;
30- ImageRotate.rotateImage(
31- SOURCE_IMAGE,
32- nextAngle,
33- (uri) => {
34- this.setState({
35- image: uri,
36- currentAngle: nextAngle,
37- width: this.state.height,
38- height: this.state.width,
39- });
40- },
41- (error) => {
42- console.error(error);
43- }
44- );
45- }
46- 
47- render() {
48- return (
49- <View style={styles.container}>
50- <View style={styles.imageContainer}>
51- <Image style={{width: this.state.width, height: this.state.height}} source={{uri: this.state.image}} />
52- </View>
53- <TouchableHighlight
54- onPress={() => this.rotate(90)}
55- style={styles.button}
56- >
57- <Text style={styles.text}>ROTATE CW</Text>
58- </TouchableHighlight>
59- 
60- <TouchableHighlight
61- onPress={() => this.rotate(-90)}
62- style={styles.button}
63- >
64- <Text style={styles.text}>ROTATE CCW</Text>
65- </TouchableHighlight>
66- </View>
67- );
68- }
69-}
70- 
71-const styles = StyleSheet.create({
72- container: {
73- flex: 1,
74- justifyContent: 'center',
75- alignItems: 'center',
76- backgroundColor: '#F5FCFF',
77- },
78- button: {
79- backgroundColor: 'red',
80- padding: 5,
81- margin: 5,
82- },
83- imageContainer: {
84- height: 240,
85- justifyContent: 'center',
86- },
87- text: {
88- color: 'white',
89- },
90-});
AOAT.xml+48-0
@@ -0,0 +1,48 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
13+-->
14+ 
15+<configuration>
16+ <oatconfig>
17+ <licensefile>LICENSE</licensefile>
18+ <policylist>
19+ <policy name="projectPolicy" desc="">
20+ <policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
21+ </policy>
22+ <policy name="projectPolicy" desc="">
23+ <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
24+ <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
25+ <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
26+ <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
27+ <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
28+ </policy>
29+ </policylist>
30+ <filefilterlist>
31+ <filefilter name="defaultFilter" desc="Files not to check">
32+ 
33+ </filefilter>
34+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
35+ <filteritem type="filename" name="LICENSE" desc="许可证说明文件,不添加版权头"/>
36+ <filteritem type="filepath" name="harmony/imageRotate/src/main/ets/Logger.ts" desc="工程配置文件,非业务代码,不添加许可证头"/>
37+ </filefilter>
38+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
39+ <filteritem type="filepath" name="harmony/imageRotate.har" desc="项目打包文件"/>
40+ </filefilter>
41+ 
42+ <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
43+ <filteritem type="filename" name="LICENSE" desc="许可证说明文件,不添加版权头"/>
44+ <filteritem type="filepath" name="harmony/imageRotate/src/main/ets/Logger.ts" desc="工程配置文件,非业务代码,不添加许可证头"/>
45+ </filefilter>
46+ </filefilterlist>
47+ </oatconfig>
48+</configuration>
MREADME.md+8-31
@@ -1,40 +1,17 @@
1# react-native-image-rotate1# react-native-image-rotate
2 2 
3-This project supports react-native >= 0.40.03+本项目基于 [react-native-image-rotate](https://github.com/dgladkov/react-native-image-rotate)
4 4 
5-This module is meant to be used together with react-native's5+## 文档地址 / Documentation URL
6-[ImageEditor](https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageEditor.js)
7-to create full-featured crop tool
8 6 
9-## Installation7+[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-rotate.md)
10 8 
11-First install the package via npm9+## Codegen
12 10 
13-`$ npm install react-native-image-rotate`11+该库已接入 codegen,具体请查阅文档。
14 12 
15-then use [rnpm](https://github.com/rnpm/rnpm) to link native libraries13+The library has been integrated with codegen. Please refer to the documentation for details.
16 14 
17-`$ react-native link react-native-image-rotate`15+## 请悉知 / Acknowledgements
18 16 
19-## Usage17+本项目基于 [The MIT License (MIT)](https://github.com/dgladkov/react-native-image-rotate/blob/master/LICENSE) ,请自由地享受和参与开源。
20- 
21-Package exposes only one class that contains one method with following signature:
22- 
23-```javascript
24- 
25-static rotateImage(
26- uri: string,
27- angle: number,
28- success: (uri: string) => void,
29- failure: (error: Object) => void
30- ) : void
31-```
32- 
33-## Example
34- 
35-Check the [Example directory](https://github.com/dgladkov/react-native-image-rotate/tree/master/Example)
36-for a working iOS/Android example
37- 
38-## License
39- 
40-MIT
@@ -1,268 +0,0 @@
1-// !$*UTF8*$!
2-{
3- archiveVersion = 1;
4- classes = {
5- };
6- objectVersion = 46;
7- objects = {
8- 
9-/* Begin PBXBuildFile section */
10- EF2D00FD1CE62B8D00E68430 /* ImageRotateModule.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = EF2D00FC1CE62B8D00E68430 /* ImageRotateModule.h */; };
11- EF2D00FF1CE62B8D00E68430 /* ImageRotateModule.m in Sources */ = {isa = PBXBuildFile; fileRef = EF2D00FE1CE62B8D00E68430 /* ImageRotateModule.m */; };
12-/* End PBXBuildFile section */
13- 
14-/* Begin PBXCopyFilesBuildPhase section */
15- EF2D00F71CE62B8D00E68430 /* CopyFiles */ = {
16- isa = PBXCopyFilesBuildPhase;
17- buildActionMask = 2147483647;
18- dstPath = "include/$(PRODUCT_NAME)";
19- dstSubfolderSpec = 16;
20- files = (
21- EF2D00FD1CE62B8D00E68430 /* ImageRotateModule.h in CopyFiles */,
22- );
23- runOnlyForDeploymentPostprocessing = 0;
24- };
25-/* End PBXCopyFilesBuildPhase section */
26- 
27-/* Begin PBXFileReference section */
28- EF2D00F91CE62B8D00E68430 /* libRNImageRotate.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNImageRotate.a; sourceTree = BUILT_PRODUCTS_DIR; };
29- EF2D00FC1CE62B8D00E68430 /* ImageRotateModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageRotateModule.h; sourceTree = "<group>"; };
30- EF2D00FE1CE62B8D00E68430 /* ImageRotateModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageRotateModule.m; sourceTree = "<group>"; };
31-/* End PBXFileReference section */
32- 
33-/* Begin PBXFrameworksBuildPhase section */
34- EF2D00F61CE62B8D00E68430 /* Frameworks */ = {
35- isa = PBXFrameworksBuildPhase;
36- buildActionMask = 2147483647;
37- files = (
38- );
39- runOnlyForDeploymentPostprocessing = 0;
40- };
41-/* End PBXFrameworksBuildPhase section */
42- 
43-/* Begin PBXGroup section */
44- EF2D00F01CE62B8D00E68430 = {
45- isa = PBXGroup;
46- children = (
47- EF2D00FB1CE62B8D00E68430 /* RNImageRotate */,
48- EF2D00FA1CE62B8D00E68430 /* Products */,
49- );
50- sourceTree = "<group>";
51- };
52- EF2D00FA1CE62B8D00E68430 /* Products */ = {
53- isa = PBXGroup;
54- children = (
55- EF2D00F91CE62B8D00E68430 /* libRNImageRotate.a */,
56- );
57- name = Products;
58- sourceTree = "<group>";
59- };
60- EF2D00FB1CE62B8D00E68430 /* RNImageRotate */ = {
61- isa = PBXGroup;
62- children = (
63- EF2D00FC1CE62B8D00E68430 /* ImageRotateModule.h */,
64- EF2D00FE1CE62B8D00E68430 /* ImageRotateModule.m */,
65- );
66- path = RNImageRotate;
67- sourceTree = "<group>";
68- };
69-/* End PBXGroup section */
70- 
71-/* Begin PBXNativeTarget section */
72- EF2D00F81CE62B8D00E68430 /* RNImageRotate */ = {
73- isa = PBXNativeTarget;
74- buildConfigurationList = EF2D01021CE62B8D00E68430 /* Build configuration list for PBXNativeTarget "RNImageRotate" */;
75- buildPhases = (
76- EF2D00F51CE62B8D00E68430 /* Sources */,
77- EF2D00F61CE62B8D00E68430 /* Frameworks */,
78- EF2D00F71CE62B8D00E68430 /* CopyFiles */,
79- );
80- buildRules = (
81- );
82- dependencies = (
83- );
84- name = RNImageRotate;
85- productName = RNImageRotate;
86- productReference = EF2D00F91CE62B8D00E68430 /* libRNImageRotate.a */;
87- productType = "com.apple.product-type.library.static";
88- };
89-/* End PBXNativeTarget section */
90- 
91-/* Begin PBXProject section */
92- EF2D00F11CE62B8D00E68430 /* Project object */ = {
93- isa = PBXProject;
94- attributes = {
95- LastUpgradeCheck = 0730;
96- ORGANIZATIONNAME = CodeBakery;
97- TargetAttributes = {
98- EF2D00F81CE62B8D00E68430 = {
99- CreatedOnToolsVersion = 7.3.1;
100- };
101- };
102- };
103- buildConfigurationList = EF2D00F41CE62B8D00E68430 /* Build configuration list for PBXProject "RNImageRotate" */;
104- compatibilityVersion = "Xcode 3.2";
105- developmentRegion = English;
106- hasScannedForEncodings = 0;
107- knownRegions = (
108- en,
109- );
110- mainGroup = EF2D00F01CE62B8D00E68430;
111- productRefGroup = EF2D00FA1CE62B8D00E68430 /* Products */;
112- projectDirPath = "";
113- projectRoot = "";
114- targets = (
115- EF2D00F81CE62B8D00E68430 /* RNImageRotate */,
116- );
117- };
118-/* End PBXProject section */
119- 
120-/* Begin PBXSourcesBuildPhase section */
121- EF2D00F51CE62B8D00E68430 /* Sources */ = {
122- isa = PBXSourcesBuildPhase;
123- buildActionMask = 2147483647;
124- files = (
125- EF2D00FF1CE62B8D00E68430 /* ImageRotateModule.m in Sources */,
126- );
127- runOnlyForDeploymentPostprocessing = 0;
128- };
129-/* End PBXSourcesBuildPhase section */
130- 
131-/* Begin XCBuildConfiguration section */
132- EF2D01001CE62B8D00E68430 /* Debug */ = {
133- isa = XCBuildConfiguration;
134- buildSettings = {
135- ALWAYS_SEARCH_USER_PATHS = NO;
136- CLANG_ANALYZER_NONNULL = YES;
137- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
138- CLANG_CXX_LIBRARY = "libc++";
139- CLANG_ENABLE_MODULES = YES;
140- CLANG_ENABLE_OBJC_ARC = YES;
141- CLANG_WARN_BOOL_CONVERSION = YES;
142- CLANG_WARN_CONSTANT_CONVERSION = YES;
143- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
144- CLANG_WARN_EMPTY_BODY = YES;
145- CLANG_WARN_ENUM_CONVERSION = YES;
146- CLANG_WARN_INT_CONVERSION = YES;
147- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
148- CLANG_WARN_UNREACHABLE_CODE = YES;
149- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
150- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
151- COPY_PHASE_STRIP = NO;
152- DEBUG_INFORMATION_FORMAT = dwarf;
153- ENABLE_STRICT_OBJC_MSGSEND = YES;
154- ENABLE_TESTABILITY = YES;
155- GCC_C_LANGUAGE_STANDARD = gnu99;
156- GCC_DYNAMIC_NO_PIC = NO;
157- GCC_NO_COMMON_BLOCKS = YES;
158- GCC_OPTIMIZATION_LEVEL = 0;
159- GCC_PREPROCESSOR_DEFINITIONS = (
160- "DEBUG=1",
161- "$(inherited)",
162- );
163- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
164- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
165- GCC_WARN_UNDECLARED_SELECTOR = YES;
166- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
167- GCC_WARN_UNUSED_FUNCTION = YES;
168- GCC_WARN_UNUSED_VARIABLE = YES;
169- IPHONEOS_DEPLOYMENT_TARGET = 7.0;
170- MTL_ENABLE_DEBUG_INFO = YES;
171- ONLY_ACTIVE_ARCH = YES;
172- SDKROOT = iphoneos;
173- };
174- name = Debug;
175- };
176- EF2D01011CE62B8D00E68430 /* Release */ = {
177- isa = XCBuildConfiguration;
178- buildSettings = {
179- ALWAYS_SEARCH_USER_PATHS = NO;
180- CLANG_ANALYZER_NONNULL = YES;
181- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
182- CLANG_CXX_LIBRARY = "libc++";
183- CLANG_ENABLE_MODULES = YES;
184- CLANG_ENABLE_OBJC_ARC = YES;
185- CLANG_WARN_BOOL_CONVERSION = YES;
186- CLANG_WARN_CONSTANT_CONVERSION = YES;
187- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188- CLANG_WARN_EMPTY_BODY = YES;
189- CLANG_WARN_ENUM_CONVERSION = YES;
190- CLANG_WARN_INT_CONVERSION = YES;
191- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
192- CLANG_WARN_UNREACHABLE_CODE = YES;
193- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
194- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
195- COPY_PHASE_STRIP = NO;
196- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
197- ENABLE_NS_ASSERTIONS = NO;
198- ENABLE_STRICT_OBJC_MSGSEND = YES;
199- GCC_C_LANGUAGE_STANDARD = gnu99;
200- GCC_NO_COMMON_BLOCKS = YES;
201- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
202- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
203- GCC_WARN_UNDECLARED_SELECTOR = YES;
204- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
205- GCC_WARN_UNUSED_FUNCTION = YES;
206- GCC_WARN_UNUSED_VARIABLE = YES;
207- IPHONEOS_DEPLOYMENT_TARGET = 7.0;
208- MTL_ENABLE_DEBUG_INFO = NO;
209- SDKROOT = iphoneos;
210- VALIDATE_PRODUCT = YES;
211- };
212- name = Release;
213- };
214- EF2D01031CE62B8D00E68430 /* Debug */ = {
215- isa = XCBuildConfiguration;
216- buildSettings = {
217- HEADER_SEARCH_PATHS = (
218- "$(inherited)",
219- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
220- "$(SRCROOT)/../react-native/React/**",
221- "$(SRCROOT)/../react-native/Libraries/Image/**",
222- );
223- OTHER_LDFLAGS = "-ObjC";
224- PRODUCT_NAME = "$(TARGET_NAME)";
225- SKIP_INSTALL = YES;
226- };
227- name = Debug;
228- };
229- EF2D01041CE62B8D00E68430 /* Release */ = {
230- isa = XCBuildConfiguration;
231- buildSettings = {
232- HEADER_SEARCH_PATHS = (
233- "$(inherited)",
234- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
235- "$(SRCROOT)/../react-native/React/**",
236- "$(SRCROOT)/../react-native/Libraries/Image/**",
237- );
238- OTHER_LDFLAGS = "-ObjC";
239- PRODUCT_NAME = "$(TARGET_NAME)";
240- SKIP_INSTALL = YES;
241- };
242- name = Release;
243- };
244-/* End XCBuildConfiguration section */
245- 
246-/* Begin XCConfigurationList section */
247- EF2D00F41CE62B8D00E68430 /* Build configuration list for PBXProject "RNImageRotate" */ = {
248- isa = XCConfigurationList;
249- buildConfigurations = (
250- EF2D01001CE62B8D00E68430 /* Debug */,
251- EF2D01011CE62B8D00E68430 /* Release */,
252- );
253- defaultConfigurationIsVisible = 0;
254- defaultConfigurationName = Release;
255- };
256- EF2D01021CE62B8D00E68430 /* Build configuration list for PBXNativeTarget "RNImageRotate" */ = {
257- isa = XCConfigurationList;
258- buildConfigurations = (
259- EF2D01031CE62B8D00E68430 /* Debug */,
260- EF2D01041CE62B8D00E68430 /* Release */,
261- );
262- defaultConfigurationIsVisible = 0;
263- defaultConfigurationName = Release;
264- };
265-/* End XCConfigurationList section */
266- };
267- rootObject = EF2D00F11CE62B8D00E68430 /* Project object */;
268-}
@@ -1,5 +0,0 @@
1-#import <React/RCTBridgeModule.h>
2- 
3-@interface ImageRotateModule : NSObject <RCTBridgeModule>
4- 
5-@end
@@ -1,77 +0,0 @@
1-#import "ImageRotateModule.h"
2- 
3-#import <UIKit/UIKit.h>
4- 
5-#import <React/RCTConvert.h>
6-#import <React/RCTLog.h>
7-#import <React/RCTUtils.h>
8-#import "RCTImageUtils.h"
9- 
10-#import "RCTImageStoreManager.h"
11-#import "RCTImageLoader.h"
12- 
13-@implementation ImageRotateModule
14- 
15-RCT_EXPORT_MODULE()
16- 
17-@synthesize bridge = _bridge;
18- 
19-static CGFloat DegreesToRadians(CGFloat degrees) {
20- return degrees * M_PI / 180.0;
21-};
22- 
23-/**
24- * Rotates an image and adds the result to the image store.
25- *
26- * @param imageURL A URL, a string identifying an asset etc.
27- * @param angle Rotation angle in degrees
28- */
29-RCT_EXPORT_METHOD(rotateImage:(NSURLRequest *)imageURL
30- angle:(nonnull NSNumber *)angle
31- successCallback:(RCTResponseSenderBlock)successCallback
32- errorCallback:(RCTResponseErrorBlock)errorCallback)
33-{
34- 
35- [_bridge.imageLoader loadImageWithURLRequest:imageURL callback:^(NSError *error, UIImage *image) {
36- if (error) {
37- errorCallback(error);
38- return;
39- }
40-
41- // calculate the size of the rotated view's containing box for our drawing space
42- UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
43- CGAffineTransform t = CGAffineTransformMakeRotation(DegreesToRadians([angle doubleValue]));
44- rotatedViewBox.transform = t;
45- CGSize rotatedSize = rotatedViewBox.frame.size;
46-
47- // Create the bitmap context
48- UIGraphicsBeginImageContext(rotatedSize);
49- CGContextRef bitmap = UIGraphicsGetCurrentContext();
50-
51- // Move the origin to the middle of the image so we will rotate and scale around the center.
52- CGContextTranslateCTM(bitmap, rotatedSize.width / 2, rotatedSize.height / 2);
53-
54- // Rotate the image context
55- CGContextRotateCTM(bitmap, DegreesToRadians([angle doubleValue]));
56-
57- // Now, draw the rotated/scaled image into the context
58- CGContextScaleCTM(bitmap, 1.0, -1.0);
59- CGContextDrawImage(bitmap, CGRectMake(-image.size.width / 2, -image.size.height / 2, image.size.width, image.size.height), [image CGImage]);
60-
61- UIImage *rotatedImage = UIGraphicsGetImageFromCurrentImageContext();
62- UIGraphicsEndImageContext();
63- 
64- // Store image
65- [_bridge.imageStoreManager storeImage:rotatedImage withBlock:^(NSString *rotatedImageTag) {
66- if (!rotatedImageTag) {
67- NSString *errorMessage = @"Error storing rotated image in RCTImageStoreManager";
68- RCTLogWarn(@"%@", errorMessage);
69- errorCallback(RCTErrorWithMessage(errorMessage));
70- return;
71- }
72- successCallback(@[rotatedImageTag]);
73- }];
74- }];
75-}
76- 
77-@end
@@ -1,30 +0,0 @@
1-buildscript {
2- repositories {
3- jcenter()
4- }
5- 
6- dependencies {
7- classpath 'com.android.tools.build:gradle:1.3.1'
8- }
9-}
10- 
11-apply plugin: 'com.android.library'
12- 
13-android {
14- compileSdkVersion 23
15- buildToolsVersion "23.0.1"
16- 
17- defaultConfig {
18- minSdkVersion 16
19- targetSdkVersion 22
20- versionCode 1
21- versionName "1.0"
22- }
23- lintOptions {
24- abortOnError false
25- }
26-}
27- 
28-dependencies {
29- compile 'com.facebook.react:react-native:+'
30-}
@@ -1,3 +0,0 @@
1-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2- package="io.codebakery.imagerotate">
3-</manifest>
@@ -1,371 +0,0 @@
1-package io.codebakery.imagerotate;
2- 
3-import javax.annotation.Nullable;
4- 
5-import java.io.File;
6-import java.io.FileOutputStream;
7-import java.io.FilenameFilter;
8-import java.io.IOException;
9-import java.io.InputStream;
10-import java.io.OutputStream;
11-import java.net.URL;
12-import java.net.URLConnection;
13-import java.util.Arrays;
14-import java.util.Collections;
15-import java.util.List;
16-import java.util.Map;
17- 
18-import android.annotation.SuppressLint;
19-import android.content.Context;
20-import android.database.Cursor;
21-import android.graphics.Bitmap;
22-import android.graphics.BitmapFactory;
23-import android.graphics.Matrix;
24-import android.media.ExifInterface;
25-import android.net.Uri;
26-import android.os.AsyncTask;
27-import android.provider.MediaStore;
28-import android.text.TextUtils;
29- 
30-import com.facebook.common.logging.FLog;
31-import com.facebook.react.bridge.Callback;
32-import com.facebook.react.bridge.GuardedAsyncTask;
33-import com.facebook.react.bridge.ReactApplicationContext;
34-import com.facebook.react.bridge.ReactContext;
35-import com.facebook.react.bridge.ReactContextBaseJavaModule;
36-import com.facebook.react.bridge.ReactMethod;
37-import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
38-import com.facebook.react.common.ReactConstants;
39- 
40-/**
41- * Native module that provides image rotation functionality.
42- */
43-public class ImageRotateModule extends ReactContextBaseJavaModule {
44- 
45- private static final List<String> LOCAL_URI_PREFIXES = Arrays.asList(
46- "file://", "content://");
47- 
48- private static final String TEMP_FILE_PREFIX = "ReactNative_rotated_image_";
49- 
50- /** Compress quality of the output file. */
51- private static final int COMPRESS_QUALITY = 90;
52- 
53- @SuppressLint("InlinedApi") private static final String[] EXIF_ATTRIBUTES = new String[] {
54- ExifInterface.TAG_APERTURE,
55- ExifInterface.TAG_DATETIME,
56- ExifInterface.TAG_DATETIME_DIGITIZED,
57- ExifInterface.TAG_EXPOSURE_TIME,
58- ExifInterface.TAG_FLASH,
59- ExifInterface.TAG_FOCAL_LENGTH,
60- ExifInterface.TAG_GPS_ALTITUDE,
61- ExifInterface.TAG_GPS_ALTITUDE_REF,
62- ExifInterface.TAG_GPS_DATESTAMP,
63- ExifInterface.TAG_GPS_LATITUDE,
64- ExifInterface.TAG_GPS_LATITUDE_REF,
65- ExifInterface.TAG_GPS_LONGITUDE,
66- ExifInterface.TAG_GPS_LONGITUDE_REF,
67- ExifInterface.TAG_GPS_PROCESSING_METHOD,
68- ExifInterface.TAG_GPS_TIMESTAMP,
69- ExifInterface.TAG_IMAGE_LENGTH,
70- ExifInterface.TAG_IMAGE_WIDTH,
71- ExifInterface.TAG_ISO,
72- ExifInterface.TAG_MAKE,
73- ExifInterface.TAG_MODEL,
74- ExifInterface.TAG_ORIENTATION,
75- ExifInterface.TAG_SUBSEC_TIME,
76- ExifInterface.TAG_SUBSEC_TIME_DIG,
77- ExifInterface.TAG_SUBSEC_TIME_ORIG,
78- ExifInterface.TAG_WHITE_BALANCE
79- };
80- 
81- public ImageRotateModule(ReactApplicationContext reactContext) {
82- super(reactContext);
83- new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
84- }
85- 
86- @Override
87- public String getName() {
88- return "ImageRotateModule";
89- }
90- 
91- @Override
92- public Map<String, Object> getConstants() {
93- return Collections.emptyMap();
94- }
95- 
96- @Override
97- public void onCatalystInstanceDestroy() {
98- new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
99- }
100- 
101- /**
102- * Asynchronous task that cleans up cache dirs (internal and, if available, external) of rotated
103- * image files. This is run when the catalyst instance is being destroyed (i.e. app is shutting
104- * down) and when the module is instantiated, to handle the case where the app crashed.
105- */
106- private static class CleanTask extends GuardedAsyncTask<Void, Void> {
107- private final Context mContext;
108- 
109- private CleanTask(ReactContext context) {
110- super(context);
111- mContext = context;
112- }
113- 
114- @Override
115- protected void doInBackgroundGuarded(Void... params) {
116- cleanDirectory(mContext.getCacheDir());
117- File externalCacheDir = mContext.getExternalCacheDir();
118- if (externalCacheDir != null) {
119- cleanDirectory(externalCacheDir);
120- }
121- }
122- 
123- private void cleanDirectory(File directory) {
124- File[] toDelete = directory.listFiles(
125- new FilenameFilter() {
126- @Override
127- public boolean accept(File dir, String filename) {
128- return filename.startsWith(TEMP_FILE_PREFIX);
129- }
130- });
131- if (toDelete != null) {
132- for (File file: toDelete) {
133- file.delete();
134- }
135- }
136- }
137- }
138- 
139- /**
140- * Rotate an image. If all goes well, the success callback will be called with the file:// URI of
141- * the new image as the only argument. This is a temporary file - consider using
142- * CameraRollManager.saveImageWithTag to save it in the gallery.
143- *
144- * @param uri the MediaStore URI of the image to rotate
145- * @param angle rotation angle
146- * @param success callback to be invoked when the image has been rotated; the only argument that
147- * is passed to this callback is the file:// URI of the new image
148- * @param error callback to be invoked when an error occurs (e.g. can't create file etc.)
149- */
150- @ReactMethod
151- public void rotateImage(
152- String uri,
153- final float angle,
154- final Callback success,
155- final Callback error) {
156- 
157- if (uri == null || uri.isEmpty()) {
158- throw new JSApplicationIllegalArgumentException("Please specify a URI");
159- }
160- 
161- RotateTask rotateTask = new RotateTask(
162- getReactApplicationContext(),
163- uri,
164- angle,
165- success,
166- error);
167- 
168- rotateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
169- }
170- 
171- private static class RotateTask extends GuardedAsyncTask<Void, Void> {
172- final Context mContext;
173- final String mUri;
174- final float mAngle;
175- final Callback mSuccess;
176- final Callback mError;
177- 
178- private RotateTask(
179- ReactContext context,
180- String uri,
181- float angle,
182- Callback success,
183- Callback error) {
184- super(context);
185- 
186- mContext = context;
187- mUri = uri;
188- mAngle = angle;
189- mSuccess = success;
190- mError = error;
191- }
192- 
193- private InputStream openBitmapInputStream() throws IOException {
194- InputStream stream;
195- if (isLocalUri(mUri)) {
196- stream = mContext.getContentResolver().openInputStream(Uri.parse(mUri));
197- } else {
198- URLConnection connection = new URL(mUri).openConnection();
199- stream = connection.getInputStream();
200- }
201- if (stream == null) {
202- throw new IOException("Cannot open bitmap: " + mUri);
203- }
204- return stream;
205- }
206- 
207- @Override
208- protected void doInBackgroundGuarded(Void... params) {
209- try {
210- BitmapFactory.Options outOptions = new BitmapFactory.Options();
211- 
212- Bitmap rotated = rotate(outOptions);
213- 
214- String mimeType = outOptions.outMimeType;
215- if (mimeType == null || mimeType.isEmpty()) {
216- throw new IOException("Could not determine MIME type");
217- }
218- 
219- File tempFile = createTempFile(mContext, mimeType);
220- writeCompressedBitmapToFile(rotated, mimeType, tempFile);
221- 
222- if (mimeType.equals("image/jpeg")) {
223- copyExif(mContext, Uri.parse(mUri), tempFile);
224- }
225- 
226- mSuccess.invoke(Uri.fromFile(tempFile).toString());
227- 
228- } catch (Exception e) {
229- mError.invoke(e.getMessage());
230- }
231- }
232- 
233- /**
234- * Reads and rotates the bitmap.
235- * @param outOptions Bitmap options, useful to determine {@code outMimeType}.
236- */
237- private Bitmap rotate(BitmapFactory.Options outOptions) throws IOException {
238- InputStream inputStream = openBitmapInputStream();
239- try {
240- // This can use a lot of memory
241- Bitmap bitmap = BitmapFactory.decodeStream(inputStream, null, outOptions);
242- if (bitmap == null) {
243- throw new IOException("Cannot decode bitmap: " + mUri);
244- }
245- Matrix rotateMatrix = new Matrix();
246- rotateMatrix.postRotate(mAngle);
247- 
248- return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), rotateMatrix, true);
249- } catch (OutOfMemoryError outOfMemoryError) {
250- // we are out of memory
251- throw new RuntimeException("We are out of memory");
252- } finally {
253- if (inputStream != null) {
254- inputStream.close();
255- }
256- }
257- }
258- 
259- }
260- 
261- // Utils
262- 
263- private static void copyExif(Context context, Uri oldImage, File newFile) throws IOException {
264- File oldFile = getFileFromUri(context, oldImage);
265- if (oldFile == null) {
266- FLog.w(ReactConstants.TAG, "Couldn't get real path for uri: " + oldImage);
267- return;
268- }
269- 
270- ExifInterface oldExif = new ExifInterface(oldFile.getAbsolutePath());
271- ExifInterface newExif = new ExifInterface(newFile.getAbsolutePath());
272- for (String attribute : EXIF_ATTRIBUTES) {
273- String value = oldExif.getAttribute(attribute);
274- if (value != null) {
275- newExif.setAttribute(attribute, value);
276- }
277- }
278- newExif.saveAttributes();
279- }
280- 
281- private static @Nullable File getFileFromUri(Context context, Uri uri) {
282- if (uri.getScheme().equals("file")) {
283- return new File(uri.getPath());
284- } else if (uri.getScheme().equals("content")) {
285- Cursor cursor = context.getContentResolver()
286- .query(uri, new String[] { MediaStore.MediaColumns.DATA }, null, null, null);
287- if (cursor != null) {
288- try {
289- if (cursor.moveToFirst()) {
290- String path = cursor.getString(0);
291- if (!TextUtils.isEmpty(path)) {
292- return new File(path);
293- }
294- }
295- } finally {
296- cursor.close();
297- }
298- }
299- }
300- 
301- return null;
302- }
303- 
304- private static boolean isLocalUri(String uri) {
305- for (String localPrefix : LOCAL_URI_PREFIXES) {
306- if (uri.startsWith(localPrefix)) {
307- return true;
308- }
309- }
310- return false;
311- }
312- 
313- private static String getFileExtensionForType(@Nullable String mimeType) {
314- if ("image/png".equals(mimeType)) {
315- return ".png";
316- }
317- if ("image/webp".equals(mimeType)) {
318- return ".webp";
319- }
320- return ".jpg";
321- }
322- 
323- private static Bitmap.CompressFormat getCompressFormatForType(String type) {
324- if ("image/png".equals(type)) {
325- return Bitmap.CompressFormat.PNG;
326- }
327- if ("image/webp".equals(type)) {
328- return Bitmap.CompressFormat.WEBP;
329- }
330- return Bitmap.CompressFormat.JPEG;
331- }
332- 
333- private static void writeCompressedBitmapToFile(Bitmap rotated, String mimeType, File tempFile)
334- throws IOException {
335- OutputStream out = new FileOutputStream(tempFile);
336- try {
337- rotated.compress(getCompressFormatForType(mimeType), COMPRESS_QUALITY, out);
338- } finally {
339- if (out != null) {
340- out.close();
341- }
342- }
343- }
344- 
345- /**
346- * Create a temporary file in the cache directory on either internal or external storage,
347- * whichever is available and has more free space.
348- *
349- * @param mimeType the MIME type of the file to create (image/*)
350- */
351- private static File createTempFile(Context context, @Nullable String mimeType)
352- throws IOException {
353- File externalCacheDir = context.getExternalCacheDir();
354- File internalCacheDir = context.getCacheDir();
355- File cacheDir;
356- if (externalCacheDir == null && internalCacheDir == null) {
357- throw new IOException("No cache directory available");
358- }
359- if (externalCacheDir == null) {
360- cacheDir = internalCacheDir;
361- }
362- else if (internalCacheDir == null) {
363- cacheDir = externalCacheDir;
364- } else {
365- cacheDir = externalCacheDir.getFreeSpace() > internalCacheDir.getFreeSpace() ?
366- externalCacheDir : internalCacheDir;
367- }
368- return File.createTempFile(TEMP_FILE_PREFIX, getFileExtensionForType(mimeType), cacheDir);
369- }
370- 
371-}
@@ -1,29 +0,0 @@
1-package io.codebakery.imagerotate;
2- 
3-import com.facebook.react.ReactPackage;
4-import com.facebook.react.bridge.JavaScriptModule;
5-import com.facebook.react.bridge.NativeModule;
6-import com.facebook.react.bridge.ReactApplicationContext;
7-import com.facebook.react.uimanager.ViewManager;
8- 
9-import java.util.Arrays;
10-import java.util.Collections;
11-import java.util.List;
12- 
13-public class ImageRotatePackage implements ReactPackage {
14- 
15- @Override
16- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
17- return Arrays.<NativeModule>asList(
18- new ImageRotateModule(reactContext));
19- }
20- 
21- public List<Class<? extends JavaScriptModule>> createJSModules() {
22- return Collections.emptyList();
23- }
24- 
25- @Override
26- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
27- return Collections.emptyList();
28- }
29-}
Binary files do not support preview
@@ -0,0 +1,25 @@
1+/*
2+ * MIT License
3+ *
4+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ 
25+export * from "./ts";
@@ -0,0 +1,28 @@
1+{
2+ "apiType": "stageMode",
3+ "buildOption": {
4+ },
5+ "buildOptionSet": [
6+ {
7+ "name": "release",
8+ "arkOptions": {
9+ "obfuscation": {
10+ "ruleOptions": {
11+ "enable": true,
12+ "files": [
13+ "./obfuscation-rules.txt"
14+ ]
15+ }
16+ }
17+ },
18+ },
19+ ],
20+ "targets": [
21+ {
22+ "name": "default"
23+ },
24+ {
25+ "name": "ohosTest"
26+ }
27+ ]
28+}
@@ -0,0 +1,6 @@
1+import { harTasks } from '@ohos/hvigor-ohos-plugin';
2+ 
3+export default {
4+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6+}
@@ -0,0 +1,18 @@
1+# Define project specific obfuscation rules here.
2+# You can include the obfuscation configuration files in the current module's build-profile.json5.
3+#
4+# For more details, see
5+# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6+ 
7+# Obfuscation options:
8+# -disable-obfuscation: disable all obfuscations
9+# -enable-property-obfuscation: obfuscate the property names
10+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
11+# -compact: remove unnecessary blank spaces and all line feeds
12+# -remove-log: remove all console.* statements
13+# -print-namecache: print the name cache that contains the mapping from the old names to new names
14+# -apply-namecache: reuse the given cache file
15+ 
16+# Keep options:
17+# -keep-property-name: specifies property names that you want to keep
18+# -keep-global-name: specifies names that you want to keep in the global scope
@@ -0,0 +1,13 @@
1+{
2+ "license": "ISC",
3+ "types": "",
4+ "devDependencies": {
5+ },
6+ "name": "imagerotate",
7+ "description": "",
8+ "main": "Index.ets",
9+ "version": "2.1.0-0.0.1",
10+ "dependencies": {
11+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony"
12+ }
13+}
Aharmony/imageRotate/src/main/ets/Logger.ts+64-0File content is under review, please try again later
@@ -0,0 +1,53 @@
1+/*
2+ * MIT License
3+ *
4+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ 
25+import {
26+ RNPackage,
27+ TurboModulesFactory,
28+ } from "@rnoh/react-native-openharmony/ts";
29+ import type {
30+ TurboModule,
31+ TurboModuleContext,
32+ } from "@rnoh/react-native-openharmony/ts";
33+ import { TM } from "@rnoh/react-native-openharmony/generated/ts";
34+ import { RNImageRotateTurboModule } from "./RNImageRotateTurboModule";
35+
36+ class ImageRotateModulesFactory extends TurboModulesFactory {
37+ createTurboModule(name: string): TurboModule | null {
38+ if (name === TM.ImageRotateNativeModule.NAME) {
39+ return new RNImageRotateTurboModule(this.ctx);
40+ }
41+ return null;
42+ }
43+
44+ hasTurboModule(name: string): boolean {
45+ return name === TM.ImageRotateNativeModule.NAME;
46+ }
47+ }
48+
49+ export class RNImageRotatePackage extends RNPackage {
50+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
51+ return new ImageRotateModulesFactory(ctx);
52+ }
53+ }
@@ -0,0 +1,216 @@
1+/*
2+ * MIT License
3+ *
4+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ 
25+import { TurboModule, TurboModuleContext} from '@rnoh/react-native-openharmony/ts';
26+import { TM } from "@rnoh/react-native-openharmony/generated/ts"
27+import { BusinessError } from '@ohos.base';
28+import { common } from '@kit.AbilityKit';
29+import image from '@ohos.multimedia.image';
30+import fs from '@ohos.file.fs';
31+import http from '@ohos.net.http'
32+import util from '@ohos.util';
33+ 
34+export class RNImageRotateTurboModule extends TurboModule implements TM.ImageRotateNativeModule.Spec {
35+ 
36+ private static TEMP_FILE_PREFIX: string = "ReactNative_rotated_image_";
37+ private static COMPRESS_QUALITY: number = 90;
38+ constructor(protected ctx: TurboModuleContext) {
39+ super(ctx);
40+ const mcontext = this.ctx.uiAbilityContext;
41+ let cleanTask = new RNImageRotateTurboModule.CleanTask(mcontext);
42+ cleanTask.cleanDirectory();
43+ }
44+ 
45+ rotateImage(muri: string, mangle: number, success: (msuccess: string) => void, error: (merror: Object) => void) {
46+ if (muri === null || muri === "") {
47+ throw new Error("Please specify a URI");
48+ }
49+ const mcontext = this.ctx.uiAbilityContext;
50+ let cleanTask = new RNImageRotateTurboModule.CleanTask(mcontext);
51+ cleanTask.cleanDirectory();
52+ 
53+ let rotateTask = new RNImageRotateTurboModule.RotateTask(
54+ mcontext,
55+ muri,
56+ mangle,
57+ success,
58+ error);
59+ rotateTask.openBitmapInputStream(rotateTask.mUri).then((imagePixelMap)=>{
60+ imagePixelMap.rotate(rotateTask.mAngle).then(() => {
61+ rotateTask.doInBackgroundGuarded(imagePixelMap);
62+ }).catch((err: BusinessError) => {
63+ console.error(`Failed to rotate pixelmap. code is ${err.code}, message is ${err.message}`);
64+ });
65+ });
66+ }
67+ 
68+ static CleanTask = class zCleanTask {
69+ mContext: common.UIAbilityContext
70+ constructor(mcontext: common.UIAbilityContext){
71+ this.mContext = mcontext;
72+ }
73+ cleanDirectory() {
74+ let options = {
75+ recursion: false,
76+ listNum: 0,
77+ filter: {
78+ 'suffix': ['.png', '.jpg', '.webp'],
79+ "displayName": ["ReactNative_rotated_image_*"],
80+ }
81+ };
82+ let pathDir = this.mContext.cacheDir;
83+ fs.listFile(pathDir, options).then((filenames)=>{
84+ for (let i = 0; i < filenames.length; i++) {
85+ let src = pathDir + '/' + filenames[i];
86+ fs.unlinkSync(src);
87+ console.info("CleanTask filename: %s", filenames[i]);
88+ console.info("CleanTask filename: %s", src);
89+ }
90+ }).catch((err) => {
91+ console.error("list file failed with error message: " + err.message + ", error code: " + err.code);
92+ });
93+ }
94+ }
95+ 
96+ private static RotateTask = class zRotateTask {
97+ private imageType: string = 'image/png';
98+ mContext: common.UIAbilityContext
99+ mUri: string
100+ mAngle: number
101+ mSuccess: (msuccess: string) => void
102+ mError: (merror: Object) => void
103+ constructor(mcontext: common.UIAbilityContext, muri: string, mangle: number, success: (uri: string) => void, error: (merror: Object) => void) {
104+ this.mContext = mcontext;
105+ this.mUri = muri;
106+ this.mAngle = mangle;
107+ this.mSuccess = success;
108+ this.mError = error;
109+ }
110+ 
111+ 
112+ // 网络图片转换为PixelMap
113+ private async getPixelMapFromURL(src: string): Promise<image.PixelMap> {
114+ const data: http.HttpResponse = await http.createHttp().request(src);
115+ if (data.responseCode === http.ResponseCode.OK && data.result instanceof ArrayBuffer) {
116+ if (data.header.hasOwnProperty('content-type')) {
117+ this.imageType = data.header['content-type'];
118+ }
119+ let imageData: ArrayBuffer = data.result;
120+ const imageSource: image.ImageSource = image.createImageSource(imageData);
121+ const imageInfo = await imageSource.getImageInfo();
122+ const imageWidth = Math.round(imageInfo.size.width);
123+ const imageHeight = Math.round(imageInfo.size.height);
124+ const option: image.InitializationOptions = {
125+ 'alphaType': 0,
126+ 'editable': false,
127+ 'pixelFormat': 3,
128+ 'scaleMode': 1,
129+ 'size': { height: imageHeight, width: imageWidth },
130+ }
131+ let pixelMap: image.PixelMap = await imageSource.createPixelMap(option);
132+ return pixelMap;
133+ }
134+ }
135+ 
136+ // 本地图片uri转pixelMap
137+ // src对应的是本地图片的协议url
138+ private async getPixelMapFromFile(src: string): Promise<image.PixelMap> {
139+ let file = fs.openSync(src, fs.OpenMode.READ_WRITE);
140+ try {
141+ const imageSource = image.createImageSource(file.fd);
142+ const imagePackApi = image.createImagePacker();
143+ const imageInfo = await imageSource.getImageInfo();
144+ this.imageType = imageInfo.mimeType;
145+ if (!['image/png', 'image/jpeg', 'image/webp'].includes(this.imageType)) {
146+ this.imageType = 'image/png';
147+ }
148+ const packOpts: image.PackingOption = {
149+ format: `${this.imageType}`,
150+ quality: 100,
151+ }
152+ let readBuffer = await imagePackApi.packing(imageSource, packOpts);
153+ const imageSourceFromBuffer: image.ImageSource = image.createImageSource(readBuffer as ArrayBuffer);
154+ const imageWidth = Math.round(imageInfo.size.width);
155+ const imageHeight = Math.round(imageInfo.size.height);
156+ const option: image.InitializationOptions = {
157+ 'alphaType': 0,
158+ 'editable': false,
159+ 'pixelFormat': 3,
160+ 'scaleMode': 1,
161+ 'size': { height: imageHeight, width: imageWidth },
162+ }
163+ return await imageSourceFromBuffer.createPixelMap(option);
164+ } catch (err) {
165+ console.error("getPixelMapFromFile failed with error message: " + err.message + ", error code: " + err.code);
166+ } finally {
167+ fs.closeSync(file);
168+ }
169+ }
170+ 
171+ async openBitmapInputStream(muri:string): Promise<image.PixelMap> {
172+ let imagePixelMap: image.PixelMap | undefined = undefined;
173+ if (muri.includes('http')) {
174+ // online picture to pixelMap
175+ imagePixelMap = await this.getPixelMapFromURL(muri);
176+ } else {
177+ imagePixelMap = await this.getPixelMapFromFile(muri);
178+ }
179+ if (imagePixelMap === undefined) {
180+ console.info('Error Bad uri, Failed to decode PixelMap: uri ' + muri);
181+ }
182+ return imagePixelMap;
183+ }
184+ 
185+ async doInBackgroundGuarded(imagePixelMap:image.PixelMap) {
186+ try {
187+ let type = imagePixelMap.getImageInfoSync().mimeType;
188+ let typetemp = this.getFileExtensionForType(type);
189+ let src = this.getCacheFilePath(typetemp);
190+ let tempFile = fs.openSync(src, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
191+ const imagePackerApi: image.ImagePacker = image.createImagePacker();
192+ const buf = await imagePackerApi.packing(imagePixelMap, {format: type, quality: RNImageRotateTurboModule.COMPRESS_QUALITY});
193+ await fs.write(tempFile.fd, buf);
194+ this.mSuccess(src);
195+ fs.closeSync(tempFile.fd);
196+ } catch (err) {
197+ console.info("生成路径失败 "+ err.message);
198+ this.mError(err.message);
199+ }
200+ }
201+ 
202+ private getCacheFilePath(type: string):string {
203+ return 'file://' + this.mContext.cacheDir + "/" + RNImageRotateTurboModule.TEMP_FILE_PREFIX + util.generateRandomUUID(true) + type;
204+ }
205+ 
206+ private getFileExtensionForType(mimeType: string): string {
207+ if (mimeType === "image/png") {
208+ return ".png";
209+ }
210+ if (mimeType === "image/webp") {
211+ return ".webp";
212+ }
213+ return ".jpg";
214+ }
215+ }
216+}
Aharmony/imageRotate/src/main/module.json5+9-0File content is under review, please try again later
@@ -0,0 +1,26 @@
1+/*
2+ * MIT License
3+ *
4+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ 
25+export * from "./src/main/ets/RNImageRotateTurboModule";
26+export * from "./src/main/ets/RNImageRotatePackage";
@@ -3,9 +3,9 @@
3 * @flow3 * @flow
4 */4 */
5'use strict';5'use strict';
6-import { NativeModules } from 'react-native';6+import { TurboModuleRegistry } from 'react-native';
7 7 
8-const RCTImageRotateModule = NativeModules.ImageRotateModule;8+const RCTImageRotateModule = TurboModuleRegistry.get('ImageRotateNativeModule');
9 9 
10export default class ImageRotate {10export default class ImageRotate {
11 /**11 /**
@@ -1,6 +1,6 @@
1{1{
2- "name": "react-native-image-rotate",2+ "name": "@react-native-oh-tpl/react-native-image-rotate",
3- "version": "2.1.0",3+ "version": "2.1.0-0.0.1",
4 "description": "Rotate images from your react-native JavaScript code",4 "description": "Rotate images from your react-native JavaScript code",
5 "main": "index.js",5 "main": "index.js",
6 "scripts": {6 "scripts": {
@@ -8,7 +8,15 @@
8 },8 },
9 "repository": {9 "repository": {
10 "type": "git",10 "type": "git",
11- "url": "git+https://github.com/dgladkov/react-native-image-rotate.git"11+ "url": "https://github.com/react-native-oh-library/react-native-image-rotate.git"
12+ },
13+ "harmony": {
14+ "alias": "react-native-image-rotate",
15+ "codegenConfig": {
16+ "specPaths": [
17+ "./src"
18+ ]
19+ }
12 },20 },
13 "keywords": [21 "keywords": [
14 "react-native",22 "react-native",
@@ -16,10 +24,9 @@
16 "react-native-component",24 "react-native-component",
17 "react",25 "react",
18 "mobile",26 "mobile",
19- "ios",
20- "android",
21 "image",27 "image",
22- "rotate"28+ "rotate",
29+ "harmony"
23 ],30 ],
24 "author": {31 "author": {
25 "name": "Dmitry Gladkov",32 "name": "Dmitry Gladkov",
@@ -0,0 +1,32 @@
1+/*
2+ * MIT License
3+ *
4+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+ 
25+import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
26+import { TurboModuleRegistry } from "react-native";
27+ 
28+export interface Spec extends TurboModule {
29+ rotateImage(muri: string, mangle: number, success: (msuccess: string) => void, error: (merror: Object) => void):void;
30+}
31+ 
32+export default TurboModuleRegistry.get<Spec>("ImageRotateNativeModule") as Spec;