Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27807
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews authored Dec 10, 2020
2 parents 5198450 + 4dd2a82 commit 387904e
Show file tree
Hide file tree
Showing 109 changed files with 7,562 additions and 5,373 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ coverage/

tests/diffs/
tests/generated/
# in-memory blobs written to disk as the expected image for image compariosn tests
tests/Resources/ios/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].png
tests/Resources/android/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].png
# in-memory blobs written to disk as the expected image for image comparison tests
tests/Resources/ios/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_*.png
tests/Resources/android/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_*.png
20 changes: 11 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ def isMainlineBranch = (env.BRANCH_NAME ==~ MAINLINE_BRANCH_REGEXP)
def buildProperties = [buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '3'))]
// For mainline branches, notify Teams channel of failures/success/not built/etc
if (isMainlineBranch) {
buildProperties << office365ConnectorWebhooks([[
notifyBackToNormal: true,
notifyFailure: true,
notifyNotBuilt: true,
notifyUnstable: true,
notifySuccess: true,
notifyRepeatedFailure: true,
url: 'https://outlook.office.com/webhook/ba1960f7-fcca-4b2c-a5f3-095ff9c87b22@300f59df-78e6-436f-9b27-b64973e34f7d/JenkinsCI/95439e5a0bef45539af8023b563dd345/72931ee3-e99d-4daf-84d2-1427168af2d9'
]])
withCredentials([string(credentialsId: 'titanium_mobile_ms_teams_webhook', variable: 'WEBHOOK_URL')]) {
buildProperties << office365ConnectorWebhooks([[
notifyBackToNormal: true,
notifyFailure: true,
notifyNotBuilt: true,
notifyUnstable: true,
notifySuccess: true,
notifyRepeatedFailure: true,
url: "${WEBHOOK_URL}"
]])
}
}
properties(buildProperties)

Expand Down
14 changes: 7 additions & 7 deletions android/app/src/main/assets/Resources/app.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
Titanium.UI.backgroundColor = '#000';

