Skip to content

Commit

Permalink
Merge branch '9_3_X' into TIMOB-28105-9_3_X
Browse files Browse the repository at this point in the history
  • Loading branch information
ssekhri committed Oct 14, 2020
2 parents b13fdca + 2513549 commit 79f5111
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 31 deletions.
46 changes: 30 additions & 16 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3291,35 +3291,49 @@ AndroidBuilder.prototype.generateI18N = async function generateI18N() {
return locale;
}

for (const locale of Object.keys(data)) {
const localeSuffixName = (locale === 'en' ? '' : '-' + resolveRegionName(locale));
const dirPath = path.join(this.buildAppMainResDir, `values${localeSuffixName}`);
const filePath = path.join(dirPath, 'ti_i18n_strings.xml');
// Traverse all loaded i18n locales and write them to XML files under the Android "res" folder.
for (const locale in data) {
// Create a localized strings dictionary if no i18n "strings.xml" file was found.
const localeData = data[locale];
if (!localeData.strings) {
localeData.strings = {};
}

// Add localized app name to strings dictionary under the "app_name" key:
// 1) If not already defined in i18n "strings.xml" file. (This is undocumented, but some devs do this.)
// 2) If defined in i18n "app.xml". (The preferred cross-platform way to localize it.)
// 3) Default to "tiapp.xml" file's <name/> if not defined under i18n. (Not localized.)
let appName = localeData.strings.app_name;
if (!appName) {
appName = localeData.app && localeData.app.appname;
if (!appName) {
appName = this.tiapp.name;
}
localeData.strings.app_name = appName;
}

// Create the XML content for all localized strings.
const dom = new DOMParser().parseFromString('<resources/>', 'text/xml');
const root = dom.documentElement;
const appname = data[locale].app && data[locale].app.appname || this.tiapp.name;
const appnameNode = dom.createElement('string');

appnameNode.setAttribute('name', 'app_name');
appnameNode.setAttribute('formatted', 'false');
appnameNode.appendChild(dom.createTextNode(appname));
root.appendChild(dom.createTextNode('\n\t'));
root.appendChild(appnameNode);
data[locale].strings && Object.keys(data[locale].strings).forEach(function (name) {
for (const name in localeData.strings) {
if (name.indexOf(' ') !== -1) {
badStringNames[locale] || (badStringNames[locale] = []);
badStringNames[locale].push(name);
} else if (name !== 'appname') {
} else {
const node = dom.createElement('string');
node.setAttribute('name', name);
node.setAttribute('formatted', 'false');
node.appendChild(dom.createTextNode(data[locale].strings[name].replace(/\\?'/g, '\\\'').replace(/^\s+/g, replaceSpaces).replace(/\s+$/g, replaceSpaces)));
node.appendChild(dom.createTextNode(localeData.strings[name].replace(/\\?'/g, '\\\'').replace(/^\s+/g, replaceSpaces).replace(/\s+$/g, replaceSpaces)));
root.appendChild(dom.createTextNode('\n\t'));
root.appendChild(node);
}
});
}
root.appendChild(dom.createTextNode('\n'));

// Create the XML file under the Android "res/values-<locale>" folder.
const localeSuffixName = (locale === 'en' ? '' : '-' + resolveRegionName(locale));
const dirPath = path.join(this.buildAppMainResDir, `values${localeSuffixName}`);
const filePath = path.join(dirPath, 'ti_i18n_strings.xml');
this.logger.debug(__('Writing %s strings => %s', locale.cyan, filePath.cyan));
await fs.ensureDir(dirPath);
await fs.writeFile(filePath, '<?xml version="1.0" encoding="UTF-8"?>\n' + dom.documentElement.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ public class AndroidModule extends KrollModule
@Kroll.constant
public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION =
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION;
@Kroll.constant
public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
@Kroll.constant
public static final int FOREGROUND_SERVICE_TYPE_CAMERA = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA;

protected RProxy r;
private LinkedList<BroadcastReceiverProxy> registeredBroadcastReceiverProxyList = new LinkedList<>();
Expand Down
162 changes: 148 additions & 14 deletions apidoc/Titanium/Android/Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1827,65 +1827,199 @@ properties:
summary: |
A special value indicates to use all types set in manifest file.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MANIFEST).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MANIFEST)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_NONE
summary: |
The default foreground service type if not been set in manifest file.
summary: The default foreground service type.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_NONE).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_NONE)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
summary: |
Constant corresponding to mediaPlayback in the R.attr.foregroundServiceType attribute. Music, video, news or other media playback.
Allows music, video, news or other media playback while the app is in the background.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="mediaPlayback"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_PHONE_CALL
summary: |
Constant corresponding to phoneCall in the R.attr.foregroundServiceType attribute. Ongoing phone call or video conference.
Allows ongoing phone call or video conferencing access while the app is in the background.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_PHONE_CALL).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="phoneCall"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_PHONE_CALL)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_LOCATION
summary: |
Constant corresponding to location in the R.attr.foregroundServiceType attribute. GPS, map, navigation location update.
Allows accessing location from the GPS, map, etc. while the app is in the background.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_LOCATION).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="location"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_LOCATION)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
summary: |
Constant corresponding to connectedDevice in the R.attr.foregroundServiceType attribute. Auto, bluetooth, TV or other devices connection, monitoring and interaction.
Allows connecting to Android Auto, bluetooth, TV or other devices while app is in the background.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="connectedDevice"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
summary: |
Constant corresponding to mediaProjection in the R.attr.foregroundServiceType attribute. Managing a media projection session, e.g for screen recording or taking screenshots.
Allows managing a media projection session for screen recording or taking screenshots
while app is in the background.
description: |
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION).
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="mediaProjection"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)
documentation for more details.
type: Number
permission: read-only
since: "8.3.0"

- name: FOREGROUND_SERVICE_TYPE_MICROPHONE
summary: Allows the microphone to be used while the app is in the background.
description: |
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="microphone"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MICROPHONE)
documentation for more details.
type: Number
permission: read-only
since: "9.3.0"

- name: FOREGROUND_SERVICE_TYPE_CAMERA
summary: Allows the camera to be used while the app is in the background.
description: |
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
To use this constant, you must also set your `<service/>` element to the
`foregroundServieType` attribute value as shown below.
``` xml
<ti:app>
<android>
<services>
<service url="<YourService.js>" android:foregroundServiceType="camera"/>
</services>
</android>
</ti:app>
```
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CAMERA)
documentation for more details.
type: Number
permission: read-only
since: "9.3.0"

- name: FLAG_AUTO_CANCEL
summary: Cancel the notification when it is clicked by the user.
description: |
Expand Down
2 changes: 1 addition & 1 deletion build/lib/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class DeviceTestDetails {
if (this.target === 'device') {
await exec(`adb -s ${await this.deviceId()} shell "run-as ${APP_ID} cat '${filepath}'" > ${dest}`);
} else {
await exec(`adb shell "run-as ${APP_ID} cat '${filepath}'" > ${dest}`);
await exec(`adb -e shell "run-as ${APP_ID} cat '${filepath}'" > ${dest}`);
}
return dest;
}
Expand Down

0 comments on commit 79f5111

Please sign in to comment.