[TIMOB-20015] iOS: Improve deprecation macros
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-11-20T03:20:05.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.2.0 |
| Components | iOS |
| Labels | qe-5.2.0 |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2015-11-19T04:31:31.000+0000 |
| Updated | 2016-01-22T00:42:29.000+0000 |
Description
The macros for deprecating an API are misleading and need to be unified:
#define DEPRECATED_REPLACED(api,in,newapi) \
DebugLog(@"[WARN] Ti%@.%@ DEPRECATED in %@, in favor of %@.",@"tanium",api,in,newapi);
This macro expects DEPRECATED_REPLACED(@"Calendar.requestAuthorization", @"5.1.0", @"Titanium.Calendar.requestContactsPermissions");
Note, that the Titanium prefix is added by the macro in the deprecated API, but needs to be added manually in the replaced API. The approach is to clean this up and unify all usages, so that we call DEPRECATED_REPLACED(@"Calendar.requestAuthorization", @"5.1.0", @"Titanium.Calendar.requestContactsPermissions"); which generated a proper Ti-prefixed warning for all API's.
PR: https://github.com/appcelerator/titanium_mobile/pull/7476 I also created a test case to check every possible macro by calling 2 properties that internally call the macros:
Ti.UI.createWindow({ backgroundColor: "#fff" }).open(); Ti.API.info("\n\nWarnings following:\n"); // -- Please run this code and verify the console logs with the logs below. /** Deprecated -> Removed warnings */ // Expected log: [WARN] Ti.Media.AUDIO_HEADPHONES DEPRECATED in 3.4.2: REMOVED in 3.6.0 var a = Ti.Media.AUDIO_HEADPHONES; // Expected log: [WARN] Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND DEPRECATED in 3.4.2: REMOVED in 3.6.0 var b = Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND; /** Deprecated -> Replaced -> Removed warnings */ // Expected log: [WARN] Ti.Media.audioLineType DEPRECATED in 3.4.2, in favor of Ti.Media.currentRoute: REMOVED in 3.6.0 var c = Ti.Media.audioLineType; // Expected log: [WARN] Ti.UI.iPhone.StatusBar.OPAQUE_BLACK DEPRECATED in 3.4.2, in favor of Ti.UI.iPhone.StatusBar.LIGHT_CONTENT: REMOVED in 3.6.0 var d = Ti.UI.iPhone.StatusBar.OPAQUE_BLACK; /** Deprecated -> Replaced warnings */ // Expected log: [WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONT var e = Ti.UI.iOS.ATTRIBUTE_FONT; // Expected log: [WARN] Ti.UI.iOS.ANIMATION_CURVE_LINEAR DEPRECATED in 2.1.0, in favor of Ti.UI.ANIMATION_CURVE_LINEAR var f = Ti.UI.iOS.ANIMATION_CURVE_LINEAR;CR done. APPROVED!
Ran the demo code provided by [~hans123] and received the following:
According to the demo, the message[WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONTshould be present ase = Ti.UI.iOS.ATTRIBUTE_FONTis called, however it is not present when run with SDK5.2.0.v20160114021251Interesting. I just tried
var e = Ti.UI.iOS.ATTRIBUTE_FONT;and got\[WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONTusing the 5_2_X branch. Anyway, it is possible that the constant is only available in conjunction with theTi.UI.AttributedStringproxy. Long story short: Can you test the following (all words except the last should be times, the logs should state the warning):var win = Titanium.UI.createWindow({ backgroundColor: '#ddd', }); win.open(); var text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.'; var attr = Titanium.UI.iOS.createAttributedString({ text: text, attributes: [{ type: Titanium.UI.iOS.ATTRIBUTE_FONT, value: "Times", range: [0, text.length - 6] }] }); var label = Titanium.UI.createLabel({ left: 20, right: 20, height: Titanium.UI.SIZE, attributedString: attr }); win.add(label);As per the above comment on the matter, using the demo code successfully returns the following:
Verified as fixed, Tested on: iPhone 6s Plus Device (9.2) & iPhone 6 Plus Device (8.4) Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.2.0.v20160114021251 Appc NPM: 4.2.3-1 App CLI: 5.2.0-228 Xcode 7.2 Node v4.2.3 *Closing Ticket.*