// create tab group
var tabGroup = Titanium.UI.createTabGroup();
const tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
const win1 = Titanium.UI.createWindow({
title: 'Tab 1',
backgroundColor: '#fff'
});
var tab1 = Titanium.UI.createTab({
const tab1 = Titanium.UI.createTab({
icon: 'KS_nav_views.png',
title: 'Tab 1',
window: win1
});

var label1 = Titanium.UI.createLabel({
const label1 = Titanium.UI.createLabel({
color: '#999',
text: 'I am Window 1',
font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
Expand All @@ -32,11 +32,11 @@ win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
const win2 = Titanium.UI.createWindow({
title: 'Tab 2',
backgroundColor: '#fff'
});
var tab2 = Titanium.UI.createTab({
const tab2 = Titanium.UI.createTab({
icon: 'KS_nav_ui.png',
title: 'Tab 2',
window: win2
Expand Down
2 changes: 1 addition & 1 deletion android/kroll-apt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ jar {

dependencies {
implementation 'com.googlecode.json-simple:json-simple:1.1'
implementation 'org.freemarker:freemarker:2.3.14'
implementation 'org.freemarker:freemarker:2.3.30'
implementation 'log4j:log4j:1.2.17'
}
Binary file removed android/kroll-apt/lib/freemarker.jar
Binary file not shown.
Binary file removed android/kroll-apt/lib/json_simple-1.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ namespace ${ns?lower_case} {
</#function>

<#assign typeInfo = {
"org.appcelerator.kroll.KrollPromise":{
"jsType":"Object",
"jsConvertType":"Value",
"jsToJavaConverter":"jsObjectToJavaPromise",
"javaToJsConverter":"javaObjectToJsPromise",
"jvalue":"l",
"javaCallMethodType":"Object",
"javaReturnType":"jobject",
"javaValidation":true,
"typeValidation":false,
"defaultValue": "null"
},
"org.appcelerator.kroll.KrollProxy":{
"jsType":"Object",
"jsConvertType":"Value",
Expand Down Expand Up @@ -436,6 +448,10 @@ namespace ${ns?lower_case} {
<#return typeInfo[type]>
</#if>

<#if type?starts_with("org.appcelerator.kroll.KrollPromise")>
<#return typeInfo["org.appcelerator.kroll.KrollPromise"]>
</#if>

<#if type?ends_with("Proxy")>
<#return typeInfo["org.appcelerator.kroll.KrollProxy"]>
</#if>
Expand All @@ -458,6 +474,10 @@ namespace ${ns?lower_case} {
<#-- Look up the type's signature. If it does not exist, this
type is a Java object. Object signatures take a special format
which has the full class name in it (ex: Ljava.lang.Object;) -->
<#if type?starts_with("org.appcelerator.kroll.KrollPromise")>
<#local type = "org.appcelerator.kroll.KrollPromise">
</#if>
<#-- FIXME: We should ideally have a general case check for removing generic type erasures from signatures here -->
<#if typeInfo?keys?seq_contains(type) && typeInfo[type]?keys?seq_contains("signature")>
<#return typeInfo[type].signature>
<#else>
Expand Down Expand Up @@ -643,7 +663,6 @@ fails, a JS exception is returned.
</#if>

<@Proxy.listMethodArguments args=args ; index, info, type, isOptional>

<#if type != "org.appcelerator.kroll.KrollInvocation">
<#if index = varArgsIndex>
<@Proxy.convertToVarArgs args=args start=index/>
Expand Down Expand Up @@ -697,11 +716,10 @@ beprovided to handle the result.
<#if hasResult>
${resultExpr}env->${callExpr}(${argExpr});

<#local jsType = info.jsType>
<#if info?keys?seq_contains("jsConvertType")>
<#local jsType = info.jsConvertType>
</#if>

<#local jsType = info.jsType>
<#if info?keys?seq_contains("jsConvertType")>
<#local jsType = info.jsConvertType>
</#if>
<#else>
env->${callExpr}(${argExpr});
</#if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollObject;
import org.appcelerator.kroll.KrollPromise;
import org.appcelerator.kroll.KrollRuntime;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
Expand Down Expand Up @@ -684,40 +686,48 @@ public boolean hasPermission(Object permissionObject)
}

@Kroll.method
public void requestPermissions(Object permissionObject,
@Kroll.argument(optional = true) KrollFunction permissionCallback)
public KrollPromise<KrollDict> requestPermissions(final Object permissionObject,
@Kroll.argument(optional = true) final KrollFunction permissionCallback)
{
if (Build.VERSION.SDK_INT >= 23) {
ArrayList<String> permissions = new ArrayList<String>();
if (permissionObject instanceof String) {
permissions.add((String) permissionObject);
} else if (permissionObject instanceof Object[]) {
for (Object permission : (Object[]) permissionObject) {
if (permission instanceof String) {
permissions.add((String) permission);
// TODO: Create a subclass of Promise that takes in KrollFunction callback and "this" KrollObject
// to fire the callback when we resolve/reject?
final KrollObject callbackThisObject = getKrollObject();
return KrollPromise.create((promise) -> {
if (Build.VERSION.SDK_INT >= 23) {
List<String> permissions = new ArrayList<String>();
if (permissionObject instanceof String) {
permissions.add((String) permissionObject);
} else if (permissionObject instanceof Object[]) {
for (Object permission : (Object[]) permissionObject) {
if (permission instanceof String) {
permissions.add((String) permission);
}
}
}
}
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
ArrayList<String> filteredPermissions = new ArrayList<String>();
for (String permission : permissions) {
if (currentActivity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
continue;
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
List<String> filteredPermissions = new ArrayList<String>();
for (String permission : permissions) {
if (currentActivity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
continue;
}
filteredPermissions.add(permission);
}
if (filteredPermissions.size() > 0) {
TiBaseActivity.registerPermissionRequestCallback(REQUEST_CODE, permissionCallback,
callbackThisObject, promise);
currentActivity.requestPermissions(filteredPermissions.toArray(
new String[filteredPermissions.size()]), REQUEST_CODE);
return;
}
filteredPermissions.add(permission);
}
if (filteredPermissions.size() > 0) {
TiBaseActivity.registerPermissionRequestCallback(REQUEST_CODE, permissionCallback, getKrollObject());
currentActivity.requestPermissions(filteredPermissions.toArray(new String[filteredPermissions.size()]),
REQUEST_CODE);
return;
// FIXME: If we're not on API level 23+, shouldn't we reject/error?
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
if (permissionCallback != null) {
permissionCallback.callAsync(callbackThisObject, response);
}
}
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
if (permissionCallback != null) {
permissionCallback.callAsync(getKrollObject(), response);
}
promise.resolve(response);
});
}

@Kroll.method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollObject;
import org.appcelerator.kroll.KrollPromise;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBaseActivity;
Expand Down Expand Up @@ -126,21 +128,26 @@ public boolean hasCalendarPermissions()
}

@Kroll.method
public void requestCalendarPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
public KrollPromise<KrollDict> requestCalendarPermissions(
@Kroll.argument(optional = true) final KrollFunction permissionCallback)
{
if (hasCalendarPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}

TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_CALENDAR, permissionCallback,
getKrollObject());
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
currentActivity.requestPermissions(
new String[] { Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR },
TiC.PERMISSION_CODE_CALENDAR);
final KrollObject callbackThisObject = getKrollObject();
return KrollPromise.create((promise) -> {
if (hasCalendarPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(callbackThisObject, response);
promise.resolve(response);
return;
}

TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_CALENDAR, permissionCallback,
callbackThisObject, promise);
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
currentActivity.requestPermissions(
new String[] { Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR },
TiC.PERMISSION_CODE_CALENDAR);
});
}

@Kroll.method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollObject;
import org.appcelerator.kroll.KrollPromise;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
Expand Down Expand Up @@ -76,21 +78,26 @@ public boolean hasContactsPermissions()
}

@Kroll.method
public void requestContactsPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
public KrollPromise<KrollDict> requestContactsPermissions(
@Kroll.argument(optional = true) final KrollFunction permissionCallback)
{
if (hasContactsPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}
final KrollObject callbackThisObject = getKrollObject();
return KrollPromise.create((promise) -> {
if (hasContactsPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(callbackThisObject, response);
promise.resolve(response);
return;
}

TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_CONTACTS, permissionCallback,
getKrollObject());
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
currentActivity.requestPermissions(
new String[] { Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS },
TiC.PERMISSION_CODE_CONTACTS);
TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_CONTACTS, permissionCallback,
callbackThisObject, promise);
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
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 @@ -18,6 +18,8 @@
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollInvocation;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollObject;
import org.appcelerator.kroll.KrollPromise;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.io.TiFileFactory;
Expand Down Expand Up @@ -113,23 +115,28 @@ private boolean hasStoragePermissions()
}

@Kroll.method
public void requestStoragePermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
public KrollPromise<KrollDict> requestStoragePermissions(
@Kroll.argument(optional = true) final KrollFunction permissionCallback)
{
if (hasStoragePermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}
final KrollObject callbackThisObject = getKrollObject();
return KrollPromise.create((promise) -> {
if (hasStoragePermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(callbackThisObject, response);
promise.resolve(response);
return;
}

String[] permissions = new String[] {
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
};
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_EXTERNAL_STORAGE, permissionCallback,
getKrollObject());
currentActivity.requestPermissions(permissions, TiC.PERMISSION_CODE_EXTERNAL_STORAGE);
String[] permissions = new String[] {
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
};
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_EXTERNAL_STORAGE,
permissionCallback, callbackThisObject, promise);
currentActivity.requestPermissions(permissions, TiC.PERMISSION_CODE_EXTERNAL_STORAGE);
});
}

@Kroll.method
Expand Down
Loading

0 comments on commit 387904e

Please sign in to comment.