Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-28185
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Oct 23, 2020
2 parents afcafd8 + b56821d commit c6af381
Show file tree
Hide file tree
Showing 55 changed files with 957 additions and 1,670 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2019 by Axway. All Rights Reserved.
* Copyright (c) 2009-2020 by Axway. All Rights Reserved.
* Licensed under the terms of the Apache Public License.
* Please see the LICENSE included with this distribution for details.
*/
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2019 by Axway. All Rights Reserved.
* Copyright (c) 2009-2020 by Axway. All Rights Reserved.
* Licensed under the terms of the Apache Public License.
* Please see the LICENSE included with this distribution for details.
*/

buildscript {
ext.kotlin_version = '1.4.0'
ext.kotlin_version = '1.4.10'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -28,7 +28,7 @@ allprojects {
// Load plugin used to enforce our Java coding style guidelines.
project.apply plugin: 'checkstyle'
checkstyle {
toolVersion = '8.34'
toolVersion = '8.36.2'
configFile file("${rootDir}/checkstyle.xml");
ignoreFailures false
showViolations true
Expand Down
64 changes: 42 additions & 22 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
'use strict';

const ADB = require('node-titanium-sdk/lib/adb'),
AdmZip = require('adm-zip'),
android = require('node-titanium-sdk/lib/android'),
androidDetect = require('../lib/detect').detect,
AndroidManifest = require('../lib/android-manifest'),
Expand Down Expand Up @@ -3069,27 +3068,48 @@ AndroidBuilder.prototype.generateRequireIndex = async function generateRequireIn
await fs.writeFile(cacheJsonFilePath, JSON.stringify(cacheAssets));
};

AndroidBuilder.prototype.getNativeModuleBindings = function getNativeModuleBindings(jarFile) {
var zip = new AdmZip(jarFile),
zipEntries = zip.getEntries(),
i = 0,
len = zipEntries.length,
pathName = 'org/appcelerator/titanium/bindings/',
pathNameLen = pathName.length,
entry, name;

for (; i < len; i++) {
entry = zipEntries[i];
name = entry.entryName.toString();
if (name.length > pathNameLen && name.indexOf(pathName) === 0) {
try {
return JSON.parse(entry.getData());
} catch (e) {
// ignore
/**
* @param {string} jarFile filepath to JAR
* @returns {Promise<Object>} parsed JSON of the module's bindings
*/
AndroidBuilder.prototype.getNativeModuleBindings = async function getNativeModuleBindings(jarFile) {
return new Promise((resolve, reject) => {
const yauzl = require('yauzl');
yauzl.open(jarFile, { lazyEntries: true }, (err, zipfile) => {
if (err) {
return reject(err);
}
return;
}
}

zipfile.once('error', reject);
zipfile.on('entry', entry => {
if (!entry.fileName.startsWith('org/appcelerator/titanium/bindings/')) {
zipfile.readEntry(); // move on
return;
}
// read the entry
zipfile.openReadStream(entry, function (err, readStream) {
if (err) {
return reject(err);
}

// read file contents and when done, parse as JSON
const chunks = [];
readStream.once('error', reject);
readStream.on('data', chunk => chunks.push(chunk));
readStream.on('end', () => {
try {
zipfile.close();
const str = Buffer.concat(chunks).toString('utf8');
return resolve(JSON.parse(str));
} catch (error) {
reject(error);
}
});
});
});
zipfile.readEntry();
});
});
};

AndroidBuilder.prototype.generateJavaFiles = async function generateJavaFiles() {
Expand Down Expand Up @@ -3136,7 +3156,7 @@ AndroidBuilder.prototype.generateJavaFiles = async function generateJavaFiles()
const jarFilePath = path.join(module.modulePath, moduleName + '.jar');
try {
if (await fs.exists(jarFilePath)) {
javaBindings = this.getNativeModuleBindings(jarFilePath);
javaBindings = await this.getNativeModuleBindings(jarFilePath);
}
} catch (ex) {
this.logger.error(__n('The module "%s" has an invalid jar file: %s', module.id, jarFilePath));
Expand Down
6 changes: 2 additions & 4 deletions android/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

'use strict';

const AdmZip = require('adm-zip'),
androidDetect = require('../lib/detect').detect,
const androidDetect = require('../lib/detect').detect,
AndroidManifest = require('../lib/android-manifest'),
appc = require('node-appc'),
archiver = require('archiver'),
Expand Down Expand Up @@ -899,8 +898,7 @@ AndroidModuleBuilder.prototype.runModule = async function (cli) {
);

// Unzip module into temp app's "modules" directory.
const zip = new AdmZip(this.moduleZipPath);
zip.extractAllTo(tmpProjectDir, true);
await util.promisify(appc.zip.unzip)(this.moduleZipPath, tmpProjectDir, null);

// Emit hook so modules can also alter project before launch
await new Promise(resolve => cli.emit('create.module.app.finalize', [ this, tmpProjectDir ], resolve));
Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
1 change: 1 addition & 0 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
2 changes: 1 addition & 1 deletion android/kroll-apt/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2019 by Axway. All Rights Reserved.
* Copyright (c) 2009-2020 by Axway. All Rights Reserved.
* Licensed under the terms of the Apache Public License.
* Please see the LICENSE included with this distribution for details.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2020 by Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -52,24 +52,32 @@ public FilesystemModule()
public FileProxy createTempFile(KrollInvocation invocation)
{
try {
File f = File.createTempFile("tifile", "tmp");
String[] parts = { f.getAbsolutePath() };
File file = File.createTempFile("tifile", ".tmp", TiApplication.getInstance().getTiTempDir());
String[] parts = { file.getAbsolutePath() };
return new FileProxy(invocation.getSourceUrl(), parts, false);
} catch (IOException e) {
Log.e(TAG, "Unable to create tmp file: " + e.getMessage(), e);
return null;
} catch (Exception ex) {
Log.e(TAG, "Unable to create tmp file: " + ex.getMessage(), ex);
}
return null;
}

@Kroll.method
public FileProxy createTempDirectory(KrollInvocation invocation)
{
String dir = String.valueOf(System.currentTimeMillis());
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
File f = new File(tmpdir, dir);
f.mkdirs();
String[] parts = { f.getAbsolutePath() };
return new FileProxy(invocation.getSourceUrl(), parts);
try {
File parentDir = TiApplication.getInstance().getTiTempDir();
String tempDirName = "tidir" + System.currentTimeMillis();
File tempDir = new File(parentDir, tempDirName);
for (int index = 0; tempDir.exists(); index++) {
tempDir = new File(parentDir, tempDirName + index);
}
tempDir.mkdirs();
String[] parts = { tempDir.getAbsolutePath() };
return new FileProxy(invocation.getSourceUrl(), parts, false);
} catch (Exception ex) {
Log.e(TAG, "Unable to create tmp directory: " + ex.getMessage(), ex);
}
return null;
}

@Kroll.method
Expand Down Expand Up @@ -186,8 +194,7 @@ public String getExternalStorageDirectory()
@Kroll.getProperty
public String getTempDirectory()
{
TiApplication tiApplication = TiApplication.getInstance();
return "file://" + tiApplication.getTempFileHelper().getTempDirectory().getAbsolutePath();
return "file://" + TiApplication.getInstance().getTiTempDir().getAbsolutePath();
}

@Kroll.method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2020 by Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -52,7 +52,6 @@
import android.util.Base64;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.util.TiTempFileHelper;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiC;
Expand Down Expand Up @@ -281,11 +280,6 @@ private TiFile createFileResponseData(boolean dumpResponseOut) throws IOExceptio
outFile = tiFile.getFile();
try {
responseOut = new FileOutputStream(outFile, dumpResponseOut);
// If the response file is in the temp folder, don't delete it during cleanup.
TiApplication app = TiApplication.getInstance();
if (app != null) {
app.getTempFileHelper().excludeFileOnCleanup(outFile);
}
} catch (FileNotFoundException e) {
responseFile = null;
tiFile = null;
Expand All @@ -299,12 +293,8 @@ private TiFile createFileResponseData(boolean dumpResponseOut) throws IOExceptio
}

if (tiFile == null) {
TiApplication app = TiApplication.getInstance();
if (app != null) {
TiTempFileHelper tempFileHelper = app.getTempFileHelper();
outFile = tempFileHelper.createTempFile("tihttp", "tmp");
tiFile = new TiFile(outFile, outFile.getAbsolutePath(), false);
}
outFile = File.createTempFile("tihttp", ".tmp", TiApplication.getInstance().getTiTempDir());
tiFile = new TiFile(outFile, outFile.getAbsolutePath(), false);
}

if (dumpResponseOut) {
Expand Down Expand Up @@ -1018,8 +1008,10 @@ private int addTitaniumFileAsPostData(String name, Object value)
blob = ((TiResourceFile) value).read();
}
String mimeType = blob.getMimeType();
File tmpFile =
File.createTempFile("tixhr", "." + TiMimeTypeHelper.getFileExtensionFromMimeType(mimeType, "txt"));
File tmpFile = File.createTempFile(
"tixhr",
"." + TiMimeTypeHelper.getFileExtensionFromMimeType(mimeType, "txt"),
TiApplication.getInstance().getTiTempDir());
createFileFromBlob(blob, tmpFile);

tmpFiles.add(tmpFile);
Expand Down Expand Up @@ -1132,8 +1124,10 @@ private Object titaniumFileAsPutData(Object value)
blob = ((TiResourceFile) value).read();
}
String mimeType = blob.getMimeType();
File tmpFile =
File.createTempFile("tixhr", "." + TiMimeTypeHelper.getFileExtensionFromMimeType(mimeType, "txt"));
File tmpFile = File.createTempFile(
"tixhr",
"." + TiMimeTypeHelper.getFileExtensionFromMimeType(mimeType, "txt"),
TiApplication.getInstance().getTiTempDir());
createFileFromBlob(blob, tmpFile);

tmpFiles.add(tmpFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,16 @@ public void updateBadge(int index)
return;
}

Object badgeValue = tabProxy.getProperty(TiC.PROPERTY_BADGE);
if ((badgeValue == null) && !TiUIHelper.isUsingMaterialTheme(this.mBottomNavigationView.getContext())) {
return;
}

int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
BadgeDrawable badgeDrawable = this.mBottomNavigationView.getOrCreateBadge(menuItemId);
if (tabProxy.getProperty(TiC.PROPERTY_BADGE) != null) {
if (badgeValue != null) {
badgeDrawable.setVisible(true);
badgeDrawable.setNumber(TiConvert.toInt(tabProxy.getProperty(TiC.PROPERTY_BADGE), 0));
badgeDrawable.setNumber(TiConvert.toInt(badgeValue, 0));
} else {
badgeDrawable.setVisible(false);
}
Expand All @@ -314,8 +319,8 @@ public void updateBadgeColor(int index)
return;
}

int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
if (tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR) != null) {
int menuItemId = this.mBottomNavigationView.getMenu().getItem(index).getItemId();
BadgeDrawable badgeDrawable = this.mBottomNavigationView.getOrCreateBadge(menuItemId);
badgeDrawable.setBackgroundColor(
TiConvert.toColor((String) tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,15 @@ public void updateBadge(int index)
return;
}

Object badgeValue = tabProxy.getProperty(TiC.PROPERTY_BADGE);
if ((badgeValue == null) && !TiUIHelper.isUsingMaterialTheme(this.mTabLayout.getContext())) {
return;
}

BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
if (tabProxy.getProperty(TiC.PROPERTY_BADGE) != null) {
if (badgeValue != null) {
badgeDrawable.setVisible(true);
badgeDrawable.setNumber(TiConvert.toInt(tabProxy.getProperty(TiC.PROPERTY_BADGE), 0));
badgeDrawable.setNumber(TiConvert.toInt(badgeValue, 0));
} else {
badgeDrawable.setVisible(false);
}
Expand All @@ -300,8 +305,8 @@ public void updateBadgeColor(int index)
return;
}

BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
if (tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR) != null) {
BadgeDrawable badgeDrawable = this.mTabLayout.getTabAt(index).getOrCreateBadge();
badgeDrawable.setVisible(true);
badgeDrawable.setBackgroundColor(
TiConvert.toColor((String) tabProxy.getProperty(TiC.PROPERTY_BADGE_COLOR)));
Expand Down
5 changes: 2 additions & 3 deletions android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
],
"architectures": ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"],
"v8": {
"version": "8.4.371.22",
"version": "8.6.395.10",
"mode": "release",
"checksum": "4fd238e9e22dda0a6d67cf132d95ac6b874cf82bec28769e25672877b3cca09ef9ef268be9482e2cc0ca20227f495e5d3ad038c83a9b90f72ad9d5e6a7bad77d",
"integrity": "sha512-YIZPTv0KMbd+TrtUDszGOBnVvpr8HnyX7cYn+s0mT/XAURC57ni1QH9hA/HCTsGciWQBeHAHX1yZjE0cR/pesw=="
"integrity": "sha512-0b+/oiaae52wbTY6svDWAGJn7wyfBfBzGHNREY5uu1VTAbG8g962SwphhB0798pM1YMLR76RO7JvKQBv6sGP9A=="
},
"minSDKVersion": "19",
"compileSDKVersion": "30",
Expand Down

0 comments on commit c6af381

Please sign in to comment.