Skip to content

Commit

Permalink
chore(android)(9_3_X): compile with API Level 30 (#11850)
Browse files Browse the repository at this point in the history
* chore(android): compile with API Level 30

- Compiles against Android 11, but not targeting it yet until all breaking-changes have been resolved.

Fixes TIMOB-28046

* fix: unit test 'activity callback' for Android 10

Co-authored-by: Gary Mathews <contact@garymathews.com>
  • Loading branch information
jquick-axway and garymathews committed Aug 8, 2020
1 parent 90f61d1 commit bb3cb87
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply plugin: 'com.android.application'

// Set up Android app project.
android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId 'com.titanium.test'
minSdkVersion 19
Expand Down
6 changes: 3 additions & 3 deletions android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"integrity": "sha512-T9I46eIt2gptZ88TLZWsa4dM+CvsKHaeJWcod7PMoJ757yaL6UguLMDKICJ/SV5dOtA4yDqbkPcq2dXmp7rXfQ=="
},
"minSDKVersion": "19",
"compileSDKVersion": "29",
"compileSDKVersion": "30",
"vendorDependencies": {
"android sdk": ">=23.x <=29.x",
"android build tools": ">=29.0.2 <=29.x",
"android platform tools": "29.x",
"android build tools": ">=29.0.2 <=30.x",
"android platform tools": "30.x",
"android tools": "<=26.x",
"android ndk": ">=r11c <=r21d",
"java": ">=1.8.x"
Expand Down
4 changes: 2 additions & 2 deletions android/titanium/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ try {
}

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionName tiBuildVersionString
versionCode tiBuildVersionCode
buildConfigField('String', 'TI_BUILD_HASH_STRING', '"' + tiBuildHashString + '"')
Expand Down
49 changes: 23 additions & 26 deletions tests/Resources/ti.android.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');
const should = require('./utilities/assertions');

describe.android('Titanium.Android', function () {
it('currentActivity', function () {
describe.android('Titanium.Android', () => {
it('currentActivity', () => {
should(Ti.Android.currentActivity).not.be.undefined();
should(Ti.Android.currentActivity).be.a.Object();
});

it('rootActivity', function () {
it('rootActivity', () => {
should(Ti.Android.rootActivity).not.be.undefined();
should(Ti.Android.rootActivity).be.a.Object();
should(Ti.Android.rootActivity.intent).not.be.undefined();
Expand Down Expand Up @@ -63,6 +63,7 @@ describe.android('Titanium.Android', function () {
});

it('activity callbacks', function (finish) {
let childWindow = null;
let wasOnCreateCalled = false;
let wasOnRestartCalled = false;
let wasOnStartCalled = false;
Expand All @@ -74,52 +75,48 @@ describe.android('Titanium.Android', function () {
this.timeout(5000);

const win = Ti.UI.createWindow();
win.activity.onCreate = function () {
win.activity.onCreate = () => {
wasOnCreateCalled = true;
win.activity.onCreate = null;
};
win.activity.onRestart = function () {
win.activity.onRestart = () => {
wasOnRestartCalled = true;
win.activity.onRestart = null;
setTimeout(function () {
// Now that app was resumed from background, test destroy behavior.
setTimeout(() => {
// Now that we've returned to this activity, test destroy behavior.
win.close();
}, 50);
};
win.activity.onStart = function () {
win.activity.onStart = () => {
wasOnStartCalled = true;
win.activity.onStart = null;
};
win.activity.onResume = function () {
win.activity.onResume = () => {
wasOnResumeCalled = true;
win.activity.onResume = null;
};
win.activity.onPause = function () {
win.activity.onPause = () => {
wasOnPauseCalled = true;
win.activity.onPause = null;
};
win.activity.onStop = function () {
win.activity.onStop = () => {
wasOnStopCalled = true;
win.activity.onStop = null;
setTimeout(function () {
// App was put into the background. Next, resume it to trigger onRestart() callback.
Ti.Android.currentActivity.startActivity(Ti.App.Android.launchIntent);
}, 50);
if (childWindow) {
// Close child activity to invoke parent's onRestart() callback.
childWindow.close();
}
};
win.activity.onDestroy = function () {
win.activity.onDestroy = () => {
wasOnDestroyCalled = true;
win.activity.onDestroy = null;
};
win.addEventListener('open', function () {
// Navigate to the device's home screen. Equivalent to pressing the "home" button.
const homeIntent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
});
homeIntent.addCategory(Ti.Android.CATEGORY_HOME);
homeIntent.flags = Ti.Android.FLAG_ACTIVITY_NEW_TASK;
Ti.Android.currentActivity.startActivity(homeIntent);
win.addEventListener('open', () => {
// Open child activity to invoke parent's onPause() and onStop() callbacks.
childWindow = Ti.UI.createWindow();
childWindow.open();
});
win.addEventListener('close', function () {
win.addEventListener('close', () => {
try {
should(wasOnCreateCalled).be.true();
should(wasOnRestartCalled).be.true();
Expand Down

0 comments on commit bb3cb87

Please sign in to comment.