New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-24510] Android: Support for custom quick settings tiles. #9310
Conversation
builder.setMessage(krollDict.getString(TiC.PROPERTY_MESSAGE)); | ||
} | ||
if (krollDict.containsKey(TiC.PROPERTY_BUTTON_NAMES)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix {
builder.setPositiveButton(text, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
fireEvent(TiC.EVENT_TILE_DIALOG_POSITIVE,null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing of ,
same below
android/cli/commands/_build.js
Outdated
if (service.type == 'quicksettings') { | ||
s = {}; | ||
var serviceName = this.appid + '.' + service.classname; | ||
var icon = '@drawable/' + this.tiapp.icon.replace(/((\.9)?\.(png|jpg))$/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var icon = '@drawable/' + (service.label || this.tiapp).icon.replace(/((\.9)?\.(png|jpg))$/, '');
android/cli/commands/_build.js
Outdated
} | ||
}); | ||
var label = this.tiapp.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var label = service.label || this.tiapp.name;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
Optimize default label and icon code in build script.
@garymathews Updated. |
android/cli/commands/_build.js
Outdated
@@ -3381,6 +3385,28 @@ AndroidBuilder.prototype.generateTheme = function generateTheme(next) { | |||
next(); | |||
}; | |||
|
|||
function serviceParser(serviceNode, result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that you're passing in an object to modify as a side-effect of calling the method. I prefer to explicitly alter a copy of an object and return the modified copy as return value. Calling methods with the intention of causing side-effect modifications on the arguments is non-obvious.
android/cli/commands/_build.js
Outdated
label: label | ||
}); | ||
const doc = new DOMParser().parseFromString(serviceXML, 'text/xml'); | ||
serviceParser(doc.firstChild, s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about serviceParser doesn't get passed in s
, since it's an empty object, and instead just creates an empty object to start from and returns the built object, with we then assign to s
here?
s = serviceParser(doc.firstChild);
It would mean that line 3629 would need to change to let s = {};
.
Fix parameters.
Add returns.
Fix default icon code. Fix parity.html template.
@sgtcoolguy Updated the PR. |
service.setLabel('Active'); | ||
service.setIcon('active.png'); | ||
} | ||
service.updateTile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is messed here.
summary: Prompts the user to unlock the device and runs the JS code | ||
parameters: | ||
- name: jsCode | ||
summary: JavaScript code to be evaluated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing .
at the end. Please also fix the other occurrences above.
Creates and shows a default Alert dialog with the provided options dictionary. | ||
|
||
Note: Alert dialog only supports one of the following: message/options. If you pass both - only `message` will | ||
be shown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break the line after message/options.
already.
- name: tiledialogneutral | ||
summary: Dispatched when the neutral (index 1) button has been clicked. | ||
|
||
- name: tiledialognegative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I do understand that we also used lowercase-only event naming-conventions, I'd like to discuss to move away from that. We should have camel-cased event-driven event-names, like tileRemoved
and tileDialogOptionSelected
. It would also look better on Alloy, e.g. on="tileRemoved"
. Any downsides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are talking about using camel-cased event-names everywhere (not only for this service) we may have some trouble with deprecated event-names which are camel-cased. I had a case where the runtime does not behave consistently when two events with the same name (one lowercased, one camel-cased) are dispatched at the same time.
@hansemannn Updated docs formatting. |
FR Passed.
Studio Ver: 4.10.0.201709271713 |
Generated by 🚫 dangerJS |
@ypbnv, If possible can you please add some unit tests. Jenkins is blocking merging because of it. |
@lokeshchdhry No unit tests can be added for this feature. |
JIRA: https://jira.appcelerator.org/browse/TIMOB-24510
Description:
Add support for custom quick settings tiles in Android N and above:
https://developer.android.com/about/versions/nougat/android-7.0.html#tile_api
Due to that being handled by a service, usage is very similar to JS file services. A file needs to be created in proper folder for Classic/Alloy projects and added in the element of tiapp.xml. For every tile you want to have you must create a new service. This service is of special type - 'quicksettings' providing two new attributes:
tiapp.xml:
<service url="quicksettingstileservice.js" label='Label' icon='logo.png' type="quicksettings"/>
Label and icon for the tile. By default they are using the application name and icon.
quicksettingstileservice.js
Documentation is on the way.