diff --git a/android/app/build.gradle b/android/app/build.gradle index 4f3dc115ddb..95068caded0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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 diff --git a/android/package.json b/android/package.json index fe9bc0b8e88..ce5aebe36a8 100644 --- a/android/package.json +++ b/android/package.json @@ -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" diff --git a/android/titanium/build.gradle b/android/titanium/build.gradle index f6cbf9cfec3..d5dd28720da 100644 --- a/android/titanium/build.gradle +++ b/android/titanium/build.gradle @@ -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 + '"') diff --git a/tests/Resources/ti.android.test.js b/tests/Resources/ti.android.test.js index 23f02cd3a0e..62ca3fb4ec5 100644 --- a/tests/Resources/ti.android.test.js +++ b/tests/Resources/ti.android.test.js @@ -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(); @@ -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; @@ -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();