Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-25656
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokesh Choudhary committed Jan 24, 2018
2 parents 5fa6952 + 27d5ccd commit eda7e3a
Show file tree
Hide file tree
Showing 54 changed files with 2,808 additions and 560 deletions.
9 changes: 6 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def isMainlineBranch = true // used to determine if we should publish to S3 (and
def isFirstBuildOnBranch = false // calculated by looking at S3's branches.json

// Variables we can change
def nodeVersion = '6.10.3' // NOTE that changing this requires we set up the desired version on jenkins master first!
def npmVersion = '5.4.1' // We can change this without any changes to Jenkins.
def nodeVersion = '8.9.1' // NOTE that changing this requires we set up the desired version on jenkins master first!
def npmVersion = '5.6.0' // We can change this without any changes to Jenkins.

def unitTests(os, nodeVersion, testSuiteBranch) {
return {
Expand Down Expand Up @@ -432,8 +432,11 @@ timestamps {
stage('Danger') {
node('osx || linux') {
nodejs(nodeJSInstallationName: "node ${nodeVersion}") {
unarchive mapping: ['mocha_*.crash': '.'] // unarchive any iOS simulator crashes
unstash 'danger' // this gives us dangerfile.js, package.json, package-lock.json, node_modules/, android java sources for format check
// ok to not grab crash logs, still run Danger.JS
try {
unarchive mapping: ['mocha_*.crash': '.'] // unarchive any iOS simulator crashes
} catch (e) {}
// ok to not grab test results, still run Danger.JS
try {
unstash 'test-report-ios' // junit.ios.report.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,14 @@ public void abort()
{
if (readyState > READY_STATE_UNSENT && readyState < READY_STATE_DONE) {
aborted = true;
if (client != null) {
client.disconnect();
client = null;

try {
if (client != null) {
client.disconnect();
}
} catch (Exception ex) {
}

// Fire the disposehandle event if the request is aborted.
// And it will dispose the handle of the httpclient in the JS.
proxy.fireEvent(TiC.EVENT_DISPOSE_HANDLE, null);
Expand Down Expand Up @@ -1306,7 +1310,10 @@ public void progress(int progress)
} catch (Throwable t) {
if (client != null) {
Log.d(TAG, "clearing the expired and idle connections", Log.DEBUG_MODE);
client.disconnect();
try {
client.disconnect();
} catch (Exception ex) {
}
} else {
Log.d(TAG, "client is not valid, unable to clear expired and idle connections");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
// clang-format off
@Kroll.proxy(creatableInModule = UIModule.class,
propertyAccessors = {
TiC.PROPERTY_CAN_SCROLL,
TiC.PROPERTY_HEADER_TITLE,
TiC.PROPERTY_FOOTER_TITLE,
TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE,
Expand Down Expand Up @@ -498,24 +499,6 @@ public void setSections(Object sections)
}
}

// clang-format off
@Kroll.method
@Kroll.setProperty
public void setCanScroll(boolean canScroll)
// clang-format on
{
setProperty(TiC.PROPERTY_CAN_SCROLL, canScroll);
}

// clang-format off
@Kroll.method
@Kroll.getProperty
public boolean getCanScroll()
// clang-format on
{
return (Boolean) getProperty(TiC.PROPERTY_CAN_SCROLL);
}

private ListSectionProxy[] handleSections()
{
if (peekView() == null && getParent() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand Down Expand Up @@ -100,25 +101,24 @@ protected void startDownload(URI uri, TiDownloadListener listener)

protected void handleFireDownloadMessage(URI uri, int what)
{
ArrayList<SoftReference<TiDownloadListener>> toRemove = new ArrayList<SoftReference<TiDownloadListener>>();
String hash = DigestUtils.shaHex(uri.toString());
ArrayList<SoftReference<TiDownloadListener>> listenerList;
synchronized (listeners)
{
String hash = DigestUtils.shaHex(uri.toString());
ArrayList<SoftReference<TiDownloadListener>> listenerList = listeners.get(hash);
for (SoftReference<TiDownloadListener> listener : listenerList) {
TiDownloadListener downloadListener = listener.get();
listenerList = listeners.get(hash);
}
if (listenerList != null) {
for (Iterator<SoftReference<TiDownloadListener>> i = listenerList.iterator(); i.hasNext();) {
TiDownloadListener downloadListener = i.next().get();
if (downloadListener != null) {
if (what == MSG_FIRE_DOWNLOAD_FINISHED) {
downloadListener.downloadTaskFinished(uri);
} else {
downloadListener.downloadTaskFailed(uri);
}
toRemove.add(listener);
i.remove();
}
}
for (SoftReference<TiDownloadListener> listener : toRemove) {
listenerList.remove(listener);
}
}
}

Expand Down Expand Up @@ -152,9 +152,12 @@ public void run()
{
listenerList = listeners.get(hash);
}
for (SoftReference<TiDownloadListener> listener : listenerList) {
if (listener.get() != null) {
listener.get().postDownload(uri);
if (listenerList != null) {
for (Iterator<SoftReference<TiDownloadListener>> i = listenerList.iterator(); i.hasNext();) {
TiDownloadListener downloadListener = i.next().get();
if (downloadListener != null) {
downloadListener.postDownload(uri);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public TiBorderWrapperView(Context context)

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
bounds = new Rect();

// TIMOB-25661: disable hardware acceleration to prevent broken
// animation behaviour on Android 7.0 and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ methods:
- name: thumbnailImageAtTime
deprecated:
since: '3.4.2'
notes: Use <Titanium.Media.VideoPlayer.mediaControlStyle> instead.
notes: Use <Titanium.Media.VideoPlayer.requestThumbnailImagesAtTimes> instead.
removed: '3.6.0'
summary: Returns a thumbnail image for the video at the specified time.
platforms: [iphone, ipad]
Expand Down
59 changes: 58 additions & 1 deletion apidoc/Titanium/UI/iOS/DocumentViewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,59 @@ description: |
using either a document from the `Resources` directory (classic Titanium) or `app/assets` (Alloy).
Alternatively, documents can also be stored in the <Titanium.Filesystem.applicationCacheDirectory>
or <Titanium.Filesystem.applicationDataDirectory>.
**Note for iOS 11.2 and later**
Apple introduced a regression in iOS 11.2 that forces **all** files to be in the application data
directory or temporary directory. We handle this workaround for you in Titanium SDK 7.0.2+, but you
can also work around it without an SDK update. Here is an example:
var fileName = 'example.pdf';
// For iOS 11.2, workaround the Apple issue by creating a temporary file and
// reference it. It will be removed from filesystem once the app closes.
// Read more here: http://nshipster.com/nstemporarydirectory/
if (isiOS11_2()) {
fileName = fileInTemporaryDirectory(fileName);
}
var docViewer = Ti.UI.iOS.createDocumentViewer({
url: fileName
});
docViewer.show();
// Check if the current device runs iOS 11.2+
function isiOS11_2() {
var version = Ti.Platform.version.split(".");
return (parseInt(version[0]) >= 11 && parseInt(version[1]) >= 2);
}
// Create a temporary file with the contents of the old file
// Expects the file to be in the resources directory. If you receive the file
// from an API-call, receive pass the Ti.Blob/Ti.File/text to "write" directly.
function fileInTemporaryDirectory(fileName) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, fileName);
if (!file.exists()) {
alert('File does not exist in resources!');
return;
}
var newFile = Titanium.Filesystem.getFile(Ti.Filesystem.tempDirectory, fileName);
newFile.createFile();
if (!newFile.exists()) {
alert('New file could not be created in temporary directory!');
return;
}
newFile.write(file);
return newFile.nativePath;
}
Read more about the issue in [TIMOB-25680](https://jira.appcelerator.org/browse/TIMOB-25680).
extends: Titanium.UI.View
platforms: [iphone,ipad]
since: "2.1.1"
Expand All @@ -50,6 +103,11 @@ properties:

- name: url
summary: URL of the document being previewed.
description: |
Important note: For iOS 11.2 and later, you need to reference this URL
from either the application data directory or temporary directory. Read
more about this change in the "Note for iOS 11.2 and later" paragraph of
the API summary.
type: String

methods:
Expand Down Expand Up @@ -137,4 +195,3 @@ properties:
If this property is not specified, the `show` method launches the document in the viewer
without showing the options menu.
type: Titanium.UI.View

5 changes: 3 additions & 2 deletions build/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const exec = require('child_process').exec, // eslint-disable-line security/dete
ROOT_DIR = path.join(__dirname, '..'),
IOS_ROOT = path.join(ROOT_DIR, 'iphone'),
IOS_LIB = path.join(IOS_ROOT, 'lib'),
TI_CORE_VERSION = 24;
TI_CORE_VERSION = 24,
TI_CORE_INTEGRITY = 'sha512-iTyrzaMs6SfPlyEgO70pg8EW08mn211tjpAI5hAmRHQaZGu1ieuBnT8uEkEYcsO8hdzAFbouqPPEaXWcJH5SLA==';

function gunzip(gzFile, destFile, next) {
console.log('Gunzipping ' + gzFile + ' to ' + destFile);
Expand Down Expand Up @@ -55,7 +56,7 @@ IOS.prototype.fetchLibTiCore = function (next) {
console.log('You don\'t seem to have the appropriate thirdparty files. I\'ll fetch them.');
console.log('This could take awhile.. Might want to grab a cup of Joe or make fun of Nolan.');

downloadURL(url, function (err, file) {
downloadURL(url, TI_CORE_INTEGRITY, function (err, file) {
if (err) {
return next(err);
}
Expand Down
38 changes: 21 additions & 17 deletions build/packager.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

const path = require('path'),
os = require('os'),
exec = require('child_process').exec, // eslint-disable-line security/detect-child-process
spawn = require('child_process').spawn, // eslint-disable-line security/detect-child-process
async = require('async'),
fs = require('fs-extra'),
utils = require('./utils'),
copyFile = utils.copyFile,
copyFiles = utils.copyFiles,
downloadURL = utils.downloadURL,
ROOT_DIR = path.join(__dirname, '..'),
SUPPORT_DIR = path.join(ROOT_DIR, 'support');
const path = require('path');
const os = require('os');
const exec = require('child_process').exec; // eslint-disable-line security/detect-child-process
const spawn = require('child_process').spawn; // eslint-disable-line security/detect-child-process
const async = require('async');
const fs = require('fs-extra');
const utils = require('./utils');
const copyFile = utils.copyFile;
const copyFiles = utils.copyFiles;
const downloadURL = utils.downloadURL;
const ROOT_DIR = path.join(__dirname, '..');
const SUPPORT_DIR = path.join(ROOT_DIR, 'support');

/**
* Given a folder we'd like to zip up and the destination filename, this will zip up the directory contents.
Expand Down Expand Up @@ -189,21 +189,25 @@ Packager.prototype.includePackagedModules = function (next) {
// that will download the all-in-one distribution.
supportedPlatforms = supportedPlatforms.concat([ 'hyperloop' ]);

let urls = []; // urls of module zips to grab
let modules = []; // module objects holding url/integrity
// Read modules.json, grab the object for each supportedPlatform
const contents = fs.readFileSync(path.join(SUPPORT_DIR, 'module', 'packaged', 'modules.json')).toString(),
modulesJSON = JSON.parse(contents);
for (let x = 0; x < supportedPlatforms.length; x++) {
const newModuleURLS = modulesJSON[supportedPlatforms[x]];
urls = urls.concat(newModuleURLS || []);
const modulesForPlatform = modulesJSON[supportedPlatforms[x]];
if (modulesForPlatform) {
modules = modules.concat(Object.values(modulesForPlatform));
}
}
// remove duplicates
modules = Array.from(new Set(modules));

// Fetch the listed modules from URLs...
const outDir = this.zipDir,
zipFiles = [];
async.each(urls, function (url, cb) {
async.each(modules, function (moduleObject, cb) {
// FIXME Don't show progress bars, because they clobber each other
downloadURL(url, function (err, file) {
downloadURL(moduleObject.url, moduleObject.integrity, function (err, file) {
if (err) {
return cb(err);
}
Expand Down
40 changes: 40 additions & 0 deletions build/scons-modules-integrity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node
'use strict';

const async = require('async'),
utils = require('./utils'),
modules = require('../support/module/packaged/modules.json');

const platforms = Object.keys(modules);
async.map(platforms, (platform, platformNext) => {
const platformModuleNames = Object.keys(modules[platform]);
async.map(platformModuleNames, (modName, modNext) => {
const modObj = modules[platform][modName];
utils.generateSSRIHashFromURL(modObj.url, function (e, hash) {
if (e) {
return modNext(e);
}
const obj = {};
modObj.integrity = hash;
obj[modName] = modObj;
modNext(null, obj);
});
}, (e, mods) => {
if (e) {
return platformNext(e);
}
// Merge the modules array into a single object
const merged = Object.assign({}, ...mods);
const platformObj = {};
platformObj[platform] = merged;
return platformNext(null, platformObj);
});
}, (e, results) => {
if (e) {
console.error(e);
process.exit(1);
}
// Merge the platforms array into a single object
const merged = Object.assign({}, ...results);
console.log(JSON.stringify(merged));
});
33 changes: 33 additions & 0 deletions build/scons-ssri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env node
'use strict';

const async = require('async'),
program = require('commander'),
utils = require('./utils');

program.parse(process.argv);

let urls = program.args;
if (urls.length <= 0) {
console.log('Please provide one or more URLs as arguments to this command to generate SSRI "integrity" values for.');
process.exit(1);
}
console.log(urls);
async.each(urls, function (url, next) {
utils.generateSSRIHashFromURL(url, function (e, hash) {
if (e) {
return next(e);
}
const obj = {
url: url,
integrity: hash
};
console.log(JSON.stringify(obj));
return next(null, hash);
});
}, function (err) {
if (err) {
process.exit(1);
}
process.exit(0);
});

0 comments on commit eda7e3a

Please sign in to comment.