Skip to content

Commit

Permalink
Add version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leontobias committed Nov 25, 2021
1 parent 4047157 commit 6375113
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 97 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [3.0.0]

### Added

* Added integration and documentation for force trim.

### Changed

* [Android] Migrated the plugin to AndroidX.
* Aligned emoji support for iOS and Android. Emoji support is not optimized for cross-platform use and disabled by default. Added option `configuration.text.allowEmojis` to opt in.

## [2.2.0]

### Added
Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@ cordova plugin add cordova-plugin-videoeditorsdk
```

### Android
**Configuration for Android:**
Configure VideoEditor SDK for Android by opening `imglyConfig.gradle`, you can comment out the modules you don't need to save size.

Because VideoEditor SDK for Android is quite large, there is a high chance that you will need to enable [Multidex](https://developer.android.com/studio/build/multidex) for your project as follows:
From version `3.0.0` the plugin uses AndroidX. To enable AndroidX in your application please adjust your `config.xml`:

```diff
<platform name="android">
...
+ <preference name="AndroidXEnabled" value="true" />
...
</platform>
```

If your application is using legacy Android Support Libraries you can use the [`cordova-plugin-androidx-adapter`](https://www.npmjs.com/package/cordova-plugin-androidx-adapter) which will migrate the legacy libraries to work with AndroidX.

#### Module Configuration

You can configure the modules used for the VideoEditor SDK for Android by opening `imglyConfig.gradle` and removing / commenting out the modules you do not need. This will also reduce the size of your application.

Because VideoEditor SDK for Android with all its modules is quite large, there is a high chance that you will need to enable [Multidex](https://developer.android.com/studio/build/multidex) for your project as follows:

```sh
cordova plugin add cordova-plugin-enable-multidex
Expand Down
11 changes: 9 additions & 2 deletions hooks/dependencies-gradle-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ module.exports = (context) => {

const BLOCK_START = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK END`;
const VERSION_BLOCK_START = "// VERSION CHANGED BY IMGLY - START - ";
const VERSION_BLOCK_END = "// VERSION CHANGED BY IMGLY - END -";
const gradlePluginVersion = '1.4.10';

const imglyDependencies =
"\n" +
BLOCK_START +
`
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
classpath "ly.img.android.sdk:plugin:8.3.4"` +
classpath "ly.img.android.sdk:plugin:9.1.0"` +
"\n" +
BLOCK_END +
"\n";
Expand Down Expand Up @@ -53,6 +55,11 @@ module.exports = (context) => {
fileContents.substr(location);
});

const regex = /ext.kotlin_version = '([0-9]*).([0-9]*).([0-9]*)'/gm;
const versionMatch = regex.exec(fileContents);
const version = versionMatch[0].replace("ext.kotlin_version = ", "");
const newVersion = `${VERSION_BLOCK_START + version}\n ext.kotlin_version = '${gradlePluginVersion}'\n ${VERSION_BLOCK_END}`;
fileContents = fileContents.replace(regex, newVersion);
fs.writeFileSync(file, fileContents, "utf8");
console.log("updated " + file + " to include imgly dependencies ");
}
Expand Down
10 changes: 9 additions & 1 deletion hooks/remove-dependencies-gradle-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = (context) => {

const BLOCK_START = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK END`;
const VERSION_BLOCK_START = "// VERSION CHANGED BY IMGLY - START - ";
const VERSION_BLOCK_END = "// VERSION CHANGED BY IMGLY - END -";

return new Promise((resolve, reject) => {
const platformRoot = path.join(
Expand All @@ -30,7 +32,13 @@ module.exports = (context) => {
fileContents.lastIndexOf(BLOCK_END) + BLOCK_END.length
);
fileContents = fileContents.replace(toRemove, "");



const regex = /VERSION CHANGED BY IMGLY - START - '([0-9]*).([0-9]*).([0-9]*)'/gm;
const versionMatch = regex.exec(fileContents);
const version = versionMatch[0].replace("VERSION CHANGED BY IMGLY - START - ", "");
const kotlinVersion = fileContents.substring(fileContents.indexOf(VERSION_BLOCK_START), fileContents.indexOf(VERSION_BLOCK_END) + VERSION_BLOCK_END.length);
fileContents = fileContents.replace(kotlinVersion, `ext.kotlin_version = ${version}`);
fs.writeFileSync(file, fileContents, "utf8");
console.log("remove imgly dependencies from " + file);
callback();
Expand Down
12 changes: 9 additions & 3 deletions hooks/remove-repositories-gradle-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ const async = require("async");

module.exports = (context) => {
"use strict";
const BLOCK_START = ` // REPOSITORIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = ` // REPOSITORIES ADDED BY IMGLY - BLOCK END`;
const BLOCK_START = `// REPOSITORIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = `// REPOSITORIES ADDED BY IMGLY - BLOCK END`;

return new Promise((resolve, reject) => {
const platformRoot = path.join(
context.opts.projectRoot,
"platforms/android"
);

var gradleFiles = [path.join(platformRoot, "build.gradle")];
var gradleFiles = [path.join(platformRoot, "build.gradle"), path.join(platformRoot, "repositories.gradle")];

async.each(
gradleFiles,
function (file, callback) {
// We need to check whether the file really exists,
// else it will throw an error for Cordova Android < 9.1.0
// since the `repositories.gradle` file will not be found.
if (!fs.existsSync(file)) {
return;
}
let fileContents = fs.readFileSync(file, "utf8");

let found = fileContents.indexOf(
Expand Down
85 changes: 54 additions & 31 deletions hooks/repositories-gradle-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,94 @@ const fs = require("fs");
const path = require("path");
const async = require("async");

/** This module adds the repositories for the Android SDK. */
module.exports = (context) => {
"use strict";
const BLOCK_START = ` // REPOSITORIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = ` // REPOSITORIES ADDED BY IMGLY - BLOCK END`;
/** The start indicator for the added repositories. */
const BLOCK_START = `// REPOSITORIES ADDED BY IMGLY - BLOCK START`;

const imglyRepositories =
"\n" +
BLOCK_START +
`
google()
gradlePluginPortal()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://artifactory.img.ly/artifactory/imgly" }` +
"\n" +
BLOCK_END +
"\n";
/** The end indicator for the added repositories. */
const BLOCK_END = `// REPOSITORIES ADDED BY IMGLY - BLOCK END`;

/** The maven repository. */
const mavenRepository = `maven { url "https://artifactory.img.ly/artifactory/imgly" }`;

/** The maven repository block for the allprojects buildscript for Android SDK version >= 9.0.0. */
const mavenRepositoryBlock = "\n " + BLOCK_START +
`
${mavenRepository}` + "\n " + BLOCK_END + "\n";

/** The root of the android platform. */
const platformRoot = path.join(
context.opts.projectRoot,
"platforms/android"
);

// const gradleFiles = findGradleFiles(platformRoot);
// We need to check both locations since from cordova v.10.* a dedicated `repositories.gradle` file
// is generated.
/** The repositories for the default buildscript. */
function imglyRepositories(indention) {
return "\n" + indention + BLOCK_START + "\n" + indention +
`${mavenRepository}` + "\n" + indention + BLOCK_END + "\n";
}

/**
* The files to add the repositories to.
* We need to check both locations since from Cordova Android v.9.1.* a dedicated `repositories.gradle` file is generated.
*/
const gradleFiles = [path.join(platformRoot, "build.gradle"), path.join(platformRoot, "repositories.gradle")];

return gradleFiles.forEach((file) => {
// We need to check whether the file really exists,
// else it will throw an error for Cordova < v.10.0.0.
// else it will throw an error for Cordova Android < 9.1.0
// since the `repositories.gradle` file will not be found.
if (!fs.existsSync(file)) {
return;
}

let fileContents = fs.readFileSync(file, "utf8");
let found = fileContents.indexOf(
'maven { url "https://artifactory.img.ly/artifactory/imgly" }'
mavenRepository
);

// Only add the repositories if they have not been added before.
if (found === -1) {
// The artifactory repository reference has NOT been found.
let insertLocations = [];

// The regex differs for the different gradle files.
const myRegexp = file == gradleFiles[0] ? /\brepositories\s*{(.*)$/gm : /\bext.repos\s=\s*{(.*)$/gm;
let match = myRegexp.exec(fileContents);
while (match != null) {
let matches = fileContents.matchAll(myRegexp);
for (const match of matches) {
insertLocations.push(match.index + match[0].length);
match = null; // just modify the first `repositories` tag
}

if (insertLocations.length > 0) {
insertLocations.reverse(); // process locations end -> beginning
// to preserve indices
insertLocations.forEach((location) => {
fileContents =
// We need to process the locations reversed in order
// to preserve indices.
insertLocations.reverse();

// Depending on whether we are inserting in the `buildscript` or
// in the `allprojects` section, we need to adjust the content.
const buildscript_index = insertLocations.length > 1 ? 1 : 0;
insertLocations.forEach((location, index) => {
if (index == buildscript_index) {
fileContents =
fileContents.substr(0, location) +
imglyRepositories +
imglyRepositories(file == gradleFiles[0] ? " " : " ") +
fileContents.substr(location);
} else {
fileContents =
fileContents.substr(0, location) +
mavenRepositoryBlock +
fileContents.substr(location);
}
});

fs.writeFileSync(file, fileContents, "utf8");
console.log("Updated " + file + " to include img.ly repositories.");
return;
} else {
// If we can not find an insert location we need to add a
// new `allprojects` block to add the maven repository.
fileContents = fileContents + "\n" + BLOCK_START + "\n" + `allprojects {\n repositories {\n ${mavenRepository}\n }\n}` + "\n" + BLOCK_END;
}
fs.writeFileSync(file, fileContents, "utf8");
console.log("Updated " + file + " to include img.ly repositories.");
return;
};
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cordova-plugin-videoeditorsdk",
"description": "A Cordova plugin for VideoEditor SDK. Integrate the video editor into your own HTML5, iOS or Android app - in minutes!",
"version": "2.2.0",
"version": "3.0.0",
"types": "./types/index.d.ts",
"main": "www/videoeditorsdk.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-videoeditorsdk" version="2.2.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-videoeditorsdk" version="3.0.0">
<name>VideoEditorSDK</name>
<description>A Cordova plugin for VideoEditor SDK. Integrate the video editor into your own HTML5, iOS or Android app - in minutes!</description>
<license>BSD-3-Clause</license>
Expand Down Expand Up @@ -68,7 +68,7 @@
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="VideoEditorSDK" spec="~> 10.27"/>
<pod name="VideoEditorSDK" spec="~> 10.28"/>
</pods>
</podspec>
</platform>
Expand Down
Loading

0 comments on commit 6375113

Please sign in to comment.