Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27133
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Aug 29, 2019
2 parents bc78932 + fb37213 commit 46fca0c
Show file tree
Hide file tree
Showing 59 changed files with 1,444 additions and 3,181 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"rules": {
"node/no-unsupported-features/es-syntax": "off"
}
},
{
Expand Down
44 changes: 26 additions & 18 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ module.exports = function (grunt) {

// Project configuration.
grunt.initConfig({
appcJs: {
src: [
'dangerfile.js',
'Gruntfile.js',
'apidoc/**/*.js',
'build/**/*.js',
'cli/!(locales)/**/*.js',
'common/**/*.js',
'android/cli/!(locales)/**/*.js',
'android/modules/**/src/js/**/*.js',
'android/runtime/common/src/js/**/*.js',
'iphone/cli/!(locales)/**/*.js',
'tests/Resources/**/*test.js'
]
eslint: {
lintOnly: {
src: [
'dangerfile.js',
'Gruntfile.js',
'apidoc/**/*.js',
'build/**/*.js',
'cli/!(locales)/**/*.js',
'common/**/*.js',
'android/cli/!(locales)/**/*.js',
'android/modules/**/src/js/**/*.js',
'android/runtime/common/src/js/**/*.js',
'iphone/cli/!(locales)/**/*.js',
'tests/Resources/**/*test.js'
],
},
fix: {
src: '<%= eslint.lintOnly.src %>',
options: {
fix: true
}
}
},
clangFormat: {
android: { src: androidSrc },
Expand Down Expand Up @@ -126,15 +134,15 @@ module.exports = function (grunt) {
grunt.registerMultiTask('checkFormat', 'Validates the source code formatting.', validateFormatting);

// Load grunt plugins for modules
grunt.loadNpmTasks('grunt-appc-js');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-clang-format');
grunt.loadNpmTasks('grunt-contrib-clean');

// linting: run eslint against js, standard appc checks, check ios/android format via clang, run doc validation script
grunt.registerTask('lint', [ 'appcJs:src:lintOnly', 'checkFormat:ios', 'checkFormat:android', 'validate:docs' ]);
// linting: run eslint against js, check ios/android format via clang, run doc validation script
grunt.registerTask('lint', [ 'eslint:lintOnly', 'checkFormat:ios', 'checkFormat:android', 'validate:docs' ]);

// Tasks for formatting the source code according to our clang/eslint rules
grunt.registerTask('format:js', [ 'appcJs:src:lint:fix' ]);
grunt.registerTask('format:js', [ 'eslint:fix' ]);
grunt.registerTask('format:android', [ 'clangFormat:android' ]);
grunt.registerTask('format:ios', [ 'clangFormat:ios' ]);
grunt.registerTask('format', [ 'format:android', 'format:ios', 'format:js' ]);
Expand Down
19 changes: 0 additions & 19 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2087,22 +2087,6 @@ AndroidBuilder.prototype.checkIfShouldForceRebuild = function checkIfShouldForce
return true;
}

// if sourceMaps changed, then we need to re-process all of the JS files
if (this.sourceMaps !== manifest.sourceMaps) {
this.logger.info(__('Forcing rebuild: JavaScript sourceMaps flag changed'));
this.logger.info(' ' + __('Was: %s', manifest.sourceMaps));
this.logger.info(' ' + __('Now: %s', this.sourceMaps));
return true;
}

// if transpile changed, then we need to re-process all of the JS files
if (this.transpile !== manifest.transpile) {
this.logger.info(__('Forcing rebuild: JavaScript transpile flag changed'));
this.logger.info(' ' + __('Was: %s', manifest.transpile));
this.logger.info(' ' + __('Now: %s', this.transpile));
return true;
}

// check if the titanium sdk paths are different
if (this.platformPath !== manifest.platformPath) {
this.logger.info(__('Forcing rebuild: Titanium SDK path changed since last build'));
Expand Down Expand Up @@ -2305,7 +2289,6 @@ AndroidBuilder.prototype.createBuildDirs = function createBuildDirs(next) {
// make directories if they don't already exist
let dir = this.buildAssetsDir;
if (this.forceRebuild) {
fs.emptyDirSync(this.buildIncrementalDir);
fs.emptyDirSync(dir);
this.unmarkBuildDirFiles(dir);
} else {
Expand Down Expand Up @@ -4634,8 +4617,6 @@ AndroidBuilder.prototype.writeBuildManifest = function writeBuildManifest(callba
skipJSMinification: !!this.cli.argv['skip-js-minify'],
mergeCustomAndroidManifest: this.config.get('android.mergeCustomAndroidManifest', true),
encryptJS: this.encryptJS,
sourceMaps: this.sourceMaps,
transpile: this.transpile,
minSDK: this.minSDK,
targetSDK: this.targetSDK,
propertiesHash: this.propertiesHash,
Expand Down
2 changes: 1 addition & 1 deletion android/cli/hooks/aar-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class SimpleFileCache {
* @return {boolean}
*/
has(key) {
return this.data.hasOwnProperty(key);
return Object.prototype.hasOwnProperty.call(this.data, key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion android/cli/tests/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ optimist
desc: 'disables colors'
});

if (optimist.argv.hasOwnProperty('colors') && !optimist.argv.colors) {
if (Object.prototype.hasOwnProperty.call(optimist.argv, 'colors') && !optimist.argv.colors) {
Base.useColors = false;
colors.mode = 'none';
}
Expand Down
2 changes: 1 addition & 1 deletion android/modules/app/src/js/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.bootstrap = function (Titanium) {
var Properties = Titanium.App.Properties;

function nullOrDefaultValue(defaultValue) {
if (typeof(defaultValue) === 'undefined') {
if (typeof defaultValue === 'undefined') {
return null;
}
return defaultValue;
Expand Down
1 change: 0 additions & 1 deletion android/modules/network/src/js/httpclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* global kroll */
'use strict';

var PersistentHandle = require('network').PersistentHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,18 @@
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

public class TiUIProgressIndicator extends TiUIView implements Handler.Callback, DialogInterface.OnCancelListener
public class TiUIProgressIndicator
extends TiUIView implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener
{
private static final String TAG = "TiUIProgressDialog";

private static final int MSG_SHOW = 100;
private static final int MSG_PROGRESS = 101;
private static final int MSG_HIDE = 102;

public static final int INDETERMINANT = 0;
public static final int DETERMINANT = 1;

public static final int STATUS_BAR = 0;
public static final int DIALOG = 1;

protected Handler handler;

protected boolean visible;
protected ProgressDialog progressDialog;
protected CharSequence statusBarTitle;
Expand All @@ -55,32 +47,6 @@ public TiUIProgressIndicator(TiViewProxy proxy)
{
super(proxy);
Log.d(TAG, "Creating an progress indicator", Log.DEBUG_MODE);
handler = new Handler(Looper.getMainLooper(), this);
}

public boolean handleMessage(Message msg)
{
switch (msg.what) {
case MSG_SHOW: {
handleShow();
return true;
}
case MSG_PROGRESS: {
if (progressDialog != null) {
progressDialog.setProgress(msg.arg1);
} else {
Activity parent = (Activity) this.proxy.getActivity();
parent.setProgress(msg.arg1);
}
return true;
}
case MSG_HIDE: {
handleHide();
return true;
}
}

return false;
}

@Override
Expand Down Expand Up @@ -109,10 +75,15 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP

} else if (key.equals(TiC.PROPERTY_VALUE)) {
if (visible) {
int value = TiConvert.toInt(newValue);
int thePos = (value - min) * incrementFactor;

handler.obtainMessage(MSG_PROGRESS, thePos, -1).sendToTarget();
int progressValue = (TiConvert.toInt(newValue, 0) - this.min) * this.incrementFactor;
if (this.progressDialog != null) {
this.progressDialog.setProgress(progressValue);
} else {
Activity activity = (Activity) this.proxy.getActivity();
if (activity != null) {
activity.setProgress(progressValue);
}
}
}

} else if (key.equals(TiC.PROPERTY_CANCELABLE)) {
Expand Down Expand Up @@ -173,6 +144,8 @@ protected void handleShow()
type = TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_TYPE));
}

int progressValue = TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_VALUE), 0);

if (location == STATUS_BAR) {
incrementFactor = 10000 / (max - min);
Activity parent = (Activity) proxy.getActivity();
Expand All @@ -189,13 +162,25 @@ protected void handleShow()
parent.setProgressBarIndeterminate(false);
parent.setProgressBarIndeterminateVisibility(false);
parent.setProgressBarVisibility(true);
parent.setProgress((progressValue - this.min) * this.incrementFactor);
statusBarTitle = parent.getTitle();
parent.setTitle(message);
} else {
Log.w(TAG, "Unknown type: " + type);
return;
}
} else if (location == DIALOG) {
incrementFactor = 1;

// If existing dialog references a destroyed activity, then drop reference to dialog.
if (progressDialog != null) {
Activity activity = progressDialog.getOwnerActivity();
if ((activity == null) || activity.isFinishing() || activity.isDestroyed()) {
progressDialog = null;
}
}

// Create progress dialog if not done already.
if (progressDialog == null) {
Activity a = TiApplication.getInstance().getCurrentActivity();
if ((a == null) || a.isFinishing() || a.isDestroyed()) {
Expand All @@ -210,81 +195,99 @@ protected void handleShow()
progressDialog.setOwnerActivity(a);
}
progressDialog.setOnCancelListener(this);
progressDialog.setOnDismissListener(this);
}

// Set up dialog.
// Note: We must call setCanceledOnTouchOutside() before setCancelable().
progressDialog.setMessage(message);
// setCanceledOnTouchOutside() overrides the value of setCancelable(), so order of execution matters.
progressDialog.setCanceledOnTouchOutside(
proxy.getProperties().optBoolean(TiC.PROPERTY_CANCELED_ON_TOUCH_OUTSIDE, false));
progressDialog.setCancelable(proxy.getProperties().optBoolean(TiC.PROPERTY_CANCELABLE, false));

if (type == INDETERMINANT) {
progressDialog.setIndeterminate(true);
} else if (type == DETERMINANT) {
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
if (min != 0) {
progressDialog.setMax(max - min); // no min setting so shift
} else {
progressDialog.setMax(max);
}
progressDialog.setProgress(0);
progressDialog.setMax(this.max - this.min);
} else {
Log.w(TAG, "Unknown type: " + type);
}

// Show the dialog.
// Note: The setProgress() method only works after the dialog is shown.
try {
progressDialog.show();
if (type == DETERMINANT) {
progressDialog.setProgress(progressValue - this.min);
}
} catch (Exception ex) {
Log.e(TAG, "Failed to show progress indicator dialog.", ex);
return;
}
} else {
Log.w(TAG, "Unknown location: " + location);
return;
}

// Flag progress indicator as shown.
visible = true;
}

public void hide(KrollDict options)
{
if (!visible) {
return;
}
handler.sendEmptyMessage(MSG_HIDE);
handleHide();
}

protected void handleHide()
{
if (progressDialog != null) {
Activity ownerActivity = progressDialog.getOwnerActivity();
if (ownerActivity instanceof TiBaseActivity) {
((TiBaseActivity) ownerActivity).removeDialog(progressDialog);
if (!ownerActivity.isFinishing() && !ownerActivity.isDestroyed()) {
try {
progressDialog.dismiss();
} catch (Exception ex) {
Log.e(TAG, "Failed to hide ProgressIndicator dialog.", ex);
if (!this.visible) {
return;
}

if (this.location == DIALOG) {
if (this.progressDialog != null) {
Activity ownerActivity = this.progressDialog.getOwnerActivity();
if (ownerActivity instanceof TiBaseActivity) {
((TiBaseActivity) ownerActivity).removeDialog(progressDialog);
if (!ownerActivity.isFinishing() && !ownerActivity.isDestroyed()) {
try {
this.progressDialog.dismiss();
} catch (Exception ex) {
Log.e(TAG, "Failed to hide ProgressIndicator dialog.", ex);
}
}
}
this.progressDialog = null;
}
progressDialog = null;
} else {
} else if (this.location == STATUS_BAR) {
Activity parent = proxy.getActivity();
if (parent != null) {
parent.setProgressBarIndeterminate(false);
parent.setProgressBarIndeterminateVisibility(false);
parent.setProgressBarVisibility(false);
if (visible) {
parent.setTitle(statusBarTitle);
if (this.visible) {
parent.setTitle(this.statusBarTitle);
}
}
statusBarTitle = null;
this.statusBarTitle = null;
}
visible = false;

this.visible = false;
}

@Override
public void onCancel(DialogInterface dialog)
{
visible = false;
this.visible = false;
this.progressDialog = null;
fireEvent(TiC.EVENT_CANCEL, null);
}

@Override
public void onDismiss(DialogInterface dialog)
{
this.visible = false;
this.progressDialog = null;
}
}

0 comments on commit 46fca0c

Please sign in to comment.