Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-18421
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjsamir committed Apr 5, 2019
2 parents cb61853 + ebaa40f commit 6ffb8e4
Show file tree
Hide file tree
Showing 114 changed files with 2,489 additions and 5,196 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ android/.idea/vcs.xml
/iphone/TitaniumKit/docs
/iphone/TitaniumKit/build
/iphone/lib/libTiCore.a

.vscode/
46 changes: 6 additions & 40 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def includeWindows = isMainlineBranch // Include Windows SDK if on a mainline br
// Note that the `includeWindows` flag also currently toggles whether we build for all OSes/platforms, or just iOS/Android for macOS
def runDanger = isPR // run Danger.JS if it's a PR by default. (should we also run on origin branches that aren't mainline?)
def publishToS3 = isMainlineBranch // publish zips to S3 if on mainline branch, by default
def runSecurityChecks = isMainlineBranch // run security checks if on mainline branch, by default (dependency check, RetireJS)

// Variables we can change
def nodeVersion = '8.9.1' // NOTE that changing this requires we set up the desired version on jenkins master first!
Expand Down Expand Up @@ -72,13 +71,15 @@ def unitTests(os, nodeVersion, npmVersion, testSuiteBranch) {
sh 'npm ci'
dir('scripts') {
try {
timeout(20) {
if ('ios'.equals(os)) {
if ('ios'.equals(os)) {
timeout(20) {
sh "node test.js -b ../../${zipName} -p ${os}"
} else {
}
} else {
timeout(30) {
sh "node test.js -C android-28-playstore-x86 -T emulator -b ../../${zipName} -p ${os}"
}
} // timeout
}
} catch (e) {
if ('ios'.equals(os)) {
// Gather the crash report(s)
Expand Down Expand Up @@ -177,9 +178,6 @@ timestamps {
}
// was it a failure?
if (npmTestResult != 0) {
// empty stashes of test reports, so danger step can still run.
stash allowEmpty: true, name: 'test-report-ios'
stash allowEmpty: true, name: 'test-report-android'
error readFile('npm_test.log')
}
}
Expand Down Expand Up @@ -246,38 +244,6 @@ timestamps {
stash includes: 'dist/parity.html', name: 'parity'
stash includes: 'tests/', name: 'override-tests'
} // end 'Build' stage

if (runSecurityChecks) {
stage('Security') {
timeout(25) { // sometimes the upload hangs forever...
// Clean up and install only production dependencies
if (isGreenKeeper) {
sh 'npm install --production'
} else {
sh 'npm ci --production'
}

// Scan for Dependency Check and RetireJS warnings
dependencyCheckAnalyzer datadir: '', hintsFile: '', includeCsvReports: true, includeHtmlReports: true, includeJsonReports: true, isAutoupdateDisabled: false, outdir: '', scanpath: 'package.json', skipOnScmChange: false, skipOnUpstreamChange: false, suppressionFile: '', zipExtensions: ''
dependencyCheckPublisher canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''

// Adding appc-license scan, until we can get the output from Dependency Check/Track
sh 'npx appc-license > output.csv'
archiveArtifacts 'output.csv'

sh 'npx retire --exitwith 0'
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Node Security Project Vulnerabilities'], [parserName: 'RetireJS']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])

// Don't upload to Threadfix, we do that in a nightly security scan job
// re-install dev dependencies for testing later...
if (isGreenKeeper) {
sh 'npm install'
} else {
sh(returnStatus: true, script: 'npm ci') // ignore PEERINVALID grunt issue for now
}
} // timeout
} // end 'Security' stage
} // if(runSecurityChecks)
} // nodeJs
} // end node for checkout/build

Expand Down
18 changes: 9 additions & 9 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,10 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
cli.tiapp.properties['ti.deploytype'] = { type: 'string', value: this.deployType };

// get the javac params
this.javacMaxMemory = cli.tiapp.properties['android.javac.maxmemory'] && cli.tiapp.properties['android.javac.maxmemory'].value || config.get('android.javac.maxMemory', '1024M');
this.javacMaxMemory = cli.tiapp.properties['android.javac.maxmemory'] && cli.tiapp.properties['android.javac.maxmemory'].value || config.get('android.javac.maxMemory', '3072M');
this.javacSource = cli.tiapp.properties['android.javac.source'] && cli.tiapp.properties['android.javac.source'].value || config.get('android.javac.source', '1.7');
this.javacTarget = cli.tiapp.properties['android.javac.target'] && cli.tiapp.properties['android.javac.target'].value || config.get('android.javac.target', '1.7');
this.dxMaxMemory = cli.tiapp.properties['android.dx.maxmemory'] && cli.tiapp.properties['android.dx.maxmemory'].value || config.get('android.dx.maxMemory', '1024M');
this.dxMaxMemory = cli.tiapp.properties['android.dx.maxmemory'] && cli.tiapp.properties['android.dx.maxmemory'].value || config.get('android.dx.maxMemory', '3072M');
this.dxMaxIdxNumber = cli.tiapp.properties['android.dx.maxIdxNumber'] && cli.tiapp.properties['android.dx.maxIdxNumber'].value || config.get('android.dx.maxIdxNumber', '65536');

// Transpilation details
Expand Down Expand Up @@ -2678,17 +2678,20 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
appc.async.series(this, tasks, function () {
const templateDir = path.join(this.platformPath, 'templates', 'app', 'default', 'template', 'Resources', 'android');

// if an app icon hasn't been copied, copy the default one
const srcIcon = path.join(templateDir, 'appicon.png');
const destIcon = path.join(this.buildBinAssetsResourcesDir, this.tiapp.icon);

// if an app icon hasn't been copied, copy the default one
if (!fs.existsSync(destIcon)) {
copyFile.call(this, srcIcon, destIcon);
}
delete this.lastBuildFiles[destIcon];

const destIcon2 = path.join(this.buildResDrawableDir, this.tiapp.icon);
if (!fs.existsSync(destIcon2)) {
copyFile.call(this, srcIcon, destIcon2);
// Note, we are explicitly copying destIcon here as we want to ensure that we're
// copying the user specified icon, srcIcon is the default Titanium icon
copyFile.call(this, destIcon, destIcon2);
}
delete this.lastBuildFiles[destIcon2];

Expand Down Expand Up @@ -2719,7 +2722,7 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
// copy js files into assets directory and minify if needed
this.logger.info(__('Processing JavaScript files'));
const sdkCommonFolder = path.join(this.titaniumSdkPath, 'common', 'Resources');
appc.async.series(this, Object.keys(jsFiles).map(function (id) {
appc.async.parallel(this, Object.keys(jsFiles).map(function (id) {
return function (done) {
const from = jsFiles[id];
let to = path.join(this.buildBinAssetsResourcesDir, id);
Expand Down Expand Up @@ -2808,7 +2811,6 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
}
};
}), function () {

// write the properties file
const buildAssetsPath = this.encryptJS ? this.buildAssetsDir : this.buildBinAssetsResourcesDir,
appPropsFile = path.join(buildAssetsPath, '_app_props_.json'),
Expand All @@ -2827,6 +2829,7 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
// Note: An empty array indicates the app has no bootstrap files.
const bootstrapJsonRelativePath = path.join('ti.internal', 'bootstrap.json'),
bootstrapJsonAbsolutePath = path.join(buildAssetsPath, bootstrapJsonRelativePath);
fs.ensureDirSync(path.dirname(bootstrapJsonAbsolutePath));
fs.writeFileSync(bootstrapJsonAbsolutePath, JSON.stringify({ scripts: jsBootstrapFiles }));
this.encryptJS && jsFilesToEncrypt.push(bootstrapJsonRelativePath);
delete this.lastBuildFiles[bootstrapJsonAbsolutePath];
Expand All @@ -2840,9 +2843,6 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
let titaniumPrep = 'titanium_prep';
if (process.platform === 'darwin') {
titaniumPrep += '.macos';
if (appc.version.lt(this.jdkInfo.version, '1.7.0')) {
titaniumPrep += '.jdk16';
}
} else if (process.platform === 'win32') {
titaniumPrep += '.win32.exe';
} else if (process.platform === 'linux') {
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 @@ -512,7 +512,7 @@ AndroidModuleBuilder.prototype.initialize = function initialize(next) {
this.androidMkTemplateFile = path.join(this.moduleGenTemplateDir, 'Android.mk.ejs');
this.applicationMkTemplateFile = path.join(this.moduleGenTemplateDir, 'Application.mk.ejs');
this.commonJsSourceTemplateFile = path.join(this.moduleGenTemplateDir, 'CommonJsSourceProvider.java.ejs');
this.assetCryptImplTemplateFile = path.join(this.moduleGenTemplateDir, 'AssetCryptImpl.java.ejs');
this.assetCryptImplTemplateFile = path.join(this.platformPath, 'templates', 'build', 'AssetCryptImpl.java');

this.moduleJarName = this.manifest.name + '.jar';
this.moduleJarFile = path.join(this.distDir, this.moduleJarName);
Expand Down Expand Up @@ -1454,8 +1454,6 @@ AndroidModuleBuilder.prototype.compileJS = function (next) {
});
}

fs.existsSync(this.buildGenAssetJavaFile) && fs.unlinkSync(this.buildGenAssetJavaFile);

// write the encrypted JS bytes to the generated Java file
fs.writeFileSync(
this.buildGenAssetJavaFile,
Expand All @@ -1466,7 +1464,7 @@ AndroidModuleBuilder.prototype.compileJS = function (next) {
);

fs.writeFileSync(
path.join(this.buildGenJavaDir, 'CommonJsSourceProvider.java'),
path.join(this.buildGenJavaDir, this.moduleIdSubDir, 'CommonJsSourceProvider.java'),
ejs.render(fs.readFileSync(this.commonJsSourceTemplateFile).toString(), { moduleid: this.manifest.moduleid })
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public static ArrayList<EventProxy> queryEvents(Uri uri, String query, String[]
visibility = "visibility";
}

Cursor eventCursor = contentResolver.query(uri,
new String[] { "_id", "title", "description", "eventLocation",
"dtstart", "dtend", "allDay", "hasAlarm",
"eventStatus", visibility, "hasExtendedProperties" },
query, queryArgs, orderBy);
Cursor eventCursor = contentResolver.query(
uri,
new String[] { "_id", "title", "description", "eventLocation", "dtstart", "dtend", "allDay", "hasAlarm",
"eventStatus", visibility, Events.RRULE, Events.CALENDAR_ID, "hasExtendedProperties" },
query, queryArgs, orderBy);

while (eventCursor.moveToNext()) {
EventProxy event = new EventProxy();
Expand All @@ -189,8 +189,17 @@ public static ArrayList<EventProxy> queryEvents(Uri uri, String query, String[]
event.hasAlarm = !eventCursor.getString(7).equals("0");
event.status = eventCursor.getInt(8);
event.visibility = eventCursor.getInt(9);
event.hasExtendedProperties = !eventCursor.getString(10).equals("0");

event.hasExtendedProperties = !eventCursor.getString(12).equals("0");
// Guarding against Cursor implementations which would throw an exception
// instead of returning null if no recurrence rule is added to the event
String recurrenceRule = null;
try {
recurrenceRule = eventCursor.getString(10);
} catch (Exception e) {
Log.w(TAG, "Trying to get a recurrence rule for an event without one.");
e.printStackTrace();
}
event.setRecurrenceRules(recurrenceRule, eventCursor.getInt(11));
events.add(event);
}
eventCursor.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void requestContactsPermissions(@Kroll.argument(optional = true) KrollFun
TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_CONTACTS, permissionCallback,
getKrollObject());
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
// Requesting for READ_CONTACTS will also enable WRITE_CONTACTS if the permission is set in the manifest.
currentActivity.requestPermissions(new String[] { Manifest.permission.READ_CONTACTS },
TiC.PERMISSION_CODE_CONTACTS);
currentActivity.requestPermissions(
new String[] { Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS },
TiC.PERMISSION_CODE_CONTACTS);
}

@Kroll.method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,12 @@ public String getApiName()
{
return "Ti.UI.NavigationWindow";
}

public WindowProxy getRootWindowProxy()
{
if (!windows.isEmpty()) {
return windows.get(0);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.os.Build;
import android.os.Message;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;

// clang-format off
Expand Down Expand Up @@ -65,6 +66,7 @@ public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow
private ArrayList<TabProxy> tabs = new ArrayList<TabProxy>();
private WeakReference<AppCompatActivity> tabGroupActivity;
private TabProxy selectedTab;
private String tabGroupTitle = null;
private boolean isFocused;

public TabGroupProxy()
Expand Down Expand Up @@ -348,6 +350,36 @@ public TabProxy getActiveTab()
}
}

@Kroll.getProperty
public String getTitle()
{
// If the native view is drawn get the title value from the SupportActionBar
if (view != null) {
if (getActivity() != null) {
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
return actionBar.getTitle().toString();
}
}
return null;
} else {
// If the native view is not drawn return tha latest String saved as a title
return tabGroupTitle;
}
}

@Kroll.setProperty
public void setTitle(String title)
{
// If the native view is drawn directly set the String as a title for the SupportActionBar.
if (view != null) {
((TiUIAbstractTabGroup) view).updateTitle(title);
} else {
// If the native view is not yet drawn save the value to be passed during creation.
this.tabGroupTitle = title;
}
}

private TabProxy handleGetActiveTab()
{
//selectedTab may not be set when user queries activeTab, so we return
Expand Down Expand Up @@ -411,7 +443,10 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
} else {
view = new TiUIBottomNavigationTabGroup(this, activity);
}

// If we have set a title before the creation of the native view, set it now.
if (this.tabGroupTitle != null) {
((TiUIAbstractTabGroup) view).updateTitle(this.tabGroupTitle);
}
setModelListener(view);

handlePostOpen();
Expand Down

0 comments on commit 6ffb8e4

Please sign in to comment